@occluze/umber 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +62 -2
  2. package/dist/chunks/capture.js +2 -0
  3. package/dist/chunks/covers.js +2 -0
  4. package/dist/chunks/flip.js +2 -0
  5. package/dist/chunks/fx.js +102 -0
  6. package/dist/chunks/gl.js +180 -0
  7. package/dist/chunks/glsl.js +239 -0
  8. package/dist/chunks/inspect.js +6 -0
  9. package/dist/chunks/instances.js +93 -0
  10. package/dist/chunks/layers.js +21 -0
  11. package/dist/chunks/licence.js +2 -0
  12. package/dist/chunks/morph.js +2 -0
  13. package/dist/chunks/restore.js +2 -0
  14. package/dist/chunks/shapes.js +2 -0
  15. package/dist/chunks/sim.js +22 -0
  16. package/dist/chunks/text.js +52 -0
  17. package/dist/chunks/video.js +2 -0
  18. package/dist/chunks/views.js +2 -0
  19. package/dist/chunks/warm.js +2 -0
  20. package/dist/modules/debug.js +36 -0
  21. package/dist/modules/debug.mjs +36 -0
  22. package/dist/modules/handoff.js +2 -0
  23. package/dist/modules/handoff.mjs +2 -0
  24. package/dist/modules/input.js +2 -0
  25. package/dist/modules/input.mjs +2 -0
  26. package/dist/modules/router-swap.js +13 -0
  27. package/dist/modules/router.js +2 -0
  28. package/dist/modules/router.mjs +2 -0
  29. package/dist/modules/scroll.js +2 -0
  30. package/dist/modules/scroll.mjs +2 -0
  31. package/dist/modules/scrub.js +8 -0
  32. package/dist/modules/scrub.mjs +8 -0
  33. package/dist/umber.css +2 -0
  34. package/dist/umber.js +2 -0
  35. package/dist/umber.mjs +2 -0
  36. package/docs/npm.md +69 -0
  37. package/package.json +116 -8
  38. package/types/debug.d.ts +27 -0
  39. package/types/esm.d.ts +33 -0
  40. package/types/handoff.d.ts +116 -0
  41. package/types/input.d.ts +235 -0
  42. package/types/router.d.ts +181 -0
  43. package/types/scroll.d.ts +132 -0
  44. package/types/scrub.d.ts +74 -0
  45. package/types/umber.d.ts +1532 -0
  46. package/index.js +0 -2
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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};
@@ -0,0 +1,22 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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
+ 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
+ vec4 next(vec2 uv){
5
+ vec4 c=texture(FIELD,uv);
6
+ for(int i=0;i<16;i++){
7
+ if(float(i)>=uCount)break;
8
+ vec2 d=(uv-uStamps[i].xy)*uView;
9
+ float k=exp(-dot(d,d)/(uBrushRadius*uBrushRadius));
10
+ vec4 v=uColor+vec4(uStamps[i].zw*uMotion,0.0,0.0);
11
+ c=uMix>0.5?mix(c,v,k*uColor.a):c+v*k;
12
+ }
13
+ return c;
14
+ }`,E=`vec4 next(vec2 uv){
15
+ vec2 v=texture(push,uv).xy;
16
+ float l=length(v);
17
+ return vec4(l<1.0/255.0?vec2(0.0):v/max(l,1.0)*uFade,0.0,1.0);
18
+ }`,T=`vec4 next(vec2 uv){
19
+ vec2 v=texture(push,uv).xy;
20
+ float l=length(v);
21
+ return vec4(l>0.0?v/l*0.5+0.5:vec2(0.5),1.0,min(l,1.0));
22
+ }`,R=a=>a.o.pointer!==!1,x=class{constructor(t){this.fx=t;this.list=new Set;this.flowSim=null;this.flowBrush=null;this.tick=t=>{let e=this.fx.stage;if(e.inactive)return;let s=!1,i=!1;for(let n of this.list)if(n.awake){if(!n.seen()){for(let o of n.brushes)o.last[0]=NaN;continue}s=n.run(t.dt)||s,i||=n.awake}s?e.markDirty():i&&e.request()};let e=t.stage;e.subsystems.push(this),e.cleanups.push(e.host.ticker.add(this.tick,{phase:"render",order:-1}));let s=n=>{let o=n,r=n.type==="pointerdown";r&&(e.pointer.x=o.clientX,e.pointer.y=o.clientY);let u=r||n.type==="pointerout"&&!o.relatedTarget;for(let l of this.list)if(u)for(let f of l.brushes)f.last[0]=NaN;else n.type==="pointermove"&&(l.pointer||l.brushes.some(R))&&l.seen()&&l.wake()},i=["pointermove","pointerdown","pointerout"];for(let n of i)addEventListener(n,s,{passive:!0});e.cleanups.push(()=>{for(let n of i)removeEventListener(n,s);this.list.clear()})}get level(){return this.fx.stage.stats.gpu?.level??4}sim(t,e=!1){if(!t||typeof t.next!="string"&&!Array.isArray(t.passes))return h.warn("gl.sim(options) needs `next` (GLSL: vec4 next(vec2 uv) { ... }) or `passes` ([{ into, next }])."),null;let s=Object.keys(t.fields||{state:0}),i=s.find(o=>!A.test(o))||(t.passes||[]).map(o=>o.into).find(o=>!s.includes(o));if(i)return h.warn(`gl.sim(): "${i}" is not one of its fields (${s.join(", ")}), or not a GLSL name; nothing was made.`),null;let n=new w(this,t,this.level);this.list.add(n);for(let o of n.fields.values()){let r=o.read.type;if(r==="float"&&o.read.b?.format.filter===this.fx.gl.NEAREST&&h.once(`gl.sim(): this GPU can't filter "float" targets, so texture() gives the nearest texel (smooth sampling turns blocky; texelFetch() is fine). Ask for type: "half" to sample smoothly.`),!(e||r===o.type)){if(r==="u8"){h.once(`gl.sim(): this GPU can't render to "${o.type}" targets, so sims run in 8 bits: values clip to 0..1 and slow fades stop short of 0. Ask for type: "u8" to skip this message.`);break}(t.fields?.[o.name]?.type||t.type)&&h.once(`gl.sim(): this GPU can't render to "${o.type}" targets, so this sim runs in "${r}": values round to about 3 digits (particle positions jitter). Ask for type: "${r}" to skip this message.`)}}return n}flow(t={}){let e=this.fx.stage,s=e.viewport.width,i=Math.min(.999,Math.max(0,t.fade??.92));if(this.flowSim===null){let o=this.sim({size:t.size??[32,48,64,64,96,128],fields:{push:{},flow:{}},output:"flow",passes:[{into:"push",next:E},{into:"flow",next:T}],uniforms:{uFade:i},settle:r=>r.idle*r.clock.hz>=y(r.uniforms.uFade)+2},!0);if(o.type==="u8"){o.release(),this.flowSim=!1;let r=e.host.engine.touch?.({fade:i,radius:(t.radius??s*.08)/s});return this.patch(()=>r?.texture),r?h.once("uFlow: this GPU can't render to half-float targets, so the flowmap is the input module's gl.touch() texture (drawn on the CPU, 8-bit)."):h.warn("uFlow: this GPU can't render to half-float targets, which the flowmap needs. Add the input module (modules/input.js, or gl.use(Input)) and uFlow falls back to its gl.touch() texture; until then uFlow stays still."),null}return this.flowSim=o,this.flowBrush=o.brush({field:"push",radius:t.radius??s*.08,motion:t.motion??.04}),this.patch(()=>o.texture),o}let n=this.flowSim;return n?(t.fade!=null&&(n.uniforms.uFade=i),t.radius!=null&&(this.flowBrush.u.uBrushRadius=Math.max(.5,t.radius)),t.motion!=null&&(this.flowBrush.u.uMotion=t.motion),t.size!=null&&t.size!==n.o.size&&(n.o.size=t.size,n.fit()),this.patch(()=>n.texture),n):null}patch(t){let e=this.fx.stage;e.flow||={texture:null},Object.defineProperty(e.flow,"texture",{configurable:!0,get:()=>t()||e.renderer.blank.texture})}lost(){for(let t of this.list)for(let e of t.brushes)e.lost()}restored(){for(let t of this.list)t.compile()&&t.reset()}};function U(a){return v(a.stage.host.log),new x(a)}export{b as Brush,w as Sim,x as Sims,U as sims};
@@ -0,0 +1,52 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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
+ float line;
4
+ float word;
5
+ float char;
6
+ float lines;
7
+ float words;
8
+ float chars;
9
+ vec4 lineBox;
10
+ vec4 wordBox;
11
+ vec4 charBox;
12
+ float ink;
13
+ vec4 lineValue;
14
+ vec4 wordValue;
15
+ vec4 charValue;
16
+ };
17
+ uniform highp usampler2D uGlyphIndex;
18
+ uniform highp sampler2D uGlyphData;
19
+ vec4 umberGlyphRow(highp int i){
20
+ highp int w=textureSize(uGlyphData,0).x;
21
+ return texelFetch(uGlyphData,ivec2(i%w,i/w),0);
22
+ }
23
+ Glyph glyph(vec2 uv){
24
+ Glyph g=Glyph(0.0,0.0,0.0,1.0,1.0,1.0,vec4(0.0,0.0,1.0,1.0),vec4(0.0,0.0,1.0,1.0),vec4(0.0,0.0,1.0,1.0),0.0,vec4(0.0),vec4(0.0),vec4(0.0));
25
+ #ifdef UMBER_FRAGMENT
26
+ g.ink=sampleImage(uv).a;
27
+ #endif
28
+ vec4 head=umberGlyphRow(0);
29
+ if(head.x<0.5)return g;
30
+ highp ivec2 size=textureSize(uGlyphIndex,0);
31
+ highp ivec2 p=clamp(ivec2(floor(uv*vec2(size))),ivec2(0),size-1);
32
+ highp int c=int(texelFetch(uGlyphIndex,p,0).r)-1;
33
+ if(c<0)return g;
34
+ highp int chars=int(head.x+0.5);
35
+ highp int words=int(head.y+0.5);
36
+ vec4 info=umberGlyphRow(1+2*c);
37
+ g.line=info.x;
38
+ g.word=info.y;
39
+ g.char=float(c);
40
+ g.chars=head.x;
41
+ g.words=head.y;
42
+ g.lines=head.z;
43
+ g.charBox=umberGlyphRow(2+2*c);
44
+ g.wordBox=umberGlyphRow(1+2*chars+int(info.y+0.5));
45
+ g.lineBox=umberGlyphRow(1+2*chars+words+int(info.x+0.5));
46
+ highp int lines=int(head.z+0.5);
47
+ highp int values=1+2*chars+words+lines;
48
+ g.lineValue=umberGlyphRow(values+int(info.x+0.5));
49
+ g.wordValue=umberGlyphRow(values+lines+int(info.y+0.5));
50
+ g.charValue=umberGlyphRow(values+lines+words+c);
51
+ return g;
52
+ }`},De=65534,ee=(e,t)=>{e.l=Math.min(e.l,t.x),e.t=Math.min(e.t,t.y),e.r=Math.max(e.r,t.x+t.w),e.b=Math.max(e.b,t.y+t.h)},Ut=e=>({l:e.x,t:e.y,r:e.x+e.w,b:e.y+e.h});function Ft(e,t=e.length){let r=new Int32Array(t),i=new Int32Array(t),n=[],a=[];for(let s=0;s<t;s++){let o=e[s],l=n[n.length-1],f=s>0?e[s-1]:null,d=o.y+o.h/2,c=!!f&&(o.rtl?o.x+o.w/2>f.x+f.w:o.x+o.w/2<f.x),A=!l||(o.unit!==void 0&&f?.unit!==void 0?o.unit!==f.unit:d>l.b||c&&o.y>=(l.t+l.b)/2);A?n.push({...Ut(o),chars:[]}):ee(l,o),n[n.length-1].chars.push(s),A||o.wordStart||!a.length?a.push(Ut(o)):ee(a[a.length-1],o),r[s]=n.length-1,i[s]=a.length-1}return{lineOf:r,wordOf:i,lines:n,words:a}}function ne(e,t,r,i=2048){let n=Math.min(e.length,De);if(!n||!(t>0)||!(r>0))return null;let{lineOf:a,wordOf:s,lines:o,words:l}=Ft(e,n),f=Math.min(1,i/Math.max(t,r)),d=Math.max(1,Math.ceil(t*f)),c=Math.max(1,Math.ceil(r*f)),A=(u,b)=>Math.max(0,Math.min(b,Math.round(u*f))),E=o.map(u=>{let b=new Uint16Array(d),M=new Float32Array(d).fill(1/0),R=new Float32Array(d).fill(-1/0),G=u.chars.slice().sort((B,L)=>e[B].x+e[B].w/2-(e[L].x+e[L].w/2)),W=0;for(let B=0;B<G.length;B++){let L=e[G[B]],Y=B+1<G.length?e[G[B+1]]:null,J=Y?Math.max(W,(L.x+L.w+Y.x)/2):t,ot=A(W,d),at=Y?A(J,d):d;at>ot&&b.fill(G[B]+1,ot,at),W=J;let K=L.ink||{l:L.x,t:L.y,r:L.x+L.w,b:L.y+L.h};for(let Z=A(K.l-1,d-1),bt=A(K.r+1,d-1);Z<=bt;Z++)K.t-1<M[Z]&&(M[Z]=K.t-1),K.b+1>R[Z]&&(R[Z]=K.b+1)}return{owner:b,inkTop:M,inkBottom:R}}),F=o.slice(0,-1).map((u,b)=>{let M=o[b+1],R=(u.b+M.t)/2,G=new Float32Array(d),W=E[b],B=E[b+1];for(let L=0;L<d;L++){let Y=W.inkBottom[L],J=B.inkTop[L];G[L]=Y>J?(Y+J)/2:Math.min(Math.max(R,Y),J)}return G}),I=new Uint16Array(d*c);for(let u=0;u<d;u++){let b=0;for(let M=0;M<o.length;M++){let R=M<F.length?Math.max(b,A(F[M][u],c)):c,G=E[M].owner[u];for(let W=b;W<R;W++)I[W*d+u]=G;b=R}}let _=1+2*n+l.length+o.length,h=_+n+l.length+o.length,g=Math.min(h,512),S=Math.ceil(h/g),P=new Float32Array(g*S*4),$=(u,b,M,R,G)=>{P.set([b,M,R,G],u*4)},et=(u,b)=>$(u,b.l/t,b.t/r,(b.r-b.l)/t,(b.b-b.t)/r);$(0,n,l.length,o.length,0);for(let u=0;u<n;u++)$(1+2*u,a[u],s[u],0,0),et(2+2*u,Ut(e[u]));return l.forEach((u,b)=>et(1+2*n+b,u)),o.forEach((u,b)=>et(1+2*n+l.length+b,u)),{chars:n,words:l.length,lines:o.length,index:I,width:d,height:c,data:P,dataWidth:g,dataHeight:S,values:_}}var Bt=[1,0,0,1,0,0];function tt(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}var Ie=(e,t,r)=>[e[0]*t+e[2]*r+e[4],e[1]*t+e[3]*r+e[5]];function re(e,t,r){let i=e[0]*e[3]-e[2]*e[1];return Math.abs(i)<1e-6?null:[(e[3]*t-e[2]*r)/i,(e[0]*r-e[1]*t)/i]}function ie(e,t,r){let i=Bt,n=!1,a=e.translate;if(a&&a!=="none"){let[c="0",A="0",E]=a.split(" ");if(E&&parseFloat(E))return!1;let F=(I,_)=>I.endsWith("%")?parseFloat(I)/100*_:parseFloat(I)||0;i=tt(i,[1,0,0,1,F(c,t),F(A,r)]),n=!0}let s=e.rotate;if(s&&s!=="none"){if(s.trim().includes(" "))return!1;let c=parseFloat(s)*Math.PI/(s.endsWith("rad")?Math.PI:s.endsWith("turn")?.5:180);i=tt(i,[Math.cos(c),Math.sin(c),-Math.sin(c),Math.cos(c),0,0]),n=!0}let o=e.scale;if(o&&o!=="none"){let[c,A=c,E]=o.split(" ").map(parseFloat);if(E!==void 0&&E!==1)return!1;i=tt(i,[c,0,0,A,0,0]),n=!0}let l=e.transform;if(l&&l!=="none"){let c=(l.slice(l.indexOf("(")).match(/-?[\d.]+(?:e-?\d+)?/g)||[]).map(Number);if(l.startsWith("matrix3d")){if(c.length!==16||c[2]||c[3]||c[6]||c[7]||c[8]||c[9]||c[11]||c[14]||c[10]!==1||c[15]!==1)return!1;i=tt(i,[c[0],c[1],c[4],c[5],c[12],c[13]])}else c.length===6&&(i=tt(i,c));n=!0}if(!n||i.every((c,A)=>Math.abs(c-Bt[A])<1e-6))return null;let[f=0,d=0]=e.transformOrigin.split(" ").map(parseFloat);return tt([1,0,0,1,f,d],tt(i,[1,0,0,1,-f,-d]))}function se(e,t,r,i,n,a){let s=e||Bt,o=1/0,l=1/0;for(let[d,c]of[[0,0],[i,0],[0,n],[i,n]]){let[A,E]=Ie(t,d,c),F=s[0]*A+s[2]*E,I=s[1]*A+s[3]*E;F<o&&(o=F),I<l&&(l=I)}let f=re(s,r.x-s[4]-o,r.y-s[5]-l);return f?(a&&a.splice(0,2,f[0],f[1]),tt(s,tt([1,0,0,1,f[0],f[1]],tt(t,[1,0,0,1,-f[0],-f[1]])))):null}function Nt(e,t){let r=re(t,e.x+e.w/2-t[4],e.y+e.h/2-t[5]);if(!r)return null;let i=Math.abs(t[0]),n=Math.abs(t[2]),a=Math.abs(t[1]),s=Math.abs(t[3]),o=i*s-n*a,l,f;return Math.abs(o)>.3*(i*s+n*a)?(l=(e.w*s-n*e.h)/o,f=(i*e.h-a*e.w)/o):(l=e.w/Math.hypot(t[0],t[1]),f=e.h/Math.hypot(t[2],t[3])),{x:r[0]-l/2,y:r[1]-f/2,w:l,h:f}}var oe=new Map;function ke(e){let t=oe.get(e);if(t===void 0){let r=typeof Intl<"u"?Intl.Segmenter:null;try{t=r?new r(e||void 0,{granularity:"word"}):null}catch{t=r?new r(void 0,{granularity:"word"}):null}oe.set(e,t)}return t}function ae(e,t="",r=ke(t)){let i=new Uint8Array(e.length+1),n=!0;if(!r){for(let s=0;s<e.length;s++){let o=/\s/.test(e[s]);!o&&n&&(i[s]=1),n=o}return i}let a=!1;for(let{segment:s,index:o,isWordLike:l}of r.segment(e)){if(!s.trim()){n=!0,a=!1;continue}(n||l&&a)&&(i[o]=1),n=!1,a=!!l}return i}function ct(e){let t=e.length;if(t<2)return{rect:e[0],hyphen:void 0};let r=e[t-1],i=t-1;for(;i>0&&Math.abs(e[i-1].top-r.top)<r.height/2;)i--;let n=i<t-1?e[i+1]:void 0;return{rect:e[i],hyphen:n&&n.width>0?n:void 0}}var Ue=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Fe=/[\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Hangul}]/u,Ot=/[\p{L}\p{N}]/u,Ht=e=>!!e&&!/^(inline|contents)/.test(e),Be=/[\u0600-\u08FF\u0900-\u0DFF\u0E00-\u0FFF\u1000-\u109F\u1780-\u17FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function fe(e){if(Be.test(e.textContent||""))return"a script that needs letter shaping";let t=[e,...Array.from(e.querySelectorAll("*"))],r=e.matches('[data-gl-status="ready"],[data-gl-status="loading"][data-gl-play],[data-gl-morphing]');for(let i of t){let n=getComputedStyle(i);if(parseFloat(n.webkitTextStrokeWidth||"0")>0)return"-webkit-text-stroke";if(!r&&n.textShadow&&n.textShadow!="none")return"text-shadow";let a=n.getPropertyValue("-webkit-text-fill-color");if(!r&&a&&a!=n.color&&!/^currentcolor$/i.test(a))return"a -webkit-text-fill-color other than its color";if(/discretionary|historical/.test(n.fontVariantLigatures))return"discretionary or historical ligatures";if(n.backgroundClip==="text"||n.webkitBackgroundClip==="text")return"background-clip: text";if(Oe(n.fontFeatureSettings))return"font-feature-settings";if(n.fontVariationSettings&&n.fontVariationSettings!=="normal")return"font-variation-settings";if(n.textDecorationLine&&n.textDecorationLine!=="none")return"text-decoration (underline / line-through)";if(n.writingMode&&n.writingMode!=="horizontal-tb")return"vertical writing-mode";if(n.textOverflow==="ellipsis")return"text-overflow: ellipsis";if(n.webkitLineClamp&&n.webkitLineClamp!=="none")return"line-clamp";if(n.fontSizeAdjust&&n.fontSizeAdjust!=="none")return"font-size-adjust";if(/full-/.test(n.textTransform))return`text-transform: ${n.textTransform}`;for(let s of[n.fontVariantNumeric,n.fontVariantAlternates,n.fontVariantEastAsian,n.fontVariantPosition])if(s&&s!=="normal")return"font-variant";if(n.fontVariantCaps&&!/^(normal|small-caps)$/.test(n.fontVariantCaps)&&!(typeof CanvasRenderingContext2D<"u"&&"fontVariantCaps"in CanvasRenderingContext2D.prototype))return"font-variant-caps";if(de(n.fontStretch)===void 0)return"a font-stretch between the keyword widths";for(let s of["::before","::after"]){let o=getComputedStyle(i,s).content;if(o&&!/^(none|normal|"\s*")$/.test(o))return`${s} content`}if(n.display.includes("list-item")&&n.listStyleType!=="none")return"a list marker";if(i==e||Ht(n.display))for(let s of["::first-letter","::first-line"]){let o=getComputedStyle(i,s);for(let l of["fontSize","fontFamily","fontWeight","fontStyle","color","letterSpacing","textTransform","fontVariantCaps"])if(o[l]&&o[l]!==n[l])return`a styled ${s}`}}return""}var Ne=new Set(["kern","liga","clig","calt"]);function Oe(e){if(!e||e==="normal")return!1;let t=e.match(/["'][\w ]{4}["']/g)||[];return!t.length||t.some(r=>!Ne.has(r.slice(1,5)))}var le=["color","opacity","font","letterSpacing","wordSpacing","textTransform"];function zt(e,t){let r=t.length!==e.length*le.length,i=0;for(let n of e)for(let a of le)t[i]!==n[a]&&(t[i]=n[a],r=!0),i++;return r}var ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;function*We(e){if(ue){yield*ue.segment(e);return}let t=0;for(let r of e)yield{segment:r,index:t},t+=r.length}function ce(e,t,r){try{return r?e.toLocaleUpperCase(t||void 0):e.toLocaleLowerCase(t||void 0)}catch{return r?e.toUpperCase():e.toLowerCase()}}function He(e,t,r,i=""){return t==="uppercase"||t==="capitalize"&&r?ce(e,i,!0):t==="lowercase"?ce(e,i,!1):e}var Wt={"50%":"ultra-condensed","62.5%":"extra-condensed","75%":"condensed","87.5%":"semi-condensed","100%":"",normal:"","112.5%":"semi-expanded","125%":"expanded","150%":"extra-expanded","200%":"ultra-expanded"};function de(e=""){return e?e in Wt?Wt[e]:Object.values(Wt).includes(e)?e:void 0:""}function ze(e,t,r){return e.position==="absolute"&&t<=1&&r<=1&&e.overflow!=="visible"}var he=new WeakSet,ht={hidden:[]};function me(e,t,r,i,n=!1,a){ht.hidden=[];let s=e.getBoundingClientRect();if(s.width<1||s.height<1)return null;let o=e.offsetWidth||s.width,l=e.offsetHeight||s.height,f=Math.abs(s.width-o)<1?1:s.width/o,d=Math.abs(s.height-l)<1?1:s.height/l,c=a?a.width:s.width/f,A=a?a.height:s.height/d,E=[0,0,0,0,0,0],F=getComputedStyle(e),I=parseFloat(F.fontSize)||16,_=Math.ceil(I*.35),h=c+_*2,g=A+_*2,S=Math.min(t,r/Math.max(h,g)),P=i||document.createElement("canvas"),$=Math.max(1,Math.ceil(h*S)),et=Math.max(1,Math.ceil(g*S));P.width!==$&&(P.width=$),P.height!==et&&(P.height=et);let u=P.getContext("2d");if(!u)return null;u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,P.width,P.height),u.setTransform(S,0,0,S,0,0),u.textBaseline="alphabetic",u.textAlign="left";let b=(y,H,V)=>{if(!a)return{x:(y.left-s.left)/f,y:(y.top-s.top)/d,w:y.width/f,h:y.height/d};a.toLocal(y.left+y.width/2,y.top+y.height/2,E);let v=Math.abs(E[2]),x=Math.abs(E[4]),q=Math.abs(E[3]),z=Math.abs(E[5]),N=v*z-x*q,D=H(),j=V;return Math.abs(N)>.3*(v*z+x*q)&&(D=(y.width*z-x*y.height)/N,j=(v*y.height-q*y.width)/N),{x:E[0]-D/2,y:E[1]-j/2,w:D,h:j}},M=y=>a?y:(Math.round((s.top+(y-_)*d)*t)/t-s.top)/d+_,R=new Map,G=y=>{let H=R.get(y);if(H)return H;let V=y===e?F:getComputedStyle(y),v=y===e||!y.parentElement?null:G(y.parentElement);if(!v)H={cs:V,lang:e.closest("[lang]")?.lang||"",hidden:!1,m:null,rest:null,unit:null,alpha:1,faded:null};else{let x=y.offsetWidth||0,q=y.offsetHeight||0,z=v.m,N=v.rest,D=V.display==="inline"?null:ie(V,x,q);if(D===!1)nt.once(`data-gl="text": a 3D transform inside it is painted as drawn now (GL can't undo it). Animate with a glyph() effect instead.`,y);else if(D&&!N){let pt=[0,0];z=se(v.m,D,b(y.getBoundingClientRect(),()=>x,q),x,q,pt)||z,z&&Math.abs(z[0]*z[3]-z[1]*z[2])<1e-6&&(N={x:pt[0],y:pt[1],h:q,adv:0})}let j=parseFloat(V.opacity);H={cs:V,lang:y.getAttribute("lang")??v.lang,hidden:v.hidden||ze(V,x,q),m:z,rest:N,unit:y.hasAttribute("data-line")?y:v.unit,alpha:v.alpha*(j>=0?j:1),faded:j<1?y:v.faded}}return R.set(y,H),H},W=document.createRange(),B=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),L=[],Y="";for(;B.nextNode();)L.push(B.currentNode),Y+=B.currentNode.nodeValue||"";let J=[],ot=ae(Y,G(e).lang),at=new Map,K=[e],Z=!1,bt=!1,Xt=!1,rt=!0,mt=!0,$t=0,Kt=0;for(let y of L){let H=y.nodeValue||"",V=$t;if($t+=H.length,!H.trim()){H&&(rt=mt=!0);continue}let v=y.parentElement;if(!v)continue;let{cs:x,lang:q,hidden:z,m:N,rest:D,unit:j,alpha:pt,faded:Lt}=G(v),Yt=x.textTransform;if(Yt=="capitalize")for(let m=y;m!=e;m=m.parentNode){let w=m.previousSibling;if(w){(w.nodeName=="BR"||w.nodeType==1&&Ht(getComputedStyle(w).display))&&(mt=!0);break}Ht(G(m.parentElement).cs.display)&&(mt=!0)}if(x.visibility==="hidden"||x.display==="none"||z){x.visibility==="hidden"&&!ht.hidden.includes(v)&&ht.hidden.push(v);continue}v!==e&&x.display!=="inline"&&Kt++,!K.includes(v)&&(v===e||v.closest("a, button")||x.color!==G(v.parentElement||e).cs.color)&&K.push(v),Lt&&!K.includes(Lt)&&K.push(Lt);let Re=x.fontVariantCaps==="small-caps"?"small-caps ":"";u.font=`${x.fontStyle} ${Re}${x.fontWeight} ${de(x.fontStretch)||""} ${x.fontSize} ${x.fontFamily}`,"fontVariantCaps"in u&&(u.fontVariantCaps=x.fontVariantCaps||"normal");let gt=x.direction==="rtl";u.direction=gt?"rtl":"ltr",u.fillStyle=x.color,u.globalAlpha=pt,"fontKerning"in u&&(u.fontKerning=x.fontKerning||"auto");let qt=u.measureText("Hg"),lt=qt.fontBoundingBoxAscent??I*.8,wt=qt.fontBoundingBoxDescent??I*.2,_t=(x.hyphenateCharacter||"auto").replace(/^auto$|["']/g,"")||"-",jt=(x.hyphens||x.webkitHyphens)==="auto",Pt=parseFloat(x.letterSpacing)||0,Ct=parseFloat(x.wordSpacing)||0,Qt=(m,w)=>{let p=u;"letterSpacing"in p&&(p.letterSpacing=`${m}px`,p.wordSpacing=`${w}px`)},yt=m=>u.measureText(m).width+Pt,Gt=(m,w)=>{let p;D?(p={x:D.x+D.adv,y:D.y,w:yt(m),h:D.h},D.adv+=p.w):(p=b(w,()=>yt(m),lt+wt),N&&(p=Nt(p,N)||p));let C=p.x+_,k=p.y+_,T=M(k+(p.h-(lt+wt))/2+lt);return u.fillText(m,C,T),Z=!0,Jt(C,p.w,T),{x:C,top:k,baseline:T,b:p}},Jt=(m,w,p)=>bt||=(Xt||=p-lt<-.5||p+wt>g+.5)||m<-.5||m+w>h+.5,Me=j?at.get(j)??at.set(j,at.size).size-1:void 0,Zt=(m,w,p,C,k,T)=>{let O=n?u.measureText(m.p):null,ut=O&&typeof O.actualBoundingBoxAscent=="number"?{l:w-O.actualBoundingBoxLeft,t:T-O.actualBoundingBoxAscent,r:w+O.actualBoundingBoxRight,b:T+O.actualBoundingBoxDescent}:void 0;J.push({x:w,y:p,w:C,h:k,wordStart:rt,ink:ut,rtl:gt,at:V+m.i,ca:m.s.length,unit:Me}),rt=!1},X=[];for(let{segment:m,index:w}of We(H)){let p=!m.trim(),C=Ot.test(m);X.push({i:w,s:m,p:p?m:He(m,Yt,mt&&C,q),sp:p}),(p||C)&&(mt=p)}let Et=(m,w)=>(W.setStart(y,X[m].i),W.setEnd(y,X[w-1].i+X[w-1].s.length),W.getClientRects()),Dt=(m,w)=>{Qt(0,0);let p;for(let C=m;C<w;C++){let k=X[C];if(ot[V+k.i]&&(rt=!0),k.sp){D&&(D.adv+=yt(k.s)+Ct),rt=!0,p=void 0;continue}let{rect:T,hyphen:O}=ct(Et(C,C+1));if(O)Gt(_t,O);else if(p&&T&&jt&&T.top>p.top+p.height/2&&!ot[V+k.i]&&Ot.test(k.s)&&Ot.test(X[C-1].s)&&!Fe.test(X[C-1].s+k.s)){let it=yt(_t)*f,U=p.left+p.width-(p.width-yt(X[C-1].p)*f>it/2?it:0);Gt(_t,{left:U,top:p.top,width:it,height:p.height})}if(p=O||gt?void 0:T,!D&&(!T||T.width<=0))continue;let{x:ut,top:xt,baseline:Tt,b:St}=Gt(k.p,T);Zt(k,ut,xt,St.w,St.h,Tt)}},Le=/^(normal|nowrap|pre-line)$/.test(x.whiteSpace||"normal"),_e=(m,w,p)=>{Qt(Pt,Ct);let C=X.slice(m,w).map((U,Q)=>Le&&U.sp?Q&&X[m+Q-1].sp?"":" ":U.p),k=C.join(""),T=b(p,()=>0,0);if(N&&(T=Nt(T,N)||T),Math.abs(u.measureText(k).width-T.w)>.5)return!1;let O=gt;if(w-m>1&&(gt||Ue.test(k))){let U=ct(Et(m,m+1)).rect,Q=ct(Et(w-1,w)).rect;if(!U||!Q)return!1;O=U.left>Q.left}let ut=T.y+_,xt=M(ut+(T.h-(lt+wt))/2+lt);u.fillText(k,T.x+_,xt),Z=!0,Jt(T.x+_,T.w,xt);let Tt=C.map(U=>U?u.measureText(U).width:0),St=T.w/(Tt.reduce((U,Q)=>U+Q,0)||1),it=T.x+_+(O?T.w:0);for(let U=m;U<w;U++){let Q=X[U],kt=Tt[U-m]*St;ot[V+Q.i]&&(rt=!0),O&&(it-=kt),Q.sp?rt=!0:Zt(Q,it,ut,kt,T.h,xt),O||(it+=kt)}return!0},Pe=!a&&!D&&(!N||!N[1]&&!N[2])&&("letterSpacing"in u||!Pt&&!Ct)&&!/none|no-/.test(x.fontVariantLigatures||"")&&!/["'](liga|clig|calt)["']\s+(0|off)/.test(x.fontFeatureSettings||"")&&!jt&&!x.textAlign.startsWith("justify")&&!H.includes("\xAD")?Ve(X,Et):null,It=0;for(let[m,w,p]of Pe||[])Dt(It,m),_e(m,w,p)||Dt(m,w),It=w;Dt(It,X.length)}if(W.detach?.(),!Z)return null;Kt>=8&&!he.has(e)&&(he.add(e),nt.info('data-gl="text" is split in the DOM: GL paints it at rest and its DOM units stay transparent. Animate with a glyph() effect; keep the DOM animation for when GL is off.',e));let Ae=n?ne(J,P.width/S,P.height/S):void 0;return{canvas:P,pad:_,layoutWidth:c,layoutHeight:A,colorEls:K,boxes:J,text:Y,glyphs:Ae,over:bt,down:Xt}}function Ve(e,t){let r=[];e.forEach((a,s)=>a.sp||r.push(s));let i=t(r[0],r[r.length-1]+1);if(i.length===1)return[[r[0],r[r.length-1]+1,i[0]]];let n=[];for(let a=0;a<r.length;){let s=ct(t(r[a],r[a]+1)).rect;if(!s||s.width<=0)return null;let o=a,l=r.length-1;for(;o<l;){let d=o+l+1>>1,c=ct(t(r[d],r[d]+1)).rect;c&&Math.abs(c.top-s.top)<s.height/2?o=d:l=d-1}let f=t(r[a],r[o]+1);if(f.length!==1)return null;n.push([r[a],r[o]+1,f[0]]),a=o+1}return n}var Xe=["lines","words","chars"],At=class{constructor(t,r,i){this.owner=t;this.level=r;this.index=i;this.text="";this.box={x:0,y:0,w:0,h:0};this.dead=!1}get slot(){return this.owner.base[this.level]+this.index}tween(t,r){let i=this,n=(this.mc||={})[t]||={get value(){return i[t]},set value(a){i[t]=a}};return this.owner.stage.tweens.to(n,r)}};["t","x","y","z"].forEach((e,t)=>Object.defineProperty(At.prototype,e,{get(){return this.dead?0:this.owner.values[this.slot*4+t]||0},set(r){this.dead||this.owner.write(this.slot*4+t,+r)}}));var vt=(e,t)=>Math.abs(e-t)<.01,pe=e=>e.replace(/\s+/g," ").trim(),ge={top:0,center:.5,middle:.5,bottom:1};function ye(e,t){return e.trim().replace(/^(top|center|middle|bottom|-?[\d.]+%|-?[\d.]+(?:px)?)(?=[\s+-]|$)/i,r=>{let i=r.toLowerCase(),n=i in ge?ge[i]*t.h:i.endsWith("%")?parseFloat(i)/100*t.h:parseFloat(i);return`${Math.round((t.y+n)*100)/100}px`})}var ft,$e=0,Rt=class{constructor(t,r){this.plane=t;this.stage=r;this.lines=[];this.words=[];this.chars=[];this.version=0;this.values=new Float32Array(0);this.base=[0,0,0];this.dirty=!1;this.changed=!1;this.rule=null}write(t,r){this.values[t]===r||t>=this.values.length||(this.values[t]=r,(this.plane.usesGlyph||this.plane._inst)&&(this.dirty=!0,this.stage.markDirty()))}update(t,r,i){let{lineOf:n,wordOf:a,lines:s,words:o}=Ft(t),l=[this.lines,this.words,this.chars],f=[s.length,o.length,t.length],d=l.some((h,g)=>h.length!==f[g]),c=[0,f[0],f[0]+f[1]],A=new Float32Array(4*(c[2]+f[2]));l.forEach((h,g)=>A.set(this.values.subarray(this.base[g]*4,(this.base[g]+Math.min(h.length,f[g]))*4),c[g]*4)),this.values=A,this.base=c;let E=new Int32Array(o.length).fill(-1),F=new Int32Array(o.length);for(let h=0;h<t.length;h++)E[a[h]]<0&&(E[a[h]]=h),F[a[h]]=h;let I=(h,g)=>r.slice(t[h].at??0,(t[g].at??0)+(t[g].ca??0)),_=(h,g,S,P,$,et,u)=>{let b=l[h],M=b[g]||=new At(this,h,g),R=M.box;return(M.text!==S||!vt(R.x,P-i)||!vt(R.y,$-i)||!vt(R.w,et)||!vt(R.h,u))&&(d=!0),M.text=S,R.x=P-i,R.y=$-i,R.w=et,R.h=u,M};return s.forEach((h,g)=>{let S=h.chars[0],P=h.chars[h.chars.length-1],$=_(0,g,pe(I(S,P)),h.l,h.t,h.r-h.l,h.b-h.t);$.chars=[S,P],$.words=[a[S],a[P]]}),o.forEach((h,g)=>{let S=_(1,g,pe(I(E[g],F[g])),h.l,h.t,h.r-h.l,h.b-h.t);S.chars=[E[g],F[g]],S.line=n[E[g]]}),t.forEach((h,g)=>{let S=_(2,g,I(g,g),h.x,h.y,h.w,h.h);S.line=n[g],S.word=a[g]}),l.forEach((h,g)=>{for(let S=f[g];S<h.length;S++)h[S].dead=!0;h.length=f[g]}),d&&(this.version++,this.changed=!0),d}progress(t,r={}){if(t!=="lines"&&t!=="words")return nt.warn(`plane.text.progress("${t}"): one per line or word only ("lines" or "words"); a character takes its word's (chars[i].word).`,this.plane.el),[];let i=this.stage.host.engine;return this[t].map(n=>i.progress(this.plane.el,{...r,start:ye(r.start||"top bottom",n.box),end:ye(r.end||"bottom top",n.box)}))}get countsGone(){return!!this.rule&&!this.rule.parentStyleSheet?.ownerNode?.isConnected}writeCounts(){let t=this.plane.el;if(ft?.ownerNode?.isConnected||(ft=document.head.appendChild(document.createElement("style")).sheet),this.rule?.parentStyleSheet!==ft){let r=t.getAttribute("data-gl-css");r||t.setAttribute("data-gl-css",r=`t${++$e}`),this.rule=ft.cssRules[ft.insertRule(`[data-gl-css="${r}"]{}`,ft.cssRules.length)]}for(let r of Xe)this.rule.style.setProperty(`--gl-${r}`,`${this[r].length}`)}dispose(){let t=this.rule,r=t?.parentStyleSheet;r&&!this.plane.el.isConnected&&r.deleteRule([...r.cssRules].indexOf(t)),this.rule=null}};var xe=()=>{let e=typeof window<"u"&&window.occluzeCapture;return e?.version==1?e:null},be=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(0)});var Ke=e=>xe()?be().then(e):"requestIdleCallback"in window?requestIdleCallback(e,{timeout:2e3}):setTimeout(e,200);function we(e){let t=!1,r=()=>{if(t=!1,e.destroyed||e.lost||e.stats.textureMB*2**21>e.textureBudget)return;let n=e.pageY+e.screen.height/2,a=null,s=1/0;for(let o of e.planes){if(o.kind!=="text"||o.textureState!=="none"||o.status==="error"||o._raster?.empty)continue;let l=o.measured?Math.abs(o.doc.y+o.doc.h/2-n):1e9+o.index;l<s&&(s=l,a=o)}a&&(e.loadMedia(a),i())},i=()=>{t||(t=!0,Ke(r))};return i}var Ee="its words or letters are animating: its DOM shows until they hold still (GL animates them with glyph())",Ye=150,Te=2e3,Se=e=>(e||"").replace(/--[\w-]+\s*:[^;]*;?/g,"").replace(/\s/g,""),ve=/opacity|transform|translate|rotate|scale|filter|clip|visibility/;function Vt(e){if(typeof e.getAnimations!="function")return!1;for(let t of e.getAnimations({subtree:!0})){let r=t.effect;if(!r||r.target===e||r.pseudoElement||t.playState!=="running"||r.getTiming?.().iterations===1/0||t.timeline&&typeof DocumentTimeline<"u"&&!(t.timeline instanceof DocumentTimeline))continue;let i=t.transitionProperty;if(i?ve.test(i):r.getKeyframes().some(n=>Object.keys(n).some(a=>ve.test(a))))return!0}return!1}var Mt=class{constructor(t){this.stage=t;this.changed=new WeakMap;this.ahead=we(t);for(let i of t.planes)i.kind=="text"&&this.units(i);let r=()=>{if(t.scrolled)return;let i=performance.now()+500,n=!1;for(let a of t.planes)a.kind=="text"&&a.soon&&a._raster&&(a._raster.colorUntil=i,n=!0);n&&t.request()};for(let i of["pointerover","pointerout"])t.listen(document,i,r)}blank(t){return{index:new st(t,"uint"),data:new st(t,"float")}}units(t){if(t.text)return;let r=new Rt(t,this.stage);Object.defineProperty(t,"text",{value:r,configurable:!0,enumerable:!0}),t._mods.list.push({name:"text",binding:{update:()=>this.frame(t,r),destroy:()=>r.dispose()}})}load(t){let r=this.stage;this.watch(t),this.units(t),t.textureState="loading";let i=()=>{t.textReason&&(t.textureState="none"),!(!r.planes.includes(t)||r.lost||t.status==="error")&&(this.rasterize(t)||(t.textureState="none"))},n=document.fonts;n?.status==="loading"?Promise.race([n.ready,new Promise(a=>setTimeout(a,1500))]).then(i):i(),this.ahead()}rasterize(t){let r=this.stage,i=t._raster||=new dt;if(t.status==="error")return!1;let n=d=>(d=`data-gl="text" stays normal DOM text: ${d}`,nt.once(d,t.el),i.textDirty=!1,t.textureState="error",t.setStatus("error",d),!1),a=fe(t.el);if(a)return n(`it uses ${a}, which GL text cannot paint. Remove data-gl="text" or that style.`);if(Vt(t.el))return this.hold(t),!1;let s=i.textCanvas||=document.createElement("canvas");s.isConnected||(s.setAttribute("data-gl-canvas","text"),s.style.display="none",r.hostEl.appendChild(s));let o=getComputedStyle(t.el);for(let d of["-webkit-font-smoothing","-moz-osx-font-smoothing"])s.style.setProperty(d,o.getPropertyValue(d));let l=me(t.el,r.dpr,r.maxTexture,s,t.usesGlyph,r.turnedText(t));if(!l)return!i.empty&&(t.textureState=="ready"||t.textureState=="queued")&&(s.width=1,r.media.queueUpload(t,s),t.text?.update([],"",0)),i.colorEls=[],i.colors=[],i.empty=!0,(i.hidden=o.visibility=="hidden")&&(t.opacity=0),i.unitsHidden=i.hidden?[]:ht.hidden,i.textDirty=!1,i.wantKey="",i.rasterKey=this.key(t),!1;if(l.over)return n(l.down?'its text runs past its box, down, and GL paints only the box. Let its height follow its lines (no fixed height), or put data-gl="text" on an element as tall as its text.':'its text runs past its box, and GL paints only the box. Let it wrap (overflow-wrap: anywhere), or put data-gl="text" on an element as wide as its text.');i.empty=i.hidden=!1,i.unitsHidden=ht.hidden,i.textCanvas=l.canvas,i.pending=!0,t.pad=l.pad,t.layoutW=l.layoutWidth,t.layoutH=l.layoutHeight,i.colorEls=l.colorEls.map(d=>getComputedStyle(d)),zt(i.colorEls,i.colors=[]),i.rasterKey=this.key(t),i.wantKey="",i.textDirty=!1,t.textureState=t.texture?.ready?"ready":"queued",t.usesGlyph&&(i.glyphPending=i.table=l.glyphs||null);let f=t.text;return f&&(f.update(l.boxes,l.text,l.pad),f.dirty||=!!i.table),r.media.queueUpload(t,l.canvas),r.markDirty(),!0}frame(t,r){r.changed?(r.changed=!1,r.writeCounts(),t.emit("text")):r.countsGone&&r.writeCounts();let i=t._raster,n=i?.table;return!r.dirty||!n?!1:(r.dirty=!1,n.data.set(r.values.subarray(0,(n.lines+n.words+n.chars)*4),n.values*4),i.glyphPending!==n&&i.glyphData?.ready&&i.glyphData.upload(n.dataWidth,n.dataHeight,n.data),!0)}key(t){let r=t.el,i=t._raster||=new dt;return(t.stale||i.wantKey||!i.size)&&(i.size=`${r.offsetWidth||Math.round(t.doc.w)}x${r.offsetHeight||Math.round(t.doc.h)}`),`${i.size}@${this.stage.dpr}`}check(t,r,i){let n=t._raster||=new dt,a=this.key(t);if(n.hidden&&t.opacity>0)return void this.rasterize(t);if(n.unitsHidden.length&&(t.stale||i||r<n.colorUntil)){for(let o of n.unitsHidden)if(getComputedStyle(o).visibility!=="hidden")return void this.rasterize(t)}if(n.textDirty&&!n.rasterKey){this.rasterize(t);return}if(!n.textDirty&&a===n.rasterKey)n.wantKey="";else{a!==n.wantKey&&(n.wantKey=a,n.wantSince=r),t.soon&&(a===n.rasterKey||r-n.wantSince>=150)&&r-(this.changed.get(t)||0)>=100&&this.rasterize(t);return}let s=i||t.stale||r<n.colorUntil;r<n.colorUntil&&this.stage.request(),t.soon&&s&&n.colorEls.length&&zt(n.colorEls,n.colors)&&(n.colorUntil=r+400,this.rasterize(t))}watch(t){let r=t._raster||=new dt;r.textObserver||(r.textObserver=new MutationObserver(i=>{let n=!1,a=!1,s=!1;for(let o of i)if(o.type!=="attributes")n=!0;else{if(o.target===t.el)continue;o.attributeName=="class"?s=!0:o.attributeName=="style"?a||=Se(o.oldValue)!==Se(o.target.getAttribute("style")):!o.attributeName.startsWith("data-gl")&&o.oldValue!==o.target.getAttribute(o.attributeName)&&(n=!0)}n&&(r.textDirty=!0,r.empty=!1,this.changed.set(t,performance.now()),t.stale=!0,this.stage.markDirty()),a||s&&Vt(t.el)?this.hold(t):s&&(r.colorUntil=performance.now()+400,this.stage.markDirty())}),r.textObserver.observe(t.el,{characterData:!0,childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0}))}hold(t){let r=t._raster;clearTimeout(r.quiet),r.quiet=setTimeout(()=>this.settle(t),Ye),!t.textReason&&(t.warned.add(Ee),t.textReason=Ee,this.stage.decide(t))}settle(t){let r=t._raster;if(!(!r||!this.stage.planes.includes(t))){if(r.quiet=0,Vt(t.el))return this.hold(t);t.texture&&(t.texture.ready=!1),r.textDirty=!0,this.changed.set(t,0),t.stale=!0,!t.program&&!this.stage.lost&&this.stage.programs.prepare(t),t.textReason=null,this.stage.decide(t),this.stage.markDirty()}}},dt=class{constructor(){this.textDirty=!0;this.empty=!1;this.hidden=!1;this.unitsHidden=[];this.rasterKey="";this.size="";this.colorEls=[];this.colors=[];this.colorUntil=0;this.wantKey="";this.wantSince=0;this.textCanvas=null;this.pending=!1;this.fresh=!1;this.freeTimer=0;this.textObserver=null;this.quiet=0;this.glyphPending=null;this.table=null;this.glyphIndex=null;this.glyphData=null;this.free=()=>{this.freeTimer=this.fresh||this.pending?setTimeout(this.free,Te):0,this.fresh=!1,!this.freeTimer&&this.textCanvas&&(this.textCanvas.width=1)}}upload(t){this.pending=!1,this.fresh=!0,this.freeTimer||=setTimeout(this.free,Te);let r=this.glyphPending;r&&(this.glyphPending=null,this.glyphIndex||=new st(t,"uint"),this.glyphData||=new st(t,"float"),this.glyphIndex.upload(r.width,r.height,r.index),this.glyphData.upload(r.dataWidth,r.dataHeight,r.data))}lost(){this.glyphIndex=this.glyphData=this.glyphPending=null}dispose(t){clearTimeout(this.quiet),clearTimeout(this.freeTimer),t?.textReason&&(t.textReason=null,t.el.removeAttribute("data-gl-status")),this.textCanvas?.remove(),this.textObserver?.disconnect(),this.textObserver=null,this.glyphIndex?.dispose(),this.glyphData?.dispose(),this.lost()}};function wn(e,t){te(e.host.log),e.text=new Mt(e),e.remake(e.glyphWaiting);let r=[...e.textWaiting];e.textWaiting.clear();for(let i of r)!e.planes.includes(i)||i.textureState!=="loading"||(i.textureState="none",e.loadMedia(i));t&&e.remake(new Set(e.planes.filter(i=>i.kind==="text"&&i.textureState==="error")))}export{Ge as GLYPH_HELPER,wn as textPlanes};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
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};
@@ -0,0 +1,36 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
2
+ "use strict";(()=>{var G="umber-debug-style",J=`
3
+ .umber-hud {
4
+ position: fixed; left: 8px; bottom: 8px; z-index: 2147483647;
5
+ width: 236px; max-width: calc(100vw - 16px); box-sizing: border-box;
6
+ padding: 8px 10px 9px; border-radius: 8px;
7
+ background: rgba(12, 12, 14, 0.86); color: #e8e8ea;
8
+ -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
9
+ box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 24px rgba(0,0,0,0.35);
10
+ font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
11
+ font-variant-numeric: tabular-nums; letter-spacing: 0; text-align: left;
12
+ pointer-events: auto; user-select: text;
13
+ }
14
+ .umber-hud[hidden] { display: none; }
15
+ .umber-hud * { box-sizing: border-box; margin: 0; padding: 0; font: inherit; color: inherit; }
16
+ .umber-hud__head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; color: #fff; cursor: pointer; }
17
+ .umber-hud__head span:last-child { color: #8a8a90; }
18
+ .umber-hud__row { display: flex; gap: 8px; white-space: nowrap; }
19
+ .umber-hud__row b { flex: 0 0 52px; font-weight: 400; color: #8a8a90; }
20
+ .umber-hud__row span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
21
+ .umber-hud canvas { display: block; width: 100%; height: 26px; margin: 3px 0 4px; }
22
+ .umber-hud.is-folded .umber-hud__body { display: none; }
23
+ .umber-hud.is-folded .umber-hud__head { margin-bottom: 0; }
24
+ .umber-outlines { position: fixed; inset: 0; z-index: 2147483646; pointer-events: none; overflow: hidden; }
25
+ .umber-outline { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-sizing: border-box; border: 1px solid var(--c); will-change: transform; }
26
+ .umber-outline[data-state="hidden"] { border-style: dashed; opacity: 0.5; }
27
+ .umber-clip { position: absolute; left: 0; top: 0; box-sizing: border-box; border: 1px dashed #c084fc; will-change: transform; }
28
+ .umber-outline span, .umber-marker span {
29
+ position: absolute; left: -1px; top: -17px; padding: 1px 5px; white-space: nowrap;
30
+ background: var(--c); color: #0c0c0e; font: 10px/15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
31
+ }
32
+ .umber-marker { position: absolute; left: 0; right: 0; top: 0; height: 0; border-top: 1px solid var(--c); will-change: transform; }
33
+ .umber-marker span { left: auto; right: 0; top: -16px; }
34
+ .umber-marker[data-edge] { right: auto; width: 0; border-top-style: dashed; }
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));})();
@@ -0,0 +1,36 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
2
+ var D="umber-debug-style",K=`
3
+ .umber-hud {
4
+ position: fixed; left: 8px; bottom: 8px; z-index: 2147483647;
5
+ width: 236px; max-width: calc(100vw - 16px); box-sizing: border-box;
6
+ padding: 8px 10px 9px; border-radius: 8px;
7
+ background: rgba(12, 12, 14, 0.86); color: #e8e8ea;
8
+ -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
9
+ box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 24px rgba(0,0,0,0.35);
10
+ font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
11
+ font-variant-numeric: tabular-nums; letter-spacing: 0; text-align: left;
12
+ pointer-events: auto; user-select: text;
13
+ }
14
+ .umber-hud[hidden] { display: none; }
15
+ .umber-hud * { box-sizing: border-box; margin: 0; padding: 0; font: inherit; color: inherit; }
16
+ .umber-hud__head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; color: #fff; cursor: pointer; }
17
+ .umber-hud__head span:last-child { color: #8a8a90; }
18
+ .umber-hud__row { display: flex; gap: 8px; white-space: nowrap; }
19
+ .umber-hud__row b { flex: 0 0 52px; font-weight: 400; color: #8a8a90; }
20
+ .umber-hud__row span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
21
+ .umber-hud canvas { display: block; width: 100%; height: 26px; margin: 3px 0 4px; }
22
+ .umber-hud.is-folded .umber-hud__body { display: none; }
23
+ .umber-hud.is-folded .umber-hud__head { margin-bottom: 0; }
24
+ .umber-outlines { position: fixed; inset: 0; z-index: 2147483646; pointer-events: none; overflow: hidden; }
25
+ .umber-outline { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-sizing: border-box; border: 1px solid var(--c); will-change: transform; }
26
+ .umber-outline[data-state="hidden"] { border-style: dashed; opacity: 0.5; }
27
+ .umber-clip { position: absolute; left: 0; top: 0; box-sizing: border-box; border: 1px dashed #c084fc; will-change: transform; }
28
+ .umber-outline span, .umber-marker span {
29
+ position: absolute; left: -1px; top: -17px; padding: 1px 5px; white-space: nowrap;
30
+ background: var(--c); color: #0c0c0e; font: 10px/15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
31
+ }
32
+ .umber-marker { position: absolute; left: 0; right: 0; top: 0; height: 0; border-top: 1px solid var(--c); will-change: transform; }
33
+ .umber-marker span { left: auto; right: 0; top: -16px; }
34
+ .umber-marker[data-edge] { right: auto; width: 0; border-top-style: dashed; }
35
+ .umber-marker[data-edge] span { left: auto; right: 0; top: 2px; }
36
+ `;function G(){if(document.getElementById(D))return;let e=document.createElement("style");e.id=D,e.textContent=K,document.head.appendChild(e)}function N(){document.getElementById(D)?.remove()}var y=(e,n=0)=>typeof e=="number"&&Number.isFinite(e)?e.toFixed(n):"-";function I(e){let n=String(e.state??"unknown");if(n==="dormant"&&e.planes===void 0)return[["gl","dormant (no [data-gl] yet, nothing loaded)"]];if(n.startsWith("off"))return[["gl",n]];let t=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",`${n} \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",t.length?[...new Set(t)].join(", "):"nothing (sleeping)"]]}function Q(e,n){G();let t=document.createElement("div");t.className="umber-hud",t.setAttribute("data-umber-hud",""),t.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"),h=document.createElement("span");c.textContent=`Umber ${e.version??"?"}`,h.textContent="ctrl \u21E7 H",r.append(c,h);let w=document.createElement("div");w.className="umber-hud__body";let b=document.createElement("div"),S=document.createElement("canvas"),k=document.createElement("div");w.append(b,S,k),t.append(r,w),document.body.appendChild(t),r.addEventListener("click",()=>t.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[U,F]=P.children;U.textContent!==x&&(U.textContent=x),F.textContent!==A&&(F.textContent=A)})}let v=new Float32Array(60),a=0,l=0,g=o=>{v[a]=o.dt*1e3,a=(a+1)%60,l<60&&l++},p=S.getContext("2d"),i=216,s=26,M=50,u=Math.min(globalThis.devicePixelRatio||1,2);S.width=i*u,S.height=s*u;function $(){if(!p)return;p.setTransform(u,0,0,u,0,0),p.clearRect(0,0,i,s),p.fillStyle="rgba(255,255,255,0.05)",p.fillRect(0,0,i,s);let o=i/60;for(let x=0;x<l;x++){let A=v[(a-l+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-l+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(i,f),p.stroke()}function _(){let o=0;for(let x=0;x<l;x++)o+=v[x];o=l?o/l:0,L(b,[["frame",l?`${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,n?[...I(f),...n.rows()]:I(f)),$()}let E=null,R;function O(){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(){t.hidden=!1,_(),O()},hide(){t.hidden=!0,C()},toggle(){t.hidden?m.show():m.hide()},destroy(){C(),removeEventListener("keydown",d),t.remove()}};return m.show(),m}var W={top:0,left:0,center:.5,middle:.5,bottom:1,right:1};function V(e){let n=/^(top|left|center|middle|bottom|right|-?\d*\.?\d+(?:px|%)?)?(?:([+-])=?(\d*\.?\d+)(px|%)?)?$/.exec(e);if(!n||!n[1]&&!n[2])return null;let t=0,r=0;if(n[1]&&n[1]in W)t=W[n[1]];else if(n[1]){let c=parseFloat(n[1]);n[1].endsWith("%")?t=c/100:r=c}if(n[2]){let c=parseFloat(n[3])*(n[2]==="-"?-1:1);n[4]==="%"?t+=c/100:r+=c}return[t,r]}function B(e,n){let t=(e||"").trim().toLowerCase();if(!t)return n;let r=V(t);return r?/^[+-]/.test(t)&&!/^-\d/.test(t)?[n[0]+r[0],n[1]+r[1]]:r:n}var Y={cover:"0110",contain:"11000011",entry:"01110100",exit:"00101110","entry-crossing":"0111","exit-crossing":"0010"};function J(e,n){let t=Y[e[0]],r=e[1]||(n?"100%":"0%"),c=r.endsWith("%")?0:parseFloat(r)||0,h=c?0:parseFloat(r)/100||0,w=b=>({el:+t[b]+(+t[b+2]-+t[b])*h,elPx:c,vp:+t[b+1]+(+t[b+3]-+t[b+1])*h,vpPx:0});return t?{...w(0),alt:t[4]?w(4):void 0}:null}function H(e,n){let t=(e||n).trim().split(/\s+/),r=J(t.map(k=>k.toLowerCase()),n.startsWith("bottom"));if(r)return r;let c=n.split(/\s+/),[h,w]=B(t[0],B(c[0],[0,0])),[b,S]=B(t[1],B(c[1],[0,0]));return{el:h,elPx:w,vp:b,vpPx:S}}var Z={ready:"#4ade80",loading:"#fbbf24",error:"#f87171"},ee="#60a5fa",X="#e879f9";function te(e){let n=[];for(let t of e.effects||[]){let r=t.options||{};typeof r.start!="string"||r.trigger==="manual"||r.trigger==="load"||n.push({label:`${t.name} start`,spec:r.start,fallback:"top 90%",color:ee})}if(e.scrub){let t=e.el,r=getComputedStyle(t),c=h=>t.getAttribute(`data-gl-scrub-${h}`)||r.getPropertyValue(`--gl-scrub-${h}`).trim()||"";n.push({label:"scrub start",spec:c("start"),fallback:"top bottom",color:X}),n.push({label:"scrub end",spec:c("end"),fallback:"bottom top",color:X})}return n}function q(e,n){G();let t=document.createElement("div");t.className="umber-outlines",t.setAttribute("data-umber-debug",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t);let r=new Map,c=new Map,h=new Map;function w(a){let l=r.get(a);if(!l){let g=document.createElement("div");g.className="umber-outline";let p=document.createElement("span");g.appendChild(p),t.appendChild(g),l={el:g,label:p,text:""},r.set(a,l)}return l}function b(a){let l=h.get(a);if(l)return l;l=[];for(let g of te(a)){let p=H(g.spec,g.fallback);for(let i of["screen","edge"]){let s=document.createElement("div");s.className="umber-marker",i==="edge"&&s.setAttribute("data-edge",""),s.style.setProperty("--c",g.color);let M=document.createElement("span");M.textContent=i==="screen"?g.label:g.label.replace(/ (start|end)$/," \xB7 $1 edge"),s.appendChild(M),t.appendChild(s),l.push({el:s,kind:i,at:i==="screen"?p.vp:p.el,px:i==="screen"?p.vpPx:p.elPx})}}return h.set(a,l),l}function S(a){let l=(a.clips?.list||[]).filter(s=>s.how!=="pruned"&&s.how!=="ignored"),g=c.get(a);for(g||c.set(a,g=[]);g.length<l.length;){let s=document.createElement("div");s.className="umber-clip",t.appendChild(s),g.push(s)}for(;g.length>l.length;)g.pop().remove();let p=a.doc.x-a.rect[0]-(a.pad?(a.rect[2]-a.doc.w)/2:0),i=a.doc.y-a.rect[1]-(a.pad?(a.rect[3]-a.doc.h)/2:0);l.forEach((s,M)=>{let u=s.bounds,$=Math.max(u[0]-p,-1e4),_=Math.max(u[1]-i,-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]-i,2e4)-_,1)}px`})}function k(a){r.get(a)?.el.remove(),r.delete(a);for(let l of c.get(a)||[])l.remove();c.delete(a);for(let l of h.get(a)||[])l.el.remove();h.delete(a)}function L(){let a=e.planes(),l=new Set(a);for(let i of[...r.keys(),...h.keys(),...c.keys()])l.has(i)||k(i);let g=innerHeight,p=innerWidth;for(let i of a){let s=i.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(n.outlines){let u=w(i);if(i.level&&!i.xfReason&&i.drawXf){let E=i.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(i.size[0],1)}px`,u.el.style.height=`${Math.max(i.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",Z[i.status]||"#a1a1aa"),u.el.dataset.state=M&&i.status==="ready"?"drawn":"hidden";let $=(i.effects||[]).map(E=>E.name).join(" "),_=`${i.kind}${$?` \xB7 ${$}`:""} \xB7 ${i.status}`;_!==u.text&&(u.label.textContent=u.text=_),(i.clips||c.has(i))&&S(i)}if(n.markers)for(let u of b(i)){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=i.inView||u.kind==="edge"?"":"none"}}}let v=e.on("frame",L,{phase:"render",order:1001,always:!1});return e.wake?.(1),{destroy(){v?.(),t.remove(),r.clear(),c.clear(),h.clear()}}}function j(e){return(e.effects||[]).map(t=>t.name).join("+")||(e.shader?`shader ${e.shader.name}`:e.kind)}function z(e){let n=new Map,t=[],r=-1,c=0,h=0,w=0,b=0,S=0,k=-1,L=new Uint8Array(4),v=null,a=null,l=[],g=new Map,p=null,i=()=>e.planes()[0]?.host,s=()=>e.context;function M(){let d=new Set;for(let m of e.planes()){let o=j(m),f=n.get(o);f||n.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 n.keys())d.has(m)||n.delete(m);t=[...n.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),l.push(a),a=null),!d||l.length>256))return;let o=n.get(j(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<l.length&&d.getQueryParameter(l[o].q,d.QUERY_RESULT_AVAILABLE);)o++;g.clear();for(let{q:f,g:x}of l.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=i();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=i(),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(h>0){h--;return}if(c===0&&r===-1&&M(),w+=o,++c<6)return;let f=w/6;if(w=0,c=0,r===-1)b=f;else{let x=t[r];u(x,!1),x&&(x.cpu=x.cpu*.6+Math.max(0,b-f)*.4)}r=r+1<t.length?r+1:-1,r===-1?h=24:u(t[r],!0)},O=e.on("frame",E,{phase:"render",order:-1e3}),C=e.on("frame",R,{phase:"render",order:999});return{rows(){let d=[...n.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(){O(),C();for(let m of n.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 l)d.deleteQuery(m);d&&a&&d.deleteQuery(a.q),l.length=0,a=null}}}function ne(){try{let e=new URLSearchParams(location.search).get("umber-debug");if(!e)return null;let n=new Set(e.split(/[\s,]+/).filter(Boolean));return{hud:n.has("hud")||n.has("cost"),outlines:n.has("outlines"),markers:n.has("markers"),cost:n.has("cost")}}catch{return null}}function re(e,n={}){let t={hud:!0,outlines:!1,markers:!1,cost:!1,...n,...ne()||{}},r=[],c=()=>{let b=t.cost?z(e):void 0;b&&r.push(b),(t.hud||b)&&r.push(Q(e,b)),(t.outlines||t.markers)&&r.push(q(e,{outlines:!!t.outlines,markers:!!t.markers}))};document.body?c():document.addEventListener("DOMContentLoaded",c,{once:!0});let h=!1,w=()=>{h||(h=!0,document.removeEventListener("DOMContentLoaded",c),r.forEach(b=>b.destroy()),N())};return e.on?.("destroy",w),w}var oe={name:"debug",version:"0.2.0",attributes:[],install(e,n){re(e,n)}},be=oe;export{oe as Debug,re as debug,be as default,ne as optionsFromUrl};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
2
+ "use strict";(()=>{function k(e=document.title){let t=document.querySelector("[data-gl-announcer]");t||(t=document.createElement("div"),t.setAttribute("data-gl-announcer",""),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),document.body.appendChild(t)),t.textContent="";let r=t;setTimeout(()=>r.textContent=e,60)}function P(e){let t=(typeof e=="string"?document.querySelector(e):e)||document.querySelector("h1")||document.querySelector("main");return t instanceof HTMLElement?(t.matches("a[href],button,input,select,textarea,[tabindex]")||t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}),document.activeElement===t):!1}var b="umber:handoff";function h(e,t=typeof location<"u"?location.href:void 0){try{let r=new URL(e,t);return r.hash="",r.href}catch{return""}}function _(e,t,r,n=()=>""){let o=[],a=new Set;for(let u of e){let d=u.el.getAttribute("data-gl-id"),[l,s,m,i]=Array.from(u.rect);if(!d||a.has(d)||u.kind!=="image"||u.status!=="ready"||!(m>0&&i>0&&l<t&&l+m>0&&s<r&&s+i>0))continue;let c=j(u.el);c&&(a.add(d),o.push({id:d,src:c,rect:[l,s,m,i],radius:n(u.el)}))}return o}function j(e){let t=e.getAttribute("data-gl-src"),r=e.matches("img")?e:e.querySelector("img"),n=t||r?.currentSrc||r?.getAttribute("src")||"";return n?h(n,e.ownerDocument?.baseURI):""}function I(e,t){try{return e.setItem(b,JSON.stringify(t)),!0}catch{return!1}}function N(e,t){let r=null;try{r=e.getItem(b),r!==null&&e.removeItem(b)}catch{return null}let n=null;try{n=r?JSON.parse(r):null}catch{return null}return J(n,t)?n:null}function J(e,t){let r=e;if(!r||typeof r!="object"||r.v!==1||!Array.isArray(r.items)||t.reload)return!1;let n=t.now-r.at;return!(n>=0&&n<=(t.maxAge??3e3))||!r.to||r.to!==h(t.url,t.url)?!1:(Math.abs(r.vw-t.vw)>1&&(r.items=[]),r.items=r.items.filter(o=>o&&typeof o.id=="string"&&typeof o.src=="string"&&Array.isArray(o.rect)&&o.rect.length===4),!0)}var R=e=>`[data-gl-id="${e.replace(/["\\]/g,"\\$&")}"]`,D=(e,t,r,n)=>[r?e/r:.5,n?t/n:.5];function M(e,t){if(e&&e.navigationType){if(e.navigationType!=="traverse")return 1;let r=e.from?.index,n=e.entry?.index;return typeof r=="number"&&typeof n=="number"&&n>r?1:-1}return t==="back_forward"?-1:1}var $={maxAge:3e3,vt:!0,cover:null,coverDuration:.8,coverEase:"umber",focus:"h1",announce:!1},q=new Set;function E(e,...t){q.has(e)||(q.add(e),console.warn("[umber]",e,...t))}function g(e,t,r,n,o){t&&(t.addEventListener(r,n,o),e.offs.push(()=>t.removeEventListener(r,n,o)))}var H=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,T=e=>e.canvas?.parentElement||document.querySelector("[data-gl-host]");var F=1500,X=.8;function Q(e,t=document){let r=[];for(let n of e){let o=t.querySelector(`${R(n.id)}[data-gl]`);if(!o||o.getAttribute("data-gl")!=="image")continue;let a=o.getBoundingClientRect();a.width>0&&a.height>0&&a.top<innerHeight&&a.bottom>0&&a.left<innerWidth&&a.right>0&&r.push({item:n,target:o})}return r}function Z(e){let t=[],r=[];for(let n of e){let o=document.querySelector(`${R(n.id)}[data-gl=image]`),a=o instanceof HTMLImageElement?o:o?.querySelector("img");a&&!a.complete&&!o.getBoundingClientRect().height&&(o.setAttribute("data-gl-waiting","image"),o.removeAttribute("data-gl"),t.push(o),r.push(a.decode().catch(()=>{})))}return[t,Promise.race([Promise.all(r),new Promise(n=>setTimeout(n,1e3))])]}function ee(e){let t=document.createElement("div"),[r,n,o,a]=e.rect;t.setAttribute("data-gl","image"),t.setAttribute("data-gl-id",e.id),t.setAttribute("data-gl-ghost",""),t.setAttribute("aria-hidden","true"),t.style.cssText=`left:${r}px;top:${n}px;width:${o}px;height:${a}px;border-radius:${e.radius||0}`;let u=document.createElement("img");return u.alt="",u.decoding="sync",u.src=e.src,t.appendChild(u),t}function U(e){return Q(e).map(({item:t,target:r})=>{let n=r.getAttribute("data-gl")||"image";r.setAttribute("data-gl-waiting",n),r.removeAttribute("data-gl");let o=ee(t);return document.body.appendChild(o),{item:t,target:r,ghost:o,kind:n}})}function y(e,t=!1){e.ghost.remove(),e.target.hasAttribute("data-gl")||e.target.setAttribute("data-gl",e.kind),t||e.target.removeAttribute("data-gl-waiting")}function te(e){return e?e.status==="ready"?Promise.resolve(!0):new Promise(t=>{let r=[e.on("ready",()=>o(!0)),e.on("error",()=>o(!1)),e.on("destroy",()=>o(!1))],n=setTimeout(()=>o(!1),F);function o(a){clearTimeout(n),r.forEach(u=>u()),t(a)}}):Promise.resolve(!1)}function ne(e){return new Promise(t=>{let r=0,n=()=>{performance.getEntriesByType?.("resource").some(a=>/chunks\/morph\.js/.test(a.name))||++r>30?e.nextFrame(()=>t()):e.nextFrame(n)};n()})}function re(e){let t=e.target.getBoundingClientRect(),r=getComputedStyle(e.target).borderRadius,n=e.ghost.animate?.([{},{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,borderRadius:r}],{duration:X*1e3,easing:"cubic-bezier(0.7, 0, 0.2, 1)",fill:"forwards"});if(!n)return void y(e);n.finished.then(()=>y(e),()=>y(e))}async function V(e){let t=e.arrived,{gl:r}=e;if(!t||!t.items.length||(document.documentElement.setAttribute("data-gl-handoff",""),H()))return w();e.direction<0&&document.readyState!=="complete"&&await new Promise(s=>{addEventListener("load",()=>s(),{once:!0}),setTimeout(s,1e3)});let[n,o]=Z(t.items),a=U(t.items);if(w(),n.length&&(await o,n.forEach(s=>(s.setAttribute("data-gl","image"),s.removeAttribute("data-gl-waiting"))),a.push(...U(t.items))),!a.length)return;if(!await r.ready||r.destroyed){a.forEach(re);return}await new Promise(s=>{r.nextFrame(()=>s(),{phase:"render"}),setTimeout(s,F)});let u=await Promise.all(a.map(s=>te(r.plane(s.ghost)))),d=a.filter((s,m)=>u[m]);if(a.filter((s,m)=>!u[m]).forEach(s=>y(s)),!d.length)return;if(await ne(r),r.destroyed)return void d.forEach(s=>y(s));let l=document.createElement("div");for(let s of d)l.appendChild(document.createElement("i")).setAttribute("data-gl-id",s.item.id);r.morph.capture(l);for(let s of d)y(s,!0);r.nextFrame(()=>r.nextFrame(()=>d.forEach(s=>s.target.removeAttribute("data-gl-waiting"))))}function w(){document.getElementById("umber-handoff")?.remove()}var oe=1500,x=new WeakMap;function O(e){x.get(e)?.el.remove(),x.delete(e)}function ie(e){return e.status==="ready"?Promise.resolve(!0):new Promise(t=>{let r=[e.on("ready",()=>o(!0)),e.on("error",()=>o(!1))],n=setTimeout(()=>o(!1),oe);function o(a){clearTimeout(n),r.forEach(u=>u()),t(a)}})}async function L(e,t,r={}){let{gl:n,options:o}=e,a=r.phase==="cover"?"cover":"reveal";if(H())return void(a==="reveal"&&O(e));let u=a==="cover"?0:1,d=1-u,l=r.duration??o.coverDuration,s=x.get(e);if(!s||s.shader!==t||!s.el.isConnected){O(e);let f=document.createElement("div");f.setAttribute("data-gl-cover",""),f.setAttribute("aria-hidden","true"),f.setAttribute("inert",""),f.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483000",u||(f.style.opacity="0"),document.body.appendChild(f),x.set(e,s={el:f,shader:t})}let m=s.el,i=n.destroyed?null:await n.add(m,{type:"shader",shader:t,order:1e4}),c=r.origin??e.origin,p=(f,v)=>i&&f in i.uniforms&&i.set(f,v);i&&!("uCover"in i.uniforms)&&E(`handoff: the cover shader "${t}" reads no uCover, so it cannot cover or reveal. Declare it: gl.shader("${t}", { uniforms: { uCover: 0, uOrigin: [0.5, 0.5], uDirection: 1 }, ... }).`),p("uCover",u),p("uOrigin",c?[c[0]/innerWidth,c[1]/innerHeight]:[.5,.5]),p("uDirection",r.direction??e.direction),i&&"uCover"in i.uniforms&&await ie(i)?(m.style.opacity="",await i.tween("uCover",{value:d,duration:l,ease:r.ease??o.coverEase})):await m.animate?.([{opacity:u},{opacity:d}],{duration:l*1e3,easing:"ease-in-out",fill:"forwards"}).finished.catch(()=>{}),a==="reveal"&&x.get(e)?.el===m&&O(e)}var B="::view-transition-group(umber-gl){animation:none}::view-transition-old(umber-gl),::view-transition-new(umber-gl){mix-blend-mode:normal}::view-transition-new(umber-gl){animation:none}",ae="[data-gl-waiting]:is(img,video),[data-gl-waiting] :is(img,video){opacity:0!important}[data-gl-ghost]{position:fixed;margin:0;padding:0;overflow:hidden;pointer-events:none;z-index:2}[data-gl-ghost] img{display:block;width:100%;height:100%;object-fit:cover}[data-gl-announcer]{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}"+B;function W(e=document){if(e.querySelector("style[data-gl-handoff-css]"))return;let t=e.createElement("style");t.setAttribute("data-gl-handoff-css",""),t.textContent=ae,(e.head||e.documentElement).appendChild(t)}var z=`<script>(function(w,d){try{var r=JSON.parse(sessionStorage.getItem("umber:handoff")),n=performance.getEntriesByType("navigation")[0],h=d.documentElement,s=d.createElement("style");s.id="umber-handoff";if(!r||!(Date.now()-r.at<3e3)||n&&n.type=="reload"||r.to!=location.href.split("#")[0])return;s.textContent=(r.items.length?r.items.map(function(i){var k='[data-gl-id="'+i.id.replace(/["\\\\]/g,"\\\\$&")+'"]';return k+':is(img,video),'+k+' :is(img,video)'}).join()+"{opacity:0!important}":"")+`+JSON.stringify(B)+';d.head.appendChild(s);setTimeout(function(){h.hasAttribute("data-gl-handoff")||s.remove()},1500);w.addEventListener("pagereveal",function(e){var v=w.__umberReveal=e.viewTransition||null,g=d.querySelector("[data-gl-host]");if(v&&r.over){if(!g){g=d.createElement("div");g.setAttribute("data-gl-host","");g.style.zIndex=1;(d.body||h).prepend(g)}g.style.viewTransitionName="umber-gl"}})}catch(e){}})(window,document)<\/script>';function K(e){let{gl:t,options:r}=e,n="",o=null,a=!1,u=null,d=!1,l=null;g(e,document,"click",i=>{let c=i.target?.closest?.("a[href]");if(!c||i.defaultPrevented||i.button>0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||c.target&&c.target!=="_self"||c.hasAttribute("download")||c.origin!==location.origin)return;n=h(c.href),u=i,a=i.detail===0;let p=i.clientX,f=i.clientY;if(a){let v=c.getBoundingClientRect();p=v.left+v.width/2,f=v.top+v.height/2}e.origin=[p,f],e.direction=1,o=D(p,f,innerWidth,innerHeight)},{capture:!0}),g(e,window,"click",i=>{i===u&&i.defaultPrevented&&(n="",o=null)});let s=window.navigation;g(e,s,"navigate",i=>{i.navigationType==="traverse"&&(e.direction=i.destination?.index<s.currentEntry?.index?-1:1),!i.destination?.sameDocument&&i.destination?.url&&(n=h(i.destination.url))}),s||g(e,window,"popstate",()=>e.direction=-1);let m=(i,c)=>{if(d||!i||i===h(location.href))return;let p=_(t.planes(),innerWidth,innerHeight,Y=>getComputedStyle(Y).borderRadius);if(!p.length&&!r.cover)return;let f=T(t),v=!!f&&!(Number(getComputedStyle(f).zIndex)<0),G={v:1,at:Date.now(),from:h(location.href),to:i,vw:innerWidth,vh:innerHeight,click:o,kb:a,over:v,items:p};d=I(sessionStorage,G),c&&r.vt&&f&&(v?(f.style.viewTransitionName="umber-gl",l=f):E('handoff: a View Transition lifts the canvas over the page only with layer "over"; this page draws GL under it, so it cross-fades with the page. gl.use(Handoff, { vt: false }) keeps it that way without this warning.'))};g(e,window,"pageswap",i=>{let c=i.activation;c&&c.navigationType==="reload"||m(c?.entry?.url?h(c.entry.url):n,i.viewTransition)}),g(e,window,"pagehide",()=>m(n,null)),g(e,window,"pageshow",i=>{if(i.persisted){if(l&&(l.style.viewTransitionName=""),l=null,d)try{sessionStorage.removeItem(b)}catch{}d=!1,n="",o=null}})}var C=()=>performance.getEntriesByType?.("navigation")[0]?.type;function se(e,t={}){let r=window,n={gl:e,options:{...$,...t},arrived:null,origin:null,direction:M(r.navigation?.activation,C()),viewTransition:r.__umberReveal||null,offs:[]};W(),K(n);let o=d=>{if(n.viewTransition=d,!d)return;let l=T(e);if(!l&&n.options.vt&&n.arrived?.over&&(l=document.createElement("div"),l.setAttribute("data-gl-host",""),l.style.zIndex="1",document.body.prepend(l)),!l||!n.options.vt||!n.arrived?.over)return;l.style.viewTransitionName="umber-gl";let s=l;d.finished.finally(()=>s.style.viewTransitionName="")};g(n,window,"pagereveal",d=>o(d.viewTransition||null));let a=()=>{n.direction=M(r.navigation?.activation,C()),n.arrived=N(sessionStorage,{url:location.href,now:Date.now(),reload:C()==="reload",vw:innerWidth,maxAge:n.options.maxAge}),n.viewTransition&&o(n.viewTransition);let d=n.arrived;if(!d)return w();d.click&&(n.origin=[d.click[0]*innerWidth,d.click[1]*innerHeight]);let l=n.options;l.announce&&k(),d.kb&&l.focus&&P(l.focus),l.cover&&L(n,l.cover,{phase:"reveal"}),V(n)};document.prerendering?g(n,document,"prerenderingchange",()=>queueMicrotask(a),{once:!0}):queueMicrotask(a);let u={get arrived(){return n.arrived},get origin(){return n.origin},get direction(){return n.direction},get viewTransition(){return n.viewTransition},options:n.options,cover:(d,l)=>L(n,d,l),announce:k,focus:P};return e.handoff=u,e.on("destroy",()=>{n.offs.splice(0).forEach(d=>d())}),u}var S={name:"handoff",version:"0.2.0",attributes:[],install(e,t){se(e,t)},headSnippet:z};var A=window;A.Umber?.use?A.Umber.use(S):((A.UmberModules||=[]).push(S),A.__umber?.engine?.use?.(S));})();