@occluze/umber 0.2.0 → 0.2.1
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.
- package/README.md +8 -8
- package/dist/chunks/capture.js +1 -1
- package/dist/chunks/covers.js +1 -1
- package/dist/chunks/flip.js +1 -1
- package/dist/chunks/fx.js +1 -1
- package/dist/chunks/gl.js +1 -1
- package/dist/chunks/glsl.js +1 -1
- package/dist/chunks/inspect.js +1 -1
- package/dist/chunks/instances.js +1 -1
- package/dist/chunks/layers.js +1 -1
- package/dist/chunks/licence.js +1 -1
- package/dist/chunks/morph.js +1 -1
- package/dist/chunks/restore.js +1 -1
- package/dist/chunks/shapes.js +1 -1
- package/dist/chunks/sim.js +1 -1
- package/dist/chunks/text.js +1 -1
- package/dist/chunks/video.js +1 -1
- package/dist/chunks/views.js +1 -1
- package/dist/chunks/warm.js +1 -1
- package/dist/modules/debug.js +2 -2
- package/dist/modules/debug.mjs +2 -2
- package/dist/modules/handoff.js +2 -2
- package/dist/modules/handoff.mjs +2 -2
- package/dist/modules/input.js +2 -2
- package/dist/modules/input.mjs +2 -2
- package/dist/modules/router-swap.js +1 -1
- package/dist/modules/router.js +2 -2
- package/dist/modules/router.mjs +2 -2
- package/dist/modules/scroll.js +2 -2
- package/dist/modules/scroll.mjs +2 -2
- package/dist/modules/scrub.js +2 -2
- package/dist/modules/scrub.mjs +2 -2
- package/dist/umber.css +1 -1
- package/dist/umber.js +2 -2
- package/dist/umber.mjs +2 -2
- package/docs/AI-quick.md +178 -0
- package/docs/AI.md +2660 -0
- package/docs/npm.md +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -12,18 +12,18 @@ A DOM-to-WebGL engine that works next to Barba, Lenis and GSAP and controls none
|
|
|
12
12
|
<!-- snippet:webflow -->
|
|
13
13
|
```html
|
|
14
14
|
<!-- Head code: the GL handshake CSS -->
|
|
15
|
-
<link rel="stylesheet" href="https://umber.occluze.com/umber@0.2.
|
|
15
|
+
<link rel="stylesheet" href="https://umber.occluze.com/umber@0.2.1/umber.css">
|
|
16
16
|
|
|
17
17
|
<!-- Footer code. Umber needs no other library; your own Lenis / Barba / GSAP tags (if the
|
|
18
18
|
site uses them) can sit before or after it. -->
|
|
19
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
19
|
+
<script src="https://umber.occluze.com/umber@0.2.1/umber.js"></script>
|
|
20
20
|
<!-- Optional modules, only if the site uses them (always the same version as umber.js):
|
|
21
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
22
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
23
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
24
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
25
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
26
|
-
<script src="https://umber.occluze.com/umber@0.2.
|
|
21
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/scrub.js"></script> scroll-scrubbed video (data-gl-scrub)
|
|
22
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/handoff.js"></script> image flights across page loads (data-gl-id, no router)
|
|
23
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/router.js"></script> Umber's own page router with transitions (instead of Barba)
|
|
24
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/input.js"></script> gl.drag, gl.trail, gl.press...
|
|
25
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/scroll.js"></script> smooth scrolling (gl.scroll), instead of a scroll library
|
|
26
|
+
<script src="https://umber.occluze.com/umber@0.2.1/modules/debug.js"></script> HUD while you build; never on the live site -->
|
|
27
27
|
<script>
|
|
28
28
|
const gl = Umber.createGL(); // every device; { devices: "desktop" } or { media: "(min-width: 900px)" } turns some off
|
|
29
29
|
// gl.effect("dissolve", { ... }); // the effects this site uses: yours to write
|
package/dist/chunks/capture.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var h=()=>new Promise(i=>{let e=new MessageChannel;e.port1.onmessage=i,e.port2.postMessage(0)});var m=i=>new Promise(e=>{let t=AbortSignal.timeout?.(i);t?t.onabort=()=>e():setTimeout(e,i)});var f=250,p=20;function g(i,e){return new d(i,e)}var d=class{constructor(e,t){this.stage=e;this.api=t;this.poll=f;this.stuckAfter=p;this.inFrame=!1;this.settle=null;this.held=[];this.was="";this.stuck=new WeakMap;this.seen=0;this.cut=1/0;this.said=!1;let s=e.gl,[n,a]=s.getParameter(s.MAX_VIEWPORT_DIMS);this.side=Math.min(s.getParameter(s.MAX_RENDERBUFFER_SIZE),n,a),e.maxTexture=s.getParameter(s.MAX_TEXTURE_SIZE);let r=e.renderer.adaptive;r.index=0,r.scale=e.stats.scale=1;let u=e.request.bind(e);e.request=()=>{u(),this.inFrame||this.news()};let o=e.host.ticker;e.cleanups.push(o.add(()=>this.inFrame=!0,{phase:"measure",order:-1/0}),o.add(()=>this.frame(),{phase:"render",order:1/0}),()=>this.settle?.()),e.ea=!0,e.wake(2)}dpr(e,t){let s=devicePixelRatio||1,n=Math.min(s,this.side/Math.max(e,1),this.side/Math.max(t,1),this.cut);return n<s&&!this.said&&(this.said=!0,this.stage.host.lib?.say("captureDpr",[s,n,Math.round(Math.max(e,t)*n)])),n}pending(e){if(e.destroyed||e.domReason||e.vt||e.textReason||e.morphHidden||e.status==="error"||e.textureState==="error"||!(e.visible||e.inView&&e.opacity>.001))return!1;let t=e.texture;return e.status==="loading"&&!e._raster?.empty||!!(t?.ready&&t.refs>0&&!t.box.length)}frame(){this.inFrame=!1;let e=this.stage;if(e.inactive)return;let t=e.gl,s=e.canvas,n=Math.min(t.drawingBufferWidth/s.width,t.drawingBufferHeight/s.height);if(n<1&&(this.cut=e.dpr*n,e.ea=!0,e.markDirty()),e.dpr!==this.seen){this.seen=e.dpr;for(let r of e.planes)e.media.sharpen(r)}if(this.settle)return;let a=[];for(let r of e.planes)this.pending(r)?(this.stuck.get(r)||0)<this.stuckAfter&&a.push(r):this.stuck.delete(r);a.length&&(this.held=a,this.was=this.state(),this.api.wait(new Promise(r=>{let u=this.settle=o=>{if(this.settle===u){if(this.settle=null,o)for(let l of a){let c=(this.stuck.get(l)||0)+1;this.stuck.set(l,c),c===this.stuckAfter&&e.host.lib?.say("captureWait",[l.el,c*this.poll/1e3])}r()}};a.every(o=>o.status==="loading"&&o.readyFrame!==-1)&&h().then(()=>u()),m(this.poll).then(()=>u(!0))})))}state(){return this.held.map(e=>`${e.status} ${e.textureState} ${e.texture?.ready} ${e.texture?.box.length} ${!!e.program} ${e.videoFrame} ${e.shapeWait} ${e._mods.frames?.pending}`).join()}news(){let e=this.settle;e&&this.state()!==this.was&&h().then(()=>e())}};export{d as Capture,f as POLL_MS,p as STUCK_AFTER,g as capture};
|
package/dist/chunks/covers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var r=e=>e.tagName.toLowerCase()+(e.id?`#${e.id}`:e.classList[0]?`.${e.classList[0]}`:""),p=(e,o)=>(e.position!=="static"||o<0)&&(+e.zIndex||0)>=o;function g(e,o,c){let i=+getComputedStyle(o).zIndex||0,d=t=>t&&t!==document.body&&t!==document.documentElement;for(let t=e.parentElement;d(t);t=t.parentElement){let n=getComputedStyle(t);if(p(n,i)&&/^rgb\(/.test(n.backgroundColor))return c.once(`data-gl-id: ${r(e)} landed in ${r(t)}, whose opaque background stacks over the canvas (z-index ${n.zIndex} >= ${i}) and hides it. Raise the canvas (createGL({ zIndex })) or move that background.`,t),!0}let a=e.getBoundingClientRect(),s=(Math.max(a.left,0)+Math.min(a.right,innerWidth))/2,l=(Math.max(a.top,0)+Math.min(a.bottom,innerHeight))/2;if(!document.elementsFromPoint||s<0||l<0||s>innerWidth||l>innerHeight)return!1;let m=document.elementsFromPoint(s,l);if(m.some(t=>e.contains(t)))return!1;for(let t of m){if(t.contains(e)||o.contains(t))break;if(/^rgb\(/.test(getComputedStyle(t).backgroundColor))for(let n=t;d(n);n=n.parentElement){let u=getComputedStyle(n);if(p(u,i))return c.once(`data-gl-id: ${r(e)} landed under ${r(n)} (z-index ${u.zIndex}), which paints over the canvas and hides it. Fly to an element that shows, or raise the canvas (createGL({ zIndex })).`,n),!0}}return!1}export{g as landed};
|
package/dist/chunks/flip.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var A={duration:.8,ease:"umber",stagger:0},D={duration:.8,ease:"umber"},g=class{constructor(s){this.stage=s;this.ends=new WeakMap}swap(s,a,l){let t=s.uniforms;t.uPrev.value=a,t.uPrevSize.value=new Float32Array([a.width,a.height]),t.uSwap.value=0;let n=this.stage.readOptions(s.el,"data-gl-swap",D);this.stage.tweens.to(t.uSwap,{value:1,duration:+n.duration||0,ease:n.ease,onComplete:l})}fly(s,a,l={}){let t=this.stage,n={...A,...l},d=t.ease(n.ease),c=t.reducedMotion?0:Math.max(0,+n.duration||0)*1e3,h=t.reducedMotion?0:Math.max(0,+n.stagger||0)*1e3,k=t.now;return Promise.all(s.map((e,P)=>new Promise(b=>{let i=a[P];this.ends.get(e)?.();let y=e.radius.slice(),F=e.radius.slice(),m=e.radiusKy,x=m,p=()=>{for(let r=0;r<4;r++)e.radius[r]!==F[r]&&(y[r]=e.radius[r]);e.radiusKy!==x&&(m=e.radiusKy)},f=()=>{if(this.ends.get(e)!==f)return b();this.ends.delete(e),e.fly===v&&(e.fly=null),p(),e.radius.set(y),e.radiusKy=m,K(),t.markDirty(),b()},K=e.on("destroy",f);this.ends.set(e,f);let v=(r,M,O)=>{let S=c?Math.min(1,Math.max(0,(t.now-k-P*h)/c)):1,u=1-d(S);p(),r[0]+=(i[0]-M-r[0])*u,r[1]+=(i[1]-O-r[1])*u,r[2]+=(i[2]-r[2])*u,r[3]+=(i[3]-r[3])*u;for(let o=0;o<4;o++)e.radius[o]=F[o]=y[o]+(i[4+o]-y[o])*u;e.radiusKy=x=m+(i[8]-m)*u,S<1?t.markDirty():f()};e.fly=v,t.markDirty()}))).then(()=>{})}lift(s){let a=this.stage,l=s.rect,t=new Float32Array(l);this.ends.get(s)?.();let n={};return["x","y","width","height"].forEach((d,c)=>Object.defineProperty(n,d,{enumerable:!0,get:()=>t[c],set:h=>{t[c]=+h||0,a.markDirty()}})),s.fly=d=>d.set(t),a.markDirty(),n}land(s,a){return s.fly?this.fly([s],[this.stage.where(s)],a):Promise.resolve()}};function T(w){return new g(w)}export{g as Flip,T as flip};
|
package/dist/chunks/fx.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var ce={info(){},warn:(o,...e)=>console.warn("[umber]",o,...e),once:(o,...e)=>console.warn("[umber]",o,...e),error:(o,...e)=>console.error("[umber]",o,...e)},p=ce;function V(o){o&&(p=o)}var he,pe,me,de,ge,ve,be,xe,B,k,Ee;function q(o){o&&({attr:he,config:pe,describe:me,findGL:de,findMedia:ge,markMedia:ve,unmarkMedia:be,needsLive:xe,say:B,tell:k,createEmitter:Ee}=o)}var D=["float","half","u8"];function ye(o,e){if(e==="u8")return{type:e,internal:o.RGBA8,pixel:o.UNSIGNED_BYTE,filter:o.LINEAR};if(!o.getExtension("EXT_color_buffer_float")&&(e==="float"||!o.getExtension("EXT_color_buffer_half_float")))return null;let r=e==="float",s={type:e,internal:r?o.RGBA32F:o.RGBA16F,pixel:r?o.FLOAT:o.HALF_FLOAT,filter:!r||o.getExtension("OES_texture_float_linear")?o.LINEAR:o.NEAREST},i=new y(o,{width:4,height:4,type:e,msaa:0,attachments:1},s,0),n=i.complete;return i.dispose(),n?s:null}function j(o,e,t,r=!1){for(let s=D.indexOf(e);s<D.length;s++){let i=D[s];t.has(i)||t.set(i,ye(o,i));let n=t.get(i);if(n)return i!==e&&!r&&p.once(`render targets: "${e}" can't be rendered to on this GPU; they use "${i}" instead (values above 1 clip and soft gradients may band). Ask for type: "${i}" to skip this message.`),n}return t.get("u8")}var y=class{constructor(e,t,r,s){this.gl=e;this.spec=t;this.format=r;this.samples=s;this.textures=[];this.msaa=null;this.db=[];this.freed=0;let{width:i,height:n,attachments:a}=t;this.key=O(t,r.type,s);let u=[];for(let l=0;l<a;l++)u.push(e.COLOR_ATTACHMENT0+l);let f=e.getParameter(e.FRAMEBUFFER_BINDING);this.fb=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.fb);for(let l=0;l<a;l++){let c=e.createTexture();e.bindTexture(e.TEXTURE_2D,c),e.texStorage2D(e.TEXTURE_2D,1,r.internal,i,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r.filter),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r.filter),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.framebufferTexture2D(e.FRAMEBUFFER,u[l],e.TEXTURE_2D,c,0),this.textures.push(c)}if(a>1&&e.drawBuffers(u),this.complete=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE,s){this.msaa=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.msaa);for(let l=0;l<a;l++){let c=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,c),e.renderbufferStorageMultisample(e.RENDERBUFFER,s,r.internal,i,n),e.framebufferRenderbuffer(e.FRAMEBUFFER,u[l],e.RENDERBUFFER,c),this.db.push(c)}a>1&&e.drawBuffers(u),this.complete&&=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE,e.bindRenderbuffer(e.RENDERBUFFER,null)}e.bindFramebuffer(e.FRAMEBUFFER,f)}get draw(){return this.msaa||this.fb}get bytes(){let{width:e,height:t,attachments:r}=this.spec,s=this.format.type==="float"?16:this.format.type==="half"?8:4;return e*t*s*r*(1+this.samples)}resolve(){let e=this.gl;if(!this.msaa)return;let{width:t,height:r,attachments:s}=this.spec;e.bindFramebuffer(e.READ_FRAMEBUFFER,this.msaa),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this.fb);let i=[];for(let n=0;n<s;n++){for(let a=0;a<s;a++)i[a]=a===n?e.COLOR_ATTACHMENT0+n:e.NONE;e.readBuffer(e.COLOR_ATTACHMENT0+n),s>1&&e.drawBuffers(i),e.blitFramebuffer(0,0,t,r,0,0,t,r,e.COLOR_BUFFER_BIT,e.NEAREST),i[n]=e.COLOR_ATTACHMENT0+n}if(s>1){for(let n=0;n<s;n++)i[n]=e.COLOR_ATTACHMENT0+n;e.drawBuffers(i)}e.invalidateFramebuffer(e.READ_FRAMEBUFFER,i.length?i:[e.COLOR_ATTACHMENT0]),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)}dispose(){let e=this.gl;for(let t of this.textures)e.deleteTexture(t);for(let t of this.db)e.deleteRenderbuffer(t);e.deleteFramebuffer(this.fb),this.msaa&&e.deleteFramebuffer(this.msaa),this.textures.length=0,this.db.length=0}},O=(o,e,t)=>`${o.width}x${o.height}|${e}|${t}|${o.attachments}`;var N=5e3,F=class{constructor(e){this.gl=e;this.free=new Map;this.live=new Set;this.formats=new Map;this._a=new Set;this.dead=!1;this.timer=0;this.grew=null;this.peak=0;this.Ma=()=>{this.timer=0;let e=performance.now(),t=!1;for(let[r,s]of this.free){for(let i=s.length-1;i>=0;i--)e-s[i].freed>=N-1?s.splice(i,1)[0].dispose():t=!0;s.length||this.free.delete(r)}this.fell(),t&&(this.timer=setTimeout(this.Ma,N))}}acquire(e){let t=this.gl,r=j(t,e.type,this.formats,e.quiet),s=e.msaa>0&&!this._a.has(r.type)?Math.min(e.msaa,t.getParameter(t.MAX_SAMPLES)||0):0,i=O(e,r.type,s),n=this.free.get(i)?.pop(),a=!n;return n||(n=new y(t,e,r,s),!n.complete&&s&&(n.dispose(),this._a.add(r.type),p.once(`render targets: this GPU refuses ${s}x MSAA for "${r.type}" targets; they draw without it (edges stair-step). Ask for msaa: 0 to skip this message.`),n=new y(t,e,r,0))),this.live.add(n),a&&this.grew?.(),n}release(e){if(!e||!this.live.delete(e)||this.dead)return;e.freed=performance.now();let t=this.free.get(e.key);t?t.push(e):this.free.set(e.key,[e]),this.timer||=setTimeout(this.Ma,N)}get bytes(){let e=0;for(let t of this.live)e+=t.bytes;for(let t of this.free.values())for(let r of t)e+=r.bytes;return e}trim(){let e=0;for(let t of this.free.values())for(let r of t)e+=r.bytes,r.dispose();return this.free.clear(),this.fell(),e}fell(){this.peak=Math.min(this.peak,this.bytes)}lost(){this.dead=!0,this.free.clear(),this.fell(),this.formats.clear(),this._a.clear()}restored(){this.dead=!1;let e=new Map,t=[...this.live];this.live.clear();for(let r of t)e.set(r,this.acquire(r.spec));return e}dispose(){this.timer&&clearTimeout(this.timer),this.timer=0;for(let e of this.live)e.dispose();for(let e of this.free.values())for(let t of e)t.dispose();this.live.clear(),this.free.clear()}};var Y="uniformMatrix2fv,uniformMatrix3fv,uniformMatrix4fv,,,,,,,,,uniformMatrix2x3fv,uniformMatrix2x4fv,uniformMatrix3x2fv,uniformMatrix3x4fv,uniformMatrix4x2fv,uniformMatrix4x3fv".split(","),S=class{constructor(e,t,r,s="program"){this.gl=e;this.vertex=t;this.fragment=r;this.label=s;this.uniforms=new Map;this.samplers=[];this.state="pending";this.error=null;this.shaders=[];this.Ka=globalThis.occluzeCapture?.version==1?null:e.getExtension("KHR_parallel_shader_compile");let i=K(e,e.VERTEX_SHADER,t),n=K(e,e.FRAGMENT_SHADER,r),a=e.createProgram();e.attachShader(a,i),e.attachShader(a,n),e.bindAttribLocation(a,0,"aPosition"),e.linkProgram(a),this.program=a,this.shaders=[i,n],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 e=this.gl,t=this.program;if(!e.getProgramParameter(t,e.LINK_STATUS)){let[s,i]=this.shaders;this.error=Q(e,s,"vertex",this.vertex,this.label)||Q(e,i,"fragment",this.fragment,this.label)||["link",this.label,e.getProgramInfoLog(t)||"",""],this.Pa(),e.deleteProgram(t),this.state="failed";return}this.Pa();let r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){let i=e.getActiveUniform(t,s);if(!i)continue;let n=i.name.replace(/\[0\]$/,""),a=e.getUniformLocation(t,i.name);a&&(this.uniforms.set(n,{loc:a,type:i.type,size:i.size}),(i.type===e.SAMPLER_2D||i.type===e.UNSIGNED_INT_SAMPLER_2D)&&this.samplers.push(n))}this.state="ok"}Pa(){for(let e of this.shaders)this.gl.deleteShader(e);this.shaders=[]}set(e,t){let r=this.state==="ok"?this.uniforms.get(e):void 0;if(!r||t==null)return;let s=this.gl,i=r.type;if(typeof t=="number"){if(r.last===t)return;r.last=t,i===s.FLOAT?s.uniform1f(r.loc,t):i===s.UNSIGNED_INT?s.uniform1ui(r.loc,t):s.uniform1i(r.loc,t);return}let n=t,a=r.last;if(a?.length===n.length){let u=n.length;for(;u--&&a[u]===n[u];);if(u<0)return}else a=r.last=[];for(let u=0;u<n.length;u++)a[u]=n[u];i===s.FLOAT_VEC2?s.uniform2fv(r.loc,n):i===s.FLOAT_VEC3?s.uniform3fv(r.loc,n,0,Math.min(n.length,r.size*3)):i===s.FLOAT_VEC4?s.uniform4fv(r.loc,n):Y[i-s.FLOAT_MAT2]?s[Y[i-s.FLOAT_MAT2]](r.loc,!1,n):i===s.FLOAT?s.uniform1fv(r.loc,n):s[`uniform${n.length/r.size}${i===s.UNSIGNED_INT||i>=s.UNSIGNED_INT_VEC2?"u":""}iv`]?.(r.loc,n)}dispose(){this.Pa(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function K(o,e,t){let r=o.createShader(e);return o.shaderSource(r,t),o.compileShader(r),r}function Q(o,e,t,r,s){return e&&!o.getShaderParameter(e,o.COMPILE_STATUS)?[t,s,o.getShaderInfoLog(e)||"",r]:null}var R={};function J(o){let e=new Set,t=r=>{let s=R[r];if(!(e.has(r)||s.defined.test(o))){for(let i of s.needs||[])t(i);e.add(r)}};for(let r in R)R[r].used.test(o)&&t(r);return[...e].map(r=>R[r].code).join(`
|
|
3
3
|
|
|
4
4
|
`)}var Re=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"]);function Te(o){if(typeof o=="number"||typeof o=="boolean")return"float";if(Array.isArray(o)||ArrayBuffer.isView(o)){let e=o.length;return e===2?"vec2":e===3?"vec3":e===4?"vec4":e===9?"mat3":e===16?"mat4":null}return typeof o=="string"?"sampler2D":o&&typeof o=="object"?"highp sampler2D":null}function G(o,e){let t=s=>s.charAt(0).toUpperCase()+s.slice(1),r=s=>s.split(/[-_\s]+/).map(t).join("");return`u${r(o)}${r(e)}`}function Z(o,e){let t=[];for(let r in o){if(Re.has(r)||new RegExp(`uniform\\s+\\w+\\s+${r}\\b`).test(e))continue;let s=Te(o[r]);s&&t.push(`uniform ${s} ${r};`)}return t.join(`
|
package/dist/chunks/gl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
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
3
|
precision highp float;
|
|
4
4
|
layout(location=0)in vec2 aPosition;
|
package/dist/chunks/glsl.js
CHANGED
package/dist/chunks/inspect.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var h="[data-gl]",O=new Set(["data-gl","data-gl-effect","data-gl-shader","data-gl-layer","data-gl-instances"]),P=[...O,"style","class","hidden","media","disabled","data-gl-src","src","srcset","sizes","data-gl-occlude","data-gl-pass","data-gl-under"];var C="[data-gl-occlude]",B=h+","+C;var b={scrub:"modules/scrub.js"};function l(e){if(!e||typeof e.tagName!="string")return"<?>";let n=e.tagName.toLowerCase();if(e.id)return`<${n}#${e.id}>`;let t=typeof e.className=="string"?e.className.trim().split(/\s+/)[0]:"";return t?`<${n}.${t}>`:`<${n}>`}function x(e,n){let t="",s=3;for(let r of n){let i=U(e.toLowerCase(),r.toLowerCase());i<s&&(t=r,s=i)}return t}function U(e,n){let t=Array.from({length:n.length+1},(s,r)=>r);for(let s=1;s<=e.length;s++){let r=t[0];t[0]=s;for(let i=1;i<=n.length;i++){let a=t[i];t[i]=Math.min(t[i]+1,t[i-1]+1,r+(e[s-1]===n[i-1]?0:1)),r=a}}return t[n.length]}var I=e=>!!e.backgroundImage&&e.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(e.backgroundColor||"transparent"),z=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],D=e=>e.position!=="static"&&e.zIndex!=="auto"||/fixed|sticky/.test(e.position)||parseFloat(e.opacity)<1||z.some(n=>(e[n]||"none")!=="none")||e.isolation==="isolate"||(e.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(e.contain)||/^(size|inline-size)$/.test(e.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(e.willChange);function k(e,n){let t=parseInt(getComputedStyle(n).zIndex,10);if(!(t>0))return null;let s=null,r="auto",i=[];for(let a=e;a&&a!==document.body&&a!==document.documentElement;a=a.parentElement){let d=getComputedStyle(a);I(d)&&!(a===e&&e.getAttribute("data-gl")==="shader")&&i.push(a),D(d)&&(s=a,r=d.position!=="static"?d.zIndex:"auto")}return!s||r==="auto"||+r<t||!i.some(a=>s.contains(a))?null:`${l(s)} (z-index ${r}, with a background) covers Umber's canvas (z-index ${t}): GL inside it is hidden. Drop that z-index (and give it data-gl-occlude if it must still cover the GL elements before it) or move the background behind the content.`}var L="https://umber.occluze.com";var w=(e,n)=>{let t=x(e,n);return t?` (did you mean "${t}"?)`:""},_=(e,n)=>{if(e==="umber.css")return"Umber's canvas host is not fixed: umber.css is not on this page, so GL is off and the DOM shows. Link umber.css in <head> on every page.";let t=e.slice(e.lastIndexOf(" has ")+5).split(":")[0];return`${e}, which makes Umber's fixed canvas ${t==="zoom"?"scale":"scroll or turn"} with the page, so GL is off and the DOM shows. Move the ${t} to a wrapper element inside <body>${n?"":", or move the [data-gl-host] element out of it"}.`},A={disabled:"switched off (devices: false, data-gl-disable on <body>, or ?umber=off in the URL)","no-webgl2":"this browser has no WebGL2",device:'a device or screen this site keeps effects off (devices: "desktop" / data-gl-devices, or media / data-gl-media)',editor:"inside the Webflow Designer / Editor (createGL({ designer: true }) runs it there)","forced-colors":"forced colours (Windows High Contrast) are on","reduced-motion":'the visitor prefers reduced motion and reducedMotion is "off"',"save-data":"the browser asks to save data (createGL({ respectSaveData: false }) ignores that)",context:"a WebGL2 context could not be created","load-failed":"chunks/gl.js failed to load","load-timeout":"chunks/gl.js took more than 4 s to download",unlicensed:"this domain isn't on an Umber licence (list it under Umber in your occluze dashboard)","context-lost":"the WebGL context was lost more than 2 times",error:"an error inside a GL frame (see the [umber] error before this)",server:"not in a browser",destroyed:"gl.destroy() was called"},S=e=>A[e]||e,p={host:_,reason:S,off:e=>`GL off: ${S(e)}`,type:(e,n,t)=>`data-gl="${n}" on ${l(e)} is not a GL type${w(n,t)}; it is drawn as an image. Use one of: ${t.join(", ")}.`,effect:(e,n,t)=>`data-gl-effect="${n}" on ${l(e)}: no effect with that name${w(n,t)}. Define it first with gl.effect("${n}", {...}): Umber ships no effects ("Writing effects" in ${L}/docs.md). Known: ${t.join(", ")||"none yet"}.`,shader:(e,n,t)=>`data-gl="shader" on ${l(e)} needs data-gl-shader="name" and gl.shader("${n||"name"}", { fragment: "..." })${n?w(n,t):""}.`,glyph:()=>'glyph() is for data-gl="text" planes; on other planes it answers one line, word and character covering the whole element.',busy:e=>`createGL({ busy }): "${e}" is not a selector; ignored.`,gpu:e=>`?umber-gpu=${e} is ignored: use 0-5, m0-m5, low, mid or high.`,texture:e=>`${e}: a canvas, bitmap, video or numbers need gl.texture(source) from the input module (modules/input.js).`,own:e=>`module "${e}": plane.${e} is Umber's own. Rename the module.`,useTwice:e=>`gl.use(): a module named "${e}" is in use already; keeping the first one.`,use:()=>"gl.use(module) needs an Umber module (an object with a name), for example Scrub from @occluze/umber/scrub.",module:(e,n)=>{let t=n.charAt(0).toUpperCase()+n.slice(1);return`data-gl-${n} on ${l(e)}: no module "${n}". Load ${b[n]} next to umber.js, or gl.use(${t}) with import { ${t} } from "@occluze/umber/${n}".`},slow:e=>`A GL element took more than ${e}s to load, so its normal DOM image/text is shown instead (slow network or a very large image? Use a smaller image).`,set:(e,n,t,s)=>`plane.set("${n}") on ${l(e)}: no effect on this plane has a uniform "${n}", so no shader reads it${w(n,t)}. Effects here: ${s}. Declare it in the effect's uniforms: { ${n}: 0 }.`,play:()=>'plane.play(): this plane has no effect with a `play` uniform. Add one (gl.effect(name, { play: "uShow", ... })) or use plane.tween(name, { value: 1 }).',image:()=>"data-gl element has no image. Put an <img> inside it or set data-gl-src.",cors:(e,n)=>`${l(e)}: its image ${n} could not become a texture, so the DOM image shows (not found, or on another domain without CORS headers? Serve it with Access-Control-Allow-Origin, or from this site's own domain).`,oval:e=>`${l(e)}: its rounded corners have different shapes (across / down), and GL draws one shape for all of them, so its DOM shows. Give every rounded corner the same proportion, or use clip-path for the shape.`,webgl2:()=>"WebGL2 is not available here; the site runs without GL.",glsl:(e,n,t,s)=>{if(e==="link")return`shader link failed (${n}): ${t}`;let r=Number((t.match(/ERROR: \d+:(\d+)/)||[])[1]||0),i=s.split(`
|
|
3
3
|
`).map((a,d)=>`${String(d+1).padStart(4)}${d+1===r?" >":" "} ${a}`).slice(Math.max(0,r-6),r+3).join(`
|
|
4
4
|
`);return`${e} shader error in "${n}":
|
package/dist/chunks/instances.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var I={info(){},warn:(s,...e)=>console.warn("[umber]",s,...e),once:(s,...e)=>console.warn("[umber]",s,...e),error:(s,...e)=>console.error("[umber]",s,...e)},x=I;function R(s){s&&(x=s)}function S(s){if(typeof s=="number"||typeof s=="boolean")return"float";if(Array.isArray(s)||ArrayBuffer.isView(s)){let e=s.length;return e===2?"vec2":e===3?"vec3":e===4?"vec4":e===9?"mat3":e===16?"mat4":null}return typeof s=="string"?"sampler2D":s&&typeof s=="object"?"highp sampler2D":null}var P=3,F=["float","vec2","vec3","vec4"],E="gl_Position = vec4(0.0, 0.0, 2.0, 1.0); return;";function $(s,e,n){let t=e.mode,o=t==="chars"||t==="words"||t==="lines",r=`uniform float uInstances;
|
|
3
3
|
uniform float uUmberWhole;
|
|
4
4
|
uniform vec4 uUmberInst;
|
package/dist/chunks/layers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var F={info(){},warn:(a,...e)=>console.warn("[umber]",a,...e),once:(a,...e)=>console.warn("[umber]",a,...e),error:(a,...e)=>console.error("[umber]",a,...e)},m=F;function I(a){a&&(m=a)}function C(a){if(!a||typeof a.tagName!="string")return"<?>";let e=a.tagName.toLowerCase();if(a.id)return`<${e}#${a.id}>`;let r=typeof a.className=="string"?a.className.trim().split(/\s+/)[0]:"";return r?`<${e}.${r}>`:`<${e}>`}var D="uniformMatrix2fv,uniformMatrix3fv,uniformMatrix4fv,,,,,,,,,uniformMatrix2x3fv,uniformMatrix2x4fv,uniformMatrix3x2fv,uniformMatrix3x4fv,uniformMatrix4x2fv,uniformMatrix4x3fv".split(","),L=class{constructor(e,r,t,i="program"){this.gl=e;this.vertex=r;this.fragment=t;this.label=i;this.uniforms=new Map;this.samplers=[];this.state="pending";this.error=null;this.shaders=[];this.Ka=globalThis.occluzeCapture?.version==1?null:e.getExtension("KHR_parallel_shader_compile");let s=N(e,e.VERTEX_SHADER,r),n=N(e,e.FRAGMENT_SHADER,t),o=e.createProgram();e.attachShader(o,s),e.attachShader(o,n),e.bindAttribLocation(o,0,"aPosition"),e.linkProgram(o),this.program=o,this.shaders=[s,n],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 e=this.gl,r=this.program;if(!e.getProgramParameter(r,e.LINK_STATUS)){let[i,s]=this.shaders;this.error=G(e,i,"vertex",this.vertex,this.label)||G(e,s,"fragment",this.fragment,this.label)||["link",this.label,e.getProgramInfoLog(r)||"",""],this.Pa(),e.deleteProgram(r),this.state="failed";return}this.Pa();let t=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let i=0;i<t;i++){let s=e.getActiveUniform(r,i);if(!s)continue;let n=s.name.replace(/\[0\]$/,""),o=e.getUniformLocation(r,s.name);o&&(this.uniforms.set(n,{loc:o,type:s.type,size:s.size}),(s.type===e.SAMPLER_2D||s.type===e.UNSIGNED_INT_SAMPLER_2D)&&this.samplers.push(n))}this.state="ok"}Pa(){for(let e of this.shaders)this.gl.deleteShader(e);this.shaders=[]}set(e,r){let t=this.state==="ok"?this.uniforms.get(e):void 0;if(!t||r==null)return;let i=this.gl,s=t.type;if(typeof r=="number"){if(t.last===r)return;t.last=r,s===i.FLOAT?i.uniform1f(t.loc,r):s===i.UNSIGNED_INT?i.uniform1ui(t.loc,r):i.uniform1i(t.loc,r);return}let n=r,o=t.last;if(o?.length===n.length){let h=n.length;for(;h--&&o[h]===n[h];);if(h<0)return}else o=t.last=[];for(let h=0;h<n.length;h++)o[h]=n[h];s===i.FLOAT_VEC2?i.uniform2fv(t.loc,n):s===i.FLOAT_VEC3?i.uniform3fv(t.loc,n,0,Math.min(n.length,t.size*3)):s===i.FLOAT_VEC4?i.uniform4fv(t.loc,n):D[s-i.FLOAT_MAT2]?i[D[s-i.FLOAT_MAT2]](t.loc,!1,n):s===i.FLOAT?i.uniform1fv(t.loc,n):i[`uniform${n.length/t.size}${s===i.UNSIGNED_INT||s>=i.UNSIGNED_INT_VEC2?"u":""}iv`]?.(t.loc,n)}dispose(){this.Pa(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function N(a,e,r){let t=a.createShader(e);return a.shaderSource(t,r),a.compileShader(t),t}function G(a,e,r,t,i){return e&&!a.getShaderParameter(e,a.COMPILE_STATUS)?[r,i,a.getShaderInfoLog(e)||"",t]:null}var O=`#version 300 es
|
|
3
3
|
layout(location=0)in vec2 aPosition;
|
|
4
4
|
uniform vec2 uCanvas;
|
package/dist/chunks/licence.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var c="https://umber.occluze.com/v1/check?h=",a=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/;function r(){let o=location.hostname;if(!o||a.test(o))return Promise.resolve(!0);let e=new AbortController,n=setTimeout(()=>e.abort(),4e3),s=AbortSignal.any&&AbortSignal.timeout?AbortSignal.any([e.signal,AbortSignal.timeout(4e3)]):e.signal;return fetch(c+encodeURIComponent(o),{credentials:"omit",signal:s}).then(t=>t.ok?t.json():null).then(t=>t?.ok===!0?!0:(console.warn(t?.ok===!1?`Umber: ${o} isn't on an Umber licence, so this page shows without GL. List the domain under Umber in your occluze dashboard (occluze.com/dashboard).`:`Umber: couldn't check ${o}'s licence at umber.occluze.com, so this page shows without GL.`),!1)).catch(()=>(console.warn(`Umber: couldn't check ${o}'s licence at umber.occluze.com, so this page shows without GL.`),!1)).finally(()=>clearTimeout(n))}export{r as ok};
|
package/dist/chunks/morph.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
function y(n){let t=[],s=/[\s,]*(\S+)([^,]*)/g;for(let e;(e=s.exec(n||""))&&e[1];){let i=e[1].replace(/,+$/,"");i!==e[1]&&(s.lastIndex=e.index+e[0].indexOf(e[1])+e[1].length),t.push([i,i!==e[1]?"1x":e[2].trim()||"1x"])}return t}function m(n){let t=/^calc\((.+)\)$/.exec(n);if(t){let i=t[1].trim().split(/\s+([+-])\s+/),o=m(i[0]);for(let r=1;r<i.length;r+=2)o+=(i[r]==="-"?-1:1)*m(i[r+1]);return o}let s=/^([\d.]+)(vw|px|r?em)$/.exec(n),e=s?Number(s[1]):NaN;return s?s[2]==="vw"?innerWidth*e/100:s[2]==="px"?e:e*16:innerWidth}function N(n){let t=[],s=0,e=0;for(let i=0;i<=n.length;i++){let o=n[i];o==="("?s++:o===")"?s--:!s&&(o===","||o===void 0)&&(t.push(n.slice(e,i).trim()),e=i+1)}for(let i of t){let o=-1;for(let a=0,c=0;a<i.length;a++)i[a]==="("?c++:i[a]===")"?c--:!c&&/\s/.test(i[a])&&(o=a);let r=o>0?i.slice(0,o):"";if(i&&(!r||matchMedia(r).matches))return m(i.slice(o+1))}return innerWidth}function w(n){let t=n.ownerDocument?.baseURI||document.baseURI,s=a=>a?new URL(a,t).href:"",e=y(n.getAttribute("srcset")).map(([a,c])=>({url:a,n:parseFloat(c)||1,w:c.endsWith("w")})),i=n.getAttribute("src");if(i&&!e.some(a=>a.w||a.n==1)&&e.push({url:i,n:1,w:!1}),!e.length)return"";let o=window.devicePixelRatio||1,r=o;return e[0].w&&(r=N(n.getAttribute("sizes")||"")*o),e.sort((a,c)=>a.n-c.n),s((e.find(a=>a.n>=r)||e[e.length-1]).url)}var R={duration:1,ease:"umber"},M=3e3,P=3e3,X=8;function C(n,t){return n.includes(`data-gl-id="${t}"`)||n.includes(`data-gl-id='${t}'`)||n.includes(`data-gl-id=${t}`)}var A=(n,t)=>n.querySelector(`[data-gl-id="${t.replace(/["\\]/g,"\\$&")}"]`);function x(n){return n&&typeof n=="object"&&"html"in n&&(n=n.html),typeof n=="string"?n?t=>C(n,t):null:n&&typeof n.querySelector=="function"?t=>!!A(n,t):null}function E(n){return n[2]>0&&n[3]>0&&n[0]<window.innerWidth&&n[0]+n[2]>0&&n[1]<window.innerHeight&&n[1]+n[3]>0}var k=n=>n.opacity<=.001&&E(n.rect);function v(n){let t=n.media,s=[n.el.getAttribute("data-gl-src")||""];if(t&&t.tagName==="IMG"){let e=t;s.push(e.currentSrc,e.getAttribute("src")||"",...y(e.getAttribute("srcset")).map(i=>i[0]))}return s.filter(Boolean).map(e=>new URL(e,document.baseURI).href)}function F(n,t){let s=v(n);return v(t).some(e=>s.includes(e))}var b=n=>{n.morphHidden=!1,n.el.removeAttribute("data-gl-morphing")},z=(n,t)=>n.Ba&&n.Ba!==t&&b(n.Ba);function H(n,t){let{from:s,to:e}=n,i=s.drawXf,o=s.rect;if(!e.level&&O(n.originXf)){i[0]=i[4]=i[8]=1,i[1]=i[2]=i[3]=i[5]=0,i[6]=o[0],i[7]=o[1],s.size[0]=o[2],s.size[1]=o[3],s.level=0;return}let r=n.originXf,a=e.drawXf,c=r[8]||1,h=a[8]||1;for(let u=0;u<9;u++)i[u]=r[u]/c+(a[u]/h-r[u]/c)*t;s.size[0]=n.originSize[0]+(e.size[0]-n.originSize[0])*t,s.size[1]=n.originSize[1]+(e.size[1]-n.originSize[1])*t,s.level=1,s.xfReason=null;let l=s.size[0]/2,d=s.size[1]/2,f=i[2]*l+i[5]*d+i[8],p=s.shaderRect;p[0]=(i[0]*l+i[3]*d+i[6])/f-l,p[1]=(i[1]*l+i[4]*d+i[7])/f-d,p[2]=s.size[0],p[3]=s.size[1]}function O(n){return n[0]===1&&n[1]===0&&n[2]===0&&n[3]===0&&n[4]===1&&n[5]===0&&n[8]===1}var S=n=>(n.sx=NaN,n),g=class{constructor(t){this.host=t;this.snapshots=new Map;this.flights=[];this.parked=new Set;this.later=new Map;this.gen=0;this.yc=t=>{t.el.isConnected&&this.host.transitioning&&!t.destroyed||(this.parked.delete(t),t.destroyed||this.La(t,!0))}}snap(t,s,e=0,i=null){let o=this.host,r=t.scrolls?o.scrollX:o.pageX,a=t.scrolls?o.scrollY:o.pageY;return{plane:t,rect:t.rect.slice(),xf:t.drawXf.slice(),size:t.size.slice(),radius:t.radius.slice(),ky:t.radiusKy,opacity:t.opacity,frozen:s,Ba:i,until:e,sx:r,sy:a,ex:t.doc.x-r,ey:t.doc.y-a}}get busy(){return this.flights.length>0}holds(t){for(let s of this.snapshots.values())if(s.plane===t)return!0;return!1}capture(t,s=!1){s||this.settle(),t&&typeof t.then=="function"&&(this.known(t),t=void 0);let e=x(t);if(!s)for(let o of this.flights.slice()){let{from:r,to:a}=o;if(!e||!e(o.id)){r.rect.set(a.rect),r.radius.set(a.radius),r.radiusKy=a.radiusKy,r.drawXf.set(a.drawXf),r.size.set(a.size),r.opacity=1,this.finish(o,this.host.drawable(a));continue}this.flights.splice(this.flights.indexOf(o),1),this.snapshots.set(o.id,S(this.snap(o.from,!0,0,o.to)))}let i=this.host.planes.filter(o=>o.visible).concat(this.host.planes.filter(o=>!o.visible&&k(o)));for(let o of i){let r=o.el.getAttribute("data-gl-id");!r||o.kind==="layer"||this.snapshots.has(r)||o.status!=="ready"||o.morphHidden||e&&!e(r)||(this.snapshots.set(r,this.snap(o,!!e)),e&&this.host.detach(o))}t&&typeof t=="object"&&!("html"in t)&&this.preload(t),this.snapshots.size&&this.host.markDirty()}known(t){if(t&&typeof t.then=="function"){let e=this.gen;t.then(i=>e===this.gen&&this.known(i),()=>{});return}let s=x(t);if(s){for(let[e,i]of this.snapshots)i.frozen||i.until||(s(e)?this.host.planes.includes(i.plane)&&(this.snapshots.set(e,this.snap(i.plane,!0)),this.host.detach(i.plane)):this.drop(e));typeof t=="object"&&t&&!("html"in t)&&this.preload(t)}}preload(t){for(let s of this.snapshots.keys()){let e=A(t,s),i=e?.matches("img")?e:e?.querySelector("img"),o=i&&!i.parentElement?.querySelector("source")&&w(i);o&&fetch(o,{mode:"cors",credentials:"omit"}).catch(()=>{})}}keep(t){let s=t.el.getAttribute("data-gl-id");return!s||this.snapshots.has(s)||t.kind==="layer"||t.status!=="ready"||t.morphHidden||this.host.reducedMotion||!t.visible&&!k(t)?!1:(this.wait(s,this.snap(t,!1,performance.now()+P)),!0)}wait(t,s){let e=[...this.snapshots].filter(([,i])=>i.until).sort((i,o)=>i[1].until-o[1].until);e.length>=X&&this.drop(e[0][0]),this.snapshots.set(t,s),setTimeout(()=>this.snapshots.get(t)===s&&this.drop(t),s.until-performance.now())}drop(t){let s=this.snapshots.get(t);s&&(this.snapshots.delete(t),this.release(s),this.host.markDirty())}forget(t){for(let[s,e]of this.snapshots)if(e.plane===t)return this.snapshots.delete(s),!0;return!1}claim(t){let s=t.el.getAttribute("data-gl-id");for(let h of this.flights.slice())h.id===s&&!h.to.el.isConnected&&this.Qb(h);let e=s?this.snapshots.get(s):void 0,i=this.host;if(!s||!e||t.kind==="layer"||i.reducedMotion)return!1;if(!i.onScreen(t.el))return i.changing&&e.plane.el.isConnected&&this.later.set(s,t),!1;this.later.delete(s),this.snapshots.delete(s),z(e,t);let o=e.plane,r=e.frozen?e:this.snap(o,!1);e.frozen||i.detach(o);let a=i.readOptions(t.el,"data-gl-morph",R),c=Math.max(0,Number(a.duration)||0);this.flights.push({id:s,from:o,to:t,origin:r.rect,originXf:r.xf,originSize:r.size,originRadius:r.radius,originKy:r.ky,originOpacity:r.opacity,start:i.now,duration:c,ease:i.ease(a.ease),doneAt:0,same:F(o,t)}),o.opacity=r.opacity,t.morphIn=!0,t.morphHidden=!0;for(let h of t._play.playables.keys())t.uniforms[h]&&(t.uniforms[h].value=1);t.el.setAttribute("data-gl-morphing","");for(let h of o._play.playables.keys()){let l=o.uniforms[h];l&&l.value<1&&i.tweens.to(l,{value:1,duration:Math.max(.3,c),ease:"cubic.out"})}return i.markDirty(),!0}retry(){let t=[];for(let[s,e]of this.later){let i=this.snapshots.get(s);i?.plane.el.isConnected&&e.el.isConnected||(this.later.delete(s),i&&e.el.isConnected&&this.host.planes.includes(e)&&this.claim(e)?t.push(e):i&&this.drop(s))}return t}Qb(t){this.flights.splice(this.flights.indexOf(t),1),b(t.to),this.wait(t.id,S(this.snap(t.from,!0,performance.now()+P)))}settle(t=!0){t&&(this.later.clear(),this.gen++);for(let[s,e]of this.snapshots)!t&&(e.until||this.later.has(s))||this.drop(s);this.Vb()}Vb(){this.parked.forEach(this.yc)}update(t){if(this.snapshots.size&&this.follow(),this.parked.size&&this.Vb(),!this.flights.length)return!1;for(let s=this.flights.length;s--;){let e=this.flights[s],{from:i,to:o}=e;if(!this.host.planes.includes(o)||o.status==="error"||o.textureState==="error"){o.status!=="error"&&!o.el.isConnected&&(this.host.changing||!i.el.isConnected&&this.host.transitioning)?this.Qb(e):this.finish(e,!1);continue}let r=e.duration>0?Math.min(1,(t-e.start)/(e.duration*1e3)):1,a=e.ease(r),c=o.rect;for(let l=0;l<4;l++)i.rect[l]=e.origin[l]+(c[l]-e.origin[l])*a,i.radius[l]=e.originRadius[l]+(o.radius[l]-e.originRadius[l])*a;if(i.radiusKy=e.originKy+(o.radiusKy-e.originKy)*a,H(e,a),i.opacity=e.originOpacity+((this.host.transitioning?1:o.opacity)-e.originOpacity)*a,r<1)continue;e.doneAt||(e.doneAt=t),(o.opacity>=.99||!this.host.transitioning)&&this.host.drawable(o)?this.finish(e,!0):t-e.doneAt>M&&this.finish(e,!1)}return!0}follow(){let t=this.host;for(let s of this.snapshots.values()){let e=s.plane;if(!s.frozen||s.sx!==s.sx)continue;let i=e.scrolls?t.scrollX:t.pageX,o=e.scrolls?t.scrollY:t.pageY;if(i===s.sx&&o===s.sy)continue;let r=e.el.isConnected?e.el.getBoundingClientRect():null;if(!r?.width){s.sx=NaN;continue}let a=e.pinned?r.left-s.ex:s.sx-i,c=e.pinned?r.top-s.ey:s.sy-o;if(s.sx=i,s.sy=o,s.ex=r.left,s.ey=r.top,!a&&!c)continue;let h=e.rect,l=e.shaderRect,d=e.drawXf;h[0]+=a,h[1]+=c,l[0]+=a,l[1]+=c;for(let f=0;f<9;f+=3)d[f]+=a*d[f+2],d[f+1]+=c*d[f+2];s.rect.set(h),s.xf.set(d),t.markDirty()}}draw(t){if(this.snapshots.size)for(let s of this.snapshots.values())s.frozen&&!this.host.planes.includes(s.plane)&&t(s.plane);for(let s of this.flights){let{from:e,to:i}=s,o=e.texture;s.same&&i.texture?.ready&&e.kind==="image"&&(e.texture=i.texture),t(e),e.texture=o}}cancel(){for(let t of this.flights.slice())this.finish(t,!1);this.settle(),this.parked.forEach(t=>this.La(t,!0)),this.parked.clear()}finish(t,s){if(this.flights.splice(this.flights.indexOf(t),1),s){t.to.morphHidden=!1;let e=t.to.el;this.host.host.loadCovers?.().then(i=>i.landed(e,this.host.hostEl,this.host.host.log),()=>{})}else b(t.to);this.La(t.from,!s),this.host.markDirty()}La(t,s){t.el.isConnected?this.host.transitioning&&!s?this.parked.add(t):this.host.attach(t):this.host.discard(t)}release(t){z(t);let s=t.plane;this.host.planes.includes(s)||this.La(s,!0)}};function T(n){return n.morph=new g(n)}export{T as morph};
|
package/dist/chunks/restore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
function l(e){if(e.failed||e.destroyed||e.gl.isContextLost())return;e.lost=!1,e.media.onLost();for(let t of e.subsystems)t.restored?.();e.planes.some(t=>t._layer)&&e.layers?.fade.get();let n=e.media.textureUrls;e.media.textureUrls=new Map;for(let t of e.planes){for(let o in t.uniforms){let r=t.uniforms[o],s=n.get(r.value);s&&(r.value=e.media.textureFromUrl(s))}if(t.status==="error"){t.videoCleanup&&e.programs.prepare(t);continue}if(t.setStatus(e.inactive?null:"loading"),t.status="loading",t.loadingSince=0,t._layer){t.near&&e.loadMedia(t);continue}e.programs.prepare(t),t.shader?t.textureState="ready":t.near&&e.loadMedia(t),t._mods.tell(o=>o.restored?.())}e.invalidate(),e.wake(2),e.views?.restored(),e.host.emit("restored")}export{l as restored};
|
package/dist/chunks/shapes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
function D(t,e){let n=e[0],r=e[1],o=e[2],i=e[3],s=e[4],a=e[5],l=e[6],c=e[7],f=e[8],u=s*f-a*c,p=-(i*f-a*l),d=i*c-s*l,h=n*u+r*p+o*d;if(!h||!Number.isFinite(h))return!1;let m=1/h;return t[0]=u*m,t[1]=-(r*f-o*c)*m,t[2]=(r*a-o*s)*m,t[3]=p*m,t[4]=(n*f-o*l)*m,t[5]=-(n*a-o*i)*m,t[6]=d*m,t[7]=-(n*c-r*l)*m,t[8]=(n*s-r*i)*m,!0}function Te(t,e,n,r,o){return t.fill(0),t[0]=r,t[4]=o,t[6]=e,t[7]=n,t[8]=1,t}function S(t,e){let n=t.trim();if(n.startsWith("calc(")&&n.endsWith(")"))n=n.slice(5,-1).trim();else if(n.includes("("))return NaN;let r=0,o=1,i=!0;for(let s of n.split(/\s+/)){if(!s)continue;if(!i){if(s==="+")o=1;else if(s==="-")o=-1;else return NaN;i=!0;continue}let a=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px|%)?$/i.exec(s);if(!a)return NaN;let l=parseFloat(a[1]);if(!a[2]&&l!==0)return NaN;r+=o*(a[2]==="%"?l/100*e:l),i=!1}return i?NaN:r}function L(t){let e=[],n=0,r="";for(let o of t.trim())o==="("?n++:o===")"&&n--,/\s/.test(o)&&n===0?(r&&e.push(r),r=""):r+=o;return r&&e.push(r),e}function lt(t){let e=[],n=0,r="";for(let o of t)o==="("?n++:o===")"&&n--,o===","&&n===0?(e.push(r.trim()),r=""):r+=o;return e.push(r.trim()),e}function ee(t,e,n){let r=[],o=[];for(let i of t){let s=L(i||"0px"),a=S(s[0]||"0px",e),l=S(s[1]??s[0]??"0px",n);if(!Number.isFinite(a)||!Number.isFinite(l))return null;let c=a<=0||l<=0;r.push(c?0:a),o.push(c?0:l)}return de({rx:r,ry:o},e,n)}function de(t,e,n){let r=[[e,t.rx[0]+t.rx[1]],[n,t.ry[1]+t.ry[2]],[e,t.rx[2]+t.rx[3]],[n,t.ry[3]+t.ry[0]]],o=1;for(let[i,s]of r)s>0&&(o=Math.min(o,Math.max(i,0)/s));if(o<1)for(let i=0;i<4;i++)t.rx[i]*=o,t.ry[i]*=o;return t}function fe(t,e,n,r){let[o,i,s,a]=e,l=[a,i,i,a],c=[o,o,s,s],f={rx:[0,0,0,0],ry:[0,0,0,0]};for(let u=0;u<4;u++)t.rx[u]<=0||t.ry[u]<=0||(f.rx[u]=Math.max(0,t.rx[u]-l[u]),f.ry[u]=Math.max(0,t.ry[u]-c[u]));return de(f,n,r)}function he(t){let e=0;for(let n=0;n<4;n++){if(t.rx[n]<=0||t.ry[n]<=0)continue;let r=t.rx[n]/t.ry[n];if(!e)e=r;else if(Math.abs(t.rx[n]/e-t.ry[n])>1)return NaN}return e||1}var ct=8;function ut(t,e){let[n,r,o,i]=e.border,[s,a,l,c]=e.padding,[f,u,p,d]=e.margin;switch(t){case"padding-box":return{x:i,y:n,w:e.w-i-r,h:e.h-n-o,edges:[n,r,o,i]};case"content-box":case"fill-box":return{x:i+c,y:n+s,w:e.w-i-r-c-a,h:e.h-n-o-s-l,edges:[n+s,r+a,o+l,i+c]};case"margin-box":return{x:-d,y:-f,w:e.w+d+u,h:e.h+f+p,edges:[-f,-u,-p,-d]};default:return{x:0,y:0,w:e.w,h:e.h,edges:[0,0,0,0]}}}var dt=/\s*\b(border-box|padding-box|content-box|margin-box|fill-box|stroke-box|view-box)\s*$/;function te(t,e,n,r,o){let i=o||{rx:[0,0,0,0],ry:[0,0,0,0]},s=he(i);return Number.isFinite(s)?{shape:{kind:0,box:[t,e*s,Math.max(0,n),Math.max(0,r)*s],radius:i.rx.slice(),points:null,ky:s}}:{reason:"mixed-corners"}}function ft(t){let[e,n]=t.split("/").map(s=>L(s)),r=s=>{let[a,l=a,c=a,f=l]=s;return[a,l,c,f]},o=r(e),i=n?r(n):o;return o.map((s,a)=>`${s} ${i[a]}`)}function ue(t,e){let[n,r]=t.split(/\bround\b/),o=L(n),[i,s=i,a=i,l=s]=o,c=S(i,e.h),f=S(s,e.w),u=S(a,e.h),p=S(l,e.w);if(![c,f,u,p].every(Number.isFinite))return{reason:"unparsed"};let d=Math.max(0,e.w-p-f),h=Math.max(0,e.h-c-u),m=null;if(r){let b=ee(ft(r),e.w,e.h);if(!b)return{reason:"unparsed"};m=de(b,d,h)}return te(e.x+p,e.y+c,d,h,m)}function ht(t,e){let n={left:[0,"x"],right:[1,"x"],top:[0,"y"],bottom:[1,"y"],center:[.5,""]};if(!t.length)return[e.w/2,e.h/2];if(t.length===1&&(t=[t[0],"center"]),t.length===2){let[r,o]=t;(n[r]?.[1]==="y"||n[o]?.[1]==="x")&&([r,o]=[o,r]);let i=n[r]?n[r][0]*e.w:S(r,e.w),s=n[o]?n[o][0]*e.h:S(o,e.h);return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}if(t.length===4){let r=[[t[0],t[1]],[t[2],t[3]]];n[r[0][0]]?.[1]==="y"&&(r=[r[1],r[0]]);let o=([a,l],c)=>{let f=S(l,c);return a==="right"||a==="bottom"?c-f:f},i=o(r[0],e.w),s=o(r[1],e.h);return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}return null}function J(t,e,n,r){return!t||t==="closest-side"?Math.min(Math.abs(e),Math.abs(n-e)):t==="farthest-side"?Math.max(Math.abs(e),Math.abs(n-e)):S(t,r)}function mt(t,e,n){let[r,o]=e.split(/\bat\b/),i=L(r),s=ht(L(o||""),n);if(!s)return{reason:"unparsed"};let[a,l]=s,c,f;if(t==="circle"){let h=i[0];c=f=!h||h.endsWith("-side")?(h==="farthest-side"?Math.max:Math.min)(J(h,a,n.w,0),J(h,l,n.h,0)):S(h,Math.hypot(n.w,n.h)/Math.SQRT2)}else c=J(i[0],a,n.w,n.w),f=J(i[1],l,n.h,n.h);if(!Number.isFinite(c)||!Number.isFinite(f))return{reason:"unparsed"};c>0&&f>0||(c=f=0);let u=f>0?c/f:1,p=n.x+a,d=(n.y+l)*u;return{shape:{kind:0,box:[p-c,d-c,2*c,2*c],radius:[c,c,c,c],points:null,ky:u}}}function pt(t,e,n,r,o,i,s,a){let l=(s-o)*(e-i)-(a-i)*(t-o),c=(s-o)*(r-i)-(a-i)*(n-o),f=(n-t)*(i-e)-(r-e)*(o-t),u=(n-t)*(a-e)-(r-e)*(s-t);return l*c<0&&f*u<0}function bt(t){let e=t.length/2;for(let n=0;n<e;n++){let r=(n+1)%e;for(let o=n+1;o<e;o++){let i=(o+1)%e;if(!(n===i||r===o)&&pt(t[n*2],t[n*2+1],t[r*2],t[r*2+1],t[o*2],t[o*2+1],t[i*2],t[i*2+1]))return!0}}return!1}function gt(t,e){let n=lt(t),r=!1;(n[0]==="evenodd"||n[0]==="nonzero")&&(r=n.shift()==="evenodd");let o=[];for(let i of n){let[s,a]=L(i),l=S(s||"",e.w),c=S(a||"",e.h);if(!Number.isFinite(l)||!Number.isFinite(c))return{reason:"unparsed"};o.push(e.x+l,e.y+c)}if(o.length===8){let i=[o[0],o[2],o[4],o[6]],s=[o[1],o[3],o[5],o[7]],a=!0;for(let p=0;p<4;p++){let d=(p+1)%4;i[p]!==i[d]&&s[p]!==s[d]&&(a=!1)}let l=Math.min(...i),c=Math.max(...i),f=Math.min(...s),u=Math.max(...s);if(a&&new Set(i).size<=2&&new Set(s).size<=2)return te(l,f,c-l,u-f,null)}return o.length/2>ct?{reason:"polygon-points"}:!r&&bt(o)?{reason:"polygon-nonzero"}:{shape:{kind:1,box:[0,0,0,0],radius:[0,0,0,0],points:o,ky:1}}}function Oe(t,e){let n=(t||"none").trim();if(n==="none"||n==="")return null;let r="border-box",o=dt.exec(n);o&&(r=o[1],n=n.slice(0,o.index).trim());let i=ut(r,e);if(!n){let c=ee(e.radius,e.w,e.h);return c?te(i.x,i.y,i.w,i.h,fe(c,i.edges,i.w,i.h)):{reason:"unparsed"}}let s=/^([a-z-]+)\((.*)\)$/s.exec(n);if(!s)return{reason:"unsupported"};let[,a,l]=s;if(/\b(min|max|clamp|var|env)\(/.test(l))return{reason:"unparsed"};switch(a){case"inset":return ue(l,i);case"rect":{let[c,f,u,p]=L(l.split(/\bround\b/)[0]),d=(w,A,v)=>w==="auto"?v:S(w,A),h=d(c,i.h,0),m=i.w-d(f,i.w,i.w),b=i.h-d(u,i.h,i.h),g=d(p,i.w,0),y=l.split(/\bround\b/)[1];return ue(`${h}px ${m}px ${b}px ${g}px${y?` round ${y}`:""}`,i)}case"xywh":{let[c,f,u,p]=L(l.split(/\bround\b/)[0]).map((h,m)=>S(h,m%2?i.h:i.w)),d=l.split(/\bround\b/)[1];return ue(`${f}px ${i.w-c-u}px ${i.h-f-p}px ${c}px${d?` round ${d}`:""}`,i)}case"circle":case"ellipse":return mt(a,l,i);case"polygon":return gt(l,i);default:return{reason:"unsupported"}}}function He(t,e,n){let r=/^rect\((.*)\)$/.exec((t||"auto").trim());if(!r)return null;let o=r[1].split(/\s*,\s*|\s+/).filter(Boolean);if(o.length!==4)return{reason:"unparsed"};let i=(f,u)=>f==="auto"?u:S(f,0),s=i(o[0],0),a=i(o[1],e),l=i(o[2],n),c=i(o[3],0);return[s,a,l,c].every(Number.isFinite)?te(c,s,a-c,l-s,null):{reason:"unparsed"}}function ze(t,e,n,r,o=0){let i=n[0],s=n[1],a=n[2],l=n[3],c=Array.from(r),f=1;for(let g=0;g<4;g++)f=Math.min(f,(g%2?l:a)/Math.max(c[g]+c[(g+1)%4],1e-5));let u=t-i,p=e-s,d=Math.abs(u-a/2)-a/2,h=Math.abs(p-l/2)-l/2,m=Math.hypot(Math.max(d,0),Math.max(h,0))+Math.min(Math.max(d,h),0),b=[u,p,a-u,p,a-u,l-p,u,l-p];for(let g=0;g<4;g++){let y=c[g]*f,w=b[g*2],A=b[g*2+1];Math.max(w,A)<y&&(m=Math.max(m,Math.hypot(w-y,A-y)-y))}return m<=o}function Be(t,e,n){let r=n.length/2,o=!1;for(let i=0,s=r-1;i<r;s=i++){let a=n[i*2],l=n[i*2+1],c=n[s*2],f=n[s*2+1];l>e!=f>e&&t<(c-a)*(e-l)/(f-l)+a&&(o=!o)}return o}var R=t=>parseFloat(t||"0")||0;function yt(t){try{return t.matches(":modal")||t.matches(":popover-open")}catch{return!1}}function xt(t,e){let n=e.get(t);if(n)return n;let r=getComputedStyle(t),o=r.maskImage&&r.maskImage!=="none"||r.webkitMaskImage&&r.webkitMaskImage!=="none"||r.maskBorderSource&&r.maskBorderSource!=="none"||r.webkitMaskBoxImageSource&&r.webkitMaskBoxImageSource!=="none";return n={el:t,tag:t.localName||t.tagName.toLowerCase(),display:r.display,position:r.position||"static",overflowX:r.overflowX||"visible",overflowY:r.overflowY||"visible",contain:r.contain||"none",contentVisibility:r.contentVisibility||"visible",willChange:r.willChange||"auto",filter:r.filter||"none",backdropFilter:r.backdropFilter||r.webkitBackdropFilter||"none",clipPath:r.clipPath||"none",clip:r.clip||"auto",mask:!!o,transform:r.transform||"none",translate:r.translate||"none",rotate:r.rotate||"none",scale:r.scale||"none",perspective:r.perspective||"none",transformOrigin:r.transformOrigin||"",perspectiveOrigin:r.perspectiveOrigin||"",transformStyle:r.transformStyle||"flat",backfaceVisibility:r.backfaceVisibility||r.webkitBackfaceVisibility||"visible",offsetPath:r.offsetPath||"none",opacity:r.opacity||"1",isolation:r.isolation||"auto",mixBlendMode:r.mixBlendMode||"normal",zoom:r.zoom||"1",topLayer:yt(t)},e.set(t,n),n}function pe(t,e){if(e.has(t.el))return;e.add(t.el);let n=getComputedStyle(t.el);t.transform=n.transform||"none",t.translate=n.translate||"none",t.rotate=n.rotate||"none",t.scale=n.scale||"none",t.transformOrigin=n.transformOrigin||"",t.perspective=n.perspective||"none",t.perspectiveOrigin=n.perspectiveOrigin||"",t.box=void 0}function be(t,e,n,r,o){let i=Math.min(n+1,t.length-1);me.length<i*2+2&&(me=new Float64Array(i*4+4));let s=me;for(let a=e;a<=i;a++){let l=t[a].el;if(!(l instanceof HTMLElement))return!1;vt(l,s,a*2);let c=I(t[a]);o[a*2]=Number.isFinite(c.width)?c.width:l.offsetWidth,o[a*2+1]=Number.isFinite(c.height)?c.height:l.offsetHeight}for(let a=e;a<i;a++){let l=t[a+1],c=l.tag!=="html"&&l.tag!=="body";r[a*2]=s[a*2]-s[(a+1)*2]-(c?l.el.scrollLeft:0),r[a*2+1]=s[a*2+1]-s[(a+1)*2+1]-(c?l.el.scrollTop:0)}return!0}var me=new Float64Array(64),ge=()=>window.scrollX||document.body?.scrollLeft||0,ye=()=>window.scrollY||document.body?.scrollTop||0,wt=t=>(t.overflowY==="auto"||t.overflowY==="scroll")&&t.el.scrollHeight>t.el.clientHeight;function vt(t,e,n){let r=0,o=0,i=t;for(;i;){r+=i.offsetLeft,o+=i.offsetTop;let s=i.offsetParent;if(!s){getComputedStyle(i).position==="fixed"&&(r+=ge(),o+=ye());break}if(s===document.body)break;r+=s.clientLeft,o+=s.clientTop,i=s}e[n]=r,e[n+1]=o}function I(t){if(t.box)return t.box;let e=t.el,n=getComputedStyle(e),r=(u,p="")=>["Top","Right","Bottom","Left"].map(d=>R(n[`${u}${d}${p}`])),o=r("border","Width"),i=r("padding"),s=r("margin"),[a,l]=kt(n),c=[0,0],f=u=>u==="auto"||u==="scroll";if(e instanceof HTMLElement&&(f(t.overflowX)||f(t.overflowY))){let u=e.offsetWidth-e.clientWidth-o[1]-o[3],p=e.offsetHeight-e.clientHeight-o[0]-o[2];c=[u>=2?u:0,p>=2?p:0]}return t.box={border:o,padding:i,margin:s,radius:[n.borderTopLeftRadius,n.borderTopRightRadius,n.borderBottomRightRadius,n.borderBottomLeftRadius].map(u=>u||"0px"),width:a,height:l,direction:n.direction||"ltr",overflowClipMargin:n.overflowClipMargin||"0px",scrollbar:c},t.box}function kt(t){let e=/px$/.test(t.width)?R(t.width):NaN,n=/px$/.test(t.height)?R(t.height):NaN;return t.boxSizing!=="border-box"&&(e+=R(t.paddingLeft)+R(t.paddingRight)+R(t.borderLeftWidth)+R(t.borderRightWidth),n+=R(t.paddingTop)+R(t.paddingBottom)+R(t.borderTopWidth)+R(t.borderBottomWidth)),[e,n]}function Mt(t){return t.assignedSlot??t.parentElement??(t.parentNode?.host||null)}function xe(t,e){let n=[],r=t;for(;r;){let o=xt(r,e);if(n.push(o),o.tag==="html"||o.topLayer)break;r=Mt(r)}return n}var q=(t,...e)=>e.some(n=>new RegExp(`\\b${n}\\b`).test(t)),Xe=t=>t.tag==="html",Ct=t=>{let e=Xe(t)?t.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):t.willChange;return q(e,"transform","perspective","filter","translate","rotate","scale")},St=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function Nt(t,e=!0){for(let r of St)if(t[r]!=="none"&&!(Xe(t)&&r.endsWith("ilter")))return`${r==="backdropFilter"?"backdrop-filter":r}: ${t[r]}`;if(q(t.contain,"layout","paint","strict","content"))return`contain: ${t.contain}`;if(t.contentVisibility==="auto"||t.contentVisibility==="hidden")return`content-visibility: ${t.contentVisibility}`;if(Ct(t))return`will-change: ${t.willChange}`;let n=parseFloat(t.zoom||"1");return e&&Number.isFinite(n)&&Math.abs(n-1)>1e-6?`zoom: ${t.zoom}`:null}var we=t=>Nt(t,!1)!==null;function De(t,e=null){for(let n=0;n<t.length;n++){let r=t[n];if(r.tag==="html")break;if(r.tag!=="body"&&r.el.classList?.contains("pin-spacer"))return!0;if(r.position==="fixed"){let o=!1;for(let i=n+1;i<t.length&&!o;i++)o=we(t[i]);if(!o)return!0}else if(r.position==="sticky"){let o=null;for(let i=n+1;i<t.length&&!o;i++){let s=t[i];(s.el===e||s.tag==="html"||s.tag==="body"||$t(s))&&(o=s)}if(!o||o.el===e||o.tag==="html"||o.tag==="body")return!0}}return!1}function $t(t){let e=n=>n==="hidden"||n==="auto"||n==="scroll"||n==="overlay";return t.display!=="inline"&&t.display!=="contents"&&(e(t.overflowX)||e(t.overflowY))}function At(t){return t.position!=="static"||we(t)}function Ft(t){return t.display==="inline"?!1:t.overflowX!=="visible"||t.overflowY!=="visible"||q(t.contain,"paint","strict","content")||t.contentVisibility==="auto"||t.contentVisibility==="hidden"}function ne(t,e=0,n=!1){let r=[],o=null;if(!t.length)return{sources:r,mask:o};let i=t[t.length-1].tag==="html"?t[t.length-1]:null,s=!i||i.overflowX==="visible"&&i.overflowY==="visible",a=t[0].position;for(let l=0;l<t.length&&!(n&&l>e);l++){let c=t[l];if(c.display!=="contents"){if(l>0&&(a==="static"||a==="relative"||a==="sticky"||a==="absolute"&&At(c)||a==="fixed"&&we(c))){let u=c.tag==="html"||c.tag==="body"&&(s||wt(c));Ft(c)&&!u&&r.push({node:c,depth:l,by:"overflow"}),a=c.position}c.clipPath!=="none"&&r.push({node:c,depth:l,by:"clip-path"}),c.clip!=="auto"&&c.clip!==""&&(c.position==="absolute"||c.position==="fixed")&&r.push({node:c,depth:l,by:"clip"}),c.mask&&!o&&(o=c)}}return{sources:r,mask:o}}function Ye(t,e,n,r){let[o,i,s,a]=e.border,[l,c]=e.scrollbar,f=a+(e.direction==="rtl"?l:0),u=o,p=n-i-(e.direction==="rtl"?0:l),d=r-s-c,h=[o,i,s,a],m=t.overflowX==="clip",b=t.overflowY==="clip";if(m||b){let k=(e.overflowClipMargin||"0px").trim().split(/\s+/),M=k.find(H=>/-box$/.test(H))||"padding-box",N=Math.max(0,S(k.find(H=>!/-box$/.test(H))||"0px",0)||0),[C,F,E,$]=e.padding,P=M==="content-box"?[C,F,E,$]:M==="border-box"?[-o,-i,-s,-a]:[0,0,0,0],O=[P[0]-N,P[1]-N,P[2]-N,P[3]-N];m&&(f+=O[3],p-=O[1]),b&&(u+=O[0],d-=O[2]),h=h.map((H,B)=>H+O[B])}let g=1e6,y=t.overflowX==="visible"&&!q(t.contain,"paint","strict","content"),w=t.overflowY==="visible"&&!q(t.contain,"paint","strict","content");y&&(f=-g,p=g),w&&(u=-g,d=g);let A=null;if(!y&&!w){let k=ee(e.radius,n,r);if(!k)return{reason:"unparsed"};A=fe(k,h,p-f,d-u)}let v=A?he(A):1;return Number.isFinite(v)?{shape:{kind:0,box:[f,u*v,Math.max(0,p-f),Math.max(0,d-u)*v],radius:A?A.rx.slice():[0,0,0,0],points:null,ky:v}}:{reason:"mixed-corners"}}function T(t){return t.fill(0),t[0]=t[5]=t[10]=t[15]=1,t}function X(t,e,n){let r=Et;for(let o=0;o<4;o++){let i=n[o*4],s=n[o*4+1],a=n[o*4+2],l=n[o*4+3];for(let c=0;c<4;c++)r[o*4+c]=e[c]*i+e[4+c]*s+e[8+c]*a+e[12+c]*l}return t.set(r),t}var Et=new Float64Array(16);function re(t,e,n,r,o=0){t!==e&&t.set(e);for(let i=0;i<4;i++){let s=t[i*4+3];t[i*4]+=n*s,t[i*4+1]+=r*s,t[i*4+2]+=o*s}return t}function Lt(t){let e=t,n=(o,i,s,a,l,c)=>e[a*4+o]*(e[l*4+i]*e[c*4+s]-e[c*4+i]*e[l*4+s])-e[l*4+o]*(e[a*4+i]*e[c*4+s]-e[c*4+i]*e[a*4+s])+e[c*4+o]*(e[a*4+i]*e[l*4+s]-e[l*4+i]*e[a*4+s]),r=-e[3]*n(0,1,2,1,2,3)+e[7]*n(0,1,2,0,2,3)-e[11]*n(0,1,2,0,1,3)+e[15]*n(0,1,2,0,1,2);return!r||!Number.isFinite(r)?NaN:n(0,1,3,0,1,3)/r}var Rt=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?$/i;function Pt(t){let e=Rt.exec(t.trim());if(!e)return NaN;let n=parseFloat(e[1]);switch((e[2]||"deg").toLowerCase()){case"rad":return n;case"grad":return n*Math.PI/200;case"turn":return n*2*Math.PI;default:return n*Math.PI/180}}function It(t,e){let n=t.trim();if(!n||n==="none")return null;let r=/^matrix(3d)?\((.*)\)$/.exec(n);if(!r)return null;let o=r[2].split(",").map(Number);return o.some(i=>!Number.isFinite(i))?null:r[1]?o.length!==16?null:(e.set(o),e):o.length!==6?null:(T(e),e[0]=o[0],e[1]=o[1],e[4]=o[2],e[5]=o[3],e[12]=o[4],e[13]=o[5],e)}function Tt(t,e){let n=t.trim().split(/\s+/);if(!n[0]||n[0]==="none")return null;let r=0,o=0,i=1,s=Pt(n[n.length-1]);return Number.isFinite(s)?(n.length===2?(r=n[0]==="x"?1:0,o=n[0]==="y"?1:0,i=n[0]==="z"?1:0):n.length===4&&(r=Number(n[0]),o=Number(n[1]),i=Number(n[2])),Ot(e,r,o,i,s)):null}function Ot(t,e,n,r,o){let i=Math.hypot(e,n,r);if(T(t),!i||!Number.isFinite(i))return t;e/=i,n/=i,r/=i;let s=Math.sin(o),a=Math.cos(o),l=1-a;return t[0]=a+e*e*l,t[1]=n*e*l+r*s,t[2]=r*e*l-n*s,t[4]=e*n*l-r*s,t[5]=a+n*n*l,t[6]=r*n*l+e*s,t[8]=e*r*l+n*s,t[9]=n*r*l-e*s,t[10]=a+r*r*l,t}function Ht(t,e){let n=t.trim().split(/\s+/);if(!n[0]||n[0]==="none")return null;let r=(a,l)=>a===void 0?l:a.endsWith("%")?parseFloat(a)/100:parseFloat(a),o=r(n[0],1),i=r(n[1],o),s=r(n[2],1);return[o,i,s].every(Number.isFinite)?(T(e),e[0]=o,e[5]=i,e[10]=s,e):null}function zt(t,e,n,r){let o=L(t);if(!o[0]||o[0]==="none")return null;let i=S(o[0],e),s=o[1]===void 0?0:S(o[1],n),a=o[2]===void 0?0:S(o[2],0);return[i,s,a].every(Number.isFinite)?(T(r),r[12]=i,r[13]=s,r[14]=a,r):null}function We(t,e,n){let r=L(t||""),o=r[0]===void 0?e/2:S(r[0],e),i=r[1]===void 0?n/2:S(r[1],n),s=r[2]===void 0?0:S(r[2],0);return[Number.isFinite(o)?o:e/2,Number.isFinite(i)?i:n/2,Number.isFinite(s)?s:0]}var Bt=new Set(["img","video","canvas","iframe","embed","object","svg","input","select","textarea","button"]);function U(t){return!(t.display==="contents"||t.display==="none"||t.display==="inline"&&!Bt.has(t.tag))}function z(t){return U(t)&&(t.transform!=="none"||t.translate!=="none"||t.rotate!=="none"||t.scale!=="none")}var Xt=new Float64Array(16);function ve(t,e,n,r){if(!z(t))return null;let[o,i,s]=We(t.transformOrigin,e,n);T(r),re(r,r,o,i,s);let a=Xt;zt(t.translate,e,n,a)&&X(r,r,a),Tt(t.rotate,a)&&X(r,r,a),Ht(t.scale,a)&&X(r,r,a),It(t.transform,a)&&X(r,r,a);let l=a;return T(l),l[12]=-o,l[13]=-i,l[14]=-s,X(r,r,l),r}function Dt(t){return Math.abs(t[2])>1e-9||Math.abs(t[3])>1e-9||Math.abs(t[6])>1e-9||Math.abs(t[7])>1e-9||Math.abs(t[8])>1e-9||Math.abs(t[9])>1e-9||Math.abs(t[11])>1e-9||Math.abs(t[10]-1)>1e-9}function Yt(t){return Math.abs(t[1])>1e-9||Math.abs(t[4])>1e-9||t[0]<=1e-9||t[5]<=1e-9}function ke(t){return!(t.transformStyle!=="preserve-3d"||t.overflowX!=="visible"||t.overflowY!=="visible"||(parseFloat(t.opacity)||0)<1&&t.opacity!==""||t.filter!=="none"||t.clipPath!=="none"||t.mask||t.isolation==="isolate"||t.mixBlendMode&&t.mixBlendMode!=="normal"||/\b(paint|strict|content)\b/.test(t.contain))}var Ge=new Float64Array(16);function oe(t,e=0){let n=0,r=Ge;for(let o=e;o<t.length;o++){let i=t[o];if(ve(i,0,0,r)){if(Dt(r)||Math.abs(r[14])>1e-9&&Wt(t,o))return 2;Yt(r)&&(n=1)}}return n}function Ve(t,e,n,r){for(let o=e;o<=n&&o+1<t.length;o++){let i=t[o+1];if(!(!z(t[o])||i.perspective==="none"||!U(i))&&!(i.overflowX==="visible"&&i.overflowY==="visible")&&r(o+1))return o+1}return-1}function Wt(t,e){for(let n=e+1;n<t.length;n++){if(t[n].perspective!=="none")return!0;if(!ke(t[n]))return!1}return!1}function Me(t,e,n){n[0]=1,n[1]=0,n[2]=0,n[3]=1;let r=Ge;for(let o=e;o<t.length;o++){if(!ve(t[o],0,0,r))continue;let i=r[0],s=r[1],a=r[4],l=r[5],c=n[0],f=n[1],u=n[2],p=n[3];n[0]=i*c+a*f,n[1]=s*c+l*f,n[2]=i*u+a*p,n[3]=s*u+l*p}return n}function Ce(t,e){let n=e;for(let r=e;r<t.length;r++){let o=t[r];(z(o)||o.perspective!=="none"&&r>e&&z(t[r-1]))&&(n=r)}return n}var Gt=new Float64Array(16),Vt=new Float64Array(16);function Se(t,e,n,r,o,i,s,a){let l=T(a.m);a.behind=!1,a.backHidden=!1,a.scene=-1;for(let c=e;c<=n&&c<t.length;c++){let f=t[c];je(l,t,c,r,o);let u=t[c+1];if(f.backfaceVisibility==="hidden"&&!a.backHidden&&Ut(t,c,n,r,o)&&(a.backHidden=!0),u&&ke(u)){a.scene=c+1;continue}jt(l)}for(let[c,f]of[[0,0],[i,0],[i,s],[0,s]])l[3]*c+l[7]*f+l[15]<=1e-6&&(a.behind=!0);return a}function je(t,e,n,r,o){let i=e[n],s=ve(i,o[n*2]||0,o[n*2+1]||0,Gt);s&&X(t,s,t),re(t,t,r[n*2]||0,r[n*2+1]||0,0);let a=e[n+1];if(a&&a.perspective!=="none"&&U(a)){let l=parseFloat(a.perspective);if(l>0){let[c,f]=We(a.perspectiveOrigin,o[(n+1)*2]||0,o[(n+1)*2+1]||0),u=T(Vt);u[11]=-1/Math.max(l,1),re(t,t,-c,-f,0),X(t,u,t),re(t,t,c,f,0)}}}function jt(t){t[2]=t[6]=t[14]=0,t[8]=t[9]=t[11]=0,t[10]=1}var qt=new Float64Array(16);function Ut(t,e,n,r,o){let i=T(qt);for(let a=e;a<=Math.max(n,e)&&a<t.length;a++){je(i,t,a,r,o);let l=t[a+1];if(!l||!ke(l))break}return Lt(i)<0}function Ne(t,e){return e[0]=t[0],e[1]=t[1],e[2]=t[3],e[3]=t[4],e[4]=t[5],e[5]=t[7],e[6]=t[12],e[7]=t[13],e[8]=t[15],e}function $e(t,e){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ae(t,e,n,r,o,i,s){let a=1/0,l=1/0,c=-1/0,f=-1/0;for(let d=0;d<4;d++){let h=d===1||d===2?e:0,m=d>=2?n:0,b=t[2]*h+t[5]*m+t[8],g=(t[0]*h+t[3]*m+t[6])/b,y=(t[1]*h+t[4]*m+t[7])/b;g<a&&(a=g),g>c&&(c=g),y<l&&(l=y),y>f&&(f=y)}let u=r-a,p=o-l;for(let d=0;d<3;d++)t[d*3]+=u*t[d*3+2],t[d*3+1]+=p*t[d*3+2];return Math.max(Math.abs(c-a-i),Math.abs(f-l-s))}function qe(t,e,n,r){let o=e/2,i=n/2,s=t[2]*o+t[5]*i+t[8],a=(t[0]*o+t[3]*i+t[6])/s,l=(t[1]*o+t[4]*i+t[7])/s,c=(t[0]-a*t[2])/s,f=(t[1]-l*t[2])/s,u=(t[3]-a*t[5])/s,p=(t[4]-l*t[5])/s,d=Math.sqrt(Math.abs(c*p-f*u))||1;return r[0]=r[1]=d,r}function K(t){return Math.abs(t[1])<1e-9&&Math.abs(t[3])<1e-9&&Math.abs(t[2])<1e-9&&Math.abs(t[5])<1e-9&&Math.abs(t[8]-1)<1e-9}function x(t){if(!t||typeof t.tagName!="string")return"<?>";let e=t.tagName.toLowerCase();if(t.id)return`<${e}#${t.id}>`;let n=typeof t.className=="string"?t.className.trim().split(/\s+/)[0]:"";return n?`<${e}.${n}>`:`<${e}>`}var W=2,_=8;function Kt(){return{list:[],occ:[],occHow:[],noSlots:!1,occSlots:[],mask:null,scissorDoc:new Float64Array(8),shaders:[],reason:null,fold:new Float32Array(4),ownRadius:new Float32Array(4),ownKy:1,count:0,xf:new Float32Array(9*W),box:new Float32Array(4*W),radius:new Float32Array(4*W),poly:new Float32Array(2*_),polyInfo:new Float32Array([-1,0]),ga:!1,scissorPx:new Int32Array(4),cutBy:null,reshaped:!1}}function Ke(t,e,n,r,o,i=[]){let s=Math.max(0,e.findIndex(u=>u.el===t.el)),{sources:a,mask:l}=ne(e,s,n);if(!a.length&&!l&&!i.length)return null;let c=o||Kt();c.occ=i,c.occSlots.length=0,c.occHow.length=i.length,c.occHow.fill("pruned");let f=[];for(let u of a){let p=c.list.find(d=>d.el===u.node.el&&d.by===u.by);f.push({el:u.node.el,by:u.by,node:u.node,own:u.depth<=s,ignored:!1,depth:u.depth,key:p?.key||"",shape:p?.shape||null,reason:p?.reason||null,m:p?.m||new Float64Array(9),inv:p?.inv||new Float64Array(9),bounds:p?.bounds||new Float64Array(4),scrolls:r(u.node.el),square:!1,how:"shader"})}return c.list=f,c.mask=l,c}function _t(t,e,n,r,o){let i=`${e.radius.join(" ")}|${e.border.join(" ")}|${e.padding.join(" ")}`;return t.by==="overflow"?`|${r}|${o}|${i}|${e.overflowClipMargin}|${e.scrollbar.join(" ")}|${e.direction}`:t.by==="clip-path"||t.by==="occlude"?`${n}|${r}|${o}|${i}|${e.margin.join(" ")}`:`${n}|${r}|${o}`}function Fe(t,e,n,r,o){let i=I(t.node),s=_t(t,i,o,n,r);if(s!==t.key||!t.shape&&!t.reason){t.key=s;let h=t.by==="overflow"?Ye(t.node,i,n,r):t.by==="clip"?He(o,n,r):Oe(o,{w:n,h:r,border:i.border,padding:i.padding,margin:i.margin,radius:i.radius});t.shape=h&&"shape"in h?h.shape:null,t.reason=h&&"reason"in h?h.reason:null,h||(t.reason="none")}e!==t.m&&t.m.set(e);let a=t.shape;if(!a)return;if(!D(t.inv,t.m)){t.inv.fill(0),t.bounds.fill(0),t.square=!0;return}t.inv[1]*=a.ky,t.inv[4]*=a.ky,t.inv[7]*=a.ky;let l,c,f,u;if(a.kind===0){let[h,m,b,g]=a.box;l=h,f=h+b,c=m/a.ky,u=(m+g)/a.ky}else{let h=a.points;l=c=1/0,f=u=-1/0;for(let m=0;m<h.length;m+=2)l=Math.min(l,h[m]),f=Math.max(f,h[m]),c=Math.min(c,h[m+1]),u=Math.max(u,h[m+1])}let p=t.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-1/0;let d=Math.max(Math.abs(l),Math.abs(f),Math.abs(c),Math.abs(u))>1e5;for(let h=0;h<4;h++){let m=h===1||h===2?f:l,b=h>=2?u:c,g=d?1:e[2]*m+e[5]*b+e[8],y=(e[0]*m+e[3]*b+e[6])/g,w=(e[1]*m+e[4]*b+e[7])/g;y<p[0]&&(p[0]=y),w<p[1]&&(p[1]=w),y>p[2]&&(p[2]=y),w>p[3]&&(p[3]=w)}t.square=a.kind===0&&a.radius.every(h=>h<=0)&&K(e)}function ie(t,e,n){let r=t.shape,o=t.inv,i=o[2]*e+o[5]*n+o[8],s=(o[0]*e+o[3]*n+o[6])/i,a=(o[1]*e+o[4]*n+o[7])/i;return r.kind===0?ze(s,a,r.box,r.radius,.01):Be(s,a,r.points)}function Qt(t,e){let n=t.shape;return n.kind===1&&!Zt(n.points)?!1:ie(t,e[0],e[1])&&ie(t,e[2],e[1])&&ie(t,e[2],e[3])&&ie(t,e[0],e[3])}function Zt(t){let e=t.length/2,n=0;for(let r=0;r<e;r++){let o=r*2,i=(r+1)%e*2,s=(r+2)%e*2,a=(t[i]-t[o])*(t[s+1]-t[i+1])-(t[i+1]-t[o+1])*(t[s]-t[i]);if(a!==0){if(n===0)n=Math.sign(a);else if(Math.sign(a)!==n)return!1}}return!0}var Jt=new Float64Array(4);function _e(t,e,n,r){e.reason=null,e.scissorDoc.fill(NaN),e.shaders.length=0,e.fold.fill(0),e.mask&&(e.reason={code:"mask",clips:[]});let o=Jt,i=r?(n[2]-n[0])*.25:0,s=r?(n[3]-n[1])*.25:0;o[0]=n[0]-i,o[1]=n[1]-s,o[2]=n[2]+i,o[3]=n[3]+s;let a=[];for(let d of e.list){if(d.ignored){d.how="ignored";continue}if(d.reason==="none"){d.how="pruned";continue}if(d.reason||!d.shape){e.reason||={code:d.reason||"unparsed",clips:[d]};continue}let h=d.scrolls===t.scrolls;if(d.square){let m=d.bounds;if(h&&m[0]<=o[0]&&m[1]<=o[1]&&m[2]>=o[2]&&m[3]>=o[3]){d.how="pruned";continue}let b=d.scrolls?0:4,g=e.scissorDoc;Number.isNaN(g[b])?g.set(m,b):(g[b]=Math.max(g[b],m[0]),g[b+1]=Math.max(g[b+1],m[1]),g[b+2]=Math.min(g[b+2],m[2]),g[b+3]=Math.min(g[b+3],m[3])),d.how="scissor";continue}a.push(d)}for(let d=a.length-1;d>=0;d--){let h=a[d];h.scrolls===t.scrolls&&Qt(h,o)&&(h.how="pruned",a.splice(d,1))}for(let d=a.length-1;d>=0&&!r;d--){let h=a[d],m=h.shape,b=h.bounds,g=h.m[0];if(t.level===0&&K(h.m)&&h.scrolls===t.scrolls&&m.kind===0&&m.ky===1&&Math.abs(g-h.m[4])<.01*g&&Math.abs(b[0]-n[0])<.5&&Math.abs(b[1]-n[1])<.5&&Math.abs(b[2]-n[2])<.5&&Math.abs(b[3]-n[3])<.5){for(let w=0;w<4;w++)e.fold[w]=Math.max(e.fold[w],m.radius[w]*g);h.how="corners",a.splice(d,1)}}let l=a.filter(d=>d.shape.kind===1);(a.length>W||l.length>1)&&(e.reason||={code:"too-many",clips:a});for(let d of a)d.how="shader",e.shaders.length<W&&e.shaders.push(d);let c=!1,f=(d,h,m)=>{let b=Math.fround(m);d[h]!==b&&(d[h]=b,c=!0)},u=-1;for(let d=0;d<e.shaders.length;d++){let h=e.shaders[d].shape;for(let m=0;m<4;m++)f(e.box,d*4+m,h.kind===0?h.box[m]:0),f(e.radius,d*4+m,h.kind===0?h.radius[m]:0);h.kind===1&&(u=d)}let p=u>=0?e.shaders[u].shape.points:null;for(let d=0;d<2*_;d++)f(e.poly,d,p&&d<p.length?p[d]:0);return f(e.polyInfo,0,u),f(e.polyInfo,1,p?p.length/2:0),c&&(e.reshaped=!0),e.reason}var en=1,Y=2,tn=new Float64Array(9);function Qe(t,e,n,r){let o=t.reshaped?Y:0;t.reshaped=!1,t.cutBy=null;let i=-1/0,s=-1/0,a=1/0,l=1/0,c=!1,f=t.scissorDoc;for(let v=0;v<8;v+=4){if(Number.isNaN(f[v]))continue;c=!0;let k=v===0?r.scrollX:r.pageX,M=v===0?r.scrollY:r.pageY;i=Math.max(i,f[v]-k),s=Math.max(s,f[v+1]-M),a=Math.min(a,f[v+2]-k),l=Math.min(l,f[v+3]-M)}let u=i,p=s,d=a,h=l,m=null,b=0,g=t.occ;if(g.length){let v=n?e[2]*.25:0,k=n?e[3]*.25:0,M=e[0]-v,N=e[1]-k,C=e[0]+e[2]+v,F=e[1]+e[3]+k;for(let E=0;E<g.length;E++){let $=g[E],P=$.bounds,O=$.scrolls?r.scrollX:r.pageX,H=$.scrolls?r.scrollY:r.pageY,B=P[0]-O,G=P[1]-H,V=P[2]-O,j=P[3]-H;if($.ignored||!$.shape||B>=C||V<=M||G>=F||j<=N){t.occHow[E]="pruned";continue}let le=B<=M&&V>=C,ce=G<=N&&j>=F,Pe=$.axis&&($.square||M>=B+$.rx&&C<=V-$.rx||N>=G+$.ry&&F<=j-$.ry);if(Pe&&le&&ce)return t.cutBy=$,t.occHow[E]="pruned",o;let Z=le&&G<=N?1:le&&j>=F?2:ce&&B<=M?3:ce&&V>=C?4:0,Ie=!t.noSlots&&t.shaders.length+b<W;Z&&(Pe||!Ie&&$.axis)?(Z===1?s=Math.max(s,j):Z===2?l=Math.min(l,G):Z===3?i=Math.max(i,V):a=Math.min(a,B),c=!0,m=$,t.occHow[E]="scissor"):Ie?(t.occSlots[b++]=$,t.occHow[E]="shader"):t.occHow[E]="uncut"}}t.occSlots.length>b&&(t.occSlots.length=b);let y=!1;if(c){if(a<=i||l<=s||!n&&(e[0]>=a||e[0]+e[2]<=i||e[1]>=l||e[1]+e[3]<=s)){let k=d<=u||h<=p||!n&&(e[0]>=d||e[0]+e[2]<=u||e[1]>=h||e[1]+e[3]<=p);return t.cutBy=!k&&m||t.list.find(M=>M.how==="scissor")||m,o}if(y=n||e[0]<i||e[1]<s||e[0]+e[2]>a||e[1]+e[3]>l,y){let k=Math.min(r.cw,Math.max(0,Math.round(i*r.kx))),M=Math.min(r.cw,Math.max(0,Math.round(a*r.kx))),N=Math.min(r.ch,Math.max(0,Math.round(s*r.ky))),C=Math.min(r.ch,Math.max(0,Math.round(l*r.ky)));if(M<=k||C<=N)return t.cutBy=m||t.list.find($=>$.how==="scissor")||null,o;let F=t.scissorPx,E=r.ch-C;(F[0]!==k||F[1]!==E||F[2]!==M-k||F[3]!==C-N)&&(F[0]=k,F[1]=E,F[2]=M-k,F[3]=C-N,o=Y)}}y!==t.ga&&(t.ga=y,o=Y);let w=t.shaders.length,A=w+b;A!==t.count&&(t.count=A,o=Y);for(let v=0;v<w;v++){let k=t.shaders[v],M=k.scrolls?r.scrollX:r.pageX,N=k.scrolls?r.scrollY:r.pageY,C=k.bounds;if(!n&&(e[0]>=C[2]-M||e[0]+e[2]<=C[0]-M||e[1]>=C[3]-N||e[1]+e[3]<=C[1]-N))return t.cutBy=k,o;o|=Ue(t,v,k,r,1)}for(let v=0;v<b;v++){let k=t.occSlots[v],M=w+v;o|=Ue(t,M,k,r,-1);let N=k.shape;for(let C=0;C<4;C++){let F=Math.fround(N.box[C]),E=Math.fround(N.radius[C]);(t.box[M*4+C]!==F||t.radius[M*4+C]!==E)&&(t.box[M*4+C]=F,t.radius[M*4+C]=E,o=Y)}}return o|en}function Ue(t,e,n,r,o){let i=n.scrolls?r.scrollX:r.pageX,s=n.scrolls?r.scrollY:r.pageY,a=1/r.kx,l=1/r.ky,c=n.inv,f=r.ch*l+s,u=tn;u[0]=c[0]*a,u[1]=c[1]*a,u[2]=c[2]*a,u[3]=-c[3]*l,u[4]=-c[4]*l,u[5]=-c[5]*l,u[6]=c[0]*i+c[3]*f+c[6],u[7]=c[1]*i+c[4]*f+c[7],u[8]=c[2]*i+c[5]*f+c[8];let p=t.xf,d=0;for(let h=0,m=e*9;h<9;h++,m++){let b=Math.fround(u[h]*o);p[m]!==b&&(p[m]=b,d=Y)}return d}function Q(t){if(t.by==="occlude")return t.shape&&t.shape.radius.some(n=>n>0)?"data-gl-occlude, rounded":"data-gl-occlude";if(t.by==="overflow"){let n=t.node,r=n.overflowX===n.overflowY?n.overflowX:`${n.overflowX} ${n.overflowY}`,o=r==="visible"?n.contentVisibility!=="visible"?`content-visibility: ${n.contentVisibility}`:`contain: ${n.contain}`:`overflow: ${r}`;return t.shape&&t.shape.radius.some(i=>i>0)?`${o}, rounded`:o}let e=t.by==="clip"?t.node.clip:t.node.clipPath;return`${t.by==="clip"?"clip: ":""}${e.length>60?`${e.slice(0,57)}...`:e}`}function Ze(t,e){let n=x(t.el),r=e.reason,o=r.clips[0],i=s=>s.length>40?`${s.slice(0,37)}...`:s;switch(r.code){case"mask":return`${n}: GL can't draw the CSS mask on ${x(e.mask?.el)}, so its DOM shows. Move the mask off the parents of GL elements, or add data-gl-clip="false" to draw it unmasked.`;case"mixed-corners":return`${n}: ${x(o.el)}'s corners mix different horizontal / vertical radii; GL needs one ratio for all of them, so its DOM shows. Use the same radius both ways (or one shape for all corners).`;case"polygon-points":return`${n}: clip-path polygon() on ${x(o.el)} has more than ${_} points; GL draws up to ${_}, so its DOM shows. Simplify the polygon${o.own?"":', or add data-gl-clip="false" to draw it uncut'}.`;case"polygon-nonzero":return`${n}: clip-path polygon() on ${x(o.el)} crosses itself, and GL fills polygons even-odd, so its DOM shows. Write polygon(evenodd, ...) or untangle it.`;case"too-many":return`${n}: cut by too many rounded or shaped parents (${r.clips.map(s=>x(s.el)).join(", ")}), so its DOM shows. Make one of them a straight overflow: hidden, keep one polygon (up to ${_} points), or add data-gl-clip="false".`;default:{let s=o?o.by==="clip"?o.node.clip:o.node.clipPath:"";return`${n}: ${o?.by==="clip"?"clip":"clip-path"} ${i(s)} on ${x(o?.el)} can't be drawn in GL, so its DOM shows. Use inset(), rect(), xywh(), circle(), ellipse() or polygon()${o?.own?"":', or add data-gl-clip="false" to draw it uncut'}.`}}}function et(t,e,n,r=t.rect){if(r[0]=t.doc.x-e,r[1]=t.doc.y-n,r[2]=t.doc.w,r[3]=t.doc.h,t.pad){let o=t.pad*(t.layoutW?t.doc.w/t.layoutW:1),i=t.pad*(t.layoutH?t.doc.h/t.layoutH:1);r[0]-=o,r[1]-=i,r[2]+=o*2,r[3]+=i*2}return r}var nn=/^(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)/,rn=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,on={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},Je=new WeakMap;function sn(t){let e=Je.get(t);if(e!==void 0)return e;try{let n=t.effect.getKeyframes();e=0;for(let r of new Set(n.flatMap(o=>Object.keys(o)))){if(!nn.test(r))continue;let o=n.map(s=>s[r]).filter(s=>s!=null),i=on[r];e=Math.max(e,rn.test(r)||i&&!(o.length&&o.every(s=>i.test(String(s).trim())))?2:1)}}catch{e=2}return Je.set(t,e),e}var Ee=t=>sn(t)>0;var an=t=>!!t.backgroundImage&&t.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(t.backgroundColor||"transparent"),ln=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],Le=t=>t.position!=="static"&&t.zIndex!=="auto"||/fixed|sticky/.test(t.position)||parseFloat(t.opacity)<1||ln.some(e=>(t[e]||"none")!=="none")||t.isolation==="isolate"||(t.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(t.contain)||/^(size|inline-size)$/.test(t.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(t.willChange);function tt(t,e){let n=parseInt(getComputedStyle(e).zIndex,10);if(!(n>0))return null;let r=null,o="auto",i=[];for(let s=t;s&&s!==document.body&&s!==document.documentElement;s=s.parentElement){let a=getComputedStyle(s);an(a)&&!(s===t&&t.getAttribute("data-gl")==="shader")&&i.push(s),Le(a)&&(r=s,o=a.position!=="static"?a.zIndex:"auto")}return!r||o==="auto"||+o<n||!i.some(s=>r.contains(s))?null:`${x(r)} (z-index ${o}, with a background) covers Umber's canvas (z-index ${n}): GL inside it is hidden. Drop that z-index (and give it data-gl-occlude if it must still cover the GL elements before it) or move the background behind the content.`}function nt(t,e,n){let r=parseInt(getComputedStyle(n).zIndex,10);if(!(r>0)||e>=r||!Le(getComputedStyle(t)))return null;let o=x(t);return[...t.querySelectorAll("[data-gl-above]")].map(i=>[i,`data-gl-above on ${x(i)} stays under Umber's canvas: ${o} around it is a stacking context (a pin, a transform, a fade) under the canvas (z-index ${r}). Give ${o} position: relative and z-index: ${r+1} (no background), or move it out.`])}function se(t){let e=[],n=!0;for(let r=t;r&&r!==document.body&&r!==document.documentElement;r=r.parentElement){let o=getComputedStyle(r),i=Le(o),s=o.position!=="static";(i||n&&s)&&e.unshift([r,s&&o.zIndex!=="auto"&&+o.zIndex||0]),(i||s)&&(n=!1)}return e}function rt(t,e,n,r){let o=0;for(;o<e.length&&o<r.length&&e[o][0]===r[o][0];)o++;let i=e[o]?.[1]??-.5,s=r[o]?.[1]??-.5;return i!==s?s>i:!!(n.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}function ot(t){let e=getComputedStyle(t),n=e.backgroundColor||"transparent";return(n!=="transparent"&&!/^rgba\(/.test(n)&&!/\/\s*(0?\.\d+|0)\s*\)$/.test(n)||!!e.backgroundImage&&e.backgroundImage!=="none")&&parseFloat(e.opacity)>=1}var cn={1:.75,2:1.5},un=3,dn=typeof navigator<"u"&&/AppleWebKit\//.test(navigator.userAgent)&&!/Chrome\/|Chromium\//.test(navigator.userAgent),fn=t=>I(t).radius.some(e=>e.split(" ").every(n=>parseFloat(n)>0));function at(t,e=!1){try{return t.getKeyframes().some(n=>"opacity"in n&&!(e&&parseFloat(n.opacity)>0)||"visibility"in n||"clipPath"in n)}catch{return!0}}var hn=/^(offset|computedOffset|easing|composite|opacity|filter|color|\w+(Color|Shadow))$/,mn=t=>!at(t,!0)&&t.getKeyframes().every(e=>Object.keys(e).every(n=>hn.test(n)));function pn(t,e){if(e.contains(t)||t.contains(e))return!0;let n=t.parentElement;for(let r=e,o=0;r&&r!==document.body&&o<4;r=r.parentElement,o++){let i=r.parentElement;if(i&&(n===i||n?.parentElement===i))return!0}return!1}var bn=/^(SPAN|B|I|EM|STRONG|SMALL|SUB|SUP|TIME|BR)$/;function it(t){for(let e=0;e<t.length;e++)if(t[e].nodeType===1&&!bn.test(t[e].nodeName))return!0;return!1}function st(t){let e=null;for(let n of t)z(n)&&(n.transform!=="none"||n.rotate!=="none")&&(e=n.el);if(!e)for(let n of t)(z(n)||n.perspective!=="none")&&(e=n.el);return e}var Re=[];function gn(t){return{el:t,by:"occlude",node:null,nodes:[],own:!1,ignored:!0,depth:0,key:"",shape:null,reason:null,m:new Float64Array(9),inv:new Float64Array(9),bounds:new Float64Array(4),scrolls:!0,square:!1,how:"pruned",live:!1,axis:!0,rx:0,ry:0,want:!1,over:!1,cuts:[],full:new Float64Array(8),from:null,warned:!1,stack:[],hidden:!1,until:0,linked:!1,fades:!1,at:null}}var ae=class{constructor(e){this.stage=e;this.gb=new Map;this.cb=new Map;this.lb=new Set;this.quad=new Float64Array(4);this.nc=new Float32Array(4);this.Fb=new Float64Array(4);this.rel=new Float64Array(64);this.sizes=new Float64Array(64);this.composed={m:new Float64Array(16),behind:!1,backHidden:!1,scene:-1};this.sb=new WeakSet;this.contexts=new WeakSet;this.held=[];this.ci={scrollX:0,scrollY:0,pageX:0,pageY:0,kx:1,ky:1,cw:1,ch:1};this.occluders=[];this.Hb=-1;this.Ab=0;this.$a=!1;this.ua=!1;this.watch=null;this.Cb=e=>{let n=this.stage.host.scroll.root;return n?n!==e&&n.contains(e):!0};let n=r=>{let o=r.target;o instanceof Element&&(r.type!=="input"||/^(checkbox|radio|select-)/.test(o.type))&&this.hook(o)&&e.request()};for(let r of["pointerover","pointerout","focusin","focusout","input"])e.listen(document,r,n)}start(e,n){this.gb.clear(),this.cb.clear(),this.lb.clear(),this.$a=!1,this.stage.gen!==this.Hb?(this.Hb=this.stage.gen,this.$b(),this.bb(),this.occluders.length&&(n=!0),this.ua=!1):this.ua&&!this.stage.scrolled&&(this.ua=!1,this.bb(),n=!0),n&&this.scanAnimations(e),this.occluders.length&&this.bc(e),this.checkHeld()}measureTransform(e,n,r,o,i,s,a){let l=e.nodes,c=n;if(n){l=e.nodes=xe(e.geomEl,this.stage.chainMemo),e.chained=!0;let m=e.dynamic;m.length=0;for(let b=0;b<l.length;b++){let g=l[b];(z(g)||g.perspective!=="none"||e.animTargets.includes(g.el))&&m.push(b)}e.chainReason=this.xc(e,l)}else if(r&&(e.level&&e.dynamic.length||e.animTargets.length)){if(e.level)for(let m of e.dynamic)pe(l[m],this.lb);for(let m of e.animTargets){let b=l.findIndex(g=>g.el===m);b>=0&&pe(l[b],this.lb)}c=!0}if(c){n||(l[0].box=void 0);let m=I(l[0]);e.boxW=Number.isFinite(m.width)&&m.width>0?m.width:o.width,e.boxH=Number.isFinite(m.height)&&m.height>0?m.height:o.height;let b=oe(l,0);b!==e.level&&e._raster&&(e._raster.textDirty=!0),e.level=b}let f=e.level;if(e.backHidden=!1,e.scene=null,e.xfReason=e.chainReason,!f||e.chainReason){e.edge[0]=e.edge[1]=1;return}let u=e.boxW,p=e.boxH,d=e.xf,h=null;if(f===1)$e(Me(l,0,this.Fb),d);else{let m=Ce(l,0);if(this.grow(l.length),!be(l,0,m,this.rel,this.sizes))h=this.ha(e,"svg",l[0].el);else{let b=Se(l,0,m,this.rel,this.sizes,u,p,this.composed);if(Ne(b.m,d),e.backHidden=b.backHidden,e.scene=b.scene>=0?l[b.scene].el:null,b.behind)h=this.ha(e,"behind",st(l));else if(dn){let g=Ve(l,0,m,y=>fn(l[y]));g>=0&&(h=this.ha(e,"rounded",l[g].el))}}}if(!h){if(Ae(d,u,p,o.left+i,o.top+s,o.width,o.height)<=cn[f])e.verifyMiss=0;else if(!(a<e.animUntil||e.scrollLinked)||++e.verifyMiss>=un){let b=l.find(g=>g.zoom&&Math.abs(parseFloat(g.zoom)-1)>1e-6);h=b?this.ha(e,"zoom",b.el):this.ha(e,"verify",st(l))}}h||qe(d,u,p,e.edge),e.xfReason=h}turnedText(e){if(!e.level||e.xfReason)return null;let n=new Float64Array(9);if(!D(n,e.xf))return null;let r=e.scrolls?this.stage.host.scroll.root:null,o=r?r.scrollLeft:ge(),i=r?r.scrollTop:ye(),s=e.xf,a=e.boxW/2,l=e.boxH/2,c=s[2]*a+s[5]*l+s[8],f=(s[0]*a+s[3]*l+s[6])/c,u=(s[1]*a+s[4]*l+s[7])/c;return{width:e.boxW,height:e.boxH,ax:(s[0]-f*s[2])/c,ay:(s[1]-u*s[2])/c,bx:(s[3]-f*s[5])/c,by:(s[4]-u*s[5])/c,toLocal(p,d,h){let m=p+o,b=d+i,g=n[2]*m+n[5]*b+n[8],y=(n[0]*m+n[3]*b+n[6])/g,w=(n[1]*m+n[4]*b+n[7])/g;h[0]=y,h[1]=w;let A=s[2]*y+s[5]*w+s[8];h[2]=(s[0]-m*s[2])/A,h[3]=(s[1]-b*s[2])/A,h[4]=(s[3]-m*s[5])/A,h[5]=(s[4]-b*s[5])/A}}}grow(e){this.rel.length>=e*2+2||(this.rel=new Float64Array(e*4),this.sizes=new Float64Array(e*4))}xc(e,n){for(let r of n){if(r.el.namespaceURI==="http://www.w3.org/2000/svg")return this.ha(e,"svg",r.el);if(r.offsetPath!=="none"&&r.offsetPath!==""&&U(r))return this.ha(e,"offset-path",r.el)}return null}ha(e,n,r){let o=x(e.el),i=x(r);switch(n){case"behind":return`${o}: part of it turns behind the viewer (3D transform on ${i}), so its DOM shows until it turns back. Lower the angle or raise the perspective.`;case"svg":return`${o}: GL elements can't sit inside an <svg> (${i}); its DOM shows. Move data-gl to an element outside the SVG.`;case"offset-path":return`${o}: offset-path on ${i} moves it along a path GL does not follow, so its DOM shows. Animate transform instead.`;case"scene":return`${o}: GL can't depth-sort several GL elements in one preserve-3d scene (${i}), so their DOM shows. Add backface-visibility: hidden to faces that turn away, or use transform-style: flat.`;case"rounded":return`${o}: WebKit draws a tilt flat when its perspective parent (${i}) also has overflow and border-radius, so its DOM shows. Put the perspective on an inner element, or round the corners with clip-path: inset(0 round <radius>).`;case"zoom":return`${o}: zoom on ${i} scales it in a way GL can't follow together with its transforms, so its DOM shows. Use transform: scale() instead of zoom.`;default:return`${o}: its on-screen box doesn't match the transforms on ${i} (turned almost edge-on?), so its DOM shows until they agree again. Lower the angle or raise the perspective.`}}checkScenes(){let e=new Map;for(let n of this.stage.planes)n.scene&&!n.backHidden&&!n.xfReason&&n.el.isConnected&&e.set(n.scene,(e.get(n.scene)||0)+1);for(let n of this.stage.planes){let r=n.scene&&!n.backHidden&&(e.get(n.scene)||0)>1?this.ha(n,"scene",n.scene):null;r!==n.sceneReason&&(n.sceneReason=r,this.stage.decide(n))}}Lb(e,n,r,o,i,s,a){let l=e[n].el,c=this.cb.get(l);if(c!==void 0)return c&&a.set(c),!!c;let f=this.za(l),u=oe(e,n),p=!0;if(u===0)Te(a,f.left+r,f.top+o,i?f.width/i:1,s?f.height/s:1);else{if(u===1)$e(Me(e,n,this.Fb),a);else{let d=Ce(e,n);this.grow(e.length),p=be(e,n,d,this.rel,this.sizes)&&!Se(e,n,d,this.rel,this.sizes,i,s,this.composed).behind,p&&Ne(this.composed.m,a)}p&&Ae(a,i,s,f.left+r,f.top+o,f.width,f.height)}return this.cb.set(l,p?a:null),p}measureClips(e,n,r=!0){if(e.nodes[e.nodes.length-1]?.topLayer)return`${x(e.el)}: it is inside an open modal <dialog> or popover (the top layer), which paints over Umber's canvas, so its DOM shows.`;let o=e.clips,i=o?o.occHow.indexOf("uncut"):-1;if(i>=0){let u=x(o.occ[i].el);this.stage.warnOnce(e,o.noSlots?`${x(e.el)}: a layer can only be cut straight, so data-gl-occlude on ${u} doesn't hide it where it passes through it or a rounded or turned corner overlaps it (GL draws over that panel there).`:`${x(e.el)}: its parents' rounded or shaped clips take both GL clip slots, so data-gl-occlude on ${u} doesn't hide it where they overlap (GL draws over that panel there). Make one of those parents' clips a straight overflow: hidden.`)}if(n){if(!this.sb.has(e)&&!this.stage.transitioning){this.sb.add(e);let p=tt(e.el,this.stage.hostEl);p&&this.stage.warnOnce(e,`${x(e.el)}: ${p}`)}if(!this.stage.transitioning){let[p]=se(e.el),d=p&&p[0]!==e.el&&!this.contexts.has(p[0])&&nt(p[0],p[1],this.stage.hostEl);if(d){this.contexts.add(p[0]);for(let[h,m]of d)this.stage.host.log.warn(m,h)}}let u=(e.el.getAttribute("data-gl-clip")||"").trim().toLowerCase()==="false";e.clips=Ke(e,e.nodes,u,this.Cb,e.clips,this.lc(e))}let s=e.clips;if(!s)return null;s.noSlots=e.kind==="layer";for(let u of s.list){let p="";if(u.by!=="overflow"){if(!n&&r){let w=getComputedStyle(u.el);u.by==="clip"?u.node.clip=w.clip||"auto":u.node.clipPath=w.clipPath||"none"}p=u.by==="clip"?u.node.clip:u.node.clipPath}let d=u.scrolls?this.stage.scrollX:this.stage.pageX,h=u.scrolls?this.stage.scrollY:this.stage.pageY,m=I(u.node),b=this.za(u.el),g=Number.isFinite(m.width)&&m.width>0?m.width:b.width,y=Number.isFinite(m.height)&&m.height>0?m.height:b.height;u.ignored=!this.Lb(e.nodes,u.depth,d,h,g,y,u.m),u.ignored||Fe(u,u.m,g,y,p)}let a=et(e,0,0,this.nc),l=this.quad;l[0]=a[0],l[1]=a[1],l[2]=a[0]+a[2],l[3]=a[1]+a[3];let c=_e(e,s,l,e.bends);e.stale&&(s.ownRadius.set(e.radius),s.ownKy=e.radiusKy);let f=!1;for(let u=0;u<4;u++)e.radius[u]=Math.max(s.ownRadius[u],s.fold[u]),f||=s.fold[u]>s.ownRadius[u];if(e.radiusKy=f?1:s.ownKy,e.kind==="layer"){if(c||s.shaders.length){let u=s.shaders[0]?.el||c?.clips[0]?.el||s.mask?.el;this.stage.warnOnce(e,`${x(e.el)}: a layer can't be cut by a rounded, shaped or masked parent (${x(u)}); it draws uncut. Make that parent's clip a straight overflow: hidden, or add data-gl-clip="false" to silence this.`),s.shaders.length=0,s.reason=null}return null}return c?Ze(e,s):null}scanAnimations(e){this.stage.animCheck=!1;let n=this.held;if(this.held=[],typeof document.getAnimations!="function")return;for(let i of this.occluders)i.until=0,i.linked=i.fades=!1;let r=!1;for(let i of this.stage.planes)i.soon&&(r=!0,i.animInfinite=i.animUntil===1/0,i.animInfinite&&(i.animUntil=0),i.scrollLinked=!1,i.animTargets.length=0,i.animUntil||(i.animLabel=""));if(!r)return;let o=typeof DocumentTimeline<"u"?DocumentTimeline:null;for(let i of document.getAnimations()){let s=i.playState,a=s==="running"&&!!i.playbackRate;if(s==="idle")continue;let l=i.effect,c=l?.target;if(!l||!c||l.pseudoElement||!Ee(i))continue;let f=!!(i.timeline&&o&&!(i.timeline instanceof o)),u=0;if(a&&!f){let h=l.getComputedTiming(),m=Number(h.endTime),b=Number(h.localTime??0)||0;u=m===1/0?1/0:e+Math.max(0,i.playbackRate<0?b:m-b)/Math.abs(i.playbackRate)+50}for(let h of this.occluders)!c.contains(h.el)||u===1/0&&mn(l)||(h.fades||=at(l,u===1/0),f?h.linked=!0:u>h.until&&(h.until=u));let p=typeof CSSTransition<"u"&&i instanceof CSSTransition?"CSS transition":typeof CSSAnimation<"u"&&i instanceof CSSAnimation?"CSS animation":"Web Animation",d=null;for(let h of this.stage.planes)if(h.soon&&(c===h.el||c.contains(h.geomEl))){if(h.animTargets.includes(c)||h.animTargets.push(c),f){h.scrollLinked=!0,h.animLabel||=`scroll-driven ${p} on ${x(c)}`;continue}if(!a){let m=!1;if(d)m=!n.some(b=>b.a===i);else{let b=n.find(g=>g.a===i);m=!b,d={a:i,t:b?b.t:i.currentTime,state:s,planes:[]},this.held.push(d)}m&&(h.heldMoved=!0),d.planes.push(h),h.animLabel||=`${s} ${p} on ${x(c)} (followed while a script moves its time)`;continue}u>h.animUntil&&(h.animUntil=u,h.animLabel=`${u===1/0?"infinite ":""}${p} on ${x(c)}`)}}for(let i of this.stage.planes)i.animInfinite&&(i.animInfinite=!1,i.animUntil!==1/0&&(i.stale=!0))}checkHeld(){for(let e of this.held){let n=e.a.playState;n!==e.state&&(e.state=n,this.stage.animCheck=!0,this.stage.request());let r=e.a.currentTime;if(r!==e.t){e.t=r;for(let o of e.planes)o.heldMoved=!0}}}Jb(e){if(this.stage.inactive)return;for(let r of this.held)if(r.a===e)return this.stage.request();if(!Ee(e))return;let n=e.effect?.target;if(n){if(this.occluders.some(r=>n.contains(r.el)))return this.stage.animCheck=!0,this.stage.request();this.stage.onAnimate(n)}}$b(){let e=document.querySelectorAll("[data-gl-occlude]");if(!e.length&&!this.occluders.length)return;this.Ab=+getComputedStyle(this.stage.hostEl).zIndex||0;let n=e.length!==this.occluders.length,r=[];if(e.forEach((o,i)=>{let s=this.occluders.find(a=>a.el===o);s||(s=gn(o)),this.occluders[i]!==s&&(n=!0),r.push(s)}),this.occluders=r,!!n){this.Ec();for(let o of this.stage.planes)o.stale=!0;this.stage.markDirty()}}bc(e){let n=this.occluders;for(let o=0;o<n.length;o++){let i=n[o];i.want=i.over=!1,!i.ignored&&!i.el.isConnected&&(i.ignored=!0,this.stage.markDirty())}let r=this.stage.planes;for(let o=0;o<r.length;o++){let i=r[o],s=i.clips,a=s?.occ;if(a?.length&&(i.soon||i.visible))for(let l=0;l<a.length;l++)a[l].want=!0,(s.occHow[l]!=="pruned"||s.cutBy===a[l])&&(a[l].over=!0)}for(let o=0;o<n.length;o++){let i=n[o],s=i.linked||e<i.until;(i.live||s)&&i.want&&i.el.isConnected&&(this.Mb(i,!1,s&&i.fades),e<i.until&&(i.until<1/0||i.over)&&(this.stage.forced||=1))}}hook(e){if(e===document.body||e===document.documentElement)return!1;for(let n of this.occluders)if(pn(e,n.el))return this.ua=!0;return!1}Ec(){if(!(typeof MutationObserver>"u")&&(this.watch?this.watch.disconnect():(this.watch=new MutationObserver(e=>{for(let n of e)(n.type==="childList"?it(n.addedNodes)||it(n.removedNodes):this.hook(n.target))&&(this.ua=!0,this.stage.request())}),this.stage.cleanups.push(()=>this.watch.disconnect())),!!this.occluders.length)){this.watch.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["aria-expanded","aria-hidden","open","data-state","hidden"]});for(let e of this.occluders)this.watch.observe(e.el,{childList:!0,subtree:!0})}}Mb(e,n,r=n){if(n&&(e.nodes=xe(e.el,this.stage.chainMemo),e.node=e.nodes[0],e.scrolls=this.Cb(e.el),e.live=De(e.nodes,this.stage.host.scroll.root)||e.el.hasAttribute("data-gl-live"),e.stack=se(e.el),e.cuts=e.nodes.length?ne(e.nodes).sources.filter(d=>d.by==="overflow"&&!oe(e.nodes,d.depth)).map(d=>d.node):[]),!e.nodes.length)return;if(r){let d=getComputedStyle(e.el);n||(e.node.clipPath=d.clipPath||"none");let h=d.visibility==="hidden"||e.el.checkVisibility?.()===!1;for(let m=0;m<e.nodes.length&&!h;m++)h=parseFloat(n?e.nodes[m].opacity:getComputedStyle(e.nodes[m].el).opacity)===0;e.hidden=h}if(n&&!e.hidden&&!e.warned&&e.el.getAttribute("data-gl")!=="shader"&&!ot(e.el)&&(e.warned=!0,this.stage.host.log.warn(`data-gl-occlude on ${x(e.el)}: its background isn't opaque (or it is faded), so GL under it is cut where the page shows through. Give it an opaque background, or remove data-gl-occlude.`,e.el)),e.ignored=e.hidden||!e.el.isConnected,e.ignored)return;let o=this.za(e.el),i=I(e.node),s=Number.isFinite(i.width)&&i.width>0?i.width:o.width,a=Number.isFinite(i.height)&&i.height>0?i.height:o.height;if(e.ignored=o.width<=0||o.height<=0,e.ignored)return;let l=e.scrolls?this.stage.scrollX:this.stage.pageX,c=e.scrolls?this.stage.scrollY:this.stage.pageY;if(e.ignored=!this.Lb(e.nodes,0,l,c,s,a,e.m),e.ignored)return;let f=e.full;if(e.shape&&e.shape===e.from)for(let d=0;d<4;d++)e.shape.box[d]=f[d],e.shape.radius[d]=f[d+4];if(Fe(e,e.m,s,a,/^(inset|circle|ellipse|rect|xywh)\(/.test(e.node.clipPath)?e.node.clipPath:"border-box"),e.shape&&e.shape!==e.from){e.from=e.shape;for(let d=0;d<4;d++)f[d]=e.shape.box[d],f[d+4]=e.shape.radius[d]}if(e.ignored=this.cut(e,l,c),e.ignored)return;n&&e.reason==="mixed-corners"&&this.stage.host.log.warn(`data-gl-occlude on ${x(e.el)}: its corners mix shapes (round and oval), so it cuts nothing (GL draws over it). Give all its corners the same shape.`,e.el),e.axis=K(e.m);let u=e.shape,p=u&&u.kind===0?Math.max(u.radius[0],u.radius[1],u.radius[2],u.radius[3]):0;e.rx=p*e.m[0],e.ry=u?p/u.ky*e.m[4]:0}cut(e,n,r){let o=e.bounds,i=e.shape,s=e.m;if(!i)return!1;if(i.kind||s[1]||s[3]||s[2]||s[5]||!(s[0]>0&&s[4]>0))return o[2]<=o[0]||o[3]<=o[1];let a=o[0],l=o[1],c=o[2],f=o[3],u=e.cuts;for(let d=0;d<u.length;d++){let h=u[d],m=this.za(h.el),{border:b,scrollbar:g,direction:y}=I(h),w=y==="rtl"?g[0]:0;h.overflowX!=="visible"&&(a=Math.max(a,m.left+n+b[3]+w),c=Math.min(c,m.right+n-b[1]-g[0]+w)),h.overflowY!=="visible"&&(l=Math.max(l,m.top+r+b[0]),f=Math.min(f,m.bottom+r-b[2]-g[1]))}if(c<=a||f<=l)return!0;if(a===o[0]&&l===o[1]&&c===o[2]&&f===o[3])return!1;let p=i.radius;return l>o[1]&&(p[0]=p[1]=0),c<o[2]&&(p[1]=p[2]=0),f<o[3]&&(p[2]=p[3]=0),a>o[0]&&(p[3]=p[0]=0),i.box[0]=(a-s[6])/s[0],i.box[1]=(l-s[7])/s[4]*i.ky,i.box[2]=(c-a)/s[0],i.box[3]=(f-l)/s[4]*i.ky,o[0]=a,o[1]=l,o[2]=c,o[3]=f,!1}bb(){if(!(this.$a||!this.occluders.length)){this.$a=!0;for(let e of this.occluders){let n=e.bounds[0]+e.bounds[1]*3+e.bounds[2]*5+e.bounds[3]*7+(e.ignored?.5:0),r=e.stack,o=e.at,i=e.nodes.length>0;if(this.Mb(e,!0),e.bounds[0]+e.bounds[1]*3+e.bounds[2]*5+e.bounds[3]*7+(e.ignored?.5:0)!==n&&this.stage.markDirty(),e.at=e.el.previousElementSibling||e.el.parentElement,i&&(e.at!==o||r.length!==e.stack.length||r.some((s,a)=>s[0]!==e.stack[a][0]||s[1]!==e.stack[a][1]))){for(let s of this.stage.planes)s.stale=!0;this.stage.markDirty()}}}}lc(e){if(!this.occluders.length||this.Ab<=0)return Re;this.bb();let n=(e.el.getAttribute("data-gl-under")||"").trim();if(n==="none")return Re;let r=null;if(n){try{r=this.occluders.filter(s=>s.el.matches(n))}catch{r=[]}r.length||(this.stage.warnOnce(e,`${x(e.el)}: data-gl-under="${n}" matches no [data-gl-occlude] element, so its occluders are the usual ones (those after it in the page).`),r=null)}let o=[],i=null;for(let s of r||this.occluders){if(s.el.contains(e.el)){r&&this.stage.warnOnce(e,`${x(e.el)}: data-gl-under names ${x(s.el)}, which holds it; a panel never cuts what is inside it.`);continue}e.el.contains(s.el)&&e.kind!=="shader"||!r&&!rt(e.el,i??=se(e.el),s.el,s.stack)||o.push(s)}return o.length?o:Re}za(e){let n=this.gb.get(e);return n||(n=e.getBoundingClientRect(),this.gb.set(e,n)),n}frame(e,n){let r=this.stage,o=this.ci;o.scrollX=r.scrollX,o.scrollY=r.scrollY,o.pageX=r.pageX,o.pageY=r.pageY,o.cw=r.canvas.width,o.ch=r.canvas.height,o.kx=r.canvas.width/Math.max(e,1),o.ky=r.canvas.height/Math.max(n,1)}clip(e,n){return Qe(e.clips,n,e.bends,this.ci)}placeDraw(e,n,r){let o=e.drawXf,i=e.pad,s=e.edge[0],a=e.size;a[0]=(e.boxW+2*i)*s,a[1]=(e.boxH+2*i)*s;let l=e.xf,c=e.xfDraw,f=1/s;c[0]=l[0]*f,c[1]=l[1]*f,c[2]=l[2]*f,c[3]=l[3]*f,c[4]=l[4]*f,c[5]=l[5]*f,c[6]=l[6]-i*(l[0]+l[3]),c[7]=l[7]-i*(l[1]+l[4]),c[8]=l[8]-i*(l[2]+l[5]);for(let m=0;m<3;m++)o[m*3]=c[m*3]-n*c[m*3+2],o[m*3+1]=c[m*3+1]-r*c[m*3+2],o[m*3+2]=c[m*3+2];let u=a[0]/2,p=a[1]/2,d=o[2]*u+o[5]*p+o[8],h=e.shaderRect;h[0]=(o[0]*u+o[3]*p+o[6])/d-u,h[1]=(o[1]*u+o[4]*p+o[7])/d-p,h[2]=a[0],h[3]=a[1]}pointer(e,n,r){let o=e.invDraw;if(!D(o,e.xfDraw))return;let i=o[2]*n+o[5]*r+o[8];e.mouseTarget[0]=(o[0]*n+o[3]*r+o[6])/i/Math.max(e.size[0],1),e.mouseTarget[1]=(o[1]*n+o[4]*r+o[7])/i/Math.max(e.size[1],1)}cutBy(e){return`it is entirely cut off by ${Q(e)} on ${x(e.el)}`}report(e,n){let r=e.clips,o=(r?.list||[]).map(i=>(i.ignored&&n.push(`the ${Q(i)} clip on ${x(i.el)} is skipped right now: part of that parent turns behind the viewer`),{el:i.el,by:i.by,shape:Q(i),how:i.how}));return r?.occ.forEach((i,s)=>{let a=r.occHow[s]||"pruned";a==="uncut"&&n.push(`data-gl-occlude on ${x(i.el)} overlaps it, but ${r.noSlots?"a layer is only cut straight":"its parents' clips take both GL clip slots"}: GL draws over that panel there`),o.push({el:i.el,by:i.by,shape:Q(i),how:a})}),o}};function Yn(t){t.shapesError=null,t.shapes=new ae(t),t.animCheck=!0;for(let e of t.planes)e.stale=!0,e.shapeWait=!1;t.markDirty()}export{Yn as shapes};
|
package/dist/chunks/sim.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var S={info(){},warn:(a,...t)=>console.warn("[umber]",a,...t),once:(a,...t)=>console.warn("[umber]",a,...t),error:(a,...t)=>console.error("[umber]",a,...t)},h=S;function v(a){a&&(h=a)}var p=class{constructor(t=60){this.hz=t;this.ia=0;this.na=!1}advance(t){this.ia+=t>0?t:0;let e=Math.floor(this.ia*this.hz+.5);return e>4?(e=4,this.ia=0):!e&&this.na?(e=1,this.ia=0):this.ia-=e/this.hz,this.na=!1,e}due(){this.na=!0,this.ia=Math.min(this.ia,0)}},P=1/255;function y(a){return a<=0?1:a>=1?1/0:Math.ceil(Math.log(P)/Math.log(a))}function m(a,t,e){return Array.isArray(a)?+a[Math.max(0,Math.min(a.length-1,t))]||e:a!=null&&+a>0?+a:e}var d=16,A=/^[A-Za-z_]\w*$/,g=(a,t)=>/\bvoid\s+main\s*\(/.test(a)?a:`${a}
|
|
3
3
|
void main() { outColor = ${t}(vUv); }`;function k(a){let t=a.read;a.read=a.write,a.write=t}var w=class{constructor(t,e,s){this.sims=t;this.o=e;this.fields=new Map;this.Sa=[];this.passes=[];this.Fa=[];this.brushes=[];this.steps=0;this.idle=0;this.awake=!1;this.released=!1;this.ok=!1;this.aspect=0;this.clock=new p(Math.max(1,+e.hz||60));let i=t.fx;this.uniforms={...e.uniforms||{},uDt:1/this.clock.hz,uStep:0,uPointer:new Float32Array([-1,-1])};let n=e.fields||{state:{init:e.init}};for(let r in n){let u=n[r]||{},l=u.type||e.type||"half",f={...this.dims(u.size,s),type:l,msaa:0,attachments:1,quiet:!0},F=i.make(f),M=i.make(f),c={name:r,read:F,write:M,size:u.size,init:u.init,type:l,holder:{get texture(){return c.read.texture}}};this.fields.set(r,c),this.Sa.push(c.holder),this.uniforms[r]=c.holder}this.out=this.fields.get(e.output)||this.fields.values().next().value;let o=e.passes||[{into:this.out.name,next:e.next}];for(let r of o){let u=this.fields.get(r.into);this.passes.push({into:u,source:g(r.next,"next"),iterations:Math.max(1,Math.round(m(r.iterations,s,1))),program:null})}for(let r of this.fields.values())r.init&&this.Fa.push({field:r,program:null});this.pointer=this.passes.some(r=>/\buPointer\b/.test(r.source)),this.own=!!this.Fa.length||e.settle===!1||this.passes.some(r=>/\bu(Time|Step)\b/.test(r.source)),this.compile(),this.start()}dims(t,e){let s=this.sims.fx.stage,i=s.gl.getParameter(s.gl.MAX_TEXTURE_SIZE)||4096,n=Math.min(i,Math.max(1,Math.round(m(t??this.o.size,e,128))));this.aspect=s.viewport.height/Math.max(1,s.viewport.width);let o=this.o.shape==="square"?n:Math.min(i,Math.max(1,Math.round(n*this.aspect)));return{width:n,height:o}}compile(){let t=this.sims.fx.passes,e=!0;for(let s of this.passes)e=!!(s.program=t.program(s.source,this.uniforms))&&e;for(let s of this.Fa)e=!!(s.program=t.program(g(s.field.init,"init"),this.uniforms))&&e;return(this.ok=e)||(this.awake=!1,h.warn("gl.sim(): a pass did not compile (the shader log is above); this sim stays still.")),e}start(){let t=this.sims.fx.stage;for(let e of this.fields.values())e.read.clear(),e.write.clear();for(let e of this.Fa)e.program&&this.draw(e.program,e.field);t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.renderer.reset(),this.steps=this.uniforms.uStep=0,this.own?this.wake():this.awake=!1}draw(t,e){let s=this.sims.fx.stage,i=e.write.b;i&&(s.gl.bindFramebuffer(s.gl.FRAMEBUFFER,i.draw),this.sims.fx.passes.draw(t,i.spec.width,i.spec.height,this.uniforms,s.time),k(e))}run(t){let e=this.sims.fx.stage;this.o.shape!=="square"&&Math.abs(e.viewport.height/Math.max(1,e.viewport.width)-this.aspect)>.01&&this.fit();let s=this.clock.advance(t);for(let i=0;i<s;i++)this.step();if(s){e.gl.bindFramebuffer(e.gl.FRAMEBUFFER,null),e.renderer.reset();let i=this.o.settle;i!==!1&&(typeof i=="function"?i(this):this.idle>=(i??2)-1e-6)&&(this.awake=!1)}return s>0}step(){let t=this.uniforms,e=this.sims.fx.stage;t.uStep=++this.steps,this.idle+=1/this.clock.hz,t.uPointer[0]=e.pointer.x<0?-1:e.pointer.x/e.viewport.width,t.uPointer[1]=e.pointer.y<0?-1:e.pointer.y/e.viewport.height;for(let s of this.brushes)s.apply();for(let s of this.passes)if(s.program)for(let i=0;i<s.iterations;i++)this.draw(s.program,s.into)}fit(){let t=this.sims.level;for(let e of this.fields.values()){let{width:s,height:i}=this.dims(e.size,t);e.read.resize(s,i),e.write.resize(s,i)}this.start()}get texture(){return this.released?null:this.out.read.texture}get width(){return this.out.read.width}get height(){return this.out.read.height}get type(){return this.out.read.type}field(t){let e=this.fields.get(t);return e||h.warn(`sim.field("${t}"): this sim has no field "${t}"; its fields are ${[...this.fields.keys()].join(", ")}.`),e?e.holder:null}wake(){return this.released?this:(this.idle=0,(!this.awake||!this.steps)&&this.clock.due(),this.awake=this.ok,this.sims.fx.stage.request(),this)}set(t,e){return this.uniforms[t]=e,this.wake()}reset(){return this.released||this.start(),this}brush(t){return this.released?null:new b(this,t||{})}seen(){let t=this.sims.fx.stage,e=this.sims.flowSim===this?t.flow:null,s=t.planes,i=this.Sa,n=!1;if(this.byPass)return!0;for(let o=0;o<i.length;o++)if(i[o].byPass)return!0;for(let o=0;o<s.length;o++){let r=s[o];if(r._layer&&(r.soon||r.visible))return!0;for(let u in r.uniforms){let l=r.uniforms[u].value;if(!(l!==this&&(!l||l!==e)&&!this.Sa.includes(l))){if(r.soon||r.visible)return!0;n=!0}}}return!n}release(){let t=this.sims;if(!this.released){if(t.flowSim===this){if(t.fx.stage.planes.some(e=>e.uniforms.uFlow))return;t.flowSim=t.flowBrush=null}this.released=!0,this.awake=!1;for(let e of this.fields.values())e.read.release(),e.write.release();this.brushes.length=0,t.list.delete(this)}}},b=class{constructor(t,e){this.sim=t;this.o=e;this.stamps=new Float32Array(d*4);this.count=0;this.last=[NaN,NaN];this.released=!1;let s=t.fields.get(e.field||"")||t.fields.values().next().value;e.field&&!t.fields.has(e.field)&&h.warn(`gl.brush(): this sim has no field "${e.field}"; it paints "${s.name}".`),this.field=s;let i=t.sims.fx.stage,n=e.color||[1,1,1,1];this.u={[s.name]:s.holder,uStamps:this.stamps,uCount:0,uBrushRadius:Math.max(.5,+e.radius||24),uColor:new Float32Array([+n[0]||0,+n[1]||0,+n[2]||0,n[3]==null?1:+n[3]]),uMotion:+e.motion||0,uView:new Float32Array([i.viewport.width,i.viewport.height]),uMix:e.mode==="mix"?1:0},this.source=g(z.replace("FIELD",s.name),"next"),t.brushes.push(this)}paint(t,e,s=0,i=0){if(this.released||this.count>=d)return this;let n=this.sim.sims.fx.stage,o=this.stamps,r=this.count++*4;return o[r]=t/n.viewport.width,o[r+1]=e/n.viewport.height,o[r+2]=s,o[r+3]=i,this.sim.wake(),this}follow(t,e){let[s,i]=this.last;if(this.last[0]=t,this.last[1]=e,s!==s||t===s&&e===i)return;let n=t-s,o=e-i,r=Math.min(d-this.count,Math.max(1,Math.ceil(Math.hypot(n,o)/(this.u.uBrushRadius*.5))));for(let u=1;u<=r;u++)this.paint(s+n*u/r,i+o*u/r,n/r,o/r)}apply(){let t=this.sim.sims.fx.stage;if(this.o.pointer!==!1&&t.pointer.x>=0&&this.follow(t.pointer.x,t.pointer.y),!this.count)return;this.program===void 0&&(this.program=this.sim.sims.fx.passes.program(this.source,this.u));let e=this.u.uView;e[0]=t.viewport.width,e[1]=t.viewport.height,this.u.uCount=this.count,this.count=0;let s=this.field,i=s.write.b;!this.program||!i||(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,i.draw),this.sim.sims.fx.passes.draw(this.program,i.spec.width,i.spec.height,this.u,t.time),k(s),this.sim.idle=0)}lost(){this.program=void 0}release(){this.released=!0;let t=this.sim.brushes,e=t.indexOf(this);e>=0&&t.splice(e,1)}},z=`uniform vec4 uStamps[16];
|
|
4
4
|
vec4 next(vec2 uv){
|
package/dist/chunks/text.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var Ce={info(){},warn:(e,...t)=>console.warn("[umber]",e,...t),once:(e,...t)=>console.warn("[umber]",e,...t),error:(e,...t)=>console.error("[umber]",e,...t)},nt=Ce;function te(e){e&&(nt=e)}var st=class{constructor(t,r){this.gl=t;this.format=r;this.width=1;this.height=1;this.ready=!1;this.texture=t.createTexture(),this.upload(1,1,r==="uint"?new Uint16Array(1):new Float32Array(4)),this.ready=!1}get bytes(){return this.ready?this.width*this.height*(this.format==="uint"?2:16):0}upload(t,r,i){let n=this.gl;n.bindTexture(n.TEXTURE_2D,this.texture),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_ALIGNMENT,1),this.format==="uint"?n.texImage2D(n.TEXTURE_2D,0,n.R16UI,t,r,0,n.RED_INTEGER,n.UNSIGNED_SHORT,i):n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,t,r,0,n.RGBA,n.FLOAT,i),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),this.width=t,this.height=r,this.ready=!0}dispose(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.ready=!1}};var Ge={used:/\bglyph\s*\(/,defined:/\bGlyph\s+glyph\s*\(/,code:`struct Glyph{
|
|
3
3
|
float line;
|
|
4
4
|
float word;
|
package/dist/chunks/video.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var R={info(){},warn:(i,...e)=>console.warn("[umber]",i,...e),once:(i,...e)=>console.warn("[umber]",i,...e),error:(i,...e)=>console.error("[umber]",i,...e)},f=R;function v(i){let e=i;return[e.displayWidth||e.videoWidth||e.naturalWidth||e.width||0,e.displayHeight||e.videoHeight||e.naturalHeight||e.height||0]}var P=i=>i instanceof HTMLVideoElement||"displayWidth"in i,d=class{constructor(e){this.gl=e;this.width=1;this.height=1;this.ready=!1;this.refs=0;this.box=[];this.mipmaps=!1;this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.params(!1)}params(e){let r=this.gl;r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e?r.LINEAR_MIPMAP_LINEAR:r.LINEAR)}get bytes(){return this.ready?this.width*this.height*4*(this.mipmaps?4/3:1):0}upload(e,r={}){let t=this.gl,s=r.mipmaps??!P(e),[o,n]=v(e);return!o||!n?!1:(t.bindTexture(t.TEXTURE_2D,this.texture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),this.ready&&o===this.width&&n===this.height&&(!s||this.mipmaps)?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,e):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),s&&t.generateMipmap(t.TEXTURE_2D),(s!==this.mipmaps||!this.ready)&&this.params(s),this.mipmaps=s,this.width=o,this.height=n,this.ready=!0,!0)}dispose(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.ready=!1}};var U=3,S=i=>!!i&&typeof i.close=="function",p=class{constructor(e,r,t){this.gl=e;this.ma=t;this.textures=new Map;this.queue=new Map;this.closing=[];this.a=-1;this.b=-1;this.amount=0;this.center=0;this.drawn=null;this.ra=null;this.error=null;this.cap=1/0;this.budget=r}put(e,r,t=!1){let s=this.queue.get(e);s&&s.image!==r&&s.close&&S(s.image)&&s.image.close(),this.queue.set(e,{image:r,close:t}),this.ma()}has(e){return this.queue.has(e)||!!this.textures.get(e)?.ready}ready(e){return!!this.textures.get(e)?.ready}show(e,r=-1,t=0){(r===e||t<=0)&&(r=-1,t=0),!(e===this.a&&r===this.b&&t===this.amount)&&(this.a=e,this.b=r,this.amount=t,this.ma())}focus(e){this.center=e}get bytes(){let e=0;return this.textures.forEach(r=>e+=r.bytes),e}get size(){return this.textures.size}get pending(){return this.queue.size+this.closing.length}keys(){return[...this.textures.keys()].filter(e=>this.textures.get(e).ready)}capacity(e,r){return Math.max(1,Math.floor(this.limit/Math.max(1,e*r*4)))}flush(){for(let t of this.closing)t.close();if(this.closing.length=0,!this.queue.size)return 0;let e=[...this.queue.keys()].sort((t,s)=>this.Nb(t)-this.Nb(s)),r=0;for(let t of e){if(r>=U&&t!==this.a&&t!==this.b)break;let s=this.queue.get(t);this.queue.delete(t);let[o,n]=v(s.image);if(o&&n){let a=this.textures.get(t)||new d(this.gl);try{a.upload(s.image,{mipmaps:!1}),this.textures.set(t,a),r++}catch(u){a.dispose(),this.textures.delete(t),this.error=u}}s.close&&S(s.image)&&this.closing.push(s.image)}return this.wb(),(this.queue.size||this.closing.length)&&this.ma(),r}Nb(e){return e===this.a?-2:e===this.b?-1:Math.abs(e-this.center)}fit(e){let r=this.bytes;return this.cap=Math.max(2*(this.drawn?.bytes||0),e),this.wb(),r-this.bytes}get limit(){return Math.min(this.budget,this.cap)}holds(e){for(let r of this.textures.values())if(r===e)return!0;return!1}wb(){let e=this.bytes;if(e<=this.limit)return;let r=[...this.textures.keys()].filter(t=>t!==this.a&&t!==this.b&&t!==this.center&&this.textures.get(t)!==this.drawn&&this.textures.get(t)!==this.ra).sort((t,s)=>Math.abs(s-this.center)-Math.abs(t-this.center));for(let t of r){if(e<=this.limit)break;let s=this.textures.get(t);e-=s.bytes,s.dispose(),this.textures.delete(t)}}get texture(){let e=this.textures.get(this.a);return e?.ready?this.drawn=e:this.drawn&&!this.drawn.ready&&(this.drawn=null),this.drawn}get next(){let e=this.b>=0&&this.drawn===this.textures.get(this.a)?this.textures.get(this.b):void 0;return this.ra=e?.ready?e:null,this.ra}get mix(){return this.ra?this.amount:0}get shown(){for(let[e,r]of this.textures)if(r===this.drawn)return e;return-1}pick(e){let r=this.texture;if(!r||e.texture===r)return!1;let t=e.texture;return e.texture=r,e.textureState!=="error"&&e.textureState!=="ready"&&(e.textureState="ready",e.resolveLoaded()),!t||t.width!==r.width||t.height!==r.height}clear(e=!1){let r=e?this.drawn:null,t=-1;this.textures.forEach((s,o)=>{s===r?t=o:s.dispose()}),this.forget(),r&&t>=0&&(this.textures.set(t,r),this.drawn=r)}forget(){this.textures.clear();for(let e of this.queue.values())e.close&&S(e.image)&&e.image.close();this.queue.clear();for(let e of this.closing)e.close();this.closing.length=0,this.drawn=null,this.ra=null}dispose(){this.clear()}};var I="[data-gl]",D=new Set(["data-gl","data-gl-effect","data-gl-shader","data-gl-layer","data-gl-instances"]),W=[...D,"style","class","hidden","media","disabled","data-gl-src","src","srcset","sizes","data-gl-occlude","data-gl-pass","data-gl-under"];var N="[data-gl-occlude]",V=I+","+N;function E(i){i.hasAttribute("data-gl-media")&&i.removeAttribute("data-gl-media"),i.querySelectorAll("[data-gl-media]").forEach(e=>e.removeAttribute("data-gl-media"))}var w=(i,e)=>i.muted&&(i.loop||i.autoplay)&&!i.controls&&e.dataset.glVideoAutopause!=="false"&&!e.hasAttribute("data-gl-scrub");function m(i){if(!i||typeof i.tagName!="string")return"<?>";let e=i.tagName.toLowerCase();if(i.id)return`<${e}#${i.id}>`;let r=typeof i.className=="string"?i.className.trim().split(/\s+/)[0]:"";return r?`<${e}.${r}>`:`<${e}>`}var k={high:128,mid:48,low:32},C={high:8,mid:2,low:1},G=3e3,x=i=>i.getAttribute("src")||i.querySelector("source")?.getAttribute("src")||"",b=class{constructor(e){this.stage=e;this.blocked=new Set;this.zb=!1;this.wa=new WeakMap;this.Qa=0;this.at=-1;this.left=0;this.na=0;this.oldest=0;this.first=0;this.waited=0;this.ta=0;this.Ja=0;this.Ob=new WeakMap;this.since=new WeakMap;this.retry=()=>{this.Ub();for(let e of this.blocked){let r=this.stage.planes.find(t=>t.media===e);r?.soon&&!r.destroyed&&e.play().catch(()=>{})}this.blocked.clear()};this.Ub=()=>{removeEventListener("pointerdown",this.retry),removeEventListener("touchstart",this.retry)}}upload(e){if(!e.videoFrame||!e.texture)return!0;let r=e.media;if(r.readyState<2)return!0;let t=this.stage,s=t.stats.renders;if(this.at!==s){let a=this.at===s-1;this.at=s,this.left=t.cap?1/0:C[t.tier],this.na=a?this.waited:0,this.oldest=this.ta,this.first=this.Ja,this.waited=this.Ja=0,this.ta=s}let o=this.Ob.get(e)??-2;if(o===s)return t.markDirty(),!0;let n=o===s-1?this.since.get(e):s;if(this.left<=(n===this.oldest?0:n<s?this.first:this.na))return n===s&&this.since.set(e,s),this.Ob.set(e,s),this.waited++,n<this.ta&&(this.ta=n,this.Ja=0),n===this.ta&&this.Ja++,t.markDirty(),!0;this.left--,n<s&&(this.na--,n===this.oldest&&this.first--);try{let a=e.texture,u=a.width,l=a.height;a.upload(r,{mipmaps:!1}),this.stage.stats.uploads++,(a.width!==u||a.height!==l)&&this.stage.media.place(e),e.textureState="ready",e.status!=="ready"&&e.readyFrame===-1&&e.resolveLoaded()}catch(a){return f.warn(`${m(e.el)}: the browser blocked its video as a texture (a cross-origin video without CORS headers?), so the DOM video shows. Serve it with Access-Control-Allow-Origin, or from this site's own domain.`,a),e.textureState="error",e.setStatus("error"),e.videoCleanup?.(),e.videoCleanup=null,!1}return e.videoFrame=!1,!0}release(e){if(e.kind!=="video"||!(e.media instanceof HTMLVideoElement))return;let r=e.media;r.pause(),r.removeAttribute("src"),r.querySelectorAll("source").forEach(t=>t.removeAttribute("src")),r.load()}renew(e,r){let t=e.media;if(!t)return;let s=this.wa.get(t);if(s===void 0)return void this.wa.set(t,x(t));let o=x(t);o===s||e._mods.feed?.src?.()===!1||(this.wa.set(t,o),this.stage.removePlane(e),r.push(e.el))}feed(e){let r=e._mods.frames,t=this.stage,s=r.flush();if(t.stats.uploads+=s,s){let o=this.frameBytes();t.stats.textureMB*2**20+(t.fx?.pool.bytes||0)+o<=t.textureBudget?this.Qa=0:o>this.Qa&&(this.Qa=o,t.media.evictFar())}return r.error&&(f.warn(`${m(e.el)}: its video frames can't become a texture (a video on another domain without CORS headers?), so the DOM video shows. Serve it with Access-Control-Allow-Origin, or from this site's own domain.`,e.el,r.error),r.error=null,e.textureState="error",e.setStatus("error"),E(e.el),r.clear()),s>0}frameBytes(){let e=0;for(let r of this.stage.planes){let t=r._mods.frames;t&&(e+=t.bytes-(t.holds(r.texture)?r.texture.bytes:0))}return e}fit(e){let r=0;for(let s of this.stage.planes)r+=s._mods.frames?.budget||0;let t=0;if(r)for(let s of this.stage.planes){let o=s._mods.frames;o&&(t+=o.fit(e*o.budget/r))}return t}frames(e){let r=this.stage;return new p(r.gl,e,()=>r.markDirty())}bind(e){let r=this.stage,t=r.host.log;for(let[o,n]of r.modulesOf(e.el)){let a=null;try{a=n.module.plane(this.context(e,o,n.options))}catch(u){t.error(`module "${o}" failed on this element; it is drawn without it.`,e.el,u)}a&&(e._mods.list.push({name:o,binding:a}),a.api!==void 0&&(o in e?r.host.lib.say("own",[o]):Object.defineProperty(e,o,{value:a.api,configurable:!0,enumerable:!0})),a.source&&!e._mods.feed&&(e._mods.feed=a))}let s=e.media;e._mods.feed&&s instanceof HTMLVideoElement&&this.wa.set(s,x(s))}context(e,r,t){let s=this.stage,o=s.host.log;return{el:e.el,plane:e,engine:s.host.engine,media:e.media,options:t,get frames(){return e._mods.frames||=s.video.frames(k[s.tier]*2**20)},tier:s.tier,maxTexture:s.maxTexture,isTouch:s.host.env.isTouch,get reducedMotion(){return s.reducedMotion},scrollKind:s.host.scroll.kind,log:o,busy(n){n!==e.busyReasons.has(r)&&(n?e.busyReasons.add(r):e.busyReasons.delete(r),s.markDirty())},wake(){s.markDirty()},fail(n){n&&o.warn(n,e.el),e.textureState="error",e.setStatus("error"),E(e.el),e._mods.frames?.clear(),s.markDirty()}}}load(e){let r=this.stage,t=e.media;if(!t){e.textureState="error",e.setStatus("error");return}this.wa.set(t,x(t)),e.textureState="loading";let s=t.currentSrc||t.src||t.querySelector("source")?.src||"",o=!1;try{o=!!s&&new URL(s,location.href).origin!==location.origin}catch{o=!1}if(o&&!t.crossOrigin){fetch(s,{method:"HEAD",mode:"cors",credentials:"omit"}).then(n=>{if(!n.ok)throw new Error(`HTTP ${n.status}`);if(r.lost||e.textureState!="loading"||!r.planes.includes(e))return;let a=!t.paused||t.autoplay&&!t.played?.length,u=t.currentTime,l=!a&&t.autoplay;t.crossOrigin="anonymous",l&&(t.autoplay=!1),t.load(),a||t.pause(),l&&(t.autoplay=!0),u&&(t.currentTime=u),a&&t.play().catch(()=>{}),this.start(e,t)}).catch(n=>{f.warn(`${m(e.el)}: the video at ${s} is on another domain that sends no CORS headers, so it can't become a texture and the DOM video shows. Serve it with Access-Control-Allow-Origin (Webflow's CDN and Bunny do), or from this site's own domain.`,n),e.textureState="error",e.setStatus("error")});return}this.start(e,t)}start(e,r){let t=this.stage,s=r.requestVideoFrameCallback?.bind(r),o=0,n=!1,a=()=>{},u=0,l=()=>{u=0;let h=e.loadingSince;if(n||e.textureState!=="loading"||!e.inView||!h)return;let c=h+G-performance.now();c<=0?t.markDirty():u=setTimeout(l,c)},y=()=>{u||l()},A=e.on("wait",y),M=e.on("enter",y),T=()=>{n||e.textureState=="error"||!(r.error||r.networkState==3)||(f.warn(`${m(e.el)}: the browser can't play its video ${r.currentSrc||r.src} (MediaError ${r.error?.code}), so the DOM video shows. Check the file, its codec (H.264) and that the server answers Range requests.`),e.textureState="error",e.setStatus("error"),E(e.el),t.markDirty())};r.addEventListener("error",T,!0);let L=()=>{n||(e.soon&&e.status!=="error"&&(e.videoFrame=!0,t.markDirty()),o=s(L))},g=()=>{n||(e.textureState==="error"&&!t.inactive&&!e.domReason&&(e.textureState="loading",e.setStatus("loading"),e.loadingSince=0,e.texture||=new d(t.gl),r.setAttribute("data-gl-media","")),e.videoFrame=!0,e.soon&&t.markDirty())};r.addEventListener("seeked",g),r.addEventListener("loadeddata",g);let _=()=>{r.removeEventListener("seeked",g),r.removeEventListener("loadeddata",g)};if(s)o=s(L);else{let h=()=>e.busyReasons.add("video"),c=()=>e.busyReasons.delete("video");r.addEventListener("playing",h),r.addEventListener("pause",c),r.addEventListener("ended",c),r.paused||h(),a=()=>{r.removeEventListener("playing",h),r.removeEventListener("pause",c),r.removeEventListener("ended",c)}}e.videoCleanup=()=>{n=!0,o&&r.cancelVideoFrameCallback?.(o),u&&clearTimeout(u),r.removeEventListener("error",T,!0),a(),_(),A(),M()},e.texture=new d(t.gl),e.videoFrame=r.readyState>=2,y(),T()}autoPause(e,r){let t=e.media;if(!(!(t instanceof HTMLVideoElement)||!w(t,e.el))){if(!r){t.paused||(t.pause(),e.autoPaused=!0);return}!e.autoPaused||this.stage.host.env.reducedMotion||(e.autoPaused=!1,t.play().catch(s=>{s?.name!=="NotAllowedError"||this.blocked.has(t)||(this.blocked.size||(addEventListener("pointerdown",this.retry,{once:!0,passive:!0}),addEventListener("touchstart",this.retry,{once:!0,passive:!0})),this.blocked.add(t),this.zb||this.stage.cleanups.push(this.Ub),this.zb=!0)}))}}};function te(i){i.video=new b(i),i.remake(i.videoWaiting)}export{te as video};
|
package/dist/chunks/views.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var ne={info(){},warn:(t,...e)=>console.warn("[umber]",t,...e),once:(t,...e)=>console.warn("[umber]",t,...e),error:(t,...e)=>console.error("[umber]",t,...e)},ie=ne;function O(t){t&&(ie=t)}var H=[1,.85,.7,.55],I={high:2,mid:1.5,low:1},oe=.8;function U(t,e,n,u,a=12e6,m=1/0){let d=0,s;typeof t=="number"&&t>0?s=t:Array.isArray(t)?(d=Math.max(0,t[0]||0),s=t[1]||I[e]):s={...I,...t&&typeof t=="object"?t:{}}[e]??2,n>m&&(s=Math.min(s,oe));let o=Math.max(d,Math.min(typeof devicePixelRatio=="number"&&devicePixelRatio||1,s));return n*u*o*o>a&&(o=Math.sqrt(a/Math.max(n*u,1))),o}var z=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(e,n,u,a){let m=e.frame-this.Db===1;this.Db=e.frame;let d=this.dts;d.push(e.dt),d.length>120&&d.shift();let s=e.dt*60;if(this.settle>0||n)return this.settle=Math.max(0,this.settle-s),!1;if(!m||d.length<30)return!1;let o=d[0];for(let f of d)f<o&&(o=f);e.dt>Math.max(o*1.5,1/40)?((u<0||u>o*1e3*.6)&&this.oa++,this.sa=0):e.dt<o*1.2&&(this.sa+=s,this.oa=Math.max(0,this.oa-s));let g=a?45:150;return this.oa>g&&this.index<H.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(e){this.settle=Math.max(this.settle,e)}reset(){this.dts.length=0,this.settle=30}Rb(e){this.index=e,this.scale=H[e],this.oa=0,this.sa=0,this.settle=30}};function N(t){if(!(!t||typeof navigator<"u"&&/apple/i.test(navigator.vendor||"")))try{t.isContextLost?.()||t.getExtension("WEBGL_lose_context")?.loseContext()}catch{}}var se=/(swiftshader|llvmpipe|software)|mali-4|mali-t|adreno \(tm\) [2-5]|powervr|intel\(r\) hd graphics [2-5]/i,ae=[1400,1600],ue=t=>t<2?"low":t<4?"mid":"high";function de(t){let e=t.trim().toLowerCase().match(/^(m?)([0-5])$|^(low|mid|high)$/);return e&&(e[3]?{level:"lmh".indexOf(e[3][0])*2+1,mobile:!1}:{level:+e[2],mobile:!!e[1]})}function le(t){let e=String(t.getParameter(t.RENDERER)||"");if(!e||/^(webkit webgl|mozilla|webgl)$/i.test(e.trim())){let n=t.getExtension("WEBGL_debug_renderer_info");n&&(e=String(t.getParameter(n.UNMASKED_RENDERER_WEBGL)||"")||e)}return e}function ce(t){let e=t.match(se);return e?[e[1]?0:1,`rule: ${e[0]}`]:[2,"default"]}function j(t,e){let n=le(e),u=t.env.isTouch&&Math.min(screen.width,screen.height)<820,a,m="url",d=t.gpu?de(t.gpu):null;if(t.gpu&&!d&&t.lib?.say("gpu",[t.gpu]),d)({level:a,mobile:u}=d);else{let[o,g]=ce(n);a=o<2?o:o+(u?0:2),m=g}let s=a>3;return{level:a,tier:ue(a),mobile:u,renderer:n,reason:m,maxTexture:Math.min(e.getParameter(e.MAX_TEXTURE_SIZE),s?4096:2048),textureBudget:(s?192:96)*2**20,wide:!u&&ae[a]||1/0}}function q(t,e){let n=e.options,{el:u,tracker:a}=e,{log:m,ticker:d}=t,s=n.renderer,o=s.domElement||null,g=!1;o&&!o.isConnected&&(o.style.display="block",o.style.width="100%",o.style.height="100%",u.appendChild(o),g=!0);let f=o&&o.isConnected&&!u.contains(o)?o:u,v=null;try{v=s.getContext?.()||null}catch{v=null}let K=v&&j(t,v).tier||"high",w=new z,F=(n.adaptive??t.options.adaptive)!==!1,X=n.pixelBudget??t.options.pixelBudget??12e6,p=Math.max(1,e.wanted),D=!1,y=null,b=!0,B="",M=0,E=0,P=0,k=!1,C=!1,W=!1,L=n.setup?"waiting":"done",G,x=[],Z=()=>t.options.reducedMotion!=="off"&&t.env.reducedMotion,h=()=>{!e.destroyed&&!C&&!k&&d.wake(1)},l={time:0,dt:0,ratio:1,frame:0,width:0,height:0,dpr:1,rect:a.rect,progress:0,velocity:0,reducedMotion:!1,renderer:s,scene:n.scene,camera:n.camera,view:e.view},$=r=>(l.time=r.time,l.dt=r.dt,l.ratio=r.ratio,l.frame=r.frame,l.width=M,l.height=E,l.dpr=P,l.rect=a.rect,l.progress=a.progress,l.velocity=r.scroll.velocity,l.reducedMotion=Z(),l);function J(){let r=getComputedStyle(f),i=V=>parseFloat(V)||0,c=f.clientWidth-i(r.paddingLeft)-i(r.paddingRight),R=f.clientHeight-i(r.paddingTop)-i(r.paddingBottom);return{w:Math.max(0,c),h:Math.max(0,R)}}if(typeof ResizeObserver<"u"){let r=new ResizeObserver(i=>{for(let c of i)c.target===f&&(y={w:c.contentRect.width,h:c.contentRect.height},b=!0);h()});r.observe(f),x.push(()=>r.disconnect())}let _=(r,i,c)=>{r&&(r.addEventListener(i,c),x.push(()=>r.removeEventListener(i,c)))};_(o,"webglcontextlost",()=>{k=!0,W=!1,e.setStatus("lost"),e.emit("lost")}),_(o,"webglcontextrestored",()=>{k=!1,B="",b=!0,w.reset(),p=Math.max(p,2),e.emit("restored"),h()}),_(typeof document<"u"?document:null,"visibilitychange",()=>{document.hidden||(w.rest(30),h())}),x.push(a.on("enter",()=>h()));function S(r,i){C||(C=!0,m.error(`gl.attach(): ${r} threw; Umber stopped drawing this view (its element stays as it is).`,i),e.setStatus("error",r))}function Q(){L="running";let r;try{r=n.setup({el:u,renderer:s,scene:n.scene,camera:n.camera,view:e.view})}catch(i){return S("setup",i)}Promise.resolve(r).then(i=>{if(e.destroyed){A(i);return}G=i,L="done",h()},i=>S("setup",i))}function A(r){try{typeof r=="function"&&r()}catch(i){m.error("gl.attach(): the setup cleanup threw",i)}}function Y(r){b=!1,y||(y=J());let i=Math.round(y.w),c=Math.round(y.h),R=U(n.dpr??t.options.dpr,K,i,c,X)*(F?w.scale:1),V=`${i}x${c}@${R}`;if(V===B||(B=V,M=i,E=c,P=R,!i||!c))return!1;s.setPixelRatio?.(R),s.setSize?.(i,c,!1);let T=n.camera;n.aspect!==!1&&T?.isPerspectiveCamera&&(T.aspect=i/c,T.updateProjectionMatrix?.()),w.onResize();try{n.resize?.($(r))}catch(re){return S("resize",re),!1}return e.emit("resize"),!0}function ee(r){$(r);try{D=n.animate?.(l)===!0&&!l.reducedMotion,n.render?n.render(l):s.render?.(n.scene,n.camera)}catch(i){return S(n.render?"render":"animate",i)}W||(W=!0,e.setStatus("ready")),F&&w.frame(r,!1,-1,!1)&&(b=!0,m.info(`gl.attach(): render scale ${w.scale}`))}function te(r){if(e.destroyed||C||k||!a.near)return;if(L==="waiting")return Q();if(L!=="done"||typeof document<"u"&&document.hidden||!a.inView)return;let i=b&&Y(r);!M||!E||(i||p>0||D||e.busy.size>0)&&(p>0&&p--,ee(r),(p>0||D||e.busy.size>0||b)&&h())}return x.push(d.add(te,{phase:"render",order:100})),h(),{wake(r){p=Math.max(p,r),h()},busy(){h()},get width(){return M},get height(){return E},get dpr(){return P},frame(){if(f===u)return null;let r=f.getBoundingClientRect();return{left:r.left,top:r.top,width:r.width,height:r.height}},destroy(){if(x.forEach(r=>r()),x.length=0,A(G),G=void 0,n.dispose!==!1){try{s.dispose?.()}catch(r){m.error("gl.attach(): renderer.dispose() threw",r)}g&&o?.remove(),o&&!o.isConnected&&N(v)}}}}function Re(t,e){return O(t.log),q(t,e)}export{Re as attach};
|
package/dist/chunks/warm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
var D={info(){},warn:(s,...e)=>console.warn("[umber]",s,...e),once:(s,...e)=>console.warn("[umber]",s,...e),error:(s,...e)=>console.error("[umber]",s,...e)},g=D;function _(s){s&&(g=s)}var M=/\b(umberHash|noise|fbm|rotate2d|screenUv|screenPx|samplePrev)\s*\(|\buScreen\b/;var A=/\bglyph\s*\(/;var L=/\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 x=s=>e=>Math.pow(e,s),Z={quad:x(2),cubic:x(3),quart:x(4),quint:x(5),sine:s=>1-Math.cos(s*Math.PI/2),expo:s=>s===0?0:Math.pow(2,10*s-10),circ:s=>1-Math.sqrt(1-s*s)};var R="umber";var T={duration:1.4,delay:0,ease:R,start:"top 90%",trigger:"auto"};function N(s){let e=[],t=/[\s,]*(\S+)([^,]*)/g;for(let r;(r=t.exec(s||""))&&r[1];){let n=r[1].replace(/,+$/,"");n!==r[1]&&(t.lastIndex=r.index+r[0].indexOf(r[1])+r[1].length),e.push([n,n!==r[1]?"1x":r[2].trim()||"1x"])}return e}function y(s){let e=/^calc\((.+)\)$/.exec(s);if(e){let n=e[1].trim().split(/\s+([+-])\s+/),o=y(n[0]);for(let i=1;i<n.length;i+=2)o+=(n[i]==="-"?-1:1)*y(n[i+1]);return o}let t=/^([\d.]+)(vw|px|r?em)$/.exec(s),r=t?Number(t[1]):NaN;return t?t[2]==="vw"?innerWidth*r/100:t[2]==="px"?r:r*16:innerWidth}function w(s){let e=[],t=0,r=0;for(let n=0;n<=s.length;n++){let o=s[n];o==="("?t++:o===")"?t--:!t&&(o===","||o===void 0)&&(e.push(s.slice(r,n).trim()),r=n+1)}for(let n of e){let o=-1;for(let a=0,u=0;a<n.length;a++)n[a]==="("?u++:n[a]===")"?u--:!u&&/\s/.test(n[a])&&(o=a);let i=o>0?n.slice(0,o):"";if(n&&(!i||matchMedia(i).matches))return y(n.slice(o+1))}return innerWidth}function E(s){let e=s.ownerDocument?.baseURI||document.baseURI,t=a=>a?new URL(a,e).href:"",r=N(s.getAttribute("srcset")).map(([a,u])=>({url:a,n:parseFloat(u)||1,w:u.endsWith("w")})),n=s.getAttribute("src");if(n&&!r.some(a=>a.w||a.n==1)&&r.push({url:n,n:1,w:!1}),!r.length)return"";let o=window.devicePixelRatio||1,i=o;return r[0].w&&(i=w(s.getAttribute("sizes")||"")*o),r.sort((a,u)=>a.n-u.n),t((r.find(a=>a.n>=i)||r[r.length-1]).url)}function H(s){if(!s.href||s.hasAttribute("download")||s.target&&s.target!=="_self")return"";let e=new URL(s.href,location.href);e.hash="";let t=new URL(location.href);return t.hash="",e.origin===location.origin&&e.href!==t.href&&/^https?:$/.test(e.protocol)?e.href:""}function C(s,e,t=0){let r=navigator.connection;if(r?.saveData||/2g/.test(r?.effectiveType||""))return()=>{};let n=new Set,o=null,i,a=0,u=0,f=0,c=()=>{let p=o?H(o):"";if(p&&!n.has(p)){n.add(p);let m=()=>t&&setTimeout(()=>n.delete(p),t);Promise.resolve(e(p)).then(m,m)}},l=()=>{clearTimeout(i),i=setTimeout(c,65)},d=p=>{let m=p,h=m.target.closest?.(s);h!==o&&(clearTimeout(i),o=h&&h.href!==void 0?h:null,o&&(a=m.clientX,u=m.clientY,f=m.timeStamp,m.pointerType&&m.pointerType!=="mouse"?c():l()))},v=p=>{let m=p,h=m.timeStamp-f;if(!o||h<=0)return;let B=Math.hypot(m.clientX-a,m.clientY-u)/h>.5;a=m.clientX,u=m.clientY,f=m.timeStamp,B&&l()},S=p=>{p.relatedTarget||(clearTimeout(i),o=null)},b={passive:!0};return document.addEventListener("pointerover",d,b),document.addEventListener("pointermove",v,b),document.addEventListener("pointerout",S,b),()=>{clearTimeout(i),document.removeEventListener("pointerover",d),document.removeEventListener("pointermove",v),document.removeEventListener("pointerout",S)}}function I(s,e,t){let r=[e-1<<4|t-1],n=-1;for(let o=0;o<e*t*4;o++){if((o&3)===3)continue;let i=Math.round(s[o]/17);n<0?n=i:(r.push(n<<4|i),n=-1)}return n>=0&&r.push(n<<4),btoa(String.fromCharCode(...r)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function O(s){let e;try{e=atob(s.trim().replace(/-/g,"+").replace(/_/g,"/"))}catch{return null}let t=(e.charCodeAt(0)>>4)+1,r=(e.charCodeAt(0)&15)+1;if(!e||e.length<1+Math.ceil(t*r*3/2))return null;let n=new Uint8ClampedArray(t*r*4);for(let o=0,i=0;o<n.length;o++)if((o&3)===3)n[o]=255;else{let a=e.charCodeAt(1+(i>>1));n[o]=(i++&1?a&15:a>>4)*17}return{w:t,h:r,data:n}}function U(s){let e=O(s);if(!e)return"";let t=document.createElement("canvas");return t.width=e.w,t.height=e.h,t.getContext("2d")?.putImageData(new ImageData(e.data,e.w,e.h),0,0),t.toDataURL()}var k=()=>{let s=typeof window<"u"&&window.occluzeCapture;return s?.version==1?s:null},z=()=>new Promise(s=>{let e=new MessageChannel;e.port1.onmessage=s,e.port2.postMessage(0)});var $=2e4,j=8e3,V=/^data:image\/|\.(avif|webp|jpe?g|png|gif|svg)([?#]|$)/i,X=()=>k()?z():new Promise(s=>"requestIdleCallback"in window?requestIdleCallback(()=>s(),{timeout:300}):setTimeout(s,16)),W=s=>s.ownerDocument!==document||!s.isConnected,P=class{constructor(e){this.stage=e;this.buf=null;this.runs=0;this.Va=null;e.cleanups.push(()=>this.hover(!1))}preload(e){let t=e.what;return t&&typeof t=="object"&&"hover"in t?this.hover(t.hover):this.run(e,this.collect(t))}warm(e){let t=this.stage,r=e.what,n=typeof r=="string"?document.querySelector(r):r;return this.run(e,t.planes.filter(o=>o.kind!=="layer"&&o.status!=="error"&&(!n||n.contains(o.el))).map(o=>this.fx().then(i=>i?.whenReady(o).then(a=>a?this.draw(o):void 0))))}async placeholder(e){let t=this.stage,r=typeof e=="string"?null:e,n=r&&(t.host.lib.findMedia(r)||r),o=typeof e=="string"?e:n?.currentSrc||n&&E(n);if(!o)return null;try{let i=await t.bitmap(o,t.maxTexture),a=6/Math.max(i.width,i.height),u=Math.max(1,Math.round(i.width*a)),f=Math.max(1,Math.round(i.height*a)),c=await createImageBitmap(i,{resizeWidth:u,resizeHeight:f,resizeQuality:"high"});"close"in i&&i.close();let l=document.createElement("canvas");l.width=u,l.height=f;let d=l.getContext("2d");return d.drawImage(c,0,0),c.close(),I(d.getImageData(0,0,u,f).data,u,f)}catch(i){return g.warn(`gl.placeholder(): ${o} could not be read (not found, or another domain without CORS headers).`,i),null}}paint(e){let t=this.stage.host.lib.findMedia(e),r=e.getAttribute("data-gl-placeholder")||"";if(!t||t.tagName!=="IMG"||t.complete&&t.naturalWidth||t.style.backgroundImage)return;let n=U(r);if(!n)return g.warn(`data-gl-placeholder="${r}" is not a placeholder Umber can read; make one with gl.placeholder(src).`,e);let o=t.style;o.backgroundImage=`url(${n})`,o.backgroundSize="cover",o.backgroundPosition="center",t.addEventListener("load",()=>o.backgroundImage=o.backgroundSize=o.backgroundPosition="",{once:!0})}note(e,t){let r=this.stage;if(e)return g.warn(`${e} is ${t[2]}x${t[3]} px, over this GPU's ${r.maxTexture} px: it is drawn shrunk, so softer. Crop it, or point data-gl-src at a smaller file.`);let n=r.planes.filter(o=>o.texture?.ready).sort((o,i)=>i.texture.bytes-o.texture.bytes);g.warn(`Images near the screen take ${t[0]>>20} MB of GPU memory${t[1]?`, render targets and video frames ${t[1]>>20} MB more`:""}, over this device's ${r.textureBudget>>20} MB (gl.info.gpuMB). The largest images: ${n.slice(0,3).map(o=>`${r.host.lib.describe(o.el)} (${o.texture.width}x${o.texture.height})`).join(", ")}. Serve smaller files (srcset and sizes, or data-gl-src).`)}collect(e,t=[]){if(!e)return t;if(typeof e=="string"||e instanceof URL){let r=new URL(String(e),document.baseURI).href;t.push(V.test(r)?this.image(r):this.page(r).then(n=>n&&this.run({},this.collect(n))))}else if(Array.isArray(e)||e instanceof NodeList)for(let r of e)this.collect(r,t);else if(typeof e.querySelectorAll=="function"){let r=e,n=[...r.querySelectorAll("[data-gl]")];r.matches?.("[data-gl]")&&n.unshift(r);for(let o of n)t.push(this.element(o))}else if(typeof e=="object"){let r=e;this.collect(r.container||r.html&&F(r.html,document.baseURI)||(typeof r.url=="object"?r.url?.href:r.url),t)}return t}page(e){return fetch(e,{credentials:"same-origin"}).then(t=>t.ok?t.text():"").then(t=>t?F(t,e):null).catch(t=>(g.info("preload: page not fetched",e,t),null))}async element(e){let t=this.stage,r=t.host.lib.findMedia(e);e.hasAttribute("data-gl-placeholder")&&W(e)&&this.paint(e);let n=null,o=(e.getAttribute("data-gl")||"").trim().toLowerCase();if(!/^(shader|text|layer|video)$/.test(o)&&r?.tagName==="IMG"){let u=e.getAttribute("data-gl-src");(u||!r.parentElement?.querySelector("source"))&&(n=this.image(u||E(r),u?new URL(u,e.ownerDocument.baseURI).href:void 0,r))}let i=this.recipe(e);if(!i||!t.programs.prepare(i))return n;let a=await q(()=>i.program.ready()||i.program.failed,t);if(i.program.failed)return t.programs.failed(i,t.planes);i.texture=await n||null,a&&await this.draw(i)}async image(e,t=e,r){let n=this.stage,o=n.media.images,i=o.get(e)||o.get(t);if(i)return await q(()=>i.ready,n)?i:null;let a=new n.Texture(n.gl);n.renderer.reset(),o.set(e,a).set(t,a);let u=()=>o.forEach((f,c)=>f===a&&o.delete(c));try{let f=r?.getAttribute("sizes"),c=await n.bitmap(t,n.maxTexture,()=>n.media.cap(a.box,f&&f!=="auto"?w(f):0));if(await X(),n.lost||n.destroyed||o.get(e)!==a)return"close"in c&&c.close(),null;a.upload(c),"close"in c&&c.close(),n.renderer.reset(),n.stats.uploads++}catch(f){g.info("preload: image not loaded",t,f),u();for(let c of n.planes)c.texture===a&&(c.texture=null,c.textureState="none",n.loadMedia(c));return a.dispose(),null}for(let f of n.planes)f.texture===a&&(f.textureState="ready",f.resolveLoaded(),n.media.sharpen(f),n.markDirty());return setTimeout(()=>{a.refs||o.get(e)!==a||(u(),a.dispose())},$),a}recipe(e){let t=this.stage,r=t.host.lib,n=(e.getAttribute("data-gl")||"").trim().toLowerCase(),o=n==="shader"||n==="text"||n==="layer"?n:n==="video"||!n&&r.findMedia(e)?.tagName==="VIDEO"?"video":"image";if(o==="layer"||t.modulesOf(e).length)return null;let i=new t.Plane(e,o,-1,t),a=1,u="";for(let c of r.attr.list(e,"data-gl-effect")){let l=t.registry.effects.get(c);if(!l)return null;let d=l.play||"",v=t.readOptions(e,`data-gl-${c}`,d?{...T,...l.options||{}}:l.options||{});t.addUniforms(i,l.uniforms||{}),d&&!i.uniforms[d]&&t.addUniforms(i,{[d]:0}),t.optionUniforms(i,c,v),l.reduced&&t.reducedMotion&&t.addUniforms(i,l.reduced),a=Math.max(a,l.segments||1),u+=JSON.stringify([l.vertex,l.fragment]),i.effects.push({name:c,def:l,options:v,ctx:null})}if(o==="shader"){let c=e.getAttribute("data-gl-shader")||"",l=t.registry.shaders.get(c);if(!l)return null;let d=t.readOptions(e,"data-gl-shader",l.options||{});t.addUniforms(i,l.uniforms||{}),t.optionUniforms(i,"",d),u+=l.fragment+(l.head||""),i.shader={name:c,def:l,options:d,ctx:null}}let f=i.shader?.def.head?1:0;for(let{def:c}of i.effects)(c.vertex?.head||c.fragment?.head)&&f++;return i.glsl=f>1||u.includes("#include")||M.test(u)||L.test(u),i.usesVelocity=u.includes("uScrollVelocity"),i.usesTime=u.includes("uTime"),i.usesProgress=u.includes("uProgress"),i.usesGlyph=A.test(u),u.includes("uBackdrop")&&t.addUniforms(i,{uBackdrop:i.backdrop={texture:null}}),i.segments=a,i.glsl&&!t.programs.glsl||i.usesGlyph&&!t.text?null:i}fx(){return this.stage.loadFx()}async draw(e){let t=this.stage,r=await this.fx();if(!r||t.lost||!e.program?.ready()||!e.grid)return;let n=this.buf||=r.pool.acquire({width:4,height:4,type:"u8",msaa:0,attachments:1}),o=e.rect,i=o.slice();o[2]>0&&o[3]>0||o.set([0,0,4,4]),e.size[0]>0||e.size.set([o[2],o[3]]);try{r.into(n,o[0],o[1],o[2],o[3],()=>t.renderer.drawPlane(e,!0))}finally{o.set(i)}}async run(e,t){let r=0;this.runs++;let n=()=>{let o=++r/t.length;e.set?.(o),e.fn?.(o)};await Promise.all(t.map(o=>o.catch(()=>{}).then(n))),!--this.runs&&this.buf&&(this.stage.fx?.pool.release(this.buf),this.buf=null)}hover(e){this.Va?.();let t=this.Va=e?C(typeof e=="string"?e:"a[href]",r=>this.run({},this.collect(r)),$):null;return t&&(()=>this.Va===t&&this.hover(!1))}};function F(s,e){let t=new DOMParser().parseFromString(s,"text/html");if(!t.querySelector("base")){let r=t.createElement("base");r.href=e,t.head.prepend(r)}return t}function q(s,e){let t=performance.now();return new Promise(r=>{let n=()=>s()?r(!0):e.destroyed||performance.now()-t>j?r(!1):setTimeout(n,30);n()})}function pe(s){return _(s.host.log),new P(s)}export{$ as KEEP_MS,P as Warm,W as ahead,pe as warm};
|
package/dist/modules/debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Umber v0.2.
|
|
1
|
+
/*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
"use strict";(()=>{var G="umber-debug-style",J=`
|
|
3
3
|
.umber-hud {
|
|
4
4
|
position: fixed; left: 8px; bottom: 8px; z-index: 2147483647;
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
.umber-marker span { left: auto; right: 0; top: -16px; }
|
|
34
34
|
.umber-marker[data-edge] { right: auto; width: 0; border-top-style: dashed; }
|
|
35
35
|
.umber-marker[data-edge] span { left: auto; right: 0; top: 2px; }
|
|
36
|
-
`;function F(){if(document.getElementById(G))return;let e=document.createElement("style");e.id=G,e.textContent=J,document.head.appendChild(e)}function X(){document.getElementById(G)?.remove()}var y=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e.toFixed(t):"-";function W(e){let t=String(e.state??"unknown");if(t==="dormant"&&e.planes===void 0)return[["gl","dormant (no [data-gl] yet, nothing loaded)"]];if(t.startsWith("off"))return[["gl",t]];let n=Array.isArray(e.busy)?e.busy:[],r=e.gpu,c=r&&e.width/(e.dpr*e.scale)>r.wide?` \xB7 cut (wider than ${r.wide}px)`:"";return[["gl",`${t} \xB7 tier ${e.tier??"?"}`],...r?[["gpu",`${r.level}${r.mobile?" phone":""} \xB7 ${r.reason} \xB7 ${r.renderer||"unknown"}`]]:[],["renders",`${y(e.renders)} drawn \xB7 ${y(e.skipped)} skipped \xB7 ${y(e.rendersPerSec)}/s`],["draws",`${y(e.draws)} \xB7 planes ${y(e.visible)}/${y(e.planes)} \xB7 ${y(e.programs)} prog`],["tex",`${y(e.textures)} on GPU \xB7 ${y(e.textureMB)} MB${e.targetMB===void 0?"":` \xB7 targets ${y(e.targetMB)} MB`} \xB7 ${y(e.uploads)} uploads`],...e.gpuMB===void 0?[]:[["memory",`${y(e.gpuMB)} MB on GPU${r?.textureBudget?` of ${y(r.textureBudget/2**20)} MB`:""}`]],["canvas",`${y(e.width)}\xD7${y(e.height)} \xB7 dpr ${y(e.dpr,2)} \xB7 \xD7${y(e.scale,2)}${c}`],["busy",n.length?[...new Set(n)].join(", "):"nothing (sleeping)"]]}function q(e,t){F();let n=document.createElement("div");n.className="umber-hud",n.setAttribute("data-umber-hud",""),n.setAttribute("aria-hidden","true");let r=document.createElement("div");r.className="umber-hud__head",r.title="Click to fold \xB7 Ctrl/Cmd+Shift+H hides it";let c=document.createElement("span"),b=document.createElement("span");c.textContent=`Umber ${e.version??"?"}`,b.textContent="ctrl \u21E7 H",r.append(c,b);let w=document.createElement("div");w.className="umber-hud__body";let h=document.createElement("div"),S=document.createElement("canvas"),k=document.createElement("div");w.append(h,S,k),n.append(r,w),document.body.appendChild(n),r.addEventListener("click",()=>n.classList.toggle("is-folded"));function L(o,f){for(;o.children.length>f.length;)o.lastElementChild.remove();f.forEach(([x,A],T)=>{let P=o.children[T];P||(P=document.createElement("div"),P.className="umber-hud__row",P.append(document.createElement("b"),document.createElement("span")),o.appendChild(P));let[N,Q]=P.children;N.textContent!==x&&(N.textContent=x),Q.textContent!==A&&(Q.textContent=A)})}let v=new Float32Array(60),a=0,i=0,g=o=>{v[a]=o.dt*1e3,a=(a+1)%60,i<60&&i++},p=S.getContext("2d"),l=216,s=26,M=50,u=Math.min(window.devicePixelRatio||1,2);S.width=l*u,S.height=s*u;function $(){if(!p)return;p.setTransform(u,0,0,u,0,0),p.clearRect(0,0,l,s),p.fillStyle="rgba(255,255,255,0.05)",p.fillRect(0,0,l,s);let o=l/60;for(let x=0;x<i;x++){let A=v[(a-i+x+60)%60],T=Math.max(1,Math.min(A/M,1)*s);p.fillStyle=A<=17.5?"#4ade80":A<=33.5?"#fbbf24":"#f87171",p.fillRect((60-i+x)*o,s-T,Math.max(1,o-1),T)}let f=Math.round(s-16.7/M*s)+.5;p.strokeStyle="rgba(255,255,255,0.35)",p.lineWidth=1,p.beginPath(),p.moveTo(0,f),p.lineTo(l,f),p.stroke()}function _(){let o=0;for(let x=0;x<i;x++)o+=v[x];o=i?o/i:0,L(h,[["frame",i?`${y(o,1)} ms \xB7 ${y(1e3/o)} fps (loop)`:"no frames yet (the loop sleeps)"]]);let f={state:"unknown"};try{f=e.info||f}catch{}L(k,t?[...W(f),...t.rows()]:W(f)),$()}let E=null,R;function H(){E||(E=e.on("frame",g,{phase:"render",order:1e3,always:!1}),R=setInterval(_,250))}function C(){E?.(),E=null,clearInterval(R)}let d=o=>{(o.ctrlKey||o.metaKey)&&o.shiftKey&&(o.key==="H"||o.key==="h")&&(o.preventDefault(),m.toggle())};addEventListener("keydown",d);let m={show(){n.hidden=!1,_(),H()},hide(){n.hidden=!0,C()},toggle(){n.hidden?m.show():m.hide()},destroy(){C(),removeEventListener("keydown",d),n.remove()}};return m.show(),m}var j={top:0,left:0,center:.5,middle:.5,bottom:1,right:1};function Z(e){let t=/^(top|left|center|middle|bottom|right|-?\d*\.?\d+(?:px|%)?)?(?:([+-])=?(\d*\.?\d+)(px|%)?)?$/.exec(e);if(!t||!t[1]&&!t[2])return null;let n=0,r=0;if(t[1]&&t[1]in j)n=j[t[1]];else if(t[1]){let c=parseFloat(t[1]);t[1].endsWith("%")?n=c/100:r=c}if(t[2]){let c=parseFloat(t[3])*(t[2]==="-"?-1:1);t[4]==="%"?n+=c/100:r+=c}return[n,r]}function B(e,t){let n=(e||"").trim().toLowerCase();if(!n)return t;let r=Z(n);return r?/^[+-]/.test(n)&&!/^-\d/.test(n)?[t[0]+r[0],t[1]+r[1]]:r:t}var ee={cover:"0110",contain:"11000011",entry:"01110100",exit:"00101110","entry-crossing":"0111","exit-crossing":"0010"};function te(e,t){let n=ee[e[0]],r=e[1]||(t?"100%":"0%"),c=r.endsWith("%")?0:parseFloat(r)||0,b=c?0:parseFloat(r)/100||0,w=h=>({el:+n[h]+(+n[h+2]-+n[h])*b,elPx:c,vp:+n[h+1]+(+n[h+3]-+n[h+1])*b,vpPx:0});return n?{...w(0),alt:n[4]?w(4):void 0}:null}function I(e,t){let n=(e||t).trim().split(/\s+/),r=te(n.map(k=>k.toLowerCase()),t.startsWith("bottom"));if(r)return r;let c=t.split(/\s+/),[b,w]=B(n[0],B(c[0],[0,0])),[h,S]=B(n[1],B(c[1],[0,0]));return{el:b,elPx:w,vp:h,vpPx:S}}var ne={ready:"#4ade80",loading:"#fbbf24",error:"#f87171"},re="#60a5fa",z="#e879f9";function oe(e){let t=[];for(let n of e.effects||[]){let r=n.options||{};typeof r.start!="string"||r.trigger==="manual"||r.trigger==="load"||t.push({label:`${n.name} start`,spec:r.start,fallback:"top 90%",color:re})}if(e.scrub){let n=e.el,r=getComputedStyle(n),c=b=>n.getAttribute(`data-gl-scrub-${b}`)||r.getPropertyValue(`--gl-scrub-${b}`).trim()||"";t.push({label:"scrub start",spec:c("start"),fallback:"top bottom",color:z}),t.push({label:"scrub end",spec:c("end"),fallback:"bottom top",color:z})}return t}function K(e,t){F();let n=document.createElement("div");n.className="umber-outlines",n.setAttribute("data-umber-debug",""),n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let r=new Map,c=new Map,b=new Map;function w(a){let i=r.get(a);if(!i){let g=document.createElement("div");g.className="umber-outline";let p=document.createElement("span");g.appendChild(p),n.appendChild(g),i={el:g,label:p,text:""},r.set(a,i)}return i}function h(a){let i=b.get(a);if(i)return i;i=[];for(let g of oe(a)){let p=I(g.spec,g.fallback);for(let l of["screen","edge"]){let s=document.createElement("div");s.className="umber-marker",l==="edge"&&s.setAttribute("data-edge",""),s.style.setProperty("--c",g.color);let M=document.createElement("span");M.textContent=l==="screen"?g.label:g.label.replace(/ (start|end)$/," \xB7 $1 edge"),s.appendChild(M),n.appendChild(s),i.push({el:s,kind:l,at:l==="screen"?p.vp:p.el,px:l==="screen"?p.vpPx:p.elPx})}}return b.set(a,i),i}function S(a){let i=(a.clips?.list||[]).filter(s=>s.how!=="pruned"&&s.how!=="ignored"),g=c.get(a);for(g||c.set(a,g=[]);g.length<i.length;){let s=document.createElement("div");s.className="umber-clip",n.appendChild(s),g.push(s)}for(;g.length>i.length;)g.pop().remove();let p=a.doc.x-a.rect[0]-(a.pad?(a.rect[2]-a.doc.w)/2:0),l=a.doc.y-a.rect[1]-(a.pad?(a.rect[3]-a.doc.h)/2:0);i.forEach((s,M)=>{let u=s.bounds,$=Math.max(u[0]-p,-1e4),_=Math.max(u[1]-l,-1e4);g[M].style.transform=`translate(${$}px, ${_}px)`,g[M].style.width=`${Math.max(Math.min(u[2]-p,2e4)-$,1)}px`,g[M].style.height=`${Math.max(Math.min(u[3]-l,2e4)-_,1)}px`})}function k(a){r.get(a)?.el.remove(),r.delete(a);for(let i of c.get(a)||[])i.remove();c.delete(a);for(let i of b.get(a)||[])i.el.remove();b.delete(a)}function L(){let a=e.planes(),i=new Set(a);for(let l of[...r.keys(),...b.keys(),...c.keys()])i.has(l)||k(l);let g=innerHeight,p=innerWidth;for(let l of a){let s=l.rect,M=s[2]>0&&s[3]>0&&s[0]<p&&s[0]+s[2]>0&&s[1]<g&&s[1]+s[3]>0;if(t.outlines){let u=w(l);if(l.level&&!l.xfReason&&l.drawXf){let E=l.drawXf;u.el.style.transform=`matrix3d(${E[0]},${E[1]},0,${E[2]},${E[3]},${E[4]},0,${E[5]},0,0,1,0,${E[6]},${E[7]},0,${E[8]})`,u.el.style.width=`${Math.max(l.size[0],1)}px`,u.el.style.height=`${Math.max(l.size[1],1)}px`}else u.el.style.transform=`translate(${s[0]}px, ${s[1]}px)`,u.el.style.width=`${Math.max(s[2],1)}px`,u.el.style.height=`${Math.max(s[3],1)}px`;u.el.style.setProperty("--c",ne[l.status]||"#a1a1aa"),u.el.dataset.state=M&&l.status==="ready"?"drawn":"hidden";let $=(l.effects||[]).map(E=>E.name).join(" "),_=`${l.kind}${$?` \xB7 ${$}`:""} \xB7 ${l.status}`;_!==u.text&&(u.label.textContent=u.text=_),(l.clips||c.has(l))&&S(l)}if(t.markers)for(let u of h(l)){let $=u.kind==="screen"?g*u.at+u.px:s[1]+s[3]*u.at+u.px;u.el.style.transform=`translate(${u.kind==="edge"?s[0]:0}px, ${$}px)`,u.kind==="edge"&&(u.el.style.width=`${Math.max(s[2],1)}px`),u.el.style.display=l.inView||u.kind==="edge"?"":"none"}}}let v=e.on("frame",L,{phase:"render",order:1001,always:!1});return e.wake?.(1),{destroy(){v?.(),n.remove(),r.clear(),c.clear(),b.clear()}}}function V(e){return(e.effects||[]).map(n=>n.name).join("+")||(e.shader?`shader ${e.shader.name}`:e.kind)}function Y(e){let t=new Map,n=[],r=-1,c=0,b=0,w=0,h=0,S=0,k=-1,L=new Uint8Array(4),v=null,a=null,i=[],g=new Map,p=null,l=()=>e.planes()[0]?.host,s=()=>e.context;function M(){let d=new Set;for(let m of e.planes()){let o=V(m),f=t.get(o);f||t.set(o,f={name:o,planes:[],cpu:0,gpu:0}),d.has(o)||(f.planes=[]),d.add(o),f.planes.push(m)}for(let m of t.keys())d.has(m)||t.delete(m);n=[...t.values()]}function u(d,m){for(let o of d?.planes||[])o.hush=m}function $(d){let m=s();if(!m||!v||(a&&(m.endQuery(v.TIME_ELAPSED_EXT),i.push(a),a=null),!d||i.length>256))return;let o=t.get(V(d)),f=o&&m.createQuery();!f||!o||(m.beginQuery(v.TIME_ELAPSED_EXT,f),a={q:f,g:o})}function _(d){if(!v)return;let m=d.getParameter(v.GPU_DISJOINT_EXT),o=0;for(;o<i.length&&d.getQueryParameter(i[o].q,d.QUERY_RESULT_AVAILABLE);)o++;g.clear();for(let{q:f,g:x}of i.splice(0,o))m||g.set(x,(g.get(x)||0)+d.getQueryParameter(f,d.QUERY_RESULT)/1e6),d.deleteQuery(f);g.forEach((f,x)=>x.gpu=x.gpu?x.gpu*.8+f*.2:f)}let E=()=>{S=performance.now();let d=l();d?.renderer&&p!==d.renderer&&(p&&(p.probe=null),p=d.renderer,v=s()?.getExtension("EXT_disjoint_timer_query_webgl2")||null,v&&(p.probe=$))},R=()=>{let d=l(),m=s();if(e.wake?.(2),!d||!m||d.stats.renders===k)return;k=d.stats.renders,_(m),m.readPixels(0,0,1,1,m.RGBA,m.UNSIGNED_BYTE,L);let o=performance.now()-S;if(b>0){b--;return}if(c===0&&r===-1&&M(),w+=o,++c<6)return;let f=w/6;if(w=0,c=0,r===-1)h=f;else{let x=n[r];u(x,!1),x&&(x.cpu=x.cpu*.6+Math.max(0,h-f)*.4)}r=r+1<n.length?r+1:-1,r===-1?b=24:u(n[r],!0)},H=e.on("frame",E,{phase:"render",order:-1e3}),C=e.on("frame",R,{phase:"render",order:999});return{rows(){let d=[...t.values()].sort((o,f)=>f.cpu+f.gpu-(o.cpu+o.gpu)).slice(0,5);if(!d.length)return[["cost","measuring..."]];let m=d.map((o,f)=>[f?"":"cost",`${o.name}: ${o.cpu.toFixed(2)} cpu${v?` \xB7 ${o.gpu.toFixed(2)} gpu`:""} ms`]);return v||m.push(["","no GPU timer here: cpu A/B only"]),m},destroy(){H(),C();for(let m of t.values())u(m,!1);p&&(p.probe=null);let d=s();if(d&&v&&a&&d.endQuery(v.TIME_ELAPSED_EXT),d)for(let{q:m}of i)d.deleteQuery(m);d&&a&&d.deleteQuery(a.q),i.length=0,a=null}}}function se(){try{let e=new URLSearchParams(location.search).get("umber-debug");if(!e)return null;let t=new Set(e.split(/[\s,]+/).filter(Boolean));return{hud:t.has("hud")||t.has("cost"),outlines:t.has("outlines"),markers:t.has("markers"),cost:t.has("cost")}}catch{return null}}function ae(e,t={}){let n={hud:!0,outlines:!1,markers:!1,cost:!1,...t,...se()||{}},r=[],c=()=>{let h=n.cost?Y(e):void 0;h&&r.push(h),(n.hud||h)&&r.push(q(e,h)),(n.outlines||n.markers)&&r.push(K(e,{outlines:!!n.outlines,markers:!!n.markers}))};document.body?c():document.addEventListener("DOMContentLoaded",c,{once:!0});let b=!1,w=()=>{b||(b=!0,document.removeEventListener("DOMContentLoaded",c),r.forEach(h=>h.destroy()),X())};return e.on?.("destroy",w),w}var O={name:"debug",version:"0.2.0",attributes:[],install(e,t){ae(e,t)}};var ie=document.currentScript,le=e=>{let t=ie?.getAttribute(`data-${e}`);return t==null?void 0:t!=="false"},U={};for(let e of["hud","outlines","markers"]){let t=le(e);t!==void 0&&(U[e]=t)}var D=window;D.Umber?.use?D.Umber.use(O,U):((D.UmberModules||=[]).push([O,U]),D.__umber?.engine?.use?.(O,U));})();
|
|
36
|
+
`;function F(){if(document.getElementById(G))return;let e=document.createElement("style");e.id=G,e.textContent=J,document.head.appendChild(e)}function X(){document.getElementById(G)?.remove()}var y=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e.toFixed(t):"-";function W(e){let t=String(e.state??"unknown");if(t==="dormant"&&e.planes===void 0)return[["gl","dormant (no [data-gl] yet, nothing loaded)"]];if(t.startsWith("off"))return[["gl",t]];let n=Array.isArray(e.busy)?e.busy:[],r=e.gpu,c=r&&e.width/(e.dpr*e.scale)>r.wide?` \xB7 cut (wider than ${r.wide}px)`:"";return[["gl",`${t} \xB7 tier ${e.tier??"?"}`],...r?[["gpu",`${r.level}${r.mobile?" phone":""} \xB7 ${r.reason} \xB7 ${r.renderer||"unknown"}`]]:[],["renders",`${y(e.renders)} drawn \xB7 ${y(e.skipped)} skipped \xB7 ${y(e.rendersPerSec)}/s`],["draws",`${y(e.draws)} \xB7 planes ${y(e.visible)}/${y(e.planes)} \xB7 ${y(e.programs)} prog`],["tex",`${y(e.textures)} on GPU \xB7 ${y(e.textureMB)} MB${e.targetMB===void 0?"":` \xB7 targets ${y(e.targetMB)} MB`} \xB7 ${y(e.uploads)} uploads`],...e.gpuMB===void 0?[]:[["memory",`${y(e.gpuMB)} MB on GPU${r?.textureBudget?` of ${y(r.textureBudget/2**20)} MB`:""}`]],["canvas",`${y(e.width)}\xD7${y(e.height)} \xB7 dpr ${y(e.dpr,2)} \xB7 \xD7${y(e.scale,2)}${c}`],["busy",n.length?[...new Set(n)].join(", "):"nothing (sleeping)"]]}function q(e,t){F();let n=document.createElement("div");n.className="umber-hud",n.setAttribute("data-umber-hud",""),n.setAttribute("aria-hidden","true");let r=document.createElement("div");r.className="umber-hud__head",r.title="Click to fold \xB7 Ctrl/Cmd+Shift+H hides it";let c=document.createElement("span"),b=document.createElement("span");c.textContent=`Umber ${e.version??"?"}`,b.textContent="ctrl \u21E7 H",r.append(c,b);let w=document.createElement("div");w.className="umber-hud__body";let h=document.createElement("div"),S=document.createElement("canvas"),k=document.createElement("div");w.append(h,S,k),n.append(r,w),document.body.appendChild(n),r.addEventListener("click",()=>n.classList.toggle("is-folded"));function L(o,f){for(;o.children.length>f.length;)o.lastElementChild.remove();f.forEach(([x,A],T)=>{let P=o.children[T];P||(P=document.createElement("div"),P.className="umber-hud__row",P.append(document.createElement("b"),document.createElement("span")),o.appendChild(P));let[N,Q]=P.children;N.textContent!==x&&(N.textContent=x),Q.textContent!==A&&(Q.textContent=A)})}let v=new Float32Array(60),a=0,i=0,g=o=>{v[a]=o.dt*1e3,a=(a+1)%60,i<60&&i++},p=S.getContext("2d"),l=216,s=26,M=50,u=Math.min(window.devicePixelRatio||1,2);S.width=l*u,S.height=s*u;function $(){if(!p)return;p.setTransform(u,0,0,u,0,0),p.clearRect(0,0,l,s),p.fillStyle="rgba(255,255,255,0.05)",p.fillRect(0,0,l,s);let o=l/60;for(let x=0;x<i;x++){let A=v[(a-i+x+60)%60],T=Math.max(1,Math.min(A/M,1)*s);p.fillStyle=A<=17.5?"#4ade80":A<=33.5?"#fbbf24":"#f87171",p.fillRect((60-i+x)*o,s-T,Math.max(1,o-1),T)}let f=Math.round(s-16.7/M*s)+.5;p.strokeStyle="rgba(255,255,255,0.35)",p.lineWidth=1,p.beginPath(),p.moveTo(0,f),p.lineTo(l,f),p.stroke()}function _(){let o=0;for(let x=0;x<i;x++)o+=v[x];o=i?o/i:0,L(h,[["frame",i?`${y(o,1)} ms \xB7 ${y(1e3/o)} fps (loop)`:"no frames yet (the loop sleeps)"]]);let f={state:"unknown"};try{f=e.info||f}catch{}L(k,t?[...W(f),...t.rows()]:W(f)),$()}let E=null,R;function H(){E||(E=e.on("frame",g,{phase:"render",order:1e3,always:!1}),R=setInterval(_,250))}function C(){E?.(),E=null,clearInterval(R)}let d=o=>{(o.ctrlKey||o.metaKey)&&o.shiftKey&&(o.key==="H"||o.key==="h")&&(o.preventDefault(),m.toggle())};addEventListener("keydown",d);let m={show(){n.hidden=!1,_(),H()},hide(){n.hidden=!0,C()},toggle(){n.hidden?m.show():m.hide()},destroy(){C(),removeEventListener("keydown",d),n.remove()}};return m.show(),m}var j={top:0,left:0,center:.5,middle:.5,bottom:1,right:1};function Z(e){let t=/^(top|left|center|middle|bottom|right|-?\d*\.?\d+(?:px|%)?)?(?:([+-])=?(\d*\.?\d+)(px|%)?)?$/.exec(e);if(!t||!t[1]&&!t[2])return null;let n=0,r=0;if(t[1]&&t[1]in j)n=j[t[1]];else if(t[1]){let c=parseFloat(t[1]);t[1].endsWith("%")?n=c/100:r=c}if(t[2]){let c=parseFloat(t[3])*(t[2]==="-"?-1:1);t[4]==="%"?n+=c/100:r+=c}return[n,r]}function B(e,t){let n=(e||"").trim().toLowerCase();if(!n)return t;let r=Z(n);return r?/^[+-]/.test(n)&&!/^-\d/.test(n)?[t[0]+r[0],t[1]+r[1]]:r:t}var ee={cover:"0110",contain:"11000011",entry:"01110100",exit:"00101110","entry-crossing":"0111","exit-crossing":"0010"};function te(e,t){let n=ee[e[0]],r=e[1]||(t?"100%":"0%"),c=r.endsWith("%")?0:parseFloat(r)||0,b=c?0:parseFloat(r)/100||0,w=h=>({el:+n[h]+(+n[h+2]-+n[h])*b,elPx:c,vp:+n[h+1]+(+n[h+3]-+n[h+1])*b,vpPx:0});return n?{...w(0),alt:n[4]?w(4):void 0}:null}function I(e,t){let n=(e||t).trim().split(/\s+/),r=te(n.map(k=>k.toLowerCase()),t.startsWith("bottom"));if(r)return r;let c=t.split(/\s+/),[b,w]=B(n[0],B(c[0],[0,0])),[h,S]=B(n[1],B(c[1],[0,0]));return{el:b,elPx:w,vp:h,vpPx:S}}var ne={ready:"#4ade80",loading:"#fbbf24",error:"#f87171"},re="#60a5fa",z="#e879f9";function oe(e){let t=[];for(let n of e.effects||[]){let r=n.options||{};typeof r.start!="string"||r.trigger==="manual"||r.trigger==="load"||t.push({label:`${n.name} start`,spec:r.start,fallback:"top 90%",color:re})}if(e.scrub){let n=e.el,r=getComputedStyle(n),c=b=>n.getAttribute(`data-gl-scrub-${b}`)||r.getPropertyValue(`--gl-scrub-${b}`).trim()||"";t.push({label:"scrub start",spec:c("start"),fallback:"top bottom",color:z}),t.push({label:"scrub end",spec:c("end"),fallback:"bottom top",color:z})}return t}function K(e,t){F();let n=document.createElement("div");n.className="umber-outlines",n.setAttribute("data-umber-debug",""),n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let r=new Map,c=new Map,b=new Map;function w(a){let i=r.get(a);if(!i){let g=document.createElement("div");g.className="umber-outline";let p=document.createElement("span");g.appendChild(p),n.appendChild(g),i={el:g,label:p,text:""},r.set(a,i)}return i}function h(a){let i=b.get(a);if(i)return i;i=[];for(let g of oe(a)){let p=I(g.spec,g.fallback);for(let l of["screen","edge"]){let s=document.createElement("div");s.className="umber-marker",l==="edge"&&s.setAttribute("data-edge",""),s.style.setProperty("--c",g.color);let M=document.createElement("span");M.textContent=l==="screen"?g.label:g.label.replace(/ (start|end)$/," \xB7 $1 edge"),s.appendChild(M),n.appendChild(s),i.push({el:s,kind:l,at:l==="screen"?p.vp:p.el,px:l==="screen"?p.vpPx:p.elPx})}}return b.set(a,i),i}function S(a){let i=(a.clips?.list||[]).filter(s=>s.how!=="pruned"&&s.how!=="ignored"),g=c.get(a);for(g||c.set(a,g=[]);g.length<i.length;){let s=document.createElement("div");s.className="umber-clip",n.appendChild(s),g.push(s)}for(;g.length>i.length;)g.pop().remove();let p=a.doc.x-a.rect[0]-(a.pad?(a.rect[2]-a.doc.w)/2:0),l=a.doc.y-a.rect[1]-(a.pad?(a.rect[3]-a.doc.h)/2:0);i.forEach((s,M)=>{let u=s.bounds,$=Math.max(u[0]-p,-1e4),_=Math.max(u[1]-l,-1e4);g[M].style.transform=`translate(${$}px, ${_}px)`,g[M].style.width=`${Math.max(Math.min(u[2]-p,2e4)-$,1)}px`,g[M].style.height=`${Math.max(Math.min(u[3]-l,2e4)-_,1)}px`})}function k(a){r.get(a)?.el.remove(),r.delete(a);for(let i of c.get(a)||[])i.remove();c.delete(a);for(let i of b.get(a)||[])i.el.remove();b.delete(a)}function L(){let a=e.planes(),i=new Set(a);for(let l of[...r.keys(),...b.keys(),...c.keys()])i.has(l)||k(l);let g=innerHeight,p=innerWidth;for(let l of a){let s=l.rect,M=s[2]>0&&s[3]>0&&s[0]<p&&s[0]+s[2]>0&&s[1]<g&&s[1]+s[3]>0;if(t.outlines){let u=w(l);if(l.level&&!l.xfReason&&l.drawXf){let E=l.drawXf;u.el.style.transform=`matrix3d(${E[0]},${E[1]},0,${E[2]},${E[3]},${E[4]},0,${E[5]},0,0,1,0,${E[6]},${E[7]},0,${E[8]})`,u.el.style.width=`${Math.max(l.size[0],1)}px`,u.el.style.height=`${Math.max(l.size[1],1)}px`}else u.el.style.transform=`translate(${s[0]}px, ${s[1]}px)`,u.el.style.width=`${Math.max(s[2],1)}px`,u.el.style.height=`${Math.max(s[3],1)}px`;u.el.style.setProperty("--c",ne[l.status]||"#a1a1aa"),u.el.dataset.state=M&&l.status==="ready"?"drawn":"hidden";let $=(l.effects||[]).map(E=>E.name).join(" "),_=`${l.kind}${$?` \xB7 ${$}`:""} \xB7 ${l.status}`;_!==u.text&&(u.label.textContent=u.text=_),(l.clips||c.has(l))&&S(l)}if(t.markers)for(let u of h(l)){let $=u.kind==="screen"?g*u.at+u.px:s[1]+s[3]*u.at+u.px;u.el.style.transform=`translate(${u.kind==="edge"?s[0]:0}px, ${$}px)`,u.kind==="edge"&&(u.el.style.width=`${Math.max(s[2],1)}px`),u.el.style.display=l.inView||u.kind==="edge"?"":"none"}}}let v=e.on("frame",L,{phase:"render",order:1001,always:!1});return e.wake?.(1),{destroy(){v?.(),n.remove(),r.clear(),c.clear(),b.clear()}}}function V(e){return(e.effects||[]).map(n=>n.name).join("+")||(e.shader?`shader ${e.shader.name}`:e.kind)}function Y(e){let t=new Map,n=[],r=-1,c=0,b=0,w=0,h=0,S=0,k=-1,L=new Uint8Array(4),v=null,a=null,i=[],g=new Map,p=null,l=()=>e.planes()[0]?.host,s=()=>e.context;function M(){let d=new Set;for(let m of e.planes()){let o=V(m),f=t.get(o);f||t.set(o,f={name:o,planes:[],cpu:0,gpu:0}),d.has(o)||(f.planes=[]),d.add(o),f.planes.push(m)}for(let m of t.keys())d.has(m)||t.delete(m);n=[...t.values()]}function u(d,m){for(let o of d?.planes||[])o.hush=m}function $(d){let m=s();if(!m||!v||(a&&(m.endQuery(v.TIME_ELAPSED_EXT),i.push(a),a=null),!d||i.length>256))return;let o=t.get(V(d)),f=o&&m.createQuery();!f||!o||(m.beginQuery(v.TIME_ELAPSED_EXT,f),a={q:f,g:o})}function _(d){if(!v)return;let m=d.getParameter(v.GPU_DISJOINT_EXT),o=0;for(;o<i.length&&d.getQueryParameter(i[o].q,d.QUERY_RESULT_AVAILABLE);)o++;g.clear();for(let{q:f,g:x}of i.splice(0,o))m||g.set(x,(g.get(x)||0)+d.getQueryParameter(f,d.QUERY_RESULT)/1e6),d.deleteQuery(f);g.forEach((f,x)=>x.gpu=x.gpu?x.gpu*.8+f*.2:f)}let E=()=>{S=performance.now();let d=l();d?.renderer&&p!==d.renderer&&(p&&(p.probe=null),p=d.renderer,v=s()?.getExtension("EXT_disjoint_timer_query_webgl2")||null,v&&(p.probe=$))},R=()=>{let d=l(),m=s();if(e.wake?.(2),!d||!m||d.stats.renders===k)return;k=d.stats.renders,_(m),m.readPixels(0,0,1,1,m.RGBA,m.UNSIGNED_BYTE,L);let o=performance.now()-S;if(b>0){b--;return}if(c===0&&r===-1&&M(),w+=o,++c<6)return;let f=w/6;if(w=0,c=0,r===-1)h=f;else{let x=n[r];u(x,!1),x&&(x.cpu=x.cpu*.6+Math.max(0,h-f)*.4)}r=r+1<n.length?r+1:-1,r===-1?b=24:u(n[r],!0)},H=e.on("frame",E,{phase:"render",order:-1e3}),C=e.on("frame",R,{phase:"render",order:999});return{rows(){let d=[...t.values()].sort((o,f)=>f.cpu+f.gpu-(o.cpu+o.gpu)).slice(0,5);if(!d.length)return[["cost","measuring..."]];let m=d.map((o,f)=>[f?"":"cost",`${o.name}: ${o.cpu.toFixed(2)} cpu${v?` \xB7 ${o.gpu.toFixed(2)} gpu`:""} ms`]);return v||m.push(["","no GPU timer here: cpu A/B only"]),m},destroy(){H(),C();for(let m of t.values())u(m,!1);p&&(p.probe=null);let d=s();if(d&&v&&a&&d.endQuery(v.TIME_ELAPSED_EXT),d)for(let{q:m}of i)d.deleteQuery(m);d&&a&&d.deleteQuery(a.q),i.length=0,a=null}}}function se(){try{let e=new URLSearchParams(location.search).get("umber-debug");if(!e)return null;let t=new Set(e.split(/[\s,]+/).filter(Boolean));return{hud:t.has("hud")||t.has("cost"),outlines:t.has("outlines"),markers:t.has("markers"),cost:t.has("cost")}}catch{return null}}function ae(e,t={}){let n={hud:!0,outlines:!1,markers:!1,cost:!1,...t,...se()||{}},r=[],c=()=>{let h=n.cost?Y(e):void 0;h&&r.push(h),(n.hud||h)&&r.push(q(e,h)),(n.outlines||n.markers)&&r.push(K(e,{outlines:!!n.outlines,markers:!!n.markers}))};document.body?c():document.addEventListener("DOMContentLoaded",c,{once:!0});let b=!1,w=()=>{b||(b=!0,document.removeEventListener("DOMContentLoaded",c),r.forEach(h=>h.destroy()),X())};return e.on?.("destroy",w),w}var O={name:"debug",version:"0.2.1",attributes:[],install(e,t){ae(e,t)}};var ie=document.currentScript,le=e=>{let t=ie?.getAttribute(`data-${e}`);return t==null?void 0:t!=="false"},U={};for(let e of["hud","outlines","markers"]){let t=le(e);t!==void 0&&(U[e]=t)}var D=window;D.Umber?.use?D.Umber.use(O,U):((D.UmberModules||=[]).push([O,U]),D.__umber?.engine?.use?.(O,U));})();
|