@cosmos.gl/graph 3.0.0-beta.5 → 3.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +14 -29
- package/dist/index.d.ts +19 -22
- package/dist/index.js +782 -549
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +158 -65
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Lines/conic-curve-module.d.ts +2 -0
- package/dist/modules/Lines/index.d.ts +10 -0
- package/dist/variables.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(de,Be){typeof exports=="object"&&typeof module<"u"?Be(exports):typeof define=="function"&&define.amd?define(["exports"],Be):(de=typeof globalThis<"u"?globalThis:de||self,Be(de.Cosmos={}))})(this,function(de){"use strict";var tb=Object.defineProperty;var nb=(de,Be,Ot)=>Be in de?tb(de,Be,{enumerable:!0,configurable:!0,writable:!0,value:Ot}):de[Be]=Ot;var g=(de,Be,Ot)=>nb(de,typeof Be!="symbol"?Be+"":Be,Ot);var Be="http://www.w3.org/1999/xhtml";const Ot={svg:"http://www.w3.org/2000/svg",xhtml:Be,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function li(n){var e=n+="",t=e.indexOf(":");return t>=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),Ot.hasOwnProperty(e)?{space:Ot[e],local:n}:n}function Vu(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Be&&e.documentElement.namespaceURI===Be?e.createElement(n):e.createElementNS(t,n)}}function Hu(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Lo(n){var e=li(n);return(e.local?Hu:Vu)(e)}function Wu(){}function Wr(n){return n==null?Wu:function(){return this.querySelector(n)}}function $u(n){typeof n!="function"&&(n=Wr(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=new Array(o),l,c,u=0;u<o;++u)(l=s[u])&&(c=n.call(l,l.__data__,u,s))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new qe(i,this._parents)}function Xu(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function Yu(){return[]}function Vo(n){return n==null?Yu:function(){return this.querySelectorAll(n)}}function qu(n){return function(){return Xu(n.apply(this,arguments))}}function ju(n){typeof n=="function"?n=qu(n):n=Vo(n);for(var e=this._groups,t=e.length,i=[],r=[],s=0;s<t;++s)for(var o=e[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(i.push(n.call(l,l.__data__,c,o)),r.push(l));return new qe(i,r)}function Ho(n){return function(){return this.matches(n)}}function Wo(n){return function(e){return e.matches(n)}}var Ku=Array.prototype.find;function Zu(n){return function(){return Ku.call(this.children,n)}}function Qu(){return this.firstElementChild}function Ju(n){return this.select(n==null?Qu:Zu(typeof n=="function"?n:Wo(n)))}var Gu=Array.prototype.filter;function ef(){return Array.from(this.children)}function tf(n){return function(){return Gu.call(this.children,n)}}function nf(n){return this.selectAll(n==null?ef:tf(typeof n=="function"?n:Wo(n)))}function rf(n){typeof n!="function"&&(n=Ho(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new qe(i,this._parents)}function $o(n){return new Array(n.length)}function sf(){return new qe(this._enter||this._groups.map($o),this._parents)}function ci(n,e){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=e}ci.prototype={constructor:ci,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,e){return this._parent.insertBefore(n,e)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function of(n){return function(){return n}}function af(n,e,t,i,r,s){for(var o=0,a,l=e.length,c=s.length;o<c;++o)(a=e[o])?(a.__data__=s[o],i[o]=a):t[o]=new ci(n,s[o]);for(;o<l;++o)(a=e[o])&&(r[o]=a)}function lf(n,e,t,i,r,s,o){var a,l,c=new Map,u=e.length,f=s.length,h=new Array(u),d;for(a=0;a<u;++a)(l=e[a])&&(h[a]=d=o.call(l,l.__data__,a,e)+"",c.has(d)?r[a]=l:c.set(d,l));for(a=0;a<f;++a)d=o.call(n,s[a],a,s)+"",(l=c.get(d))?(i[a]=l,l.__data__=s[a],c.delete(d)):t[a]=new ci(n,s[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(h[a])===l&&(r[a]=l)}function cf(n){return n.__data__}function uf(n,e){if(!arguments.length)return Array.from(this,cf);var t=e?lf:af,i=this._parents,r=this._groups;typeof n!="function"&&(n=of(n));for(var s=r.length,o=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var u=i[c],f=r[c],h=f.length,d=ff(n.call(u,u&&u.__data__,c,i)),_=d.length,I=a[c]=new Array(_),P=o[c]=new Array(_),A=l[c]=new Array(h);t(u,f,I,P,A,d,e);for(var O=0,E=0,y,R;O<_;++O)if(y=I[O]){for(O>=E&&(E=O+1);!(R=P[E])&&++E<_;);y._next=R||null}}return o=new qe(o,i),o._enter=a,o._exit=l,o}function ff(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function hf(){return new qe(this._exit||this._groups.map($o),this._parents)}function df(n,e,t){var i=this.enter(),r=this,s=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?s.remove():t(s),i&&r?i.merge(r).order():r}function pf(n){for(var e=n.selection?n.selection():n,t=this._groups,i=e._groups,r=t.length,s=i.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=i[l],f=c.length,h=a[l]=new Array(f),d,_=0;_<f;++_)(d=c[_]||u[_])&&(h[_]=d);for(;l<r;++l)a[l]=t[l];return new qe(a,this._parents)}function gf(){for(var n=this._groups,e=-1,t=n.length;++e<t;)for(var i=n[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function mf(n){n||(n=_f);function e(f,h){return f&&h?n(f.__data__,h.__data__):!f-!h}for(var t=this._groups,i=t.length,r=new Array(i),s=0;s<i;++s){for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new qe(r,this._parents).order()}function _f(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function yf(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function xf(){return Array.from(this)}function vf(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function bf(){let n=0;for(const e of this)++n;return n}function Sf(){return!this.node()}function Tf(n){for(var e=this._groups,t=0,i=e.length;t<i;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&n.call(a,a.__data__,s,r);return this}function wf(n){return function(){this.removeAttribute(n)}}function Af(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Cf(n,e){return function(){this.setAttribute(n,e)}}function If(n,e){return function(){this.setAttributeNS(n.space,n.local,e)}}function Pf(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(n):this.setAttribute(n,t)}}function Ef(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}function Rf(n,e){var t=li(n);if(arguments.length<2){var i=this.node();return t.local?i.getAttributeNS(t.space,t.local):i.getAttribute(t)}return this.each((e==null?t.local?Af:wf:typeof e=="function"?t.local?Ef:Pf:t.local?If:Cf)(t,e))}function Xo(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function kf(n){return function(){this.style.removeProperty(n)}}function Df(n,e,t){return function(){this.style.setProperty(n,e,t)}}function Mf(n,e,t){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,t)}}function Ff(n,e,t){return arguments.length>1?this.each((e==null?kf:typeof e=="function"?Mf:Df)(n,e,t??"")):tn(this.node(),n)}function tn(n,e){return n.style.getPropertyValue(e)||Xo(n).getComputedStyle(n,null).getPropertyValue(e)}function Nf(n){return function(){delete this[n]}}function Of(n,e){return function(){this[n]=e}}function Bf(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function Uf(n,e){return arguments.length>1?this.each((e==null?Nf:typeof e=="function"?Bf:Of)(n,e)):this.node()[n]}function Yo(n){return n.trim().split(/^|\s+/)}function $r(n){return n.classList||new qo(n)}function qo(n){this._node=n,this._names=Yo(n.getAttribute("class")||"")}qo.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function jo(n,e){for(var t=$r(n),i=-1,r=e.length;++i<r;)t.add(e[i])}function Ko(n,e){for(var t=$r(n),i=-1,r=e.length;++i<r;)t.remove(e[i])}function zf(n){return function(){jo(this,n)}}function Lf(n){return function(){Ko(this,n)}}function Vf(n,e){return function(){(e.apply(this,arguments)?jo:Ko)(this,n)}}function Hf(n,e){var t=Yo(n+"");if(arguments.length<2){for(var i=$r(this.node()),r=-1,s=t.length;++r<s;)if(!i.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?Vf:e?zf:Lf)(t,e))}function Wf(){this.textContent=""}function $f(n){return function(){this.textContent=n}}function Xf(n){return function(){var e=n.apply(this,arguments);this.textContent=e??""}}function Yf(n){return arguments.length?this.each(n==null?Wf:(typeof n=="function"?Xf:$f)(n)):this.node().textContent}function qf(){this.innerHTML=""}function jf(n){return function(){this.innerHTML=n}}function Kf(n){return function(){var e=n.apply(this,arguments);this.innerHTML=e??""}}function Zf(n){return arguments.length?this.each(n==null?qf:(typeof n=="function"?Kf:jf)(n)):this.node().innerHTML}function Qf(){this.nextSibling&&this.parentNode.appendChild(this)}function Jf(){return this.each(Qf)}function Gf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eh(){return this.each(Gf)}function th(n){var e=typeof n=="function"?n:Lo(n);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nh(){return null}function ih(n,e){var t=typeof n=="function"?n:Lo(n),i=e==null?nh:typeof e=="function"?e:Wr(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),i.apply(this,arguments)||null)})}function rh(){var n=this.parentNode;n&&n.removeChild(this)}function sh(){return this.each(rh)}function oh(){var n=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function ah(){var n=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function lh(n){return this.select(n?ah:oh)}function ch(n){return arguments.length?this.property("__data__",n):this.node().__data__}function uh(n){return function(e){n.call(this,e,this.__data__)}}function fh(n){return n.trim().split(/^|\s+/).map(function(e){var t="",i=e.indexOf(".");return i>=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function hh(n){return function(){var e=this.__on;if(e){for(var t=0,i=-1,r=e.length,s;t<r;++t)s=e[t],(!n.type||s.type===n.type)&&s.name===n.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function dh(n,e,t){return function(){var i=this.__on,r,s=uh(e);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=t),r.value=e;return}}this.addEventListener(n.type,s,t),r={type:n.type,name:n.name,value:e,listener:s,options:t},i?i.push(r):this.__on=[r]}}function ph(n,e,t){var i=fh(n+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(r=0,u=a[l];r<s;++r)if((o=i[r]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?dh:hh,r=0;r<s;++r)this.each(a(i[r],e,t));return this}function Zo(n,e,t){var i=Xo(n),r=i.CustomEvent;typeof r=="function"?r=new r(e,t):(r=i.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),n.dispatchEvent(r)}function gh(n,e){return function(){return Zo(this,n,e)}}function mh(n,e){return function(){return Zo(this,n,e.apply(this,arguments))}}function _h(n,e){return this.each((typeof e=="function"?mh:gh)(n,e))}function*yh(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Qo=[null];function qe(n,e){this._groups=n,this._parents=e}function In(){return new qe([[document.documentElement]],Qo)}function xh(){return this}qe.prototype=In.prototype={constructor:qe,select:$u,selectAll:ju,selectChild:Ju,selectChildren:nf,filter:rf,data:uf,enter:sf,exit:hf,join:df,merge:pf,selection:xh,order:gf,sort:mf,call:yf,nodes:xf,node:vf,size:bf,empty:Sf,each:Tf,attr:Rf,style:Ff,property:Uf,classed:Hf,text:Yf,html:Zf,raise:Jf,lower:eh,append:th,insert:ih,remove:sh,clone:lh,datum:ch,on:ph,dispatch:_h,[Symbol.iterator]:yh};function we(n){return typeof n=="string"?new qe([[document.querySelector(n)]],[document.documentElement]):new qe([[n]],Qo)}function vh(n){let e;for(;e=n.sourceEvent;)n=e;return n}function xt(n,e){if(n=vh(n),e===void 0&&(e=n.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var i=t.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[n.clientX-r.left-e.clientLeft,n.clientY-r.top-e.clientTop]}}return[n.pageX,n.pageY]}var bh={value:()=>{}};function ui(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new fi(t)}function fi(n){this._=n}function Sh(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}fi.prototype=ui.prototype={constructor:fi,on:function(n,e){var t=this._,i=Sh(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(n=i[s]).type)&&(r=Th(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(n=i[s]).type)t[r]=Jo(t[r],n.name,e);else if(e==null)for(r in t)t[r]=Jo(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new fi(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function Th(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function Jo(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=bh,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var nn=0,Pn=0,En=0,Go=1e3,hi,Rn,di=0,Bt=0,pi=0,kn=typeof performance=="object"&&performance.now?performance:Date,ea=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Xr(){return Bt||(ea(wh),Bt=kn.now()+pi)}function wh(){Bt=0}function gi(){this._call=this._time=this._next=null}gi.prototype=ta.prototype={constructor:gi,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Xr():+t)+(e==null?0:+e),!this._next&&Rn!==this&&(Rn?Rn._next=this:hi=this,Rn=this),this._call=n,this._time=t,Yr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yr())}};function ta(n,e,t){var i=new gi;return i.restart(n,e,t),i}function Ah(){Xr(),++nn;for(var n=hi,e;n;)(e=Bt-n._time)>=0&&n._call.call(null,e),n=n._next;--nn}function na(){Bt=(di=kn.now())+pi,nn=Pn=0;try{Ah()}finally{nn=0,Ih(),Bt=0}}function Ch(){var n=kn.now(),e=n-di;e>Go&&(pi-=e,di=n)}function Ih(){for(var n,e=hi,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:hi=t);Rn=n,Yr(i)}function Yr(n){if(!nn){Pn&&(Pn=clearTimeout(Pn));var e=n-Bt;e>24?(n<1/0&&(Pn=setTimeout(na,n-kn.now()-pi)),En&&(En=clearInterval(En))):(En||(di=kn.now(),En=setInterval(Ch,Go)),nn=1,ea(na))}}function ia(n,e,t){var i=new gi;return e=e==null?0:+e,i.restart(r=>{i.stop(),n(r+e)},e,t),i}var Ph=ui("start","end","cancel","interrupt"),Eh=[],ra=0,sa=1,qr=2,mi=3,oa=4,jr=5,_i=6;function yi(n,e,t,i,r,s){var o=n.__transition;if(!o)n.__transition={};else if(t in o)return;Rh(n,t,{name:e,index:i,group:r,on:Ph,tween:Eh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ra})}function Kr(n,e){var t=it(n,e);if(t.state>ra)throw new Error("too late; already scheduled");return t}function ft(n,e){var t=it(n,e);if(t.state>mi)throw new Error("too late; already running");return t}function it(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Rh(n,e,t){var i=n.__transition,r;i[e]=t,t.timer=ta(s,0,t.time);function s(c){t.state=sa,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,f,h,d;if(t.state!==sa)return l();for(u in i)if(d=i[u],d.name===t.name){if(d.state===mi)return ia(o);d.state===oa?(d.state=_i,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[u]):+u<e&&(d.state=_i,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[u])}if(ia(function(){t.state===mi&&(t.state=oa,t.timer.restart(a,t.delay,t.time),a(c))}),t.state=qr,t.on.call("start",n,n.__data__,t.index,t.group),t.state===qr){for(t.state=mi,r=new Array(h=t.tween.length),u=0,f=-1;u<h;++u)(d=t.tween[u].value.call(n,n.__data__,t.index,t.group))&&(r[++f]=d);r.length=f+1}}function a(c){for(var u=c<t.duration?t.ease.call(null,c/t.duration):(t.timer.restart(l),t.state=jr,1),f=-1,h=r.length;++f<h;)r[f].call(n,u);t.state===jr&&(t.on.call("end",n,n.__data__,t.index,t.group),l())}function l(){t.state=_i,t.timer.stop(),delete i[e];for(var c in i)return;delete n.__transition}}function xi(n,e){var t=n.__transition,i,r,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((i=t[o]).name!==e){s=!1;continue}r=i.state>qr&&i.state<jr,i.state=_i,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete t[o]}s&&delete n.__transition}}function kh(n){return this.each(function(){xi(this,n)})}function Zr(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function aa(n,e){var t=Object.create(n.prototype);for(var i in e)t[i]=e[i];return t}function Dn(){}var Mn=.7,vi=1/Mn,rn="\\s*([+-]?\\d+)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Dh=/^#([0-9a-f]{3,8})$/,Mh=new RegExp(`^rgb\\(${rn},${rn},${rn}\\)$`),Fh=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),Nh=new RegExp(`^rgba\\(${rn},${rn},${rn},${Fn}\\)$`),Oh=new RegExp(`^rgba\\(${ht},${ht},${ht},${Fn}\\)$`),Bh=new RegExp(`^hsl\\(${Fn},${ht},${ht}\\)$`),Uh=new RegExp(`^hsla\\(${Fn},${ht},${ht},${Fn}\\)$`),la={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Zr(Dn,kt,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:ca,formatHex:ca,formatHex8:zh,formatHsl:Lh,formatRgb:ua,toString:ua});function ca(){return this.rgb().formatHex()}function zh(){return this.rgb().formatHex8()}function Lh(){return ga(this).formatHsl()}function ua(){return this.rgb().formatRgb()}function kt(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=Dh.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?fa(e):t===3?new $e(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?bi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?bi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Mh.exec(n))?new $e(e[1],e[2],e[3],1):(e=Fh.exec(n))?new $e(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Nh.exec(n))?bi(e[1],e[2],e[3],e[4]):(e=Oh.exec(n))?bi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Bh.exec(n))?pa(e[1],e[2]/100,e[3]/100,1):(e=Uh.exec(n))?pa(e[1],e[2]/100,e[3]/100,e[4]):la.hasOwnProperty(n)?fa(la[n]):n==="transparent"?new $e(NaN,NaN,NaN,0):null}function fa(n){return new $e(n>>16&255,n>>8&255,n&255,1)}function bi(n,e,t,i){return i<=0&&(n=e=t=NaN),new $e(n,e,t,i)}function Vh(n){return n instanceof Dn||(n=kt(n)),n?(n=n.rgb(),new $e(n.r,n.g,n.b,n.opacity)):new $e}function Qr(n,e,t,i){return arguments.length===1?Vh(n):new $e(n,e,t,i??1)}function $e(n,e,t,i){this.r=+n,this.g=+e,this.b=+t,this.opacity=+i}Zr($e,Qr,aa(Dn,{brighter(n){return n=n==null?vi:Math.pow(vi,n),new $e(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Mn:Math.pow(Mn,n),new $e(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new $e(Ut(this.r),Ut(this.g),Ut(this.b),Si(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ha,formatHex:ha,formatHex8:Hh,formatRgb:da,toString:da}));function ha(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function Hh(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function da(){const n=Si(this.opacity);return`${n===1?"rgb(":"rgba("}${Ut(this.r)}, ${Ut(this.g)}, ${Ut(this.b)}${n===1?")":`, ${n})`}`}function Si(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Ut(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function zt(n){return n=Ut(n),(n<16?"0":"")+n.toString(16)}function pa(n,e,t,i){return i<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new rt(n,e,t,i)}function ga(n){if(n instanceof rt)return new rt(n.h,n.s,n.l,n.opacity);if(n instanceof Dn||(n=kt(n)),!n)return new rt;if(n instanceof rt)return n;n=n.rgb();var e=n.r/255,t=n.g/255,i=n.b/255,r=Math.min(e,t,i),s=Math.max(e,t,i),o=NaN,a=s-r,l=(s+r)/2;return a?(e===s?o=(t-i)/a+(t<i)*6:t===s?o=(i-e)/a+2:o=(e-t)/a+4,a/=l<.5?s+r:2-s-r,o*=60):a=l>0&&l<1?0:o,new rt(o,a,l,n.opacity)}function Wh(n,e,t,i){return arguments.length===1?ga(n):new rt(n,e,t,i??1)}function rt(n,e,t,i){this.h=+n,this.s=+e,this.l=+t,this.opacity=+i}Zr(rt,Wh,aa(Dn,{brighter(n){return n=n==null?vi:Math.pow(vi,n),new rt(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Mn:Math.pow(Mn,n),new rt(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,r=2*t-i;return new $e(Jr(n>=240?n-240:n+120,r,i),Jr(n,r,i),Jr(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new rt(ma(this.h),Ti(this.s),Ti(this.l),Si(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Si(this.opacity);return`${n===1?"hsl(":"hsla("}${ma(this.h)}, ${Ti(this.s)*100}%, ${Ti(this.l)*100}%${n===1?")":`, ${n})`}`}}));function ma(n){return n=(n||0)%360,n<0?n+360:n}function Ti(n){return Math.max(0,Math.min(1,n||0))}function Jr(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const Gr=n=>()=>n;function $h(n,e){return function(t){return n+t*e}}function Xh(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(i){return Math.pow(n+i*e,t)}}function Yh(n){return(n=+n)==1?_a:function(e,t){return t-e?Xh(e,t,n):Gr(isNaN(e)?t:e)}}function _a(n,e){var t=e-n;return t?$h(n,t):Gr(isNaN(n)?e:n)}const wi=function n(e){var t=Yh(e);function i(r,s){var o=t((r=Qr(r)).r,(s=Qr(s)).r),a=t(r.g,s.g),l=t(r.b,s.b),c=_a(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=l(u),r.opacity=c(u),r+""}}return i.gamma=n,i}(1);function qh(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,i=e.slice(),r;return function(s){for(r=0;r<t;++r)i[r]=n[r]*(1-s)+e[r]*s;return i}}function jh(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Kh(n,e){var t=e?e.length:0,i=n?Math.min(t,n.length):0,r=new Array(i),s=new Array(t),o;for(o=0;o<i;++o)r[o]=ns(n[o],e[o]);for(;o<t;++o)s[o]=e[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function Zh(n,e){var t=new Date;return n=+n,e=+e,function(i){return t.setTime(n*(1-i)+e*i),t}}function st(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function Qh(n,e){var t={},i={},r;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in n?t[r]=ns(n[r],e[r]):i[r]=e[r];return function(s){for(r in t)i[r]=t[r](s);return i}}var es=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ts=new RegExp(es.source,"g");function Jh(n){return function(){return n}}function Gh(n){return function(e){return n(e)+""}}function ya(n,e){var t=es.lastIndex=ts.lastIndex=0,i,r,s,o=-1,a=[],l=[];for(n=n+"",e=e+"";(i=es.exec(n))&&(r=ts.exec(e));)(s=r.index)>t&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:st(i,r)})),t=ts.lastIndex;return t<e.length&&(s=e.slice(t),a[o]?a[o]+=s:a[++o]=s),a.length<2?l[0]?Gh(l[0].x):Jh(e):(e=l.length,function(c){for(var u=0,f;u<e;++u)a[(f=l[u]).i]=f.x(c);return a.join("")})}function ns(n,e){var t=typeof e,i;return e==null||t==="boolean"?Gr(e):(t==="number"?st:t==="string"?(i=kt(e))?(e=i,wi):ya:e instanceof kt?wi:e instanceof Date?Zh:jh(e)?qh:Array.isArray(e)?Kh:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Qh:st)(n,e)}function ed(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}var xa=180/Math.PI,is={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function va(n,e,t,i,r,s){var o,a,l;return(o=Math.sqrt(n*n+e*e))&&(n/=o,e/=o),(l=n*t+e*i)&&(t-=n*l,i-=e*l),(a=Math.sqrt(t*t+i*i))&&(t/=a,i/=a,l/=a),n*i<e*t&&(n=-n,e=-e,l=-l,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,n)*xa,skewX:Math.atan(l)*xa,scaleX:o,scaleY:a}}var Ai;function td(n){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return e.isIdentity?is:va(e.a,e.b,e.c,e.d,e.e,e.f)}function nd(n){return n==null||(Ai||(Ai=document.createElementNS("http://www.w3.org/2000/svg","g")),Ai.setAttribute("transform",n),!(n=Ai.transform.baseVal.consolidate()))?is:(n=n.matrix,va(n.a,n.b,n.c,n.d,n.e,n.f))}function ba(n,e,t,i){function r(c){return c.length?c.pop()+" ":""}function s(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push("translate(",null,e,null,t);_.push({i:I-4,x:st(c,f)},{i:I-2,x:st(u,h)})}else(f||h)&&d.push("translate("+f+e+h+t)}function o(c,u,f,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:st(c,u)})):u&&f.push(r(f)+"rotate("+u+i)}function a(c,u,f,h){c!==u?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:st(c,u)}):u&&f.push(r(f)+"skewX("+u+i)}function l(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push(r(d)+"scale(",null,",",null,")");_.push({i:I-4,x:st(c,f)},{i:I-2,x:st(u,h)})}else(f!==1||h!==1)&&d.push(r(d)+"scale("+f+","+h+")")}return function(c,u){var f=[],h=[];return c=n(c),u=n(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,h),o(c.rotate,u.rotate,f,h),a(c.skewX,u.skewX,f,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,h),c=u=null,function(d){for(var _=-1,I=h.length,P;++_<I;)f[(P=h[_]).i]=P.x(d);return f.join("")}}}var id=ba(td,"px, ","px)","deg)"),rd=ba(nd,", ",")",")"),sd=1e-12;function Sa(n){return((n=Math.exp(n))+1/n)/2}function od(n){return((n=Math.exp(n))-1/n)/2}function ad(n){return((n=Math.exp(2*n))-1)/(n+1)}const ld=function n(e,t,i){function r(s,o){var a=s[0],l=s[1],c=s[2],u=o[0],f=o[1],h=o[2],d=u-a,_=f-l,I=d*d+_*_,P,A;if(I<sd)A=Math.log(h/c)/e,P=function(U){return[a+U*d,l+U*_,c*Math.exp(e*U*A)]};else{var O=Math.sqrt(I),E=(h*h-c*c+i*I)/(2*c*t*O),y=(h*h-c*c-i*I)/(2*h*t*O),R=Math.log(Math.sqrt(E*E+1)-E),N=Math.log(Math.sqrt(y*y+1)-y);A=(N-R)/e,P=function(U){var W=U*A,q=Sa(R),G=c/(t*O)*(q*ad(e*W+R)-od(R));return[a+G*d,l+G*_,c*q/Sa(e*W+R)]}}return P.duration=A*1e3*e/Math.SQRT2,P}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,l=a*a;return n(o,a,l)},r}(Math.SQRT2,2,4);function cd(n,e){var t,i;return function(){var r=ft(this,n),s=r.tween;if(s!==t){i=t=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function ud(n,e,t){var i,r;if(typeof t!="function")throw new Error;return function(){var s=ft(this,n),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:e,value:t},l=0,c=r.length;l<c;++l)if(r[l].name===e){r[l]=a;break}l===c&&r.push(a)}s.tween=r}}function fd(n,e){var t=this._id;if(n+="",arguments.length<2){for(var i=it(this.node(),t).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===n)return o.value;return null}return this.each((e==null?cd:ud)(t,n,e))}function rs(n,e,t){var i=n._id;return n.each(function(){var r=ft(this,i);(r.value||(r.value={}))[e]=t.apply(this,arguments)}),function(r){return it(r,i).value[e]}}function Ta(n,e){var t;return(typeof e=="number"?st:e instanceof kt?wi:(t=kt(e))?(e=t,wi):ya)(n,e)}function hd(n){return function(){this.removeAttribute(n)}}function dd(n){return function(){this.removeAttributeNS(n.space,n.local)}}function pd(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttribute(n);return o===r?null:o===i?s:s=e(i=o,t)}}function gd(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttributeNS(n.space,n.local);return o===r?null:o===i?s:s=e(i=o,t)}}function md(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(n):(o=this.getAttribute(n),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function _d(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(n.space,n.local):(o=this.getAttributeNS(n.space,n.local),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function yd(n,e){var t=li(n),i=t==="transform"?rd:Ta;return this.attrTween(n,typeof e=="function"?(t.local?_d:md)(t,i,rs(this,"attr."+n,e)):e==null?(t.local?dd:hd)(t):(t.local?gd:pd)(t,i,e))}function xd(n,e){return function(t){this.setAttribute(n,e.call(this,t))}}function vd(n,e){return function(t){this.setAttributeNS(n.space,n.local,e.call(this,t))}}function bd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&vd(n,s)),t}return r._value=e,r}function Sd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&xd(n,s)),t}return r._value=e,r}function Td(n,e){var t="attr."+n;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var i=li(n);return this.tween(t,(i.local?bd:Sd)(i,e))}function wd(n,e){return function(){Kr(this,n).delay=+e.apply(this,arguments)}}function Ad(n,e){return e=+e,function(){Kr(this,n).delay=e}}function Cd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?wd:Ad)(e,n)):it(this.node(),e).delay}function Id(n,e){return function(){ft(this,n).duration=+e.apply(this,arguments)}}function Pd(n,e){return e=+e,function(){ft(this,n).duration=e}}function Ed(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?Id:Pd)(e,n)):it(this.node(),e).duration}function Rd(n,e){if(typeof e!="function")throw new Error;return function(){ft(this,n).ease=e}}function kd(n){var e=this._id;return arguments.length?this.each(Rd(e,n)):it(this.node(),e).ease}function Dd(n,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;ft(this,n).ease=t}}function Md(n){if(typeof n!="function")throw new Error;return this.each(Dd(this._id,n))}function Fd(n){typeof n!="function"&&(n=Ho(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new vt(i,this._parents,this._name,this._id)}function Nd(n){if(n._id!==this._id)throw new Error;for(var e=this._groups,t=n._groups,i=e.length,r=t.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var l=e[a],c=t[a],u=l.length,f=o[a]=new Array(u),h,d=0;d<u;++d)(h=l[d]||c[d])&&(f[d]=h);for(;a<i;++a)o[a]=e[a];return new vt(o,this._parents,this._name,this._id)}function Od(n){return(n+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Bd(n,e,t){var i,r,s=Od(e)?Kr:ft;return function(){var o=s(this,n),a=o.on;a!==i&&(r=(i=a).copy()).on(e,t),o.on=r}}function Ud(n,e){var t=this._id;return arguments.length<2?it(this.node(),t).on.on(n):this.each(Bd(t,n,e))}function zd(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Ld(){return this.on("end.remove",zd(this._id))}function Vd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=Wr(n));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],l=a.length,c=s[o]=new Array(l),u,f,h=0;h<l;++h)(u=a[h])&&(f=n.call(u,u.__data__,h,a))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,yi(c[h],e,t,h,c,it(u,t)));return new vt(s,this._parents,e,t)}function Hd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=Vo(n));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var l=i[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var h=n.call(u,u.__data__,f,l),d,_=it(u,t),I=0,P=h.length;I<P;++I)(d=h[I])&&yi(d,e,t,I,h,_);s.push(h),o.push(u)}return new vt(s,o,e,t)}var Wd=In.prototype.constructor;function $d(){return new Wd(this._groups,this._parents)}function Xd(n,e){var t,i,r;return function(){var s=tn(this,n),o=(this.style.removeProperty(n),tn(this,n));return s===o?null:s===t&&o===i?r:r=e(t=s,i=o)}}function wa(n){return function(){this.style.removeProperty(n)}}function Yd(n,e,t){var i,r=t+"",s;return function(){var o=tn(this,n);return o===r?null:o===i?s:s=e(i=o,t)}}function qd(n,e,t){var i,r,s;return function(){var o=tn(this,n),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(n),tn(this,n))),o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a))}}function jd(n,e){var t,i,r,s="style."+e,o="end."+s,a;return function(){var l=ft(this,n),c=l.on,u=l.value[s]==null?a||(a=wa(e)):void 0;(c!==t||r!==u)&&(i=(t=c).copy()).on(o,r=u),l.on=i}}function Kd(n,e,t){var i=(n+="")=="transform"?id:Ta;return e==null?this.styleTween(n,Xd(n,i)).on("end.style."+n,wa(n)):typeof e=="function"?this.styleTween(n,qd(n,i,rs(this,"style."+n,e))).each(jd(this._id,n)):this.styleTween(n,Yd(n,i,e),t).on("end.style."+n,null)}function Zd(n,e,t){return function(i){this.style.setProperty(n,e.call(this,i),t)}}function Qd(n,e,t){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&Zd(n,o,t)),i}return s._value=e,s}function Jd(n,e,t){var i="style."+(n+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,Qd(n,e,t??""))}function Gd(n){return function(){this.textContent=n}}function ep(n){return function(){var e=n(this);this.textContent=e??""}}function tp(n){return this.tween("text",typeof n=="function"?ep(rs(this,"text",n)):Gd(n==null?"":n+""))}function np(n){return function(e){this.textContent=n.call(this,e)}}function ip(n){var e,t;function i(){var r=n.apply(this,arguments);return r!==t&&(e=(t=r)&&np(r)),e}return i._value=n,i}function rp(n){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(n==null)return this.tween(e,null);if(typeof n!="function")throw new Error;return this.tween(e,ip(n))}function sp(){for(var n=this._name,e=this._id,t=Aa(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=it(l,e);yi(l,n,t,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new vt(i,this._parents,n,t)}function op(){var n,e,t=this,i=t._id,r=t.size();return new Promise(function(s,o){var a={value:o},l={value:function(){--r===0&&s()}};t.each(function(){var c=ft(this,i),u=c.on;u!==n&&(e=(n=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),r===0&&s()})}var ap=0;function vt(n,e,t,i){this._groups=n,this._parents=e,this._name=t,this._id=i}function Aa(){return++ap}var bt=In.prototype;vt.prototype={constructor:vt,select:Vd,selectAll:Hd,selectChild:bt.selectChild,selectChildren:bt.selectChildren,filter:Fd,merge:Nd,selection:$d,transition:sp,call:bt.call,nodes:bt.nodes,node:bt.node,size:bt.size,empty:bt.empty,each:bt.each,on:Ud,attr:yd,attrTween:Td,style:Kd,styleTween:Jd,text:tp,textTween:rp,remove:Ld,tween:fd,delay:Cd,duration:Ed,ease:kd,easeVarying:Md,end:op,[Symbol.iterator]:bt[Symbol.iterator]};function lp(n){return n*n}function cp(n){return n*(2-n)}function up(n){return((n*=2)<=1?n*n:--n*(2-n)+1)/2}function fp(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var hp={time:null,delay:0,duration:250,ease:fp};function dp(n,e){for(var t;!(t=n.__transition)||!(t=t[e]);)if(!(n=n.parentNode))throw new Error(`transition ${e} not found`);return t}function pp(n){var e,t;n instanceof vt?(e=n._id,n=n._name):(e=Aa(),(t=hp).time=Xr(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&yi(l,n,e,c,o,t||dp(l,e));return new vt(i,this._parents,n,e)}In.prototype.interrupt=kh,In.prototype.transition=pp;function Ca(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}class Ia{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Ca(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ca()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class gp{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:i}=e;let r=this.stats[t];return r||(e instanceof Ia?r=e:r=new Ia(t,i),this.stats[t]=r),r}}class mp{constructor(){g(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new gp({id:e})),this.stats.get(e)}}const Pa=new mp,Ci=globalThis,sn=globalThis.process||{},_p=globalThis.navigator||{};function Ea(n){var i,r;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((r=process.versions)!=null&&r.electron))return!0;const t=typeof navigator<"u"&&navigator.userAgent;return!!(t&&t.indexOf("Electron")>=0)}function Lt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||Ea()}function yp(n){return Lt()?Ea()?"Electron":(_p.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const Ra="4.1.0";function xp(n){try{const e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class vp{constructor(e,t,i="sessionStorage"){this.storage=xp(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function bp(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Sp(n,e=8){const t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Ii;(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ii||(Ii={}));const Tp=10;function ka(n){return typeof n!="string"?n:(n=n.toUpperCase(),Ii[n]||Ii.WHITE)}function wp(n,e,t){return!Lt&&typeof n=="string"&&(e&&(n=`\x1B[${ka(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${ka(t)+Tp}m${n}\x1B[49m`)),n}function Ap(n,e=["constructor"]){const t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(const s of i){const o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}function ss(n,e){if(!n)throw new Error("Assertion failed")}function on(){var e,t,i;let n;if(Lt()&&Ci.performance)n=(t=(e=Ci==null?void 0:Ci.performance)==null?void 0:e.now)==null?void 0:t.call(e);else if("hrtime"in sn){const r=(i=sn==null?void 0:sn.hrtime)==null?void 0:i.call(sn);n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}const an={debug:Lt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Cp={enabled:!0,level:0};function ln(){}const Da={},Ma={once:!0};class Fa{constructor({id:e}={id:""}){this.VERSION=Ra,this._startTs=on(),this._deltaTs=on(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new vp(`__probe-${this.id}__`,Cp),this.timeStamp(`${this.id} started`),Ap(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((on()-this._startTs).toPrecision(10))}getDelta(){return Number((on()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,an.warn,arguments,Ma)}error(e){return this._getLogFunction(0,e,an.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,an.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,an.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,an.debug||an.info,arguments,Ma)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||ln,i&&[i],{tag:Pp(t)}):ln}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||ln)}group(e,t,i={collapsed:!1}){const r=Oa({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return r.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||ln)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Na(e)}_getLogFunction(e,t,i,r,s){if(this._shouldLog(e)){s=Oa({logLevel:e,message:t,args:r,opts:s}),i=i||s.method,ss(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=on();const o=s.tag||s.message;if(s.once&&o)if(!Da[o])Da[o]=on();else return ln;return t=Ip(this.id,s.message,s),i.bind(console,t,...s.args)}return ln}}Fa.VERSION=Ra;function Na(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return ss(Number.isFinite(e)&&e>=0),e}function Oa(n){const{logLevel:e,message:t}=n;n.logLevel=Na(e);const i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break}typeof n.message=="function"&&(n.message=n.message());const r=typeof n.message;return ss(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}function Ip(n,e,t){if(typeof e=="string"){const i=t.time?Sp(bp(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=wp(e,t.color,t.background)}return e}function Pp(n){for(const e in n)for(const t in n[e])return t||"untitled";return"empty"}const D=new Fa({id:"luma.gl"}),os={};function Pi(n="id"){os[n]=os[n]||1;const e=os[n]++;return`${n}-${e}`}class le{constructor(e,t,i){g(this,"id");g(this,"props");g(this,"userData",{});g(this,"_device");g(this,"destroyed",!1);g(this,"allocatedBytes",0);g(this,"_attachedResources",new Set);if(!e)throw new Error("no device");this._device=e,this.props=Ep(t,i);const r=this.props.id!=="undefined"?this.props.id:Pi(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}g(le,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Ep(n,e){const t={...e};for(const i in n)n[i]!==void 0&&(t[i]=n[i]);return t}const ke=class ke extends le{constructor(t,i){const r={...i};(i.usage||0)&ke.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?r.indexType="uint32":i.data instanceof Uint16Array?r.indexType="uint16":i.data instanceof Uint8Array&&(r.indexType="uint8")),delete r.data;super(t,r,ke.defaultProps);g(this,"usage");g(this,"indexType");g(this,"updateTimestamp");g(this,"debugData",new ArrayBuffer(0));this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(t){return this.device.createBuffer({...this.props,...t})}_setDebugData(t,i,r){const s=ArrayBuffer.isView(t)?t.buffer:t,o=Math.min(t?t.byteLength:r,ke.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):i===0&&r===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(i,i+o)}};g(ke,"INDEX",16),g(ke,"VERTEX",32),g(ke,"UNIFORM",64),g(ke,"STORAGE",128),g(ke,"INDIRECT",256),g(ke,"QUERY_RESOLVE",512),g(ke,"MAP_READ",1),g(ke,"MAP_WRITE",2),g(ke,"COPY_SRC",4),g(ke,"COPY_DST",8),g(ke,"DEBUG_DATA_MAX_LENGTH",32),g(ke,"defaultProps",{...le.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let L=ke;function Ba(n){const[e,t,i]=as[n],r=n.includes("norm"),s=!r&&!n.startsWith("float"),o=n.startsWith("s");return{signedType:e,primitiveType:t,byteLength:i,normalized:r,integer:s,signed:o}}function Rp(n){const e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function kp(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Ua(n){const e=ArrayBuffer.isView(n)?n.constructor:n;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(as).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function za(n){const[,,,,e]=as[n];return e}const as={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function ls(n){let e;n.endsWith("-webgl")&&(n.replace("-webgl",""),e=!0);const[t,i]=n.split("x"),r=t,s=i?parseInt(i):1,o=Ba(r),a={type:r,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function Dp(n,e,t){const i=t?Rp(n):n;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function Mp(n,e,t){if(!e||e>4)throw new Error(`size ${e}`);const i=e,r=Ua(n);return Dp(r,i,t)}function Fp(n){let e;switch(n.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?e:`${e}x${n.components}`}const De="texture-compression-bc",ce="texture-compression-astc",dt="texture-compression-etc2",Np="texture-compression-etc1-webgl",Ei="texture-compression-pvrtc-webgl",cs="texture-compression-atc-webgl",Ri="float32-renderable-webgl",us="float16-renderable-webgl",Op="rgb9e5ufloat-renderable-webgl",fs="snorm8-renderable-webgl",Nn="norm16-renderable-webgl",hs="snorm16-renderable-webgl",ki="float32-filterable",La="float16-filterable-webgl";function Va(n){const e=Bp[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}const Bp={...{r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:fs},rg8snorm:{render:fs},"rgb8snorm-webgl":{},rgba8snorm:{render:fs},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Nn},rg16unorm:{render:Nn},"rgb16unorm-webgl":{f:Nn},rgba16unorm:{render:Nn},r16snorm:{f:hs},rg16snorm:{render:hs},"rgb16snorm-webgl":{f:Nn},rgba16snorm:{render:hs},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:us,filter:"float16-filterable-webgl"},rg16float:{render:us,filter:La},rgba16float:{render:us,filter:La},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Ri,filter:ki},rg32float:{render:!1,filter:ki},"rgb32float-webgl":{render:Ri,filter:ki},rgba32float:{render:Ri,filter:ki},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Op},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ri},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},...{"bc1-rgb-unorm-webgl":{f:De},"bc1-rgb-unorm-srgb-webgl":{f:De},"bc1-rgba-unorm":{f:De},"bc1-rgba-unorm-srgb":{f:De},"bc2-rgba-unorm":{f:De},"bc2-rgba-unorm-srgb":{f:De},"bc3-rgba-unorm":{f:De},"bc3-rgba-unorm-srgb":{f:De},"bc4-r-unorm":{f:De},"bc4-r-snorm":{f:De},"bc5-rg-unorm":{f:De},"bc5-rg-snorm":{f:De},"bc6h-rgb-ufloat":{f:De},"bc6h-rgb-float":{f:De},"bc7-rgba-unorm":{f:De},"bc7-rgba-unorm-srgb":{f:De},"etc2-rgb8unorm":{f:dt},"etc2-rgb8unorm-srgb":{f:dt},"etc2-rgb8a1unorm":{f:dt},"etc2-rgb8a1unorm-srgb":{f:dt},"etc2-rgba8unorm":{f:dt},"etc2-rgba8unorm-srgb":{f:dt},"eac-r11unorm":{f:dt},"eac-r11snorm":{f:dt},"eac-rg11unorm":{f:dt},"eac-rg11snorm":{f:dt},"astc-4x4-unorm":{f:ce},"astc-4x4-unorm-srgb":{f:ce},"astc-5x4-unorm":{f:ce},"astc-5x4-unorm-srgb":{f:ce},"astc-5x5-unorm":{f:ce},"astc-5x5-unorm-srgb":{f:ce},"astc-6x5-unorm":{f:ce},"astc-6x5-unorm-srgb":{f:ce},"astc-6x6-unorm":{f:ce},"astc-6x6-unorm-srgb":{f:ce},"astc-8x5-unorm":{f:ce},"astc-8x5-unorm-srgb":{f:ce},"astc-8x6-unorm":{f:ce},"astc-8x6-unorm-srgb":{f:ce},"astc-8x8-unorm":{f:ce},"astc-8x8-unorm-srgb":{f:ce},"astc-10x5-unorm":{f:ce},"astc-10x5-unorm-srgb":{f:ce},"astc-10x6-unorm":{f:ce},"astc-10x6-unorm-srgb":{f:ce},"astc-10x8-unorm":{f:ce},"astc-10x8-unorm-srgb":{f:ce},"astc-10x10-unorm":{f:ce},"astc-10x10-unorm-srgb":{f:ce},"astc-12x10-unorm":{f:ce},"astc-12x10-unorm-srgb":{f:ce},"astc-12x12-unorm":{f:ce},"astc-12x12-unorm-srgb":{f:ce},"pvrtc-rgb4unorm-webgl":{f:Ei},"pvrtc-rgba4unorm-webgl":{f:Ei},"pvrtc-rbg2unorm-webgl":{f:Ei},"pvrtc-rgba2unorm-webgl":{f:Ei},"etc1-rbg-unorm-webgl":{f:Np},"atc-rgb-unorm-webgl":{f:cs},"atc-rgba-unorm-webgl":{f:cs},"atc-rgbai-unorm-webgl":{f:cs}}},Up=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],zp=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class Lp{getInfo(e){return Ha(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return Up.some(t=>e.startsWith(t))}getCapabilities(e){const t=Va(e),i={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=Ha(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=r==null?void 0:r.signed,a=r==null?void 0:r.integer,l=r==null?void 0:r.webgl;return i.render&&(i.render=!o),i.filter&&(i.filter=!s&&!o&&!a&&!l),i}}const Vt=new Lp;function Ha(n){let e=Vp(n);if(Vt.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const i=Hp(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}const t=zp.exec(n);if(t){const[,i,r,s,o,a]=t,l=`${s}${r}`,c=Ba(l),u=c.byteLength*8,f=i.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:c.signedType,components:f,channels:i,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*i.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function Vp(n){var s;const e=Va(n),t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||((s=e.channels)==null?void 0:s.length)||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function Hp(n){const t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){const[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return null}function Wp(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function $p(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}class Xp{}class Yp{constructor(e=[],t){g(this,"features");g(this,"disabledFeatures");this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const br=class br{constructor(e){g(this,"id");g(this,"props");g(this,"userData",{});g(this,"statsManager",Pa);g(this,"timestamp",0);g(this,"_reused",!1);g(this,"_lumaData",{});g(this,"_textureCaps",{});this.props={...br.defaultProps,...e},this.id=this.props.id||Pi(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return ls(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Vt.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){const r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return Wp(e)}getExternalImageSize(e){return $p(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Vt.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:D.error(e.message,t,...i)}debug(){if(this.props.debug)debugger;else D.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
2
|
-
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=Vt.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&L.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};g(br,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[i,r]=e.getDevicePixelSize();D.log(1,`${e} resized => ${i}x${r}px`)()},onPositionChange:(e,t)=>{const[i,r]=e.getPosition();D.log(1,`${e} repositioned => ${i},${r}`)()},onVisibilityChange:e=>D.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>D.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:D.get("debug")||void 0,debugShaders:D.get("debug-shaders")||void 0,debugFramebuffers:!!D.get("debug-framebuffers"),debugFactories:!!D.get("debug-factories"),debugWebGL:!!D.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let Ht=br;const qp="set luma.log.level=1 (or higher) to trace rendering",Wa="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ii=class ii{constructor(){g(this,"stats",Pa);g(this,"log",D);g(this,"VERSION","9.2.6");g(this,"spector");g(this,"preregisteredAdapters",new Map);if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw D.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),D.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");D.error("This version of luma.gl has already been initialized")()}D.log(1,`${this.VERSION} - ${qp}`)(),globalThis.luma=this}async createDevice(e={}){const t={...ii.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(Wa);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){var s;const i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(Wa);return await((s=r==null?void 0:r.attach)==null?void 0:s.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>{var r;return(r=i.isSupported)==null?void 0:r.call(i)}).map(i=>i.type)}getBestAvailableAdapterType(e=[]){var r,s;const t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(const o of t)if((s=(r=i.get(o))==null?void 0:r.isSupported)!=null&&s.call(r))return o;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));const r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){var s;const r=this._getAdapterMap(t).get("webgl");r||D.warn("enforceWebGL2: webgl adapter not found")(),(s=r==null?void 0:r.enforceWebGL2)==null||s.call(r,e)}setDefaultDeviceProps(e){Object.assign(ii.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?D.warn("WebGL1 is not supported",e)():D.warn("Unknown handle type",e)(),null)}};g(ii,"defaultProps",{...Ht.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let ds=ii;const jp=new ds;class Kp{get pageLoaded(){return Jp()}}const Zp=Lt()&&typeof document<"u",Qp=()=>Zp&&document.readyState==="complete";let Di=null;function Jp(){return Di||(Qp()||typeof window>"u"?Di=Promise.resolve():Di=new Promise(n=>window.addEventListener("load",()=>n()))),Di}function Gp(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}const Qt=class Qt{constructor(e){g(this,"id");g(this,"props");g(this,"canvas");g(this,"htmlCanvas");g(this,"offscreenCanvas");g(this,"type");g(this,"initialized");g(this,"isInitialized",!1);g(this,"isVisible",!0);g(this,"cssWidth");g(this,"cssHeight");g(this,"devicePixelRatio");g(this,"devicePixelWidth");g(this,"devicePixelHeight");g(this,"drawingBufferWidth");g(this,"drawingBufferHeight");g(this,"_initializedResolvers",Gp());g(this,"_resizeObserver");g(this,"_intersectionObserver");g(this,"_position");g(this,"destroyed",!1);var t,i;if(this.props={...Qt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Lt()?e.canvas?typeof e.canvas=="string"?this.canvas=tg(e.canvas):this.canvas=e.canvas:this.canvas=ng(e):this.canvas={width:e.width||1,height:e.height||1},Qt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Qt.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((i=this.htmlCanvas)==null?void 0:i.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],Qt.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(r=>this._handleIntersection(r)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(r=>this._handleResize(r));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return ig(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(r=>r.target===this.canvas);if(!t)return;const i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){var l,c;const t=e.find(u=>u.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;const i=this.getDevicePixelSize(),r=((l=t.devicePixelContentBoxSize)==null?void 0:l[0].inlineSize)||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=((c=t.devicePixelContentBoxSize)==null?void 0:c[0].blockSize)||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(r,o)),this.devicePixelHeight=Math.max(1,Math.min(s,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var t,i,r;const e=(t=this.htmlCanvas)==null?void 0:t.getBoundingClientRect();if(e){const s=[e.left,e.top];if(this._position??(this._position=s),s[0]!==this._position[0]||s[1]!==this._position[1]){const a=this._position;this._position=s,(r=(i=this.device.props).onPositionChange)==null||r.call(i,this,{oldPosition:a})}}}};g(Qt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Mi=Qt;function eg(n){if(typeof n=="string"){const e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function tg(n){const e=document.getElementById(n);if(!Mi.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function ng(n){const{width:e,height:t}=n,i=document.createElement("canvas");i.id=Pi("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n!=null&&n.visible||(i.style.visibility="hidden");const r=eg((n==null?void 0:n.container)||null);return r.insertBefore(i,r.firstChild),i}function ig(n,e,t,i,r){const s=n,o=$a(s[0],e,t);let a=Xa(s[1],e,i,r),l=$a(s[0]+1,e,t);const c=l===t-1?l:l-1;l=Xa(s[1]+1,e,i,r);let u;return r?(l=l===0?l:l+1,u=a,a=l):u=l===i-1?l:l-1,{x:o,y:a,width:Math.max(c-o+1,1),height:Math.max(u-a+1,1)}}function $a(n,e,t){return Math.min(Math.round(n*e),t-1)}function Xa(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}const ri=class ri extends le{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=ri.normalizeProps(e,t),super(e,t,ri.defaultProps)}static normalizeProps(e,t){return t}};g(ri,"defaultProps",{...le.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let cn=ri;const rg={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ce=class Ce extends le{constructor(t,i){i=Ce.normalizeProps(t,i);super(t,i,Ce.defaultProps);g(this,"dimension");g(this,"baseDimension");g(this,"format");g(this,"width");g(this,"height");g(this,"depth");g(this,"mipLevels");g(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=rg[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.props.width===void 0||this.props.height===void 0)if(t.isExternalImage(i.data)){const r=t.getExternalImageSize(i.data);this.width=(r==null?void 0:r.width)||1,this.height=(r==null?void 0:r.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&D.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(t){this.sampler=t instanceof cn?t:this.device.createSampler(t)}clone(t){return this.device.createTexture({...this.props,...t})}static normalizeProps(t,i){const r={...i},{width:s,height:o}=r;return typeof s=="number"&&(r.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(r.height=Math.max(1,Math.ceil(o))),r}_initializeData(t){this.device.isExternalImage(t)?this.copyExternalImage({image:t,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):t&&this.copyImageData({data:t,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(t){const{width:i,height:r,depth:s}=this,o={...Ce.defaultCopyDataOptions,width:i,height:r,depth:s,...t},a=this.device.getTextureFormatInfo(this.format);if(!t.bytesPerRow&&!a.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return o.bytesPerRow=t.bytesPerRow||i*(a.bytesPerPixel||4),o.rowsPerImage=t.rowsPerImage||r,o}_normalizeCopyExternalImageOptions(t){const i=this.device.getExternalImageSize(t.image),r={...Ce.defaultCopyExternalImageOptions,...i,...t};return r.width=Math.min(r.width,this.width-r.x),r.height=Math.min(r.height,this.height-r.y),r}};g(Ce,"SAMPLE",4),g(Ce,"STORAGE",8),g(Ce,"RENDER",16),g(Ce,"COPY_SRC",1),g(Ce,"COPY_DST",2),g(Ce,"TEXTURE",4),g(Ce,"RENDER_ATTACHMENT",16),g(Ce,"defaultProps",{...le.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Ce.TEXTURE|Ce.RENDER_ATTACHMENT|Ce.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),g(Ce,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),g(Ce,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let Q=Ce;const Sr=class Sr extends le{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,Sr.defaultProps)}};g(Sr,"defaultProps",{...le.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Fi=Sr;function sg(n,e,t){let i="";const r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++)for(i+=Ya(r[a-1],a,t);s.length>o&&s[o].lineNum===a;){const l=s[o++];i+=ps(l,r,l.lineNum,{...t,inlineSource:!1})}for(;s.length>o;){const a=s[o++];i+=ps(a,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(const a of n)i+=ps(a,r,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return i}}function ps(n,e,t,i){if(i!=null&&i.inlineSource){const s=og(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^
|
|
1
|
+
(function(te,Ue){typeof exports=="object"&&typeof module<"u"?Ue(exports):typeof define=="function"&&define.amd?define(["exports"],Ue):(te=typeof globalThis<"u"?globalThis:te||self,Ue(te.Cosmos={}))})(this,function(te){"use strict";var rb=Object.defineProperty;var sb=(te,Ue,Ot)=>Ue in te?rb(te,Ue,{enumerable:!0,configurable:!0,writable:!0,value:Ot}):te[Ue]=Ot;var m=(te,Ue,Ot)=>sb(te,typeof Ue!="symbol"?Ue+"":Ue,Ot);var Ue="http://www.w3.org/1999/xhtml";const Ot={svg:"http://www.w3.org/2000/svg",xhtml:Ue,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function li(n){var e=n+="",t=e.indexOf(":");return t>=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),Ot.hasOwnProperty(e)?{space:Ot[e],local:n}:n}function Gu(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Ue&&e.documentElement.namespaceURI===Ue?e.createElement(n):e.createElementNS(t,n)}}function ef(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Vo(n){var e=li(n);return(e.local?ef:Gu)(e)}function tf(){}function $r(n){return n==null?tf:function(){return this.querySelector(n)}}function nf(n){typeof n!="function"&&(n=$r(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=new Array(o),l,c,u=0;u<o;++u)(l=s[u])&&(c=n.call(l,l.__data__,u,s))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new qe(i,this._parents)}function rf(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function sf(){return[]}function Ho(n){return n==null?sf:function(){return this.querySelectorAll(n)}}function of(n){return function(){return rf(n.apply(this,arguments))}}function af(n){typeof n=="function"?n=of(n):n=Ho(n);for(var e=this._groups,t=e.length,i=[],r=[],s=0;s<t;++s)for(var o=e[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(i.push(n.call(l,l.__data__,c,o)),r.push(l));return new qe(i,r)}function Wo(n){return function(){return this.matches(n)}}function $o(n){return function(e){return e.matches(n)}}var lf=Array.prototype.find;function cf(n){return function(){return lf.call(this.children,n)}}function uf(){return this.firstElementChild}function ff(n){return this.select(n==null?uf:cf(typeof n=="function"?n:$o(n)))}var hf=Array.prototype.filter;function df(){return Array.from(this.children)}function pf(n){return function(){return hf.call(this.children,n)}}function mf(n){return this.selectAll(n==null?df:pf(typeof n=="function"?n:$o(n)))}function gf(n){typeof n!="function"&&(n=Wo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new qe(i,this._parents)}function Xo(n){return new Array(n.length)}function _f(){return new qe(this._enter||this._groups.map(Xo),this._parents)}function ci(n,e){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=e}ci.prototype={constructor:ci,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,e){return this._parent.insertBefore(n,e)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function xf(n){return function(){return n}}function yf(n,e,t,i,r,s){for(var o=0,a,l=e.length,c=s.length;o<c;++o)(a=e[o])?(a.__data__=s[o],i[o]=a):t[o]=new ci(n,s[o]);for(;o<l;++o)(a=e[o])&&(r[o]=a)}function vf(n,e,t,i,r,s,o){var a,l,c=new Map,u=e.length,f=s.length,h=new Array(u),d;for(a=0;a<u;++a)(l=e[a])&&(h[a]=d=o.call(l,l.__data__,a,e)+"",c.has(d)?r[a]=l:c.set(d,l));for(a=0;a<f;++a)d=o.call(n,s[a],a,s)+"",(l=c.get(d))?(i[a]=l,l.__data__=s[a],c.delete(d)):t[a]=new ci(n,s[a]);for(a=0;a<u;++a)(l=e[a])&&c.get(h[a])===l&&(r[a]=l)}function bf(n){return n.__data__}function Sf(n,e){if(!arguments.length)return Array.from(this,bf);var t=e?vf:yf,i=this._parents,r=this._groups;typeof n!="function"&&(n=xf(n));for(var s=r.length,o=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var u=i[c],f=r[c],h=f.length,d=Tf(n.call(u,u&&u.__data__,c,i)),_=d.length,I=a[c]=new Array(_),P=o[c]=new Array(_),A=l[c]=new Array(h);t(u,f,I,P,A,d,e);for(var O=0,E=0,x,R;O<_;++O)if(x=I[O]){for(O>=E&&(E=O+1);!(R=P[E])&&++E<_;);x._next=R||null}}return o=new qe(o,i),o._enter=a,o._exit=l,o}function Tf(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function wf(){return new qe(this._exit||this._groups.map(Xo),this._parents)}function Af(n,e,t){var i=this.enter(),r=this,s=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?s.remove():t(s),i&&r?i.merge(r).order():r}function Cf(n){for(var e=n.selection?n.selection():n,t=this._groups,i=e._groups,r=t.length,s=i.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=i[l],f=c.length,h=a[l]=new Array(f),d,_=0;_<f;++_)(d=c[_]||u[_])&&(h[_]=d);for(;l<r;++l)a[l]=t[l];return new qe(a,this._parents)}function If(){for(var n=this._groups,e=-1,t=n.length;++e<t;)for(var i=n[e],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Pf(n){n||(n=Ef);function e(f,h){return f&&h?n(f.__data__,h.__data__):!f-!h}for(var t=this._groups,i=t.length,r=new Array(i),s=0;s<i;++s){for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new qe(r,this._parents).order()}function Ef(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function Rf(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function kf(){return Array.from(this)}function Df(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Mf(){let n=0;for(const e of this)++n;return n}function Ff(){return!this.node()}function Nf(n){for(var e=this._groups,t=0,i=e.length;t<i;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&n.call(a,a.__data__,s,r);return this}function Of(n){return function(){this.removeAttribute(n)}}function Bf(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Uf(n,e){return function(){this.setAttribute(n,e)}}function zf(n,e){return function(){this.setAttributeNS(n.space,n.local,e)}}function Lf(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(n):this.setAttribute(n,t)}}function Vf(n,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}function Hf(n,e){var t=li(n);if(arguments.length<2){var i=this.node();return t.local?i.getAttributeNS(t.space,t.local):i.getAttribute(t)}return this.each((e==null?t.local?Bf:Of:typeof e=="function"?t.local?Vf:Lf:t.local?zf:Uf)(t,e))}function Yo(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function Wf(n){return function(){this.style.removeProperty(n)}}function $f(n,e,t){return function(){this.style.setProperty(n,e,t)}}function Xf(n,e,t){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,t)}}function Yf(n,e,t){return arguments.length>1?this.each((e==null?Wf:typeof e=="function"?Xf:$f)(n,e,t??"")):tn(this.node(),n)}function tn(n,e){return n.style.getPropertyValue(e)||Yo(n).getComputedStyle(n,null).getPropertyValue(e)}function qf(n){return function(){delete this[n]}}function jf(n,e){return function(){this[n]=e}}function Kf(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function Zf(n,e){return arguments.length>1?this.each((e==null?qf:typeof e=="function"?Kf:jf)(n,e)):this.node()[n]}function qo(n){return n.trim().split(/^|\s+/)}function Xr(n){return n.classList||new jo(n)}function jo(n){this._node=n,this._names=qo(n.getAttribute("class")||"")}jo.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Ko(n,e){for(var t=Xr(n),i=-1,r=e.length;++i<r;)t.add(e[i])}function Zo(n,e){for(var t=Xr(n),i=-1,r=e.length;++i<r;)t.remove(e[i])}function Qf(n){return function(){Ko(this,n)}}function Jf(n){return function(){Zo(this,n)}}function Gf(n,e){return function(){(e.apply(this,arguments)?Ko:Zo)(this,n)}}function eh(n,e){var t=qo(n+"");if(arguments.length<2){for(var i=Xr(this.node()),r=-1,s=t.length;++r<s;)if(!i.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?Gf:e?Qf:Jf)(t,e))}function th(){this.textContent=""}function nh(n){return function(){this.textContent=n}}function ih(n){return function(){var e=n.apply(this,arguments);this.textContent=e??""}}function rh(n){return arguments.length?this.each(n==null?th:(typeof n=="function"?ih:nh)(n)):this.node().textContent}function sh(){this.innerHTML=""}function oh(n){return function(){this.innerHTML=n}}function ah(n){return function(){var e=n.apply(this,arguments);this.innerHTML=e??""}}function lh(n){return arguments.length?this.each(n==null?sh:(typeof n=="function"?ah:oh)(n)):this.node().innerHTML}function ch(){this.nextSibling&&this.parentNode.appendChild(this)}function uh(){return this.each(ch)}function fh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hh(){return this.each(fh)}function dh(n){var e=typeof n=="function"?n:Vo(n);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function ph(){return null}function mh(n,e){var t=typeof n=="function"?n:Vo(n),i=e==null?ph:typeof e=="function"?e:$r(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),i.apply(this,arguments)||null)})}function gh(){var n=this.parentNode;n&&n.removeChild(this)}function _h(){return this.each(gh)}function xh(){var n=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function yh(){var n=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(n,this.nextSibling):n}function vh(n){return this.select(n?yh:xh)}function bh(n){return arguments.length?this.property("__data__",n):this.node().__data__}function Sh(n){return function(e){n.call(this,e,this.__data__)}}function Th(n){return n.trim().split(/^|\s+/).map(function(e){var t="",i=e.indexOf(".");return i>=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function wh(n){return function(){var e=this.__on;if(e){for(var t=0,i=-1,r=e.length,s;t<r;++t)s=e[t],(!n.type||s.type===n.type)&&s.name===n.name?this.removeEventListener(s.type,s.listener,s.options):e[++i]=s;++i?e.length=i:delete this.__on}}}function Ah(n,e,t){return function(){var i=this.__on,r,s=Sh(e);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=t),r.value=e;return}}this.addEventListener(n.type,s,t),r={type:n.type,name:n.name,value:e,listener:s,options:t},i?i.push(r):this.__on=[r]}}function Ch(n,e,t){var i=Th(n+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(r=0,u=a[l];r<s;++r)if((o=i[r]).type===u.type&&o.name===u.name)return u.value}return}for(a=e?Ah:wh,r=0;r<s;++r)this.each(a(i[r],e,t));return this}function Qo(n,e,t){var i=Yo(n),r=i.CustomEvent;typeof r=="function"?r=new r(e,t):(r=i.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),n.dispatchEvent(r)}function Ih(n,e){return function(){return Qo(this,n,e)}}function Ph(n,e){return function(){return Qo(this,n,e.apply(this,arguments))}}function Eh(n,e){return this.each((typeof e=="function"?Ph:Ih)(n,e))}function*Rh(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var i=n[e],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var Jo=[null];function qe(n,e){this._groups=n,this._parents=e}function In(){return new qe([[document.documentElement]],Jo)}function kh(){return this}qe.prototype=In.prototype={constructor:qe,select:nf,selectAll:af,selectChild:ff,selectChildren:mf,filter:gf,data:Sf,enter:_f,exit:wf,join:Af,merge:Cf,selection:kh,order:If,sort:Pf,call:Rf,nodes:kf,node:Df,size:Mf,empty:Ff,each:Nf,attr:Hf,style:Yf,property:Zf,classed:eh,text:rh,html:lh,raise:uh,lower:hh,append:dh,insert:mh,remove:_h,clone:vh,datum:bh,on:Ch,dispatch:Eh,[Symbol.iterator]:Rh};function we(n){return typeof n=="string"?new qe([[document.querySelector(n)]],[document.documentElement]):new qe([[n]],Jo)}function Dh(n){let e;for(;e=n.sourceEvent;)n=e;return n}function yt(n,e){if(n=Dh(n),e===void 0&&(e=n.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var i=t.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(e.getScreenCTM().inverse()),[i.x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[n.clientX-r.left-e.clientLeft,n.clientY-r.top-e.clientTop]}}return[n.pageX,n.pageY]}var Mh={value:()=>{}};function ui(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new fi(t)}function fi(n){this._=n}function Fh(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}fi.prototype=ui.prototype={constructor:fi,on:function(n,e){var t=this._,i=Fh(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(n=i[s]).type)&&(r=Nh(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(n=i[s]).type)t[r]=Go(t[r],n.name,e);else if(e==null)for(r in t)t[r]=Go(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new fi(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function Nh(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function Go(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=Mh,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var nn=0,Pn=0,En=0,ea=1e3,hi,Rn,di=0,Bt=0,pi=0,kn=typeof performance=="object"&&performance.now?performance:Date,ta=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Yr(){return Bt||(ta(Oh),Bt=kn.now()+pi)}function Oh(){Bt=0}function mi(){this._call=this._time=this._next=null}mi.prototype=na.prototype={constructor:mi,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?Yr():+t)+(e==null?0:+e),!this._next&&Rn!==this&&(Rn?Rn._next=this:hi=this,Rn=this),this._call=n,this._time=t,qr()},stop:function(){this._call&&(this._call=null,this._time=1/0,qr())}};function na(n,e,t){var i=new mi;return i.restart(n,e,t),i}function Bh(){Yr(),++nn;for(var n=hi,e;n;)(e=Bt-n._time)>=0&&n._call.call(null,e),n=n._next;--nn}function ia(){Bt=(di=kn.now())+pi,nn=Pn=0;try{Bh()}finally{nn=0,zh(),Bt=0}}function Uh(){var n=kn.now(),e=n-di;e>ea&&(pi-=e,di=n)}function zh(){for(var n,e=hi,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:hi=t);Rn=n,qr(i)}function qr(n){if(!nn){Pn&&(Pn=clearTimeout(Pn));var e=n-Bt;e>24?(n<1/0&&(Pn=setTimeout(ia,n-kn.now()-pi)),En&&(En=clearInterval(En))):(En||(di=kn.now(),En=setInterval(Uh,ea)),nn=1,ta(ia))}}function ra(n,e,t){var i=new mi;return e=e==null?0:+e,i.restart(r=>{i.stop(),n(r+e)},e,t),i}var Lh=ui("start","end","cancel","interrupt"),Vh=[],sa=0,oa=1,jr=2,gi=3,aa=4,Kr=5,_i=6;function xi(n,e,t,i,r,s){var o=n.__transition;if(!o)n.__transition={};else if(t in o)return;Hh(n,t,{name:e,index:i,group:r,on:Lh,tween:Vh,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:sa})}function Zr(n,e){var t=it(n,e);if(t.state>sa)throw new Error("too late; already scheduled");return t}function ft(n,e){var t=it(n,e);if(t.state>gi)throw new Error("too late; already running");return t}function it(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Hh(n,e,t){var i=n.__transition,r;i[e]=t,t.timer=na(s,0,t.time);function s(c){t.state=oa,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,f,h,d;if(t.state!==oa)return l();for(u in i)if(d=i[u],d.name===t.name){if(d.state===gi)return ra(o);d.state===aa?(d.state=_i,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[u]):+u<e&&(d.state=_i,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[u])}if(ra(function(){t.state===gi&&(t.state=aa,t.timer.restart(a,t.delay,t.time),a(c))}),t.state=jr,t.on.call("start",n,n.__data__,t.index,t.group),t.state===jr){for(t.state=gi,r=new Array(h=t.tween.length),u=0,f=-1;u<h;++u)(d=t.tween[u].value.call(n,n.__data__,t.index,t.group))&&(r[++f]=d);r.length=f+1}}function a(c){for(var u=c<t.duration?t.ease.call(null,c/t.duration):(t.timer.restart(l),t.state=Kr,1),f=-1,h=r.length;++f<h;)r[f].call(n,u);t.state===Kr&&(t.on.call("end",n,n.__data__,t.index,t.group),l())}function l(){t.state=_i,t.timer.stop(),delete i[e];for(var c in i)return;delete n.__transition}}function yi(n,e){var t=n.__transition,i,r,s=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((i=t[o]).name!==e){s=!1;continue}r=i.state>jr&&i.state<Kr,i.state=_i,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete t[o]}s&&delete n.__transition}}function Wh(n){return this.each(function(){yi(this,n)})}function Qr(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function la(n,e){var t=Object.create(n.prototype);for(var i in e)t[i]=e[i];return t}function Dn(){}var Mn=.7,vi=1/Mn,rn="\\s*([+-]?\\d+)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$h=/^#([0-9a-f]{3,8})$/,Xh=new RegExp(`^rgb\\(${rn},${rn},${rn}\\)$`),Yh=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),qh=new RegExp(`^rgba\\(${rn},${rn},${rn},${Fn}\\)$`),jh=new RegExp(`^rgba\\(${ht},${ht},${ht},${Fn}\\)$`),Kh=new RegExp(`^hsl\\(${Fn},${ht},${ht}\\)$`),Zh=new RegExp(`^hsla\\(${Fn},${ht},${ht},${Fn}\\)$`),ca={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Qr(Dn,kt,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:ua,formatHex:ua,formatHex8:Qh,formatHsl:Jh,formatRgb:fa,toString:fa});function ua(){return this.rgb().formatHex()}function Qh(){return this.rgb().formatHex8()}function Jh(){return ga(this).formatHsl()}function fa(){return this.rgb().formatRgb()}function kt(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=$h.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?ha(e):t===3?new Xe(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?bi(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?bi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Xh.exec(n))?new Xe(e[1],e[2],e[3],1):(e=Yh.exec(n))?new Xe(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=qh.exec(n))?bi(e[1],e[2],e[3],e[4]):(e=jh.exec(n))?bi(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Kh.exec(n))?ma(e[1],e[2]/100,e[3]/100,1):(e=Zh.exec(n))?ma(e[1],e[2]/100,e[3]/100,e[4]):ca.hasOwnProperty(n)?ha(ca[n]):n==="transparent"?new Xe(NaN,NaN,NaN,0):null}function ha(n){return new Xe(n>>16&255,n>>8&255,n&255,1)}function bi(n,e,t,i){return i<=0&&(n=e=t=NaN),new Xe(n,e,t,i)}function Gh(n){return n instanceof Dn||(n=kt(n)),n?(n=n.rgb(),new Xe(n.r,n.g,n.b,n.opacity)):new Xe}function Jr(n,e,t,i){return arguments.length===1?Gh(n):new Xe(n,e,t,i??1)}function Xe(n,e,t,i){this.r=+n,this.g=+e,this.b=+t,this.opacity=+i}Qr(Xe,Jr,la(Dn,{brighter(n){return n=n==null?vi:Math.pow(vi,n),new Xe(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Mn:Math.pow(Mn,n),new Xe(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new Xe(Ut(this.r),Ut(this.g),Ut(this.b),Si(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:da,formatHex:da,formatHex8:ed,formatRgb:pa,toString:pa}));function da(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function ed(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function pa(){const n=Si(this.opacity);return`${n===1?"rgb(":"rgba("}${Ut(this.r)}, ${Ut(this.g)}, ${Ut(this.b)}${n===1?")":`, ${n})`}`}function Si(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Ut(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function zt(n){return n=Ut(n),(n<16?"0":"")+n.toString(16)}function ma(n,e,t,i){return i<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new rt(n,e,t,i)}function ga(n){if(n instanceof rt)return new rt(n.h,n.s,n.l,n.opacity);if(n instanceof Dn||(n=kt(n)),!n)return new rt;if(n instanceof rt)return n;n=n.rgb();var e=n.r/255,t=n.g/255,i=n.b/255,r=Math.min(e,t,i),s=Math.max(e,t,i),o=NaN,a=s-r,l=(s+r)/2;return a?(e===s?o=(t-i)/a+(t<i)*6:t===s?o=(i-e)/a+2:o=(e-t)/a+4,a/=l<.5?s+r:2-s-r,o*=60):a=l>0&&l<1?0:o,new rt(o,a,l,n.opacity)}function td(n,e,t,i){return arguments.length===1?ga(n):new rt(n,e,t,i??1)}function rt(n,e,t,i){this.h=+n,this.s=+e,this.l=+t,this.opacity=+i}Qr(rt,td,la(Dn,{brighter(n){return n=n==null?vi:Math.pow(vi,n),new rt(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Mn:Math.pow(Mn,n),new rt(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,r=2*t-i;return new Xe(Gr(n>=240?n-240:n+120,r,i),Gr(n,r,i),Gr(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new rt(_a(this.h),Ti(this.s),Ti(this.l),Si(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Si(this.opacity);return`${n===1?"hsl(":"hsla("}${_a(this.h)}, ${Ti(this.s)*100}%, ${Ti(this.l)*100}%${n===1?")":`, ${n})`}`}}));function _a(n){return n=(n||0)%360,n<0?n+360:n}function Ti(n){return Math.max(0,Math.min(1,n||0))}function Gr(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const es=n=>()=>n;function nd(n,e){return function(t){return n+t*e}}function id(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(i){return Math.pow(n+i*e,t)}}function rd(n){return(n=+n)==1?xa:function(e,t){return t-e?id(e,t,n):es(isNaN(e)?t:e)}}function xa(n,e){var t=e-n;return t?nd(n,t):es(isNaN(n)?e:n)}const wi=function n(e){var t=rd(e);function i(r,s){var o=t((r=Jr(r)).r,(s=Jr(s)).r),a=t(r.g,s.g),l=t(r.b,s.b),c=xa(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=l(u),r.opacity=c(u),r+""}}return i.gamma=n,i}(1);function sd(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,i=e.slice(),r;return function(s){for(r=0;r<t;++r)i[r]=n[r]*(1-s)+e[r]*s;return i}}function od(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function ad(n,e){var t=e?e.length:0,i=n?Math.min(t,n.length):0,r=new Array(i),s=new Array(t),o;for(o=0;o<i;++o)r[o]=is(n[o],e[o]);for(;o<t;++o)s[o]=e[o];return function(a){for(o=0;o<i;++o)s[o]=r[o](a);return s}}function ld(n,e){var t=new Date;return n=+n,e=+e,function(i){return t.setTime(n*(1-i)+e*i),t}}function st(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function cd(n,e){var t={},i={},r;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in n?t[r]=is(n[r],e[r]):i[r]=e[r];return function(s){for(r in t)i[r]=t[r](s);return i}}var ts=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ns=new RegExp(ts.source,"g");function ud(n){return function(){return n}}function fd(n){return function(e){return n(e)+""}}function ya(n,e){var t=ts.lastIndex=ns.lastIndex=0,i,r,s,o=-1,a=[],l=[];for(n=n+"",e=e+"";(i=ts.exec(n))&&(r=ns.exec(e));)(s=r.index)>t&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:st(i,r)})),t=ns.lastIndex;return t<e.length&&(s=e.slice(t),a[o]?a[o]+=s:a[++o]=s),a.length<2?l[0]?fd(l[0].x):ud(e):(e=l.length,function(c){for(var u=0,f;u<e;++u)a[(f=l[u]).i]=f.x(c);return a.join("")})}function is(n,e){var t=typeof e,i;return e==null||t==="boolean"?es(e):(t==="number"?st:t==="string"?(i=kt(e))?(e=i,wi):ya:e instanceof kt?wi:e instanceof Date?ld:od(e)?sd:Array.isArray(e)?ad:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?cd:st)(n,e)}function hd(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}var va=180/Math.PI,rs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ba(n,e,t,i,r,s){var o,a,l;return(o=Math.sqrt(n*n+e*e))&&(n/=o,e/=o),(l=n*t+e*i)&&(t-=n*l,i-=e*l),(a=Math.sqrt(t*t+i*i))&&(t/=a,i/=a,l/=a),n*i<e*t&&(n=-n,e=-e,l=-l,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,n)*va,skewX:Math.atan(l)*va,scaleX:o,scaleY:a}}var Ai;function dd(n){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return e.isIdentity?rs:ba(e.a,e.b,e.c,e.d,e.e,e.f)}function pd(n){return n==null||(Ai||(Ai=document.createElementNS("http://www.w3.org/2000/svg","g")),Ai.setAttribute("transform",n),!(n=Ai.transform.baseVal.consolidate()))?rs:(n=n.matrix,ba(n.a,n.b,n.c,n.d,n.e,n.f))}function Sa(n,e,t,i){function r(c){return c.length?c.pop()+" ":""}function s(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push("translate(",null,e,null,t);_.push({i:I-4,x:st(c,f)},{i:I-2,x:st(u,h)})}else(f||h)&&d.push("translate("+f+e+h+t)}function o(c,u,f,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:f.push(r(f)+"rotate(",null,i)-2,x:st(c,u)})):u&&f.push(r(f)+"rotate("+u+i)}function a(c,u,f,h){c!==u?h.push({i:f.push(r(f)+"skewX(",null,i)-2,x:st(c,u)}):u&&f.push(r(f)+"skewX("+u+i)}function l(c,u,f,h,d,_){if(c!==f||u!==h){var I=d.push(r(d)+"scale(",null,",",null,")");_.push({i:I-4,x:st(c,f)},{i:I-2,x:st(u,h)})}else(f!==1||h!==1)&&d.push(r(d)+"scale("+f+","+h+")")}return function(c,u){var f=[],h=[];return c=n(c),u=n(u),s(c.translateX,c.translateY,u.translateX,u.translateY,f,h),o(c.rotate,u.rotate,f,h),a(c.skewX,u.skewX,f,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,h),c=u=null,function(d){for(var _=-1,I=h.length,P;++_<I;)f[(P=h[_]).i]=P.x(d);return f.join("")}}}var md=Sa(dd,"px, ","px)","deg)"),gd=Sa(pd,", ",")",")"),_d=1e-12;function Ta(n){return((n=Math.exp(n))+1/n)/2}function xd(n){return((n=Math.exp(n))-1/n)/2}function yd(n){return((n=Math.exp(2*n))-1)/(n+1)}const vd=function n(e,t,i){function r(s,o){var a=s[0],l=s[1],c=s[2],u=o[0],f=o[1],h=o[2],d=u-a,_=f-l,I=d*d+_*_,P,A;if(I<_d)A=Math.log(h/c)/e,P=function(U){return[a+U*d,l+U*_,c*Math.exp(e*U*A)]};else{var O=Math.sqrt(I),E=(h*h-c*c+i*I)/(2*c*t*O),x=(h*h-c*c-i*I)/(2*h*t*O),R=Math.log(Math.sqrt(E*E+1)-E),N=Math.log(Math.sqrt(x*x+1)-x);A=(N-R)/e,P=function(U){var W=U*A,q=Ta(R),G=c/(t*O)*(q*yd(e*W+R)-xd(R));return[a+G*d,l+G*_,c*q/Ta(e*W+R)]}}return P.duration=A*1e3*e/Math.SQRT2,P}return r.rho=function(s){var o=Math.max(.001,+s),a=o*o,l=a*a;return n(o,a,l)},r}(Math.SQRT2,2,4);function bd(n,e){var t,i;return function(){var r=ft(this,n),s=r.tween;if(s!==t){i=t=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===e){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function Sd(n,e,t){var i,r;if(typeof t!="function")throw new Error;return function(){var s=ft(this,n),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:e,value:t},l=0,c=r.length;l<c;++l)if(r[l].name===e){r[l]=a;break}l===c&&r.push(a)}s.tween=r}}function Td(n,e){var t=this._id;if(n+="",arguments.length<2){for(var i=it(this.node(),t).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===n)return o.value;return null}return this.each((e==null?bd:Sd)(t,n,e))}function ss(n,e,t){var i=n._id;return n.each(function(){var r=ft(this,i);(r.value||(r.value={}))[e]=t.apply(this,arguments)}),function(r){return it(r,i).value[e]}}function wa(n,e){var t;return(typeof e=="number"?st:e instanceof kt?wi:(t=kt(e))?(e=t,wi):ya)(n,e)}function wd(n){return function(){this.removeAttribute(n)}}function Ad(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Cd(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttribute(n);return o===r?null:o===i?s:s=e(i=o,t)}}function Id(n,e,t){var i,r=t+"",s;return function(){var o=this.getAttributeNS(n.space,n.local);return o===r?null:o===i?s:s=e(i=o,t)}}function Pd(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(n):(o=this.getAttribute(n),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function Ed(n,e,t){var i,r,s;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(n.space,n.local):(o=this.getAttributeNS(n.space,n.local),l=a+"",o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a)))}}function Rd(n,e){var t=li(n),i=t==="transform"?gd:wa;return this.attrTween(n,typeof e=="function"?(t.local?Ed:Pd)(t,i,ss(this,"attr."+n,e)):e==null?(t.local?Ad:wd)(t):(t.local?Id:Cd)(t,i,e))}function kd(n,e){return function(t){this.setAttribute(n,e.call(this,t))}}function Dd(n,e){return function(t){this.setAttributeNS(n.space,n.local,e.call(this,t))}}function Md(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&Dd(n,s)),t}return r._value=e,r}function Fd(n,e){var t,i;function r(){var s=e.apply(this,arguments);return s!==i&&(t=(i=s)&&kd(n,s)),t}return r._value=e,r}function Nd(n,e){var t="attr."+n;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var i=li(n);return this.tween(t,(i.local?Md:Fd)(i,e))}function Od(n,e){return function(){Zr(this,n).delay=+e.apply(this,arguments)}}function Bd(n,e){return e=+e,function(){Zr(this,n).delay=e}}function Ud(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?Od:Bd)(e,n)):it(this.node(),e).delay}function zd(n,e){return function(){ft(this,n).duration=+e.apply(this,arguments)}}function Ld(n,e){return e=+e,function(){ft(this,n).duration=e}}function Vd(n){var e=this._id;return arguments.length?this.each((typeof n=="function"?zd:Ld)(e,n)):it(this.node(),e).duration}function Hd(n,e){if(typeof e!="function")throw new Error;return function(){ft(this,n).ease=e}}function Wd(n){var e=this._id;return arguments.length?this.each(Hd(e,n)):it(this.node(),e).ease}function $d(n,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;ft(this,n).ease=t}}function Xd(n){if(typeof n!="function")throw new Error;return this.each($d(this._id,n))}function Yd(n){typeof n!="function"&&(n=Wo(n));for(var e=this._groups,t=e.length,i=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,a=i[r]=[],l,c=0;c<o;++c)(l=s[c])&&n.call(l,l.__data__,c,s)&&a.push(l);return new vt(i,this._parents,this._name,this._id)}function qd(n){if(n._id!==this._id)throw new Error;for(var e=this._groups,t=n._groups,i=e.length,r=t.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var l=e[a],c=t[a],u=l.length,f=o[a]=new Array(u),h,d=0;d<u;++d)(h=l[d]||c[d])&&(f[d]=h);for(;a<i;++a)o[a]=e[a];return new vt(o,this._parents,this._name,this._id)}function jd(n){return(n+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Kd(n,e,t){var i,r,s=jd(e)?Zr:ft;return function(){var o=s(this,n),a=o.on;a!==i&&(r=(i=a).copy()).on(e,t),o.on=r}}function Zd(n,e){var t=this._id;return arguments.length<2?it(this.node(),t).on.on(n):this.each(Kd(t,n,e))}function Qd(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Jd(){return this.on("end.remove",Qd(this._id))}function Gd(n){var e=this._name,t=this._id;typeof n!="function"&&(n=$r(n));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],l=a.length,c=s[o]=new Array(l),u,f,h=0;h<l;++h)(u=a[h])&&(f=n.call(u,u.__data__,h,a))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,xi(c[h],e,t,h,c,it(u,t)));return new vt(s,this._parents,e,t)}function ep(n){var e=this._name,t=this._id;typeof n!="function"&&(n=Ho(n));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var l=i[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var h=n.call(u,u.__data__,f,l),d,_=it(u,t),I=0,P=h.length;I<P;++I)(d=h[I])&&xi(d,e,t,I,h,_);s.push(h),o.push(u)}return new vt(s,o,e,t)}var tp=In.prototype.constructor;function np(){return new tp(this._groups,this._parents)}function ip(n,e){var t,i,r;return function(){var s=tn(this,n),o=(this.style.removeProperty(n),tn(this,n));return s===o?null:s===t&&o===i?r:r=e(t=s,i=o)}}function Aa(n){return function(){this.style.removeProperty(n)}}function rp(n,e,t){var i,r=t+"",s;return function(){var o=tn(this,n);return o===r?null:o===i?s:s=e(i=o,t)}}function sp(n,e,t){var i,r,s;return function(){var o=tn(this,n),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(n),tn(this,n))),o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a))}}function op(n,e){var t,i,r,s="style."+e,o="end."+s,a;return function(){var l=ft(this,n),c=l.on,u=l.value[s]==null?a||(a=Aa(e)):void 0;(c!==t||r!==u)&&(i=(t=c).copy()).on(o,r=u),l.on=i}}function ap(n,e,t){var i=(n+="")=="transform"?md:wa;return e==null?this.styleTween(n,ip(n,i)).on("end.style."+n,Aa(n)):typeof e=="function"?this.styleTween(n,sp(n,i,ss(this,"style."+n,e))).each(op(this._id,n)):this.styleTween(n,rp(n,i,e),t).on("end.style."+n,null)}function lp(n,e,t){return function(i){this.style.setProperty(n,e.call(this,i),t)}}function cp(n,e,t){var i,r;function s(){var o=e.apply(this,arguments);return o!==r&&(i=(r=o)&&lp(n,o,t)),i}return s._value=e,s}function up(n,e,t){var i="style."+(n+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,cp(n,e,t??""))}function fp(n){return function(){this.textContent=n}}function hp(n){return function(){var e=n(this);this.textContent=e??""}}function dp(n){return this.tween("text",typeof n=="function"?hp(ss(this,"text",n)):fp(n==null?"":n+""))}function pp(n){return function(e){this.textContent=n.call(this,e)}}function mp(n){var e,t;function i(){var r=n.apply(this,arguments);return r!==t&&(e=(t=r)&&pp(r)),e}return i._value=n,i}function gp(n){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(n==null)return this.tween(e,null);if(typeof n!="function")throw new Error;return this.tween(e,mp(n))}function _p(){for(var n=this._name,e=this._id,t=Ca(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=it(l,e);xi(l,n,t,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new vt(i,this._parents,n,t)}function xp(){var n,e,t=this,i=t._id,r=t.size();return new Promise(function(s,o){var a={value:o},l={value:function(){--r===0&&s()}};t.each(function(){var c=ft(this,i),u=c.on;u!==n&&(e=(n=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),r===0&&s()})}var yp=0;function vt(n,e,t,i){this._groups=n,this._parents=e,this._name=t,this._id=i}function Ca(){return++yp}var bt=In.prototype;vt.prototype={constructor:vt,select:Gd,selectAll:ep,selectChild:bt.selectChild,selectChildren:bt.selectChildren,filter:Yd,merge:qd,selection:np,transition:_p,call:bt.call,nodes:bt.nodes,node:bt.node,size:bt.size,empty:bt.empty,each:bt.each,on:Zd,attr:Rd,attrTween:Nd,style:ap,styleTween:up,text:dp,textTween:gp,remove:Jd,tween:Td,delay:Ud,duration:Vd,ease:Wd,easeVarying:Xd,end:xp,[Symbol.iterator]:bt[Symbol.iterator]};function vp(n){return n*n}function bp(n){return n*(2-n)}function Sp(n){return((n*=2)<=1?n*n:--n*(2-n)+1)/2}function Tp(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var wp={time:null,delay:0,duration:250,ease:Tp};function Ap(n,e){for(var t;!(t=n.__transition)||!(t=t[e]);)if(!(n=n.parentNode))throw new Error(`transition ${e} not found`);return t}function Cp(n){var e,t;n instanceof vt?(e=n._id,n=n._name):(e=Ca(),(t=wp).time=Yr(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&xi(l,n,e,c,o,t||Ap(l,e));return new vt(i,this._parents,n,e)}In.prototype.interrupt=Wh,In.prototype.transition=Cp;function Ia(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}class Pa{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Ia(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ia()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Ip{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:i}=e;let r=this.stats[t];return r||(e instanceof Pa?r=e:r=new Pa(t,i),this.stats[t]=r),r}}class Pp{constructor(){m(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ip({id:e})),this.stats.get(e)}}const Ea=new Pp,Ci=globalThis,sn=globalThis.process||{},Ep=globalThis.navigator||{};function Ra(n){var i,r;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((r=process.versions)!=null&&r.electron))return!0;const t=typeof navigator<"u"&&navigator.userAgent;return!!(t&&t.indexOf("Electron")>=0)}function Lt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||Ra()}function Rp(n){return Lt()?Ra()?"Electron":(Ep.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const ka="4.1.0";function kp(n){try{const e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class Dp{constructor(e,t,i="sessionStorage"){this.storage=kp(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function Mp(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Fp(n,e=8){const t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Ii;(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ii||(Ii={}));const Np=10;function Da(n){return typeof n!="string"?n:(n=n.toUpperCase(),Ii[n]||Ii.WHITE)}function Op(n,e,t){return!Lt&&typeof n=="string"&&(e&&(n=`\x1B[${Da(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Da(t)+Np}m${n}\x1B[49m`)),n}function Bp(n,e=["constructor"]){const t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(const s of i){const o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}function os(n,e){if(!n)throw new Error("Assertion failed")}function on(){var e,t,i;let n;if(Lt()&&Ci.performance)n=(t=(e=Ci==null?void 0:Ci.performance)==null?void 0:e.now)==null?void 0:t.call(e);else if("hrtime"in sn){const r=(i=sn==null?void 0:sn.hrtime)==null?void 0:i.call(sn);n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}const an={debug:Lt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Up={enabled:!0,level:0};function ln(){}const Ma={},Fa={once:!0};class Na{constructor({id:e}={id:""}){this.VERSION=ka,this._startTs=on(),this._deltaTs=on(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Dp(`__probe-${this.id}__`,Up),this.timeStamp(`${this.id} started`),Bp(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((on()-this._startTs).toPrecision(10))}getDelta(){return Number((on()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,an.warn,arguments,Fa)}error(e){return this._getLogFunction(0,e,an.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,an.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,an.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,an.debug||an.info,arguments,Fa)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||ln,i&&[i],{tag:Lp(t)}):ln}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||ln)}group(e,t,i={collapsed:!1}){const r=Ba({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return r.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||ln)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Oa(e)}_getLogFunction(e,t,i,r,s){if(this._shouldLog(e)){s=Ba({logLevel:e,message:t,args:r,opts:s}),i=i||s.method,os(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=on();const o=s.tag||s.message;if(s.once&&o)if(!Ma[o])Ma[o]=on();else return ln;return t=zp(this.id,s.message,s),i.bind(console,t,...s.args)}return ln}}Na.VERSION=ka;function Oa(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return os(Number.isFinite(e)&&e>=0),e}function Ba(n){const{logLevel:e,message:t}=n;n.logLevel=Oa(e);const i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break}typeof n.message=="function"&&(n.message=n.message());const r=typeof n.message;return os(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}function zp(n,e,t){if(typeof e=="string"){const i=t.time?Fp(Mp(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Op(e,t.color,t.background)}return e}function Lp(n){for(const e in n)for(const t in n[e])return t||"untitled";return"empty"}const D=new Na({id:"luma.gl"}),as={};function Pi(n="id"){as[n]=as[n]||1;const e=as[n]++;return`${n}-${e}`}class ce{constructor(e,t,i){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"_device");m(this,"destroyed",!1);m(this,"allocatedBytes",0);m(this,"_attachedResources",new Set);if(!e)throw new Error("no device");this._device=e,this.props=Vp(t,i);const r=this.props.id!=="undefined"?this.props.id:Pi(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}m(ce,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Vp(n,e){const t={...e};for(const i in n)n[i]!==void 0&&(t[i]=n[i]);return t}const ke=class ke extends ce{constructor(t,i){const r={...i};(i.usage||0)&ke.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?r.indexType="uint32":i.data instanceof Uint16Array?r.indexType="uint16":i.data instanceof Uint8Array&&(r.indexType="uint8")),delete r.data;super(t,r,ke.defaultProps);m(this,"usage");m(this,"indexType");m(this,"updateTimestamp");m(this,"debugData",new ArrayBuffer(0));this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(t){return this.device.createBuffer({...this.props,...t})}_setDebugData(t,i,r){const s=ArrayBuffer.isView(t)?t.buffer:t,o=Math.min(t?t.byteLength:r,ke.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):i===0&&r===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(i,i+o)}};m(ke,"INDEX",16),m(ke,"VERTEX",32),m(ke,"UNIFORM",64),m(ke,"STORAGE",128),m(ke,"INDIRECT",256),m(ke,"QUERY_RESOLVE",512),m(ke,"MAP_READ",1),m(ke,"MAP_WRITE",2),m(ke,"COPY_SRC",4),m(ke,"COPY_DST",8),m(ke,"DEBUG_DATA_MAX_LENGTH",32),m(ke,"defaultProps",{...ce.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let L=ke;function Ua(n){const[e,t,i]=ls[n],r=n.includes("norm"),s=!r&&!n.startsWith("float"),o=n.startsWith("s");return{signedType:e,primitiveType:t,byteLength:i,normalized:r,integer:s,signed:o}}function Hp(n){const e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Wp(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function za(n){const e=ArrayBuffer.isView(n)?n.constructor:n;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(ls).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function La(n){const[,,,,e]=ls[n];return e}const ls={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function cs(n){let e;n.endsWith("-webgl")&&(n.replace("-webgl",""),e=!0);const[t,i]=n.split("x"),r=t,s=i?parseInt(i):1,o=Ua(r),a={type:r,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function $p(n,e,t){const i=t?Hp(n):n;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function Xp(n,e,t){if(!e||e>4)throw new Error(`size ${e}`);const i=e,r=za(n);return $p(r,i,t)}function Yp(n){let e;switch(n.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?e:`${e}x${n.components}`}const De="texture-compression-bc",ue="texture-compression-astc",dt="texture-compression-etc2",qp="texture-compression-etc1-webgl",Ei="texture-compression-pvrtc-webgl",us="texture-compression-atc-webgl",Ri="float32-renderable-webgl",fs="float16-renderable-webgl",jp="rgb9e5ufloat-renderable-webgl",hs="snorm8-renderable-webgl",Nn="norm16-renderable-webgl",ds="snorm16-renderable-webgl",ki="float32-filterable",Va="float16-filterable-webgl";function Ha(n){const e=Kp[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}const Kp={...{r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:hs},rg8snorm:{render:hs},"rgb8snorm-webgl":{},rgba8snorm:{render:hs},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Nn},rg16unorm:{render:Nn},"rgb16unorm-webgl":{f:Nn},rgba16unorm:{render:Nn},r16snorm:{f:ds},rg16snorm:{render:ds},"rgb16snorm-webgl":{f:Nn},rgba16snorm:{render:ds},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:fs,filter:"float16-filterable-webgl"},rg16float:{render:fs,filter:Va},rgba16float:{render:fs,filter:Va},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Ri,filter:ki},rg32float:{render:!1,filter:ki},"rgb32float-webgl":{render:Ri,filter:ki},rgba32float:{render:Ri,filter:ki},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:jp},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ri},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},...{"bc1-rgb-unorm-webgl":{f:De},"bc1-rgb-unorm-srgb-webgl":{f:De},"bc1-rgba-unorm":{f:De},"bc1-rgba-unorm-srgb":{f:De},"bc2-rgba-unorm":{f:De},"bc2-rgba-unorm-srgb":{f:De},"bc3-rgba-unorm":{f:De},"bc3-rgba-unorm-srgb":{f:De},"bc4-r-unorm":{f:De},"bc4-r-snorm":{f:De},"bc5-rg-unorm":{f:De},"bc5-rg-snorm":{f:De},"bc6h-rgb-ufloat":{f:De},"bc6h-rgb-float":{f:De},"bc7-rgba-unorm":{f:De},"bc7-rgba-unorm-srgb":{f:De},"etc2-rgb8unorm":{f:dt},"etc2-rgb8unorm-srgb":{f:dt},"etc2-rgb8a1unorm":{f:dt},"etc2-rgb8a1unorm-srgb":{f:dt},"etc2-rgba8unorm":{f:dt},"etc2-rgba8unorm-srgb":{f:dt},"eac-r11unorm":{f:dt},"eac-r11snorm":{f:dt},"eac-rg11unorm":{f:dt},"eac-rg11snorm":{f:dt},"astc-4x4-unorm":{f:ue},"astc-4x4-unorm-srgb":{f:ue},"astc-5x4-unorm":{f:ue},"astc-5x4-unorm-srgb":{f:ue},"astc-5x5-unorm":{f:ue},"astc-5x5-unorm-srgb":{f:ue},"astc-6x5-unorm":{f:ue},"astc-6x5-unorm-srgb":{f:ue},"astc-6x6-unorm":{f:ue},"astc-6x6-unorm-srgb":{f:ue},"astc-8x5-unorm":{f:ue},"astc-8x5-unorm-srgb":{f:ue},"astc-8x6-unorm":{f:ue},"astc-8x6-unorm-srgb":{f:ue},"astc-8x8-unorm":{f:ue},"astc-8x8-unorm-srgb":{f:ue},"astc-10x5-unorm":{f:ue},"astc-10x5-unorm-srgb":{f:ue},"astc-10x6-unorm":{f:ue},"astc-10x6-unorm-srgb":{f:ue},"astc-10x8-unorm":{f:ue},"astc-10x8-unorm-srgb":{f:ue},"astc-10x10-unorm":{f:ue},"astc-10x10-unorm-srgb":{f:ue},"astc-12x10-unorm":{f:ue},"astc-12x10-unorm-srgb":{f:ue},"astc-12x12-unorm":{f:ue},"astc-12x12-unorm-srgb":{f:ue},"pvrtc-rgb4unorm-webgl":{f:Ei},"pvrtc-rgba4unorm-webgl":{f:Ei},"pvrtc-rbg2unorm-webgl":{f:Ei},"pvrtc-rgba2unorm-webgl":{f:Ei},"etc1-rbg-unorm-webgl":{f:qp},"atc-rgb-unorm-webgl":{f:us},"atc-rgba-unorm-webgl":{f:us},"atc-rgbai-unorm-webgl":{f:us}}},Zp=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Qp=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class Jp{getInfo(e){return Wa(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return Zp.some(t=>e.startsWith(t))}getCapabilities(e){const t=Ha(e),i={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=Wa(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=r==null?void 0:r.signed,a=r==null?void 0:r.integer,l=r==null?void 0:r.webgl;return i.render&&(i.render=!o),i.filter&&(i.filter=!s&&!o&&!a&&!l),i}}const Vt=new Jp;function Wa(n){let e=Gp(n);if(Vt.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const i=em(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}const t=Qp.exec(n);if(t){const[,i,r,s,o,a]=t,l=`${s}${r}`,c=Ua(l),u=c.byteLength*8,f=i.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:c.signedType,components:f,channels:i,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*i.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function Gp(n){var s;const e=Ha(n),t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||((s=e.channels)==null?void 0:s.length)||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function em(n){const t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){const[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return null}function tm(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function nm(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}class im{}class rm{constructor(e=[],t){m(this,"features");m(this,"disabledFeatures");this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const Sr=class Sr{constructor(e){m(this,"id");m(this,"props");m(this,"userData",{});m(this,"statsManager",Ea);m(this,"timestamp",0);m(this,"_reused",!1);m(this,"_lumaData",{});m(this,"_textureCaps",{});this.props={...Sr.defaultProps,...e},this.id=this.props.id||Pi(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return cs(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Vt.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){const r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return tm(e)}getExternalImageSize(e){return nm(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Vt.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:D.error(e.message,t,...i)}debug(){if(this.props.debug)debugger;else D.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
2
|
+
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=Vt.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&L.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};m(Sr,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[i,r]=e.getDevicePixelSize();D.log(1,`${e} resized => ${i}x${r}px`)()},onPositionChange:(e,t)=>{const[i,r]=e.getPosition();D.log(1,`${e} repositioned => ${i},${r}`)()},onVisibilityChange:e=>D.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>D.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:D.get("debug")||void 0,debugShaders:D.get("debug-shaders")||void 0,debugFramebuffers:!!D.get("debug-framebuffers"),debugFactories:!!D.get("debug-factories"),debugWebGL:!!D.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let Ht=Sr;const sm="set luma.log.level=1 (or higher) to trace rendering",$a="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ii=class ii{constructor(){m(this,"stats",Ea);m(this,"log",D);m(this,"VERSION","9.2.6");m(this,"spector");m(this,"preregisteredAdapters",new Map);if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw D.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),D.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");D.error("This version of luma.gl has already been initialized")()}D.log(1,`${this.VERSION} - ${sm}`)(),globalThis.luma=this}async createDevice(e={}){const t={...ii.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error($a);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){var s;const i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error($a);return await((s=r==null?void 0:r.attach)==null?void 0:s.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>{var r;return(r=i.isSupported)==null?void 0:r.call(i)}).map(i=>i.type)}getBestAvailableAdapterType(e=[]){var r,s;const t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(const o of t)if((s=(r=i.get(o))==null?void 0:r.isSupported)!=null&&s.call(r))return o;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));const r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){var s;const r=this._getAdapterMap(t).get("webgl");r||D.warn("enforceWebGL2: webgl adapter not found")(),(s=r==null?void 0:r.enforceWebGL2)==null||s.call(r,e)}setDefaultDeviceProps(e){Object.assign(ii.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?D.warn("WebGL1 is not supported",e)():D.warn("Unknown handle type",e)(),null)}};m(ii,"defaultProps",{...Ht.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let ps=ii;const om=new ps;class am{get pageLoaded(){return um()}}const lm=Lt()&&typeof document<"u",cm=()=>lm&&document.readyState==="complete";let Di=null;function um(){return Di||(cm()||typeof window>"u"?Di=Promise.resolve():Di=new Promise(n=>window.addEventListener("load",()=>n()))),Di}function fm(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}const Qt=class Qt{constructor(e){m(this,"id");m(this,"props");m(this,"canvas");m(this,"htmlCanvas");m(this,"offscreenCanvas");m(this,"type");m(this,"initialized");m(this,"isInitialized",!1);m(this,"isVisible",!0);m(this,"cssWidth");m(this,"cssHeight");m(this,"devicePixelRatio");m(this,"devicePixelWidth");m(this,"devicePixelHeight");m(this,"drawingBufferWidth");m(this,"drawingBufferHeight");m(this,"_initializedResolvers",fm());m(this,"_resizeObserver");m(this,"_intersectionObserver");m(this,"_position");m(this,"destroyed",!1);var t,i;if(this.props={...Qt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Lt()?e.canvas?typeof e.canvas=="string"?this.canvas=dm(e.canvas):this.canvas=e.canvas:this.canvas=pm(e):this.canvas={width:e.width||1,height:e.height||1},Qt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Qt.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((t=this.htmlCanvas)==null?void 0:t.clientWidth)||this.canvas.width,this.cssHeight=((i=this.htmlCanvas)==null?void 0:i.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],Qt.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(r=>this._handleIntersection(r)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(r=>this._handleResize(r));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return mm(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;((t=this.htmlCanvas)==null?void 0:t.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(r=>r.target===this.canvas);if(!t)return;const i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){var l,c;const t=e.find(u=>u.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;const i=this.getDevicePixelSize(),r=((l=t.devicePixelContentBoxSize)==null?void 0:l[0].inlineSize)||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=((c=t.devicePixelContentBoxSize)==null?void 0:c[0].blockSize)||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(r,o)),this.devicePixelHeight=Math.max(1,Math.min(s,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var t,i,r;const e=(t=this.htmlCanvas)==null?void 0:t.getBoundingClientRect();if(e){const s=[e.left,e.top];if(this._position??(this._position=s),s[0]!==this._position[0]||s[1]!==this._position[1]){const a=this._position;this._position=s,(r=(i=this.device.props).onPositionChange)==null||r.call(i,this,{oldPosition:a})}}}};m(Qt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let Mi=Qt;function hm(n){if(typeof n=="string"){const e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function dm(n){const e=document.getElementById(n);if(!Mi.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function pm(n){const{width:e,height:t}=n,i=document.createElement("canvas");i.id=Pi("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n!=null&&n.visible||(i.style.visibility="hidden");const r=hm((n==null?void 0:n.container)||null);return r.insertBefore(i,r.firstChild),i}function mm(n,e,t,i,r){const s=n,o=Xa(s[0],e,t);let a=Ya(s[1],e,i,r),l=Xa(s[0]+1,e,t);const c=l===t-1?l:l-1;l=Ya(s[1]+1,e,i,r);let u;return r?(l=l===0?l:l+1,u=a,a=l):u=l===i-1?l:l-1,{x:o,y:a,width:Math.max(c-o+1,1),height:Math.max(u-a+1,1)}}function Xa(n,e,t){return Math.min(Math.round(n*e),t-1)}function Ya(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}const ri=class ri extends ce{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=ri.normalizeProps(e,t),super(e,t,ri.defaultProps)}static normalizeProps(e,t){return t}};m(ri,"defaultProps",{...ce.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let cn=ri;const gm={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ce=class Ce extends ce{constructor(t,i){i=Ce.normalizeProps(t,i);super(t,i,Ce.defaultProps);m(this,"dimension");m(this,"baseDimension");m(this,"format");m(this,"width");m(this,"height");m(this,"depth");m(this,"mipLevels");m(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=gm[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.props.width===void 0||this.props.height===void 0)if(t.isExternalImage(i.data)){const r=t.getExternalImageSize(i.data);this.width=(r==null?void 0:r.width)||1,this.height=(r==null?void 0:r.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&D.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(t){this.sampler=t instanceof cn?t:this.device.createSampler(t)}clone(t){return this.device.createTexture({...this.props,...t})}static normalizeProps(t,i){const r={...i},{width:s,height:o}=r;return typeof s=="number"&&(r.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(r.height=Math.max(1,Math.ceil(o))),r}_initializeData(t){this.device.isExternalImage(t)?this.copyExternalImage({image:t,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):t&&this.copyImageData({data:t,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(t){const{width:i,height:r,depth:s}=this,o={...Ce.defaultCopyDataOptions,width:i,height:r,depth:s,...t},a=this.device.getTextureFormatInfo(this.format);if(!t.bytesPerRow&&!a.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return o.bytesPerRow=t.bytesPerRow||i*(a.bytesPerPixel||4),o.rowsPerImage=t.rowsPerImage||r,o}_normalizeCopyExternalImageOptions(t){const i=this.device.getExternalImageSize(t.image),r={...Ce.defaultCopyExternalImageOptions,...i,...t};return r.width=Math.min(r.width,this.width-r.x),r.height=Math.min(r.height,this.height-r.y),r}};m(Ce,"SAMPLE",4),m(Ce,"STORAGE",8),m(Ce,"RENDER",16),m(Ce,"COPY_SRC",1),m(Ce,"COPY_DST",2),m(Ce,"TEXTURE",4),m(Ce,"RENDER_ATTACHMENT",16),m(Ce,"defaultProps",{...ce.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Ce.TEXTURE|Ce.RENDER_ATTACHMENT|Ce.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),m(Ce,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),m(Ce,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let Q=Ce;const Tr=class Tr extends ce{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,Tr.defaultProps)}};m(Tr,"defaultProps",{...ce.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Fi=Tr;function _m(n,e,t){let i="";const r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++)for(i+=qa(r[a-1],a,t);s.length>o&&s[o].lineNum===a;){const l=s[o++];i+=ms(l,r,l.lineNum,{...t,inlineSource:!1})}for(;s.length>o;){const a=s[o++];i+=ms(a,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(const a of n)i+=ms(a,r,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return i}}function ms(n,e,t,i){if(i!=null&&i.inlineSource){const s=xm(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^
|
|
3
3
|
`:"";return`
|
|
4
4
|
${s}${o}${n.type.toUpperCase()}: ${n.message}
|
|
5
5
|
|
|
6
|
-
`}const r=n.type==="error"?"red":"#8B4000";return i!=null&&i.html?`<div class='luma-compiler-log-error' style="color:${r};"><b> ${n.type.toUpperCase()}: ${n.message}</b></div>`:`${n.type.toUpperCase()}: ${n.message}`}function
|
|
7
|
-
`}`}function
|
|
6
|
+
`}const r=n.type==="error"?"red":"#8B4000";return i!=null&&i.html?`<div class='luma-compiler-log-error' style="color:${r};"><b> ${n.type.toUpperCase()}: ${n.message}</b></div>`:`${n.type.toUpperCase()}: ${n.message}`}function xm(n,e,t){let i="";for(let r=e-2;r<=e;r++){const s=n[r-1];s!==void 0&&(i+=qa(s,e,t))}return i}function qa(n,e,t){const i=t!=null&&t.html?vm(n):n;return`${ym(String(e),4)}: ${i}${t!=null&&t.html?"<br/>":`
|
|
7
|
+
`}`}function ym(n,e){let t="";for(let i=n.length;i<e;++i)t+=" ";return t+n}function vm(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}const wr=class wr extends ce{constructor(t,i){i={...i,debugShaders:i.debugShaders||t.props.debugShaders||"errors"};super(t,{id:bm(i),...i},wr.defaultProps);m(this,"stage");m(this,"source");m(this,"compilationStatus","pending");this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const t=this.props.debugShaders;switch(t){case"never":return;case"errors":if(this.compilationStatus==="success")return;break}const i=await this.getCompilationInfo();t==="warnings"&&(i==null?void 0:i.length)===0||this._displayShaderLog(i,this.id)}_displayShaderLog(t,i){var u;if(typeof document>"u"||!(document!=null&&document.createElement))return;const r=i,s=`${this.stage} shader "${r}"`;let o=_m(t,this.source,{showSourceCode:"all",html:!0});const a=this.getTranslatedSource();a&&(o+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${a}</pre></code>`);const l=document.createElement("Button");l.innerHTML=`
|
|
8
8
|
<h1>Compilation error in ${s}</h1><br /><br />
|
|
9
9
|
<code style="user-select:text;"><pre>
|
|
10
10
|
${o}
|
|
11
|
-
</pre></code>`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(u=document.getElementsByClassName("luma-compiler-log-error")[0])==null||u.scrollIntoView(),l.onclick=()=>{const f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}};g(Tr,"defaultProps",{...le.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Ni=Tr;function cg(n){return ug(n.source)||n.id||Pi(`unnamed ${n.stage}-shader`)}function ug(n,e="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n);return i?i[1]:e}const wr=class wr extends le{constructor(t,i={}){super(t,i,wr.defaultProps);g(this,"width");g(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(t){const i=this.colorAttachments.map(s=>s.texture.clone(t)),r=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(t);return this.device.createFramebuffer({...this.props,colorAttachments:i,depthStencilAttachment:r})}resize(t){let i=!t;if(t){const[r,s]=Array.isArray(t)?t:[t.width,t.height];i=i||s!==this.height||r!==this.width,this.width=r,this.height=s}i&&(D.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((i,r)=>{if(typeof i=="string"){const s=this.createColorTexture(i,r);return this.attachResource(s),s.view}return i instanceof Q?i.view:i});const t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){const i=this.createDepthStencilTexture(t);this.attachResource(i),this.depthStencilAttachment=i.view}else t instanceof Q?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t,i){return this.device.createTexture({id:`${this.id}-color-attachment-${i}`,usage:Q.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(t){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Q.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,i){for(let r=0;r<this.colorAttachments.length;++r)if(this.colorAttachments[r]){const s=this.colorAttachments[r].texture.clone({width:t,height:i});this.destroyAttachedResource(this.colorAttachments[r]),this.colorAttachments[r]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){const r=this.depthStencilAttachment.texture.clone({width:t,height:i});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=r.view,this.attachResource(r)}this.updateAttachments()}};g(wr,"defaultProps",{...le.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let Oi=wr;const Ar=class Ar extends le{constructor(t,i){super(t,i,Ar.defaultProps);g(this,"shaderLayout");g(this,"bufferLayout");g(this,"linkStatus","pending");g(this,"hash","");this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};g(Ar,"defaultProps",{...le.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Wt=Ar;const ut=class ut extends le{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=ut.normalizeProps(e,t),super(e,t,ut.defaultProps)}static normalizeProps(e,t){return t}};g(ut,"defaultClearColor",[0,0,0,1]),g(ut,"defaultClearDepth",1),g(ut,"defaultClearStencil",0),g(ut,"defaultProps",{...le.defaultProps,framebuffer:null,parameters:void 0,clearColor:ut.defaultClearColor,clearColors:void 0,clearDepth:ut.defaultClearDepth,clearStencil:ut.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let gs=ut;const Cr=class Cr extends le{constructor(t,i){super(t,i,Cr.defaultProps);g(this,"hash","");g(this,"shaderLayout");this.shaderLayout=i.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};g(Cr,"defaultProps",{...le.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Bi=Cr;const Ir=class Ir extends le{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ir.defaultProps)}};g(Ir,"defaultProps",{...le.defaultProps,measureExecutionTime:void 0});let ms=Ir;const Pr=class Pr extends le{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Pr.defaultProps)}};g(Pr,"defaultProps",{...le.defaultProps});let _s=Pr;function qa(n){return pg[n]}function fg(n){const[e,t]=dg[n],i=e==="i32"||e==="u32",r=e!=="u32",s=hg[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:r}}const hg={f32:4,f16:2,i32:4,u32:4},dg={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},pg={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function ja(n,e){const t={};for(const i of n.attributes){const r=mg(n,e,i.name);r&&(t[i.name]=r)}return t}function gg(n,e,t=16){const i=ja(n,e),r=new Array(t).fill(null);for(const s of Object.values(i))r[s.location]=s;return r}function mg(n,e,t){const i=_g(n,t),r=yg(e,t);if(!i)return null;const s=fg(i.type),o=Fp(s),a=(r==null?void 0:r.vertexFormat)||o,l=ls(a);return{attributeName:(r==null?void 0:r.attributeName)||i.name,bufferName:(r==null?void 0:r.bufferName)||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:s.integer,stepMode:(r==null?void 0:r.stepMode)||i.stepMode||"vertex",byteOffset:(r==null?void 0:r.byteOffset)||0,byteStride:(r==null?void 0:r.byteStride)||0}}function _g(n,e){const t=n.attributes.find(i=>i.name===e);return t||D.warn(`shader layout attribute "${e}" not present in shader`),t||null}function yg(n,e){xg(n);let t=vg(n,e);return t||(t=bg(n,e),t)?t:(D.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function xg(n){for(const e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&D.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function vg(n,e){for(const t of n)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function bg(n,e){var t;for(const i of n){let r=i.byteStride;if(typeof i.byteStride!="number")for(const o of i.attributes||[]){const a=ls(o.format);r+=a.byteLength}const s=(t=i.attributes)==null?void 0:t.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:r}}return null}const Er=class Er extends le{constructor(t,i){super(t,i,Er.defaultProps);g(this,"maxVertexAttributes");g(this,"attributeInfos");g(this,"indexBuffer",null);g(this,"attributes");this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=gg(i.shaderLayout,i.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(t,i){this.device.reportError(new Error("constant attributes not supported"),this)()}};g(Er,"defaultProps",{...le.defaultProps,shaderLayout:void 0,bufferLayout:[]});let ys=Er;const Rr=class Rr extends le{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Rr.defaultProps)}};g(Rr,"defaultProps",{...le.defaultProps,layout:void 0,buffers:{}});let xs=Rr;const kr=class kr extends le{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,kr.defaultProps)}};g(kr,"defaultProps",{...le.defaultProps,type:void 0,count:void 0});let vs=kr,Ui;function Ka(n){return(!Ui||Ui.byteLength<n)&&(Ui=new ArrayBuffer(n)),Ui}function Sg(n,e){const t=Ka(n.BYTES_PER_ELEMENT*e);return new n(t,0,e)}function Tg(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function zi(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":Tg(n)}const wg=1024;class Ag{constructor(e,t={}){g(this,"layout",{});g(this,"byteLength");let i=0;for(const[s,o]of Object.entries(e)){const a=qa(o),{type:l,components:c}=a,u=c*((t==null?void 0:t[s])??1);i=kp(i,u);const f=i;i+=u,this.layout[s]={type:l,size:u,offset:f}}i+=(4-i%4)%4;const r=i*4;this.byteLength=Math.max(r,wg)}getData(e){const t=Ka(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[r,s]of Object.entries(e)){const o=this.layout[r];if(!o){D.warn(`Supplied uniform value ${r} not present in uniform block layout`)();continue}const{type:a,size:l,offset:c}=o,u=i[a];if(l===1){if(typeof s!="number"&&typeof s!="boolean"){D.warn(`Supplied value for single component uniform ${r} is not a number: ${s}`)();continue}u[c]=Number(s)}else{if(!zi(s)){D.warn(`Supplied value for multi component / array uniform ${r} is not a numeric array: ${s}`)();continue}u.set(s,c)}}return new Uint8Array(t,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}function Cg(n,e,t=16){if(n!==e)return!1;const i=n,r=e;if(!zi(i))return!1;if(zi(r)&&i.length===r.length){for(let s=0;s<i.length;++s)if(r[s]!==i[s])return!1}return!0}function Ig(n){return zi(n)?n.slice():n}class Pg{constructor(e){g(this,"name");g(this,"uniforms",{});g(this,"modifiedUniforms",{});g(this,"modified",!0);g(this,"bindingLayout",{});g(this,"needsRedraw","initialized");var t;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&(e!=null&&e.shaderLayout)){const i=(t=e==null?void 0:e.shaderLayout.bindings)==null?void 0:t.find(s=>s.type==="uniform"&&s.name===(e==null?void 0:e.name));if(!i)throw new Error(e==null?void 0:e.name);const r=i;for(const s of r.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Cg(this.uniforms[e],t)||(this.uniforms[e]=Ig(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}class ye{constructor(e){g(this,"uniformBlocks",new Map);g(this,"uniformBufferLayouts",new Map);g(this,"uniformBuffers",new Map);for(const[t,i]of Object.entries(e)){const r=t,s=new Ag(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(r,s);const o=new Pg({name:t});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(r,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[i,r]of Object.entries(e))(t=this.uniformBlocks.get(i))==null||t.setUniforms(r);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var i,r;const t=((i=this.uniformBlocks.get(e))==null?void 0:i.getAllUniforms())||{};return(r=this.uniformBufferLayouts.get(e))==null?void 0:r.getData(t)}createUniformBuffer(e,t,i){i&&this.setUniforms(i);const r=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:L.UNIFORM|L.COPY_DST,byteLength:r}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const i=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:L.UNIFORM|L.COPY_DST,byteLength:i});this.uniformBuffers.set(t,r)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(t);e||(e=i)}return e&&D.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var s;const t=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),r=!1;if(i&&(t!=null&&t.needsRedraw)){r||(r=t.needsRedraw);const o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i==null||i.write(o);const a=(s=this.uniformBlocks.get(e))==null?void 0:s.getAllUniforms();D.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}}var $t;(function(n){n[n.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",n[n.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",n[n.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n[n.ZERO=0]="ZERO",n[n.ONE=1]="ONE",n[n.SRC_COLOR=768]="SRC_COLOR",n[n.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.DST_ALPHA=772]="DST_ALPHA",n[n.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",n[n.DST_COLOR=774]="DST_COLOR",n[n.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",n[n.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",n[n.CONSTANT_COLOR=32769]="CONSTANT_COLOR",n[n.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",n[n.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",n[n.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",n[n.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",n[n.BLEND_EQUATION=32777]="BLEND_EQUATION",n[n.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",n[n.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",n[n.BLEND_DST_RGB=32968]="BLEND_DST_RGB",n[n.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",n[n.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",n[n.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",n[n.BLEND_COLOR=32773]="BLEND_COLOR",n[n.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",n[n.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",n[n.LINE_WIDTH=2849]="LINE_WIDTH",n[n.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",n[n.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",n[n.CULL_FACE_MODE=2885]="CULL_FACE_MODE",n[n.FRONT_FACE=2886]="FRONT_FACE",n[n.DEPTH_RANGE=2928]="DEPTH_RANGE",n[n.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",n[n.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",n[n.DEPTH_FUNC=2932]="DEPTH_FUNC",n[n.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",n[n.STENCIL_FUNC=2962]="STENCIL_FUNC",n[n.STENCIL_FAIL=2964]="STENCIL_FAIL",n[n.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",n[n.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",n[n.STENCIL_REF=2967]="STENCIL_REF",n[n.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",n[n.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",n[n.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",n[n.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",n[n.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",n[n.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",n[n.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",n[n.VIEWPORT=2978]="VIEWPORT",n[n.SCISSOR_BOX=3088]="SCISSOR_BOX",n[n.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",n[n.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",n[n.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",n[n.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",n[n.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",n[n.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",n[n.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",n[n.RED_BITS=3410]="RED_BITS",n[n.GREEN_BITS=3411]="GREEN_BITS",n[n.BLUE_BITS=3412]="BLUE_BITS",n[n.ALPHA_BITS=3413]="ALPHA_BITS",n[n.DEPTH_BITS=3414]="DEPTH_BITS",n[n.STENCIL_BITS=3415]="STENCIL_BITS",n[n.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",n[n.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",n[n.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",n[n.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",n[n.SAMPLES=32937]="SAMPLES",n[n.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",n[n.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",n[n.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",n[n.VENDOR=7936]="VENDOR",n[n.RENDERER=7937]="RENDERER",n[n.VERSION=7938]="VERSION",n[n.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",n[n.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",n[n.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",n[n.STATIC_DRAW=35044]="STATIC_DRAW",n[n.STREAM_DRAW=35040]="STREAM_DRAW",n[n.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BUFFER_SIZE=34660]="BUFFER_SIZE",n[n.BUFFER_USAGE=34661]="BUFFER_USAGE",n[n.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",n[n.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",n[n.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",n[n.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",n[n.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",n[n.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",n[n.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",n[n.CULL_FACE=2884]="CULL_FACE",n[n.FRONT=1028]="FRONT",n[n.BACK=1029]="BACK",n[n.FRONT_AND_BACK=1032]="FRONT_AND_BACK",n[n.BLEND=3042]="BLEND",n[n.DEPTH_TEST=2929]="DEPTH_TEST",n[n.DITHER=3024]="DITHER",n[n.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",n[n.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",n[n.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",n[n.SCISSOR_TEST=3089]="SCISSOR_TEST",n[n.STENCIL_TEST=2960]="STENCIL_TEST",n[n.NO_ERROR=0]="NO_ERROR",n[n.INVALID_ENUM=1280]="INVALID_ENUM",n[n.INVALID_VALUE=1281]="INVALID_VALUE",n[n.INVALID_OPERATION=1282]="INVALID_OPERATION",n[n.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",n[n.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",n[n.CW=2304]="CW",n[n.CCW=2305]="CCW",n[n.DONT_CARE=4352]="DONT_CARE",n[n.FASTEST=4353]="FASTEST",n[n.NICEST=4354]="NICEST",n[n.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.INT=5124]="INT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.DOUBLE=5130]="DOUBLE",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.ALPHA=6406]="ALPHA",n[n.RGB=6407]="RGB",n[n.RGBA=6408]="RGBA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",n[n.VERTEX_SHADER=35633]="VERTEX_SHADER",n[n.COMPILE_STATUS=35713]="COMPILE_STATUS",n[n.DELETE_STATUS=35712]="DELETE_STATUS",n[n.LINK_STATUS=35714]="LINK_STATUS",n[n.VALIDATE_STATUS=35715]="VALIDATE_STATUS",n[n.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",n[n.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",n[n.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",n[n.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",n[n.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",n[n.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",n[n.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",n[n.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",n[n.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",n[n.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",n[n.SHADER_TYPE=35663]="SHADER_TYPE",n[n.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",n[n.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",n[n.NEVER=512]="NEVER",n[n.LESS=513]="LESS",n[n.EQUAL=514]="EQUAL",n[n.LEQUAL=515]="LEQUAL",n[n.GREATER=516]="GREATER",n[n.NOTEQUAL=517]="NOTEQUAL",n[n.GEQUAL=518]="GEQUAL",n[n.ALWAYS=519]="ALWAYS",n[n.KEEP=7680]="KEEP",n[n.REPLACE=7681]="REPLACE",n[n.INCR=7682]="INCR",n[n.DECR=7683]="DECR",n[n.INVERT=5386]="INVERT",n[n.INCR_WRAP=34055]="INCR_WRAP",n[n.DECR_WRAP=34056]="DECR_WRAP",n[n.NEAREST=9728]="NEAREST",n[n.LINEAR=9729]="LINEAR",n[n.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",n[n.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",n[n.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",n[n.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE=5890]="TEXTURE",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n[n.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",n[n.TEXTURE0=33984]="TEXTURE0",n[n.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",n[n.REPEAT=10497]="REPEAT",n[n.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n[n.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",n[n.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_CUBE=35680]="SAMPLER_CUBE",n[n.LOW_FLOAT=36336]="LOW_FLOAT",n[n.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",n[n.HIGH_FLOAT=36338]="HIGH_FLOAT",n[n.LOW_INT=36339]="LOW_INT",n[n.MEDIUM_INT=36340]="MEDIUM_INT",n[n.HIGH_INT=36341]="HIGH_INT",n[n.FRAMEBUFFER=36160]="FRAMEBUFFER",n[n.RENDERBUFFER=36161]="RENDERBUFFER",n[n.RGBA4=32854]="RGBA4",n[n.RGB5_A1=32855]="RGB5_A1",n[n.RGB565=36194]="RGB565",n[n.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",n[n.STENCIL_INDEX=6401]="STENCIL_INDEX",n[n.STENCIL_INDEX8=36168]="STENCIL_INDEX8",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n[n.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",n[n.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",n[n.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",n[n.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",n[n.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",n[n.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",n[n.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",n[n.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",n[n.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",n[n.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",n[n.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",n[n.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",n[n.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",n[n.NONE=0]="NONE",n[n.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",n[n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",n[n.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",n[n.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",n[n.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",n[n.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",n[n.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",n[n.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",n[n.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",n[n.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",n[n.READ_BUFFER=3074]="READ_BUFFER",n[n.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",n[n.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",n[n.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",n[n.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",n[n.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",n[n.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",n[n.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",n[n.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",n[n.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",n[n.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",n[n.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",n[n.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",n[n.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",n[n.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",n[n.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",n[n.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",n[n.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",n[n.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",n[n.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",n[n.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",n[n.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",n[n.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",n[n.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",n[n.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",n[n.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",n[n.RED=6403]="RED",n[n.RGB8=32849]="RGB8",n[n.RGBA8=32856]="RGBA8",n[n.RGB10_A2=32857]="RGB10_A2",n[n.TEXTURE_3D=32879]="TEXTURE_3D",n[n.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",n[n.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",n[n.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",n[n.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",n[n.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",n[n.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",n[n.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",n[n.SRGB=35904]="SRGB",n[n.SRGB8=35905]="SRGB8",n[n.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",n[n.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",n[n.RGBA32F=34836]="RGBA32F",n[n.RGB32F=34837]="RGB32F",n[n.RGBA16F=34842]="RGBA16F",n[n.RGB16F=34843]="RGB16F",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",n[n.R11F_G11F_B10F=35898]="R11F_G11F_B10F",n[n.RGB9_E5=35901]="RGB9_E5",n[n.RGBA32UI=36208]="RGBA32UI",n[n.RGB32UI=36209]="RGB32UI",n[n.RGBA16UI=36214]="RGBA16UI",n[n.RGB16UI=36215]="RGB16UI",n[n.RGBA8UI=36220]="RGBA8UI",n[n.RGB8UI=36221]="RGB8UI",n[n.RGBA32I=36226]="RGBA32I",n[n.RGB32I=36227]="RGB32I",n[n.RGBA16I=36232]="RGBA16I",n[n.RGB16I=36233]="RGB16I",n[n.RGBA8I=36238]="RGBA8I",n[n.RGB8I=36239]="RGB8I",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.R8=33321]="R8",n[n.RG8=33323]="RG8",n[n.R16F=33325]="R16F",n[n.R32F=33326]="R32F",n[n.RG16F=33327]="RG16F",n[n.RG32F=33328]="RG32F",n[n.R8I=33329]="R8I",n[n.R8UI=33330]="R8UI",n[n.R16I=33331]="R16I",n[n.R16UI=33332]="R16UI",n[n.R32I=33333]="R32I",n[n.R32UI=33334]="R32UI",n[n.RG8I=33335]="RG8I",n[n.RG8UI=33336]="RG8UI",n[n.RG16I=33337]="RG16I",n[n.RG16UI=33338]="RG16UI",n[n.RG32I=33339]="RG32I",n[n.RG32UI=33340]="RG32UI",n[n.R8_SNORM=36756]="R8_SNORM",n[n.RG8_SNORM=36757]="RG8_SNORM",n[n.RGB8_SNORM=36758]="RGB8_SNORM",n[n.RGBA8_SNORM=36759]="RGBA8_SNORM",n[n.RGB10_A2UI=36975]="RGB10_A2UI",n[n.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",n[n.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.HALF_FLOAT=5131]="HALF_FLOAT",n[n.RG=33319]="RG",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",n[n.CURRENT_QUERY=34917]="CURRENT_QUERY",n[n.QUERY_RESULT=34918]="QUERY_RESULT",n[n.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",n[n.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",n[n.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",n[n.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",n[n.DRAW_BUFFER0=34853]="DRAW_BUFFER0",n[n.DRAW_BUFFER1=34854]="DRAW_BUFFER1",n[n.DRAW_BUFFER2=34855]="DRAW_BUFFER2",n[n.DRAW_BUFFER3=34856]="DRAW_BUFFER3",n[n.DRAW_BUFFER4=34857]="DRAW_BUFFER4",n[n.DRAW_BUFFER5=34858]="DRAW_BUFFER5",n[n.DRAW_BUFFER6=34859]="DRAW_BUFFER6",n[n.DRAW_BUFFER7=34860]="DRAW_BUFFER7",n[n.DRAW_BUFFER8=34861]="DRAW_BUFFER8",n[n.DRAW_BUFFER9=34862]="DRAW_BUFFER9",n[n.DRAW_BUFFER10=34863]="DRAW_BUFFER10",n[n.DRAW_BUFFER11=34864]="DRAW_BUFFER11",n[n.DRAW_BUFFER12=34865]="DRAW_BUFFER12",n[n.DRAW_BUFFER13=34866]="DRAW_BUFFER13",n[n.DRAW_BUFFER14=34867]="DRAW_BUFFER14",n[n.DRAW_BUFFER15=34868]="DRAW_BUFFER15",n[n.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",n[n.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",n[n.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",n[n.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",n[n.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",n[n.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",n[n.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",n[n.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",n[n.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",n[n.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",n[n.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",n[n.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",n[n.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",n[n.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",n[n.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",n[n.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",n[n.SAMPLER_3D=35679]="SAMPLER_3D",n[n.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",n[n.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",n[n.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",n[n.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",n[n.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",n[n.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",n[n.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",n[n.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",n[n.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",n[n.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",n[n.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",n[n.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",n[n.MAX_SAMPLES=36183]="MAX_SAMPLES",n[n.SAMPLER_BINDING=35097]="SAMPLER_BINDING",n[n.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",n[n.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",n[n.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",n[n.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",n[n.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",n[n.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",n[n.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",n[n.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",n[n.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",n[n.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",n[n.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",n[n.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",n[n.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",n[n.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",n[n.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",n[n.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",n[n.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",n[n.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",n[n.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",n[n.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",n[n.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",n[n.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",n[n.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",n[n.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",n[n.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",n[n.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",n[n.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",n[n.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",n[n.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",n[n.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",n[n.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",n[n.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",n[n.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",n[n.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",n[n.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",n[n.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",n[n.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",n[n.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",n[n.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",n[n.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",n[n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n[n.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",n[n.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",n[n.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",n[n.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",n[n.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",n[n.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",n[n.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",n[n.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",n[n.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",n[n.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",n[n.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",n[n.UNIFORM_TYPE=35383]="UNIFORM_TYPE",n[n.UNIFORM_SIZE=35384]="UNIFORM_SIZE",n[n.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",n[n.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",n[n.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",n[n.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",n[n.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",n[n.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",n[n.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",n[n.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",n[n.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",n[n.OBJECT_TYPE=37138]="OBJECT_TYPE",n[n.SYNC_CONDITION=37139]="SYNC_CONDITION",n[n.SYNC_STATUS=37140]="SYNC_STATUS",n[n.SYNC_FLAGS=37141]="SYNC_FLAGS",n[n.SYNC_FENCE=37142]="SYNC_FENCE",n[n.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",n[n.UNSIGNALED=37144]="UNSIGNALED",n[n.SIGNALED=37145]="SIGNALED",n[n.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",n[n.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",n[n.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",n[n.WAIT_FAILED=37149]="WAIT_FAILED",n[n.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",n[n.COLOR=6144]="COLOR",n[n.DEPTH=6145]="DEPTH",n[n.STENCIL=6146]="STENCIL",n[n.MIN=32775]="MIN",n[n.MAX=32776]="MAX",n[n.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",n[n.STREAM_READ=35041]="STREAM_READ",n[n.STREAM_COPY=35042]="STREAM_COPY",n[n.STATIC_READ=35045]="STATIC_READ",n[n.STATIC_COPY=35046]="STATIC_COPY",n[n.DYNAMIC_READ=35049]="DYNAMIC_READ",n[n.DYNAMIC_COPY=35050]="DYNAMIC_COPY",n[n.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",n[n.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",n[n.INVALID_INDEX=4294967295]="INVALID_INDEX",n[n.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",n[n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",n[n.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",n[n.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",n[n.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",n[n.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",n[n.R16_EXT=33322]="R16_EXT",n[n.RG16_EXT=33324]="RG16_EXT",n[n.RGB16_EXT=32852]="RGB16_EXT",n[n.RGBA16_EXT=32859]="RGBA16_EXT",n[n.R16_SNORM_EXT=36760]="R16_SNORM_EXT",n[n.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",n[n.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",n[n.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",n[n.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",n[n.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",n[n.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",n[n.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",n[n.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",n[n.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",n[n.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",n[n.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",n[n.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",n[n.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",n[n.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",n[n.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",n[n.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",n[n.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",n[n.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",n[n.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",n[n.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",n[n.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",n[n.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",n[n.LINE_WEBGL=6913]="LINE_WEBGL",n[n.FILL_WEBGL=6914]="FILL_WEBGL",n[n.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",n[n.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",n[n.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",n[n.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",n[n.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",n[n.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",n[n.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",n[n.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",n[n.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",n[n.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",n[n.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",n[n.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",n[n.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",n[n.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",n[n.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",n[n.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",n[n.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",n[n.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",n[n.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",n[n.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",n[n.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",n[n.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",n[n.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",n[n.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})($t||($t={}));const Eg={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},Rg=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),kg=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),Dg=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}});function Mg(n=!0){const e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){const r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&Fg(r),r}return this.originalGetContext(t,i)}}function Fg(n){n.getExtension("EXT_color_buffer_float");const e={...Eg,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Rg(n),OES_vertex_array_object:kg(n),ANGLE_instanced_arrays:Dg(n)},t=n.getExtension;n.getExtension=function(r){const s=t.call(n,r);return s||(r in e?e[r]:null)};const i=n.getSupportedExtensions;n.getSupportedExtensions=function(){const r=i.apply(n)||[];return r==null?void 0:r.concat(Object.keys(e))}}async function Za(n,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",n),new Promise((r,s)=>{i.onload=r,i.onerror=o=>s(new Error(`Unable to load script '${n}': ${o}`)),t.appendChild(i)})}const Ng=1;let fe=null,Qa=!1;const bs={debugSpectorJS:D.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function Og(n){if(!globalThis.SPECTOR)try{await Za(n.debugSpectorJSUrl||bs.debugSpectorJSUrl)}catch(e){D.warn(String(e))}}function Bg(n){var e;if(n={...bs,...n},!n.debugSpectorJS)return null;if(!fe&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){D.probe(Ng,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;fe=new t,globalThis.luma&&(globalThis.luma.spector=fe)}if(!fe)return null;if(Qa||(Qa=!0,fe.spyCanvases(),fe==null||fe.onCaptureStarted.add(t=>D.info("Spector capture started:",t)()),fe==null||fe.onCapture.add(t=>{D.info("Spector capture complete:",t)(),fe==null||fe.getResultUI(),fe==null||fe.resultView.display(),fe==null||fe.resultView.addCapture(t)})),n.gl){const t=n.gl,i=t.device;fe==null||fe.startCapture(n.gl,500),t.device=i,new Promise(r=>setTimeout(r,2e3)).then(r=>{D.info("Spector capture stopped after 2 seconds")(),fe==null||fe.stopCapture()})}return fe}const Ug="https://unpkg.com/webgl-debug@2.0.1/index.js";function Ja(n){return n.luma=n.luma||{},n.luma}async function zg(){Lt()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Za(Ug))}function Lg(n,e={}){return e.debugWebGL||e.traceWebGL?Hg(n,e):Vg(n)}function Vg(n){const e=Ja(n);return e.realContext?e.realContext:n}function Hg(n,e){if(!globalThis.WebGLDebugUtils)return D.warn("webgl-debug not loaded")(),n;const t=Ja(n);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...$t,...n});const i=globalThis.WebGLDebugUtils.makeDebugContext(n,Wg.bind(null,e),$g.bind(null,e));for(const o in $t)!(o in i)&&typeof $t[o]=="number"&&(i[o]=$t[o]);class r{}Object.setPrototypeOf(i,Object.getPrototypeOf(n)),Object.setPrototypeOf(r,i);const s=Object.create(r);return t.realContext=n,t.debugContext=s,s.debug=!0,s}function Ga(n,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(n,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${n}(${t})`}function Wg(n,e,t,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);const r=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,i),o=`${r} in gl.${t}(${s})`;D.error(o)();debugger}function $g(n,e,t){let i="";D.level>=1&&(i=Ga(e,t),n.traceWebGL&&D.log(1,i)());for(const r of t)if(r===void 0){i=i||Ga(e,t);debugger}}const Li=1;class Xg extends Kp{constructor(){super();g(this,"type","webgl");Ht.defaultProps={...Ht.defaultProps,...bs}}enforceWebGL2(t){Mg(t)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&t instanceof WebGLRenderingContext&&D.warn("WebGL1 is not supported",t)(),!1)}async attach(t,i={}){const{WebGLDevice:r}=await Promise.resolve().then(()=>wl);if(t instanceof r)return t;if((t==null?void 0:t.device)instanceof r)return t.device;if(!Yg(t))throw new Error("Invalid WebGL2RenderingContext");const s=i.createCanvasContext===!0?{}:i.createCanvasContext;return new r({...i,_handle:t,createCanvasContext:{canvas:t.canvas,autoResize:!1,...s}})}async create(t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>wl);D.groupCollapsed(Li,"WebGLDevice created")();try{const r=[];(t.debugWebGL||t.debug)&&r.push(zg()),t.debugSpectorJS&&r.push(Og(t));const s=await Promise.allSettled(r);for(const l of s)l.status==="rejected"&&D.error(`Failed to initialize debug libraries ${l.reason}`)();const o=new i(t),a=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return D.probe(Li,a)(),D.table(Li,o.info)(),o}finally{D.groupEnd(Li)()}}}function Yg(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&Number.isFinite(n._version))}const qg=new Xg,Ss={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},be=(n,e,t)=>e?n.enable(t):n.disable(t),el=(n,e,t)=>n.hint(t,e),je=(n,e,t)=>n.pixelStorei(t,e),tl=(n,e,t)=>{const i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},On=(n,e,t)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};function Ts(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}const jg={3042:be,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:be,2885:(n,e)=>n.cullFace(e),2929:be,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:be,35723:el,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>{var t;return(t=n.bindTransformFeedback)==null?void 0:t.call(n,36386,e)},34229:(n,e)=>n.bindVertexArray(e),36006:tl,36010:tl,34964:On,36662:On,36663:On,35053:On,35055:On,2886:(n,e)=>n.frontFace(e),33170:el,2849:(n,e)=>n.lineWidth(e),32823:be,32824:"polygonOffset",10752:"polygonOffset",35977:be,32926:be,32928:be,32938:"sampleCoverage",32939:"sampleCoverage",3089:be,3088:(n,e)=>n.scissor(...e),2960:be,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:be,10754:be,12288:be,12289:be,12290:be,12291:be,12292:be,12293:be,12294:be,12295:be,3333:je,3317:je,37440:je,37441:je,37443:je,3330:je,3332:je,3331:je,3314:je,32878:je,3316:je,3315:je,32877:je,framebuffer:(n,e)=>{const t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{const t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=Ts(e)?e:[e,e];const[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=Ts(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=Ts(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};function xe(n,e,t){return e[n]!==void 0?e[n]:t[n]}const Kg={blendEquation:(n,e,t)=>n.blendEquationSeparate(xe(32777,e,t),xe(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(xe(32969,e,t),xe(32968,e,t),xe(32971,e,t),xe(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(xe(32824,e,t),xe(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(xe(32938,e,t),xe(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,xe(2962,e,t),xe(2967,e,t),xe(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,xe(34816,e,t),xe(36003,e,t),xe(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,xe(2964,e,t),xe(2965,e,t),xe(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,xe(34817,e,t),xe(34818,e,t),xe(34819,e,t))},nl={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},pt=(n,e)=>n.isEnabled(e),il={3042:pt,2884:pt,2929:pt,3024:pt,32823:pt,32926:pt,32928:pt,3089:pt,2960:pt,35977:pt},Zg=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function un(n,e){if(Jg(e))return;const t={};for(const r in e){const s=Number(r),o=jg[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}const i=n.state&&n.state.cache;if(i)for(const r in t){const s=Kg[r];s(n,e,i)}}function rl(n,e=Ss){if(typeof e=="number"){const r=e,s=il[r];return s?s(n,r):n.getParameter(r)}const t=Array.isArray(e)?e:Object.keys(e),i={};for(const r of t){const s=il[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function Qg(n){un(n,Ss)}function Jg(n){for(const e in n)return!1;return!0}function Gg(n,e){if(n===e)return!0;if(sl(n)&&sl(e)&&n.length===e.length){for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}return!1}function sl(n){return Array.isArray(n)||ArrayBuffer.isView(n)}class Xt{constructor(e,t){g(this,"gl");g(this,"program",null);g(this,"stateStack",[]);g(this,"enable",!0);g(this,"cache",null);g(this,"log");g(this,"initialized",!1);this.gl=e,this.log=(t==null?void 0:t.log)||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];un(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?rl(e):Object.assign({},Ss),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,tm(e);for(const i in nl){const r=nl[i];em(e,i,r)}ol(e,"getParameter"),ol(e,"isEnabled")}_updateCache(e){let t=!1,i;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const s in e){const o=e[s],a=this.cache[s];Gg(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}function ol(n,e){const t=n[e].bind(n);n[e]=function(r){if(r===void 0||Zg.has(r))return t(r);const s=Xt.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function em(n,e,t){if(!n[e])return;const i=n[e].bind(n);n[e]=function(...s){const o=Xt.get(n),{valueChanged:a,oldValue:l}=t(o._updateCache,...s);return a&&i(...s),l},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function tm(n){const e=n.useProgram.bind(n);n.useProgram=function(i){const r=Xt.get(n);r.program!==i&&(e(i),r.program=i)}}function nm(n,e,t){let i="";const r={preserveDrawingBuffer:!0,...t};let s=null;if(s||(s=n.getContext("webgl2",r)),r.failIfMajorPerformanceCaveat&&(i||(i="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!s&&!t.failIfMajorPerformanceCaveat&&(r.failIfMajorPerformanceCaveat=!1,s=n.getContext("webgl2",r),s.luma||(s.luma={}),s.luma.softwareRenderer=!0),s||(s=n.getContext("webgl",{}),s&&(s=null,i||(i="Your browser only supports WebGL1"))),!s)throw i||(i="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${i}`);const{onContextLost:o,onContextRestored:a}=e;return n.addEventListener("webglcontextlost",l=>o(l),!1),n.addEventListener("webglcontextrestored",l=>a(l),!1),s.luma||(s.luma={}),s}function fn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}function im(n,e){const t=n.getParameter(7936),i=n.getParameter(7937);fn(n,"WEBGL_debug_renderer_info",e);const r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,l=o||i,c=n.getParameter(7938),u=al(a,l),f=rm(a,l),h=sm(a,l);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:l,version:c,shadingLanguage:"glsl",shadingLanguageVersion:300}}function al(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function rm(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function sm(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(al(n,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ll(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}const Bn="WEBGL_compressed_texture_s3tc",Un="WEBGL_compressed_texture_s3tc_srgb",hn="EXT_texture_compression_rgtc",dn="EXT_texture_compression_bptc",om="WEBGL_compressed_texture_etc",am="WEBGL_compressed_texture_astc",lm="WEBGL_compressed_texture_etc1",cm="WEBGL_compressed_texture_pvrtc",um="WEBGL_compressed_texture_atc",cl="EXT_texture_norm16",ul="EXT_render_snorm",fm="EXT_color_buffer_float",ws={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[ul],"norm16-renderable-webgl":[cl],"snorm16-renderable-webgl":[cl,ul],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Bn,Un,hn,dn],"texture-compression-bc5-webgl":[hn],"texture-compression-bc7-webgl":[dn],"texture-compression-etc2":[om],"texture-compression-astc":[am],"texture-compression-etc1-webgl":[lm],"texture-compression-pvrtc-webgl":[cm],"texture-compression-atc-webgl":[um]};function hm(n){return n in ws}function dm(n,e,t){return(ws[e]||[]).every(r=>fn(n,r,t))}const As={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:fm,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Bn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Un},"bc1-rgba-unorm":{gl:33777,x:Bn},"bc1-rgba-unorm-srgb":{gl:35916,x:Un},"bc2-rgba-unorm":{gl:33778,x:Bn},"bc2-rgba-unorm-srgb":{gl:35918,x:Un},"bc3-rgba-unorm":{gl:33779,x:Bn},"bc3-rgba-unorm-srgb":{gl:35919,x:Un},"bc4-r-unorm":{gl:36283,x:hn},"bc4-r-snorm":{gl:36284,x:hn},"bc5-rg-unorm":{gl:36285,x:hn},"bc5-rg-snorm":{gl:36286,x:hn},"bc6h-rgb-ufloat":{gl:36495,x:dn},"bc6h-rgb-float":{gl:36494,x:dn},"bc7-rgba-unorm":{gl:36492,x:dn},"bc7-rgba-unorm-srgb":{gl:36493,x:dn},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function pm(n,e,t){let i=e.create;const r=As[e.format];return(r==null?void 0:r.gl)===void 0&&(i=!1),r!=null&&r.x&&(i=i&&!!fn(n,r.x,t)),{format:e.format,create:i&&e.create,render:i&&e.render,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function fl(n){var r;const e=As[n],t=_m(n),i=Vt.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:(e==null?void 0:e.dataFormat)||mm(i.channels,i.integer,i.normalized,t),type:i.dataType?ll(i.dataType):((r=e==null?void 0:e.types)==null?void 0:r[0])||5121,compressed:i.compressed||!1}}function gm(n){switch(Vt.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function mm(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function _m(n){const e=As[n],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}const hl={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class ym extends Yp{constructor(t,i,r){super([],r);g(this,"gl");g(this,"extensions");g(this,"testedFeatures",new Set);this.gl=t,this.extensions=i,fn(t,"EXT_color_buffer_float",i)}*[Symbol.iterator](){const t=this.getFeatures();for(const i of t)this.has(i)&&(yield i);return[]}has(t){var i;return(i=this.disabledFeatures)!=null&&i[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),hm(t)&&dm(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){const t=this.getFeatures().filter(i=>i!=="polygon-mode-webgl");for(const i of t)this.has(i)}getFeatures(){return[...Object.keys(hl),...Object.keys(ws)]}getWebGLFeature(t){const i=hl[t];return typeof i=="string"?!!fn(this.gl,i,this.extensions):!!i}}class xm extends Xp{constructor(t){super();g(this,"gl");g(this,"limits",{});this.gl=t}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}class zn extends Oi{constructor(t,i){super(t,i);g(this,"device");g(this,"gl");g(this,"handle");g(this,"colorAttachments",[]);g(this,"depthStencilAttachment",null);const r=i.handle===null;this.device=t,this.gl=t.gl,this.handle=this.props.handle||r?this.props.handle:this.gl.createFramebuffer(),r||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const t=this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i<this.colorAttachments.length;++i){const r=this.colorAttachments[i];if(r){const s=36064+i;this._attachTextureView(s,r)}}if(this.depthStencilAttachment){const i=gm(this.depthStencilAttachment.props.format);this._attachTextureView(i,this.depthStencilAttachment)}if(this.device.props.debug){const i=this.gl.checkFramebufferStatus(36160);if(i!==36053)throw new Error(`Framebuffer ${bm(i)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,i){const{gl:r}=this.device,{texture:s}=i,o=i.props.baseMipLevel,a=i.props.baseArrayLayer;switch(r.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:r.framebufferTextureLayer(36160,t,s.handle,o,a);break;case 34067:const l=vm(a);r.framebufferTexture2D(36160,t,l,s.handle,o);break;case 3553:r.framebufferTexture2D(36160,t,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}r.bindTexture(s.glTarget,null)}}function vm(n){return n<34069?n+34069:n}function bm(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}class Sm extends Mi{constructor(t,i){super(i);g(this,"device");g(this,"handle",null);g(this,"_framebuffer",null);this.device=t,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._updateDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new zn(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}const Cs={};function Tm(n="id"){Cs[n]=Cs[n]||1;const e=Cs[n]++;return`${n}-${e}`}class Ln extends L{constructor(t,i={}){super(t,i);g(this,"device");g(this,"gl");g(this,"handle");g(this,"glTarget");g(this,"glUsage");g(this,"glIndexType",5123);g(this,"byteLength",0);g(this,"bytesUsed",0);this.device=t,this.gl=this.device.gl;const r=typeof i=="object"?i.handle:void 0;this.handle=r||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=wm(this.props.usage),this.glUsage=Am(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,i.data?this._initWithData(i.data,i.byteOffset,i.byteLength):this._initWithByteLength(i.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(t,i=0,r=t.byteLength+i){const s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bufferSubData(s,i,t),this.gl.bindBuffer(s,null),this.bytesUsed=r,this.byteLength=r,this._setDebugData(t,i,r),this.trackAllocatedMemory(r)}_initWithByteLength(t){let i=t;t===0&&(i=new Float32Array(0));const r=this.glTarget;return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bindBuffer(r,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}write(t,i=0){const r=ArrayBuffer.isView(t)?t:new Uint8Array(t),s=36663;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,i,r),this.gl.bindBuffer(s,null),this._setDebugData(t,i,t.byteLength)}async mapAndWriteAsync(t,i=0,r=this.byteLength-i){const s=new ArrayBuffer(r);await t(s,"copied"),this.write(s,i)}async readAsync(t=0,i){return this.readSyncWebGL(t,i)}async mapAndReadAsync(t,i=0,r){const s=await this.readAsync(i,r);return await t(s.buffer,"copied")}readSyncWebGL(t=0,i){i=i??this.byteLength-t;const r=new Uint8Array(i),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,r,s,i),this.gl.bindBuffer(36662,null),this._setDebugData(r,t,i),r}}function wm(n){return n&L.INDEX?34963:n&L.VERTEX?34962:n&L.UNIFORM?35345:34962}function Am(n){return n&L.INDEX||n&L.VERTEX?35044:n&L.UNIFORM?35048:35044}function Cm(n){const e=n.split(/\r?\n/),t=[];for(const i of e){if(i.length<=1)continue;const r=i.split(":");if(r.length===2){const[f,h]=r;t.push({message:h.trim(),type:dl(f),lineNum:0,linePos:0});continue}const[s,o,a,...l]=r;let c=parseInt(a,10);isNaN(c)&&(c=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:l.join(":").trim(),type:dl(s),lineNum:c,linePos:u})}return t}function dl(n){const e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}class Im extends Ni{constructor(t,i){super(t,i);g(this,"device");g(this,"handle");switch(this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const t=this.device.gl.getShaderInfoLog(this.handle);return t?Cm(t):[]}getTranslatedSource(){const i=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(i==null?void 0:i.getTranslatedShaderSource(this.handle))||null}async _compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
12
|
-
${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}D.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),D.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function Pm(n,e,t,i){if(Dm(e))return i(n);const r=n;r.pushState();try{return Em(n,e),un(r.gl,t),i(n)}finally{r.popState()}}function Em(n,e){const t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Yt("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){const s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Yt("provokingVertex",e.provokingVertex,{first:36429,last:36430});s==null||s.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){const s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Yt("polygonMode",e.polygonMode,{fill:6914,line:6913});s==null||s.polygonModeWEBGL(1028,o),s==null||s.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(km("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(Is("depthCompare",e.depthCompare))),e.stencilWriteMask){const r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&D.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const r=e.stencilReadMask||4294967295,s=Is("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const r=Ps("stencilPassOperation",e.stencilPassOperation),s=Ps("stencilFailOperation",e.stencilFailOperation),o=Ps("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const r=pl("blendColorOperation",e.blendColorOperation||"add"),s=pl("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);const o=Vi("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Vi("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=Vi("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),c=Vi("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,l,c)}}function Is(n,e){return Yt(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Ps(n,e){return Yt(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function pl(n,e){return Yt(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Vi(n,e,t="color"){return Yt(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Rm(n,e){return`Illegal parameter ${e} for ${n}`}function Yt(n,e,t){if(!(e in t))throw new Error(Rm(n,e));return t[e]}function km(n,e){return e}function Dm(n){let e=!0;for(const t in n){e=!1;break}return e}function gl(n){const e={};return n.addressModeU&&(e[10242]=Es(n.addressModeU)),n.addressModeV&&(e[10243]=Es(n.addressModeV)),n.addressModeW&&(e[32882]=Es(n.addressModeW)),n.magFilter&&(e[10240]=Rs(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=Mm(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=Is("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function Es(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Rs(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function Mm(n,e="none"){if(!e)return Rs(n);switch(e){case"none":return Rs(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}class Fm extends cn{constructor(t,i){super(t,i);g(this,"device");g(this,"handle");g(this,"parameters");this.device=t,this.parameters=gl(i),this.handle=i.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(const[i,r]of Object.entries(t)){const s=Number(i);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,r);break;default:this.device.gl.samplerParameteri(this.handle,s,r);break}}}}function Vn(n,e,t){if(Nm(e))return t(n);const{nocatch:i=!0}=e,r=Xt.get(n);r.push(),un(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function Nm(n){for(const e in n)return!1;return!0}class pn extends Fi{constructor(t,i){super(t,{...Q.defaultProps,...i});g(this,"device");g(this,"gl");g(this,"handle");g(this,"texture");this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=i.texture}}class Hn extends Q{constructor(t,i){super(t,i);g(this,"device");g(this,"gl");g(this,"handle");g(this,"sampler");g(this,"view");g(this,"glTarget");g(this,"glFormat");g(this,"glType");g(this,"glInternalFormat");g(this,"compressed");g(this,"_textureUnit",0);this.device=t,this.gl=this.device.gl;const r=fl(this.props.format);this.glTarget=Om(this.props.dimension),this.glInternalFormat=r.internalFormat,this.glFormat=r.format,this.glType=r.type,this.compressed=r.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:s,width:o,height:a,depth:l,mipLevels:c,glTarget:u,glInternalFormat:f}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(u,c,f,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,c,f,o,a,l);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(i.data),this.setSampler(this.props.sampler),this.view=new pn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(t){return new pn(this.device,{...t,texture:this})}setSampler(t={}){super.setSampler(t);const i=gl(this.sampler.props);this._setSamplerParameters(i)}copyImageData(t){const i=this._normalizeCopyImageDataOptions(t),r=i.data,{width:s,height:o,depth:a}=this,{mipLevel:l=0,byteOffset:c=0,x:u=0,y:f=0,z:h=0}=i,{glFormat:d,glType:_,compressed:I}=this,P=ml(this.glTarget,this.dimension,h);let A;if(!this.compressed){const{bytesPerPixel:E}=this.device.getTextureFormatInfo(this.format);if(E){if(i.bytesPerRow%E!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${E}) for ${this.format}`);A=i.bytesPerRow/E}}const O=this.compressed?{}:{...A!==void 0?{3314:A}:{},32878:i.rowsPerImage};this.gl.bindTexture(P,this.handle),Vn(this.gl,O,()=>{switch(this.dimension){case"2d":case"cube":I?this.gl.compressedTexSubImage2D(P,l,u,f,s,o,d,r,c):this.gl.texSubImage2D(P,l,u,f,s,o,d,_,r,c);break;case"2d-array":case"3d":I?this.gl.compressedTexSubImage3D(P,l,u,f,h,s,o,a,d,r,c):this.gl.texSubImage3D(P,l,u,f,h,s,o,a,d,_,r,c);break;default:}}),this.gl.bindTexture(P,null)}copyExternalImage(t){const i=this._normalizeCopyExternalImageOptions(t);if(i.sourceX||i.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:r,glType:s}=this,{image:o,depth:a,mipLevel:l,x:c,y:u,z:f,width:h,height:d}=i,_=ml(this.glTarget,this.dimension,a),I=i.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Vn(this.gl,I,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(_,l,c,u,h,d,r,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(_,l,c,u,f,h,d,a,r,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:i.width,height:i.height}}generateMipmapsWebGL(t){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(D.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(t!=null&&t.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(r){D.warn(`Error generating mipmap for ${this}: ${r.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){D.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[i,r]of Object.entries(t)){const s=Number(i),o=r;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,this.handle),t}_unbind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,null),t}}function Om(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(n)}function ml(n,e,t){return e==="cube"?34069+t:n}function Bm(n){return Vm[n]}function ks(n){return Lm[n]}function Um(n){return!!_l[n]}function zm(n){return _l[n]}const Lm={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},_l={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Vm={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Hm(n,e){const t={attributes:[],bindings:[]};t.attributes=Wm(n,e);const i=Ym(n,e);for(const a of i){const l=a.uniforms.map(c=>({name:c.name,format:c.format,byteOffset:c.byteOffset,byteStride:c.byteStride,arrayLength:c.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:l})}const r=Xm(n,e);let s=0;for(const a of r)if(Um(a.type)){const{viewDimension:l,sampleType:c}=zm(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:l,sampleType:c}),a.textureUnit=s,s+=1}r.length&&(t.uniforms=r);const o=$m(n,e);return o!=null&&o.length&&(t.varyings=o),t}function Wm(n,e){const t=[],i=n.getProgramParameter(e,35721);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a}=s,l=n.getAttribLocation(e,o);if(l>=0){const c=ks(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:l,stepMode:u,type:c})}}return t.sort((r,s)=>r.location-s.location),t}function $m(n,e){const t=[],i=n.getProgramParameter(e,35971);for(let r=0;r<i;r++){const s=n.getTransformFeedbackVarying(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a,size:l}=s,c=ks(a),{type:u,components:f}=qa(c);t.push({location:r,name:o,type:u,size:l*f})}return t.sort((r,s)=>r.location-s.location),t}function Xm(n,e){const t=[],i=n.getProgramParameter(e,35718);for(let r=0;r<i;r++){const s=n.getActiveUniform(e,r);if(!s)throw new Error("activeInfo");const{name:o,size:a,type:l}=s,{name:c,isArray:u}=qm(o);let f=n.getUniformLocation(e,c);const h={location:f,name:c,size:a,type:l,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){const _=`${c}[${d}]`;f=n.getUniformLocation(e,_);const I={...h,name:_,location:f};t.push(I)}}return t}function Ym(n,e){const t=(s,o)=>n.getActiveUniformBlockParameter(e,s,o),i=[],r=n.getProgramParameter(e,35382);for(let s=0;s<r;s++){const o={name:n.getActiveUniformBlockName(e,s)||"",location:t(s,35391),byteLength:t(s,35392),vertex:t(s,35396),fragment:t(s,35398),uniformCount:t(s,35394),uniforms:[]},a=t(s,35395)||[],l=n.getActiveUniforms(e,a,35383),c=n.getActiveUniforms(e,a,35384),u=n.getActiveUniforms(e,a,35387),f=n.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){const d=n.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");const _=ks(l[h]);o.uniforms.push({name:d.name,format:_,type:l[h],arrayLength:c[h],byteOffset:u[h],byteStride:f[h]})}i.push(o)}return i.sort((s,o)=>s.location-o.location),i}function qm(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(n);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${n}`);return{name:t[1],length:t[2]?1:0,isArray:!!t[2]}}function jm(n,e,t,i){const r=n;let s=i;s===!0&&(s=1),s===!1&&(s=0);const o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function Km(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function Zm(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}const yl=4;class Qm extends Wt{constructor(t,i){super(t,i);g(this,"device");g(this,"handle");g(this,"vs");g(this,"fs");g(this,"introspectedLayout");g(this,"uniforms",{});g(this,"bindings",{});g(this,"varyings",null);g(this,"_uniformCount",0);g(this,"_uniformSetters",{});this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=i.vs,this.fs=i.fs;const{varyings:r,bufferMode:s=35981}=i;r&&r.length>0&&(this.varyings=r,this.device.gl.transformFeedbackVaryings(this.handle,r,s)),this._linkShaders(),D.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Hm(this.device.gl,this.handle),D.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=i.shaderLayout?Jm(this.introspectedLayout,i.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(t,i){for(const[r,s]of Object.entries(t)){const o=this.shaderLayout.bindings.find(a=>a.name===r)||this.shaderLayout.bindings.find(a=>a.name===`${r}Uniforms`);if(!o){const a=this.shaderLayout.bindings.map(l=>`"${l.name}"`).join(", ");i!=null&&i.disableWarnings||D.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)();continue}switch(s||D.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof Ln)&&!(s.buffer instanceof Ln))throw new Error("buffer value");break;case"texture":if(!(s instanceof pn||s instanceof Hn||s instanceof zn))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":D.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}}draw(t){var P;const{renderPass:i,parameters:r=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:l,isInstanced:c=!1,firstVertex:u=0,transformFeedback:f}=t,h=Km(s),d=!!o.indexBuffer,_=(P=o.indexBuffer)==null?void 0:P.glIndexType;if(this.linkStatus!=="success")return D.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return D.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(i),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const I=i;return Pm(this.device,r,I.glParameters,()=>{d&&c?this.device.gl.drawElementsInstanced(h,a||0,_,u,l||0):d?this.device.gl.drawElements(h,a||0,_,u):c?this.device.gl.drawArraysInstanced(h,u,a||0,l||0):this.device.gl.drawArrays(h,u,a||0),f&&f.end()}),o.unbindAfterRender(i),!0}async _linkShaders(){const{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),D.time(yl,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),D.timeEnd(yl,`linkProgram for ${this.id}`)(),D.level,!this.device.features.has("compilation-status-async-webgl")){const r=this._getLinkStatus();this._reportLinkStatus(r);return}D.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),D.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const i=this._getLinkStatus();this._reportLinkStatus(i)}async _reportLinkStatus(t){var i;switch(t){case"success":return;default:const r=t==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((i=this.fs)==null?void 0:i.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const s=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${s}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(const i of this.shaderLayout.bindings)!this.bindings[i.name]&&!this.bindings[i.name.replace(/Uniforms$/,"")]&&(D.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:t}=this.device;t.useProgram(this.handle);let i=0,r=0;for(const s of this.shaderLayout.bindings){const o=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":const{name:a}=s,l=t.getUniformBlockIndex(this.handle,a);if(l===4294967295)throw new Error(`Invalid uniform block name ${a}`);t.uniformBlockBinding(this.handle,r,l),o instanceof Ln?t.bindBufferBase(35345,r,o.handle):t.bindBufferRange(35345,r,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),r+=1;break;case"texture":if(!(o instanceof pn||o instanceof Hn||o instanceof zn))throw new Error("texture");let c;if(o instanceof pn)c=o.texture;else if(o instanceof Hn)c=o;else if(o instanceof zn&&o.colorAttachments[0]instanceof pn)D.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=o.colorAttachments[0].texture;else throw new Error("No texture");t.activeTexture(33984+i),t.bindTexture(c.glTarget,c.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(const t of this.shaderLayout.uniforms||[]){const{name:i,location:r,type:s,textureUnit:o}=t,a=this.uniforms[i]??o;a!==void 0&&jm(this.device.gl,r,s,a)}}}function Jm(n,e){const t={...n,attributes:n.attributes.map(i=>({...i}))};for(const i of(e==null?void 0:e.attributes)||[]){const r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):D.warn(`shader layout attribute ${i.name} not present in shader`)}return t}class Gm extends _s{constructor(t){super(t,{});g(this,"device");g(this,"handle",null);g(this,"commands",[]);this.device=t}_executeCommands(t=this.commands){for(const i of t)switch(i.name){case"copy-buffer-to-buffer":e_(this.device,i.options);break;case"copy-buffer-to-texture":t_(this.device,i.options);break;case"copy-texture-to-buffer":n_(this.device,i.options);break;case"copy-texture-to-texture":i_(this.device,i.options);break;default:throw new Error(i.name)}}}function e_(n,e){const t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function t_(n,e){throw new Error("Not implemented")}function n_(n,e){const{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:l=[0,0],destinationBuffer:c,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==0||f||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:_}=xl(t);let I;try{const P=c,A=s||d.width,O=o||d.height,E=fl(d.colorAttachments[0].texture.props.format),y=E.format,R=E.type;n.gl.bindBuffer(35051,P.handle),I=n.gl.bindFramebuffer(36160,d.handle),n.gl.readPixels(l[0],l[1],A,O,y,R,u)}finally{n.gl.bindBuffer(35051,null),I!==void 0&&n.gl.bindFramebuffer(36160,I),_&&d.destroy()}}function i_(n,e){const{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0],destinationTexture:o}=e;let{width:a=e.destinationTexture.width,height:l=e.destinationTexture.height}=e;const{framebuffer:c,destroyFramebuffer:u}=xl(t),[f,h]=r,[d,_,I]=s,P=n.gl.bindFramebuffer(36160,c.handle);let A,O;if(o instanceof Hn)A=o,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A._bind(0),O=A.glTarget;else throw new Error("invalid destination");switch(O){case 3553:case 34067:n.gl.copyTexSubImage2D(O,i,d,_,f,h,a,l);break;case 35866:case 32879:n.gl.copyTexSubImage3D(O,i,d,_,I,f,h,a,l);break}A&&A._unbind(),n.gl.bindFramebuffer(36160,P),u&&c.destroy()}function xl(n){if(n instanceof Q){const{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}const r_=[1,2,4,8];class s_ extends gs{constructor(t,i){var o;super(t,i);g(this,"device");g(this,"handle",null);g(this,"glParameters",{});this.device=t;let r;if(!((o=i==null?void 0:i.parameters)!=null&&o.viewport))if(i!=null&&i.framebuffer){const{width:a,height:l}=i.framebuffer;r=[0,0,a,l]}else{const[a,l]=t.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,a,l]}this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters});const s=this.props.framebuffer;if(this.props.framebuffer&&(s!=null&&s.handle)){const a=this.props.framebuffer.colorAttachments.map((l,c)=>36064+c);this.device.gl.drawBuffers(a)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){const i={...this.glParameters};i.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(i.depthMask=!this.props.depthReadOnly),i.stencilMask=this.props.stencilReadOnly?0:1,i[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(i.viewport=t.viewport.slice(0,4),i.depthRange=[t.viewport[4],t.viewport[5]]):i.viewport=t.viewport),t.scissorRect&&(i.scissorTest=!0,i.scissor=t.scissorRect),t.blendConstant&&(i.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),i[2967]=t.stencilReference),"colorMask"in t&&(i.colorMask=r_.map(r=>!!(r&t.colorMask))),this.glParameters=i,un(this.device.gl,i)}beginOcclusionQuery(t){const i=this.props.occlusionQuerySet;i==null||i.beginOcclusionQuery()}endOcclusionQuery(){const t=this.props.occlusionQuerySet;t==null||t.endOcclusionQuery()}clear(){const t={...this.glParameters};let i=0;this.props.clearColors&&this.props.clearColors.forEach((r,s)=>{r&&this.clearColorBuffer(s,r)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(i|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(i|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(i|=1024,t.clearStencil=this.props.clearStencil),i!==0&&Vn(this.device.gl,t,()=>{this.device.gl.clear(i)})}clearColorBuffer(t=0,i=[0,0,0,0]){Vn(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(i.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,i);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,i);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,i);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class vl extends ms{constructor(t,i){super(t,i);g(this,"device");g(this,"handle",null);g(this,"commandBuffer");this.device=t,this.commandBuffer=new Gm(t)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(t){return new s_(this.device,t)}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,i,r){}}function o_(n){const{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s;let a=0;for(let l=i;a<s;a++)e[l++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+o-a),a=o);return n.target}class Ds extends ys{constructor(t,i){super(t,i);g(this,"device");g(this,"handle");g(this,"buffer",null);g(this,"bufferValue",null);this.device=t,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return yp()==="Chrome"}destroy(){var t;super.destroy(),this.buffer&&((t=this.buffer)==null||t.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){const i=t;if(i&&i.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,i?i.handle:null),this.indexBuffer=i,this.device.gl.bindVertexArray(null)}setBuffer(t,i){const r=i;if(r.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:s,type:o,stride:a,offset:l,normalized:c,integer:u,divisor:f}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,r.handle),u?this.device.gl.vertexAttribIPointer(t,s,o,a,l):this.device.gl.vertexAttribPointer(t,s,o,c,a,l),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,f||0),this.attributes[t]=r,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,i){this._enable(t,!1),this.attributes[t]=i}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){const i=this.attributes[t];ArrayBuffer.isView(i)&&this.device.setConstantAttributeWebGL(t,i)}}_getAccessor(t){const i=this.attributeInfos[t];if(!i)throw new Error(`Unknown attribute location ${t}`);const r=ll(i.bufferDataType);return{size:i.bufferComponents,type:r,stride:i.byteStride,offset:i.byteOffset,normalized:i.normalized,integer:i.integer,divisor:i.stepMode==="instance"?1:0}}_enable(t,i=!0){const s=Ds.isConstantAttributeZeroSupported(this.device)||t!==0;(i||s)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),i?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,i){const r=a_(i),s=r.byteLength*t,o=r.length*t;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),a||(a=!l_(r,this.bufferValue)),a){const l=Sg(i.constructor,o);o_({target:l,source:r,start:0,count:o}),this.buffer.write(l),this.bufferValue=i}return this.buffer}}function a_(n){return Array.isArray(n)?new Float32Array(n):n}function l_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}class c_ extends xs{constructor(t,i){super(t,i);g(this,"device");g(this,"gl");g(this,"handle");g(this,"layout");g(this,"buffers",{});g(this,"unusedBuffers",{});g(this,"bindOnUse",!0);g(this,"_bound",!1);this.device=t,this.gl=t.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,i.buffers&&this.setBuffers(i.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zm(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const i in t)this.setBuffer(i,t[i])})}setBuffer(t,i){const r=this._getVaryingIndex(t),{buffer:s,byteLength:o,byteOffset:a}=this._getBufferRange(i);if(r<0){this.unusedBuffers[t]=s,D.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[r]={buffer:s,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(r,s,a,o)}getBuffer(t){if(bl(t))return this.buffers[t]||null;const i=this._getVaryingIndex(t);return i>=0?this.buffers[i]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let i;return this._bound?i=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,i=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),i}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof Ln)return{buffer:t,byteOffset:0,byteLength:t.byteLength};const{buffer:i,byteOffset:r=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:i,byteOffset:r,byteLength:s}}_getVaryingIndex(t){if(bl(t))return Number(t);for(const i of this.layout.varyings||[])if(t===i.name)return i.location;return-1}_bindBuffers(){for(const t in this.buffers){const{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),i,s,r)}}_unbindBuffers(){for(const t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,i,r=0,s){const o=i&&i.handle;!o||s===void 0?this.gl.bindBufferBase(35982,t,o):this.gl.bindBufferRange(35982,t,o,r,s)}}function bl(n){return typeof n=="number"?Number.isInteger(n):/^\d+$/.test(n)}class u_ extends vs{constructor(t,i){super(t,i);g(this,"device");g(this,"handle");g(this,"target",null);g(this,"_queryPending",!1);g(this,"_pollingPromise",null);if(this.device=t,i.count>1)throw new Error("WebGL QuerySet can only have one value");const r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");this.handle=r,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(t){return this._begin(t!=null&&t.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let i=0;return this._pollingPromise=new Promise((r,s)=>{const o=()=>{this.isResultAvailable()?(r(this.getResult()),this._pollingPromise=null):i++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}}function Sl(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function f_(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function h_(n){return d_[n]}const d_={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function p_(n,e){var O;const{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:l,sourceFormat:c,sourceType:u}=e||{};const{framebuffer:f,deleteFramebuffer:h}=Tl(n),{gl:d,handle:_}=f;o||(o=f.width),a||(a=f.height);const I=(O=f.colorAttachments[r])==null?void 0:O.texture;if(!I)throw new Error(`Invalid framebuffer attachment ${r}`);l=(I==null?void 0:I.depth)||1,c||(c=(I==null?void 0:I.glFormat)||6408),u||(u=(I==null?void 0:I.glType)||5121),s=__(s,u,c,o,a);const P=Ua(s);u=u||Bm(P);const A=d.bindFramebuffer(36160,_);return d.readBuffer(36064+r),d.readPixels(t,i,o,a,c,u,s),d.readBuffer(36064),d.bindFramebuffer(36160,A||null),h&&f.destroy(),s}function g_(n,e){const{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=e||{};const{framebuffer:u,deleteFramebuffer:f}=Tl(n);a=a||u.width,l=l||u.height;const h=u;c=c||5121;let d=t;if(!d){const I=Sl(s),P=f_(c),A=o+a*l*I*P;d=h.device.createBuffer({byteLength:A})}const _=n.device.createCommandEncoder();return _.copyTextureToBuffer({sourceTexture:n,width:a,height:l,origin:[i,r],destinationBuffer:d,byteOffset:o}),_.destroy(),f&&u.destroy(),d}function Tl(n){return n instanceof Oi?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:m_(n),deleteFramebuffer:!0}}function m_(n,e){const{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function __(n,e,t,i,r,s){if(n)return n;e||(e=5121);const o=h_(e),a=za(o),l=Sl(t);return new a(i*r*l)}class y_ extends Ht{constructor(t){var f,h;super({...t,id:t.id||Tm("webgl-device")});g(this,"type","webgl");g(this,"handle");g(this,"features");g(this,"limits");g(this,"info");g(this,"canvasContext");g(this,"preferredColorFormat","rgba8unorm");g(this,"preferredDepthFormat","depth24plus");g(this,"commandEncoder");g(this,"lost");g(this,"_resolveContextLost");g(this,"gl");g(this,"_constants");g(this,"_extensions",{});g(this,"_polyfilled",!1);g(this,"spectorJS");const i=Ht._getCanvasContextProps(t);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let r=(h=(f=i.canvas)==null?void 0:f.gl)==null?void 0:h.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Sm(this,i),this.lost=new Promise(d=>{this._resolveContextLost=d});const s={...t.webgl};i.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference);const a=this.props._handle||nm(this.canvasContext.canvas,{onContextLost:d=>{var _;return(_=this._resolveContextLost)==null?void 0:_.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:d=>console.log("WebGL context restored")},s);if(!a)throw new Error("WebGL context creation failed");if(r=a.device,r){if(t._reuseDevices)return D.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=Bg({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=im(this.gl,this._extensions),this.limits=new xm(this.gl),this.features=new ym(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Xt(this.gl,{log:(...d)=>D.log(1,...d)()}).trackState(this.gl,{copyState:!1});const c=t.debugWebGL||t.debug,u=t.debugWebGL;c&&(this.gl=Lg(this.gl,{debugWebGL:c,traceWebGL:u}),D.warn("WebGL debug mode activated. Performance reduced.")(),t.debugWebGL&&(D.level=Math.max(D.level,1))),this.commandEncoder=new vl(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){switch(t){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){const i=this._normalizeBufferProps(t);return new Ln(this,i)}createTexture(t){return new Hn(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Fm(this,t)}createShader(t){return new Im(this,t)}createFramebuffer(t){return new zn(this,t)}createVertexArray(t){return new Ds(this,t)}createTransformFeedback(t){return new c_(this,t)}createQuerySet(t){return new u_(this,t)}createRenderPipeline(t){return new Qm(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(t={}){return new vl(this,t)}submit(t){t||(t=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),t._executeCommands()}readPixelsToArrayWebGL(t,i){return p_(t,i)}readPixelsToBufferWebGL(t,i){return g_(t,i)}setParametersWebGL(t){un(this.gl,t)}getParametersWebGL(t){return rl(this.gl,t)}withParametersWebGL(t,i){return Vn(this.gl,t,i)}resetWebGL(){D.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Qg(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return pm(this.gl,t,this._extensions)}loseDevice(){var s;let t=!1;const r=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return r&&(t=!0,r.loseContext()),(s=this._resolveContextLost)==null||s.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){Xt.get(this.gl).push()}popState(){Xt.get(this.gl).pop()}getGLKey(t,i){const r=Number(t);for(const s in this.gl)if(this.gl[s]===r)return`GL.${s}`;return i!=null&&i.emptyIfUnknown?"":String(t)}getGLKeys(t){const i={emptyIfUnknown:!0};return Object.entries(t).reduce((r,[s,o])=>(r[`${s}:${this.getGLKey(s,i)}`]=`${o}:${this.getGLKey(o,i)}`,r),{})}setConstantAttributeWebGL(t,i){const r=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(r).fill(null);const s=this._constants[t];switch(s&&S_(s,i)&&D.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=i,i.constructor){case Float32Array:x_(this,t,i);break;case Int32Array:v_(this,t,i);break;case Uint32Array:b_(this,t,i);break;default:throw new Error("constant")}}getExtension(t){return fn(this.gl,t,this._extensions),this._extensions}_setWebGLDebugMetadata(t,i,r){t.luma=i;const s={props:r.spector,id:r.spector.id};t.__SPECTOR_Metadata=s}}function x_(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break}}function v_(n,e,t){n.gl.vertexAttribI4iv(e,t)}function b_(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function S_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}const wl=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:y_},Symbol.toStringTag,{value:"Module"})),T_="#b3b3b3",w_=void 0,Ms=void 0,A_=1,C_=4,I_="#666666",P_=.1,E_=1,R_=1,Al="#222222",V={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},k_=.7,D_=.95,M_=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:Cl,setPrototypeOf:Il,isFrozen:F_,getPrototypeOf:N_,getOwnPropertyDescriptor:O_}=Object;let{freeze:Ue,seal:Qe,create:Pl}=Object,{apply:Fs,construct:Ns}=typeof Reflect<"u"&&Reflect;Ue||(Ue=function(e){return e}),Qe||(Qe=function(e){return e}),Fs||(Fs=function(e,t,i){return e.apply(t,i)}),Ns||(Ns=function(e,t){return new e(...t)});const Hi=Le(Array.prototype.forEach),B_=Le(Array.prototype.lastIndexOf),El=Le(Array.prototype.pop),Wn=Le(Array.prototype.push),U_=Le(Array.prototype.splice),Wi=Le(String.prototype.toLowerCase),Os=Le(String.prototype.toString),Rl=Le(String.prototype.match),$n=Le(String.prototype.replace),z_=Le(String.prototype.indexOf),L_=Le(String.prototype.trim),ot=Le(Object.prototype.hasOwnProperty),ze=Le(RegExp.prototype.test),Xn=V_(TypeError);function Le(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Fs(n,e,i)}}function V_(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Ns(n,t)}}function te(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Wi;Il&&Il(n,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const s=t(r);s!==r&&(F_(e)||(e[i]=s),r=s)}n[r]=!0}return n}function H_(n){for(let e=0;e<n.length;e++)ot(n,e)||(n[e]=null);return n}function St(n){const e=Pl(null);for(const[t,i]of Cl(n))ot(n,t)&&(Array.isArray(i)?e[t]=H_(i):i&&typeof i=="object"&&i.constructor===Object?e[t]=St(i):e[t]=i);return e}function Yn(n,e){for(;n!==null;){const i=O_(n,e);if(i){if(i.get)return Le(i.get);if(typeof i.value=="function")return Le(i.value)}n=N_(n)}function t(){return null}return t}const kl=Ue(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Bs=Ue(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Us=Ue(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),W_=Ue(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),zs=Ue(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$_=Ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Dl=Ue(["#text"]),Ml=Ue(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ls=Ue(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fl=Ue(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$i=Ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),X_=Qe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y_=Qe(/<%[\w\W]*|[\w\W]*%>/gm),q_=Qe(/\$\{[\w\W]*/gm),j_=Qe(/^data-[\-\w.\u00B7-\uFFFF]+$/),K_=Qe(/^aria-[\-\w]+$/),Nl=Qe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Z_=Qe(/^(?:\w+script|data):/i),Q_=Qe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ol=Qe(/^html$/i),J_=Qe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Bl=Object.freeze({__proto__:null,ARIA_ATTR:K_,ATTR_WHITESPACE:Q_,CUSTOM_ELEMENT:J_,DATA_ATTR:j_,DOCTYPE_NAME:Ol,ERB_EXPR:Y_,IS_ALLOWED_URI:Nl,IS_SCRIPT_OR_DATA:Z_,MUSTACHE_EXPR:X_,TMPLIT_EXPR:q_});const qn={element:1,text:3,progressingInstruction:7,comment:8,document:9},G_=function(){return typeof window>"u"?null:window},ey=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ul=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function zl(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:G_();const e=Y=>zl(Y);if(e.version="3.2.6",e.removed=[],!n||!n.document||n.document.nodeType!==qn.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const i=t,r=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:h,trustedTypes:d}=n,_=l.prototype,I=Yn(_,"cloneNode"),P=Yn(_,"remove"),A=Yn(_,"nextSibling"),O=Yn(_,"childNodes"),E=Yn(_,"parentNode");if(typeof o=="function"){const Y=t.createElement("template");Y.content&&Y.content.ownerDocument&&(t=Y.content.ownerDocument)}let y,R="";const{implementation:N,createNodeIterator:U,createDocumentFragment:W,getElementsByTagName:q}=t,{importNode:G}=i;let B=Ul();e.isSupported=typeof Cl=="function"&&typeof E=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:he,ERB_EXPR:ie,TMPLIT_EXPR:C,DATA_ATTR:H,ARIA_ATTR:M,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:Z,CUSTOM_ELEMENT:j}=Bl;let{IS_ALLOWED_URI:ee}=Bl,J=null;const ge=te({},[...kl,...Bs,...Us,...zs,...Dl]);let ue=null;const Te=te({},[...Ml,...Ls,...Fl,...$i]);let se=Object.seal(Pl(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),He=null,We=null,nt=!0,Gt=!0,bu=!1,Su=!0,vn=!1,Or=!0,en=!1,ko=!1,Do=!1,bn=!1,Br=!1,Ur=!1,Tu=!0,wu=!1;const qv="user-content-";let Mo=!0,si=!1,Sn={},Tn=null;const Au=te({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Cu=null;const Iu=te({},["audio","video","img","source","image","track"]);let Fo=null;const Pu=te({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zr="http://www.w3.org/1998/Math/MathML",Lr="http://www.w3.org/2000/svg",Pt="http://www.w3.org/1999/xhtml";let wn=Pt,No=!1,Oo=null;const jv=te({},[zr,Lr,Pt],Os);let Vr=te({},["mi","mo","mn","ms","mtext"]),Hr=te({},["annotation-xml"]);const Kv=te({},["title","style","font","a","script"]);let oi=null;const Zv=["application/xhtml+xml","text/html"],Qv="text/html";let Ee=null,An=null;const Jv=t.createElement("form"),Eu=function(x){return x instanceof RegExp||x instanceof Function},Bo=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(An&&An===x)){if((!x||typeof x!="object")&&(x={}),x=St(x),oi=Zv.indexOf(x.PARSER_MEDIA_TYPE)===-1?Qv:x.PARSER_MEDIA_TYPE,Ee=oi==="application/xhtml+xml"?Os:Wi,J=ot(x,"ALLOWED_TAGS")?te({},x.ALLOWED_TAGS,Ee):ge,ue=ot(x,"ALLOWED_ATTR")?te({},x.ALLOWED_ATTR,Ee):Te,Oo=ot(x,"ALLOWED_NAMESPACES")?te({},x.ALLOWED_NAMESPACES,Os):jv,Fo=ot(x,"ADD_URI_SAFE_ATTR")?te(St(Pu),x.ADD_URI_SAFE_ATTR,Ee):Pu,Cu=ot(x,"ADD_DATA_URI_TAGS")?te(St(Iu),x.ADD_DATA_URI_TAGS,Ee):Iu,Tn=ot(x,"FORBID_CONTENTS")?te({},x.FORBID_CONTENTS,Ee):Au,He=ot(x,"FORBID_TAGS")?te({},x.FORBID_TAGS,Ee):St({}),We=ot(x,"FORBID_ATTR")?te({},x.FORBID_ATTR,Ee):St({}),Sn=ot(x,"USE_PROFILES")?x.USE_PROFILES:!1,nt=x.ALLOW_ARIA_ATTR!==!1,Gt=x.ALLOW_DATA_ATTR!==!1,bu=x.ALLOW_UNKNOWN_PROTOCOLS||!1,Su=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,vn=x.SAFE_FOR_TEMPLATES||!1,Or=x.SAFE_FOR_XML!==!1,en=x.WHOLE_DOCUMENT||!1,bn=x.RETURN_DOM||!1,Br=x.RETURN_DOM_FRAGMENT||!1,Ur=x.RETURN_TRUSTED_TYPE||!1,Do=x.FORCE_BODY||!1,Tu=x.SANITIZE_DOM!==!1,wu=x.SANITIZE_NAMED_PROPS||!1,Mo=x.KEEP_CONTENT!==!1,si=x.IN_PLACE||!1,ee=x.ALLOWED_URI_REGEXP||Nl,wn=x.NAMESPACE||Pt,Vr=x.MATHML_TEXT_INTEGRATION_POINTS||Vr,Hr=x.HTML_INTEGRATION_POINTS||Hr,se=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Eu(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(se.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Eu(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(se.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(se.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),vn&&(Gt=!1),Br&&(bn=!0),Sn&&(J=te({},Dl),ue=[],Sn.html===!0&&(te(J,kl),te(ue,Ml)),Sn.svg===!0&&(te(J,Bs),te(ue,Ls),te(ue,$i)),Sn.svgFilters===!0&&(te(J,Us),te(ue,Ls),te(ue,$i)),Sn.mathMl===!0&&(te(J,zs),te(ue,Fl),te(ue,$i))),x.ADD_TAGS&&(J===ge&&(J=St(J)),te(J,x.ADD_TAGS,Ee)),x.ADD_ATTR&&(ue===Te&&(ue=St(ue)),te(ue,x.ADD_ATTR,Ee)),x.ADD_URI_SAFE_ATTR&&te(Fo,x.ADD_URI_SAFE_ATTR,Ee),x.FORBID_CONTENTS&&(Tn===Au&&(Tn=St(Tn)),te(Tn,x.FORBID_CONTENTS,Ee)),Mo&&(J["#text"]=!0),en&&te(J,["html","head","body"]),J.table&&(te(J,["tbody"]),delete He.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=x.TRUSTED_TYPES_POLICY,R=y.createHTML("")}else y===void 0&&(y=ey(d,r)),y!==null&&typeof R=="string"&&(R=y.createHTML(""));Ue&&Ue(x),An=x}},Ru=te({},[...Bs,...Us,...W_]),ku=te({},[...zs,...$_]),Gv=function(x){let F=E(x);(!F||!F.tagName)&&(F={namespaceURI:wn,tagName:"template"});const X=Wi(x.tagName),me=Wi(F.tagName);return Oo[x.namespaceURI]?x.namespaceURI===Lr?F.namespaceURI===Pt?X==="svg":F.namespaceURI===zr?X==="svg"&&(me==="annotation-xml"||Vr[me]):!!Ru[X]:x.namespaceURI===zr?F.namespaceURI===Pt?X==="math":F.namespaceURI===Lr?X==="math"&&Hr[me]:!!ku[X]:x.namespaceURI===Pt?F.namespaceURI===Lr&&!Hr[me]||F.namespaceURI===zr&&!Vr[me]?!1:!ku[X]&&(Kv[X]||!Ru[X]):!!(oi==="application/xhtml+xml"&&Oo[x.namespaceURI]):!1},yt=function(x){Wn(e.removed,{element:x});try{E(x).removeChild(x)}catch{P(x)}},Cn=function(x,F){try{Wn(e.removed,{attribute:F.getAttributeNode(x),from:F})}catch{Wn(e.removed,{attribute:null,from:F})}if(F.removeAttribute(x),x==="is")if(bn||Br)try{yt(F)}catch{}else try{F.setAttribute(x,"")}catch{}},Du=function(x){let F=null,X=null;if(Do)x="<remove></remove>"+x;else{const Ie=Rl(x,/^[\r\n\t ]+/);X=Ie&&Ie[0]}oi==="application/xhtml+xml"&&wn===Pt&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const me=y?y.createHTML(x):x;if(wn===Pt)try{F=new h().parseFromString(me,oi)}catch{}if(!F||!F.documentElement){F=N.createDocument(wn,"template",null);try{F.documentElement.innerHTML=No?R:me}catch{}}const Ne=F.body||F.documentElement;return x&&X&&Ne.insertBefore(t.createTextNode(X),Ne.childNodes[0]||null),wn===Pt?q.call(F,en?"html":"body")[0]:en?F.documentElement:Ne},Mu=function(x){return U.call(x.ownerDocument||x,x,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Uo=function(x){return x instanceof f&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof u)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Fu=function(x){return typeof a=="function"&&x instanceof a};function Et(Y,x,F){Hi(Y,X=>{X.call(e,x,F,An)})}const Nu=function(x){let F=null;if(Et(B.beforeSanitizeElements,x,null),Uo(x))return yt(x),!0;const X=Ee(x.nodeName);if(Et(B.uponSanitizeElement,x,{tagName:X,allowedTags:J}),Or&&x.hasChildNodes()&&!Fu(x.firstElementChild)&&ze(/<[/\w!]/g,x.innerHTML)&&ze(/<[/\w!]/g,x.textContent)||x.nodeType===qn.progressingInstruction||Or&&x.nodeType===qn.comment&&ze(/<[/\w]/g,x.data))return yt(x),!0;if(!J[X]||He[X]){if(!He[X]&&Bu(X)&&(se.tagNameCheck instanceof RegExp&&ze(se.tagNameCheck,X)||se.tagNameCheck instanceof Function&&se.tagNameCheck(X)))return!1;if(Mo&&!Tn[X]){const me=E(x)||x.parentNode,Ne=O(x)||x.childNodes;if(Ne&&me){const Ie=Ne.length;for(let Ye=Ie-1;Ye>=0;--Ye){const Rt=I(Ne[Ye],!0);Rt.__removalCount=(x.__removalCount||0)+1,me.insertBefore(Rt,A(x))}}}return yt(x),!0}return x instanceof l&&!Gv(x)||(X==="noscript"||X==="noembed"||X==="noframes")&&ze(/<\/no(script|embed|frames)/i,x.innerHTML)?(yt(x),!0):(vn&&x.nodeType===qn.text&&(F=x.textContent,Hi([he,ie,C],me=>{F=$n(F,me," ")}),x.textContent!==F&&(Wn(e.removed,{element:x.cloneNode()}),x.textContent=F)),Et(B.afterSanitizeElements,x,null),!1)},Ou=function(x,F,X){if(Tu&&(F==="id"||F==="name")&&(X in t||X in Jv))return!1;if(!(Gt&&!We[F]&&ze(H,F))){if(!(nt&&ze(M,F))){if(!ue[F]||We[F]){if(!(Bu(x)&&(se.tagNameCheck instanceof RegExp&&ze(se.tagNameCheck,x)||se.tagNameCheck instanceof Function&&se.tagNameCheck(x))&&(se.attributeNameCheck instanceof RegExp&&ze(se.attributeNameCheck,F)||se.attributeNameCheck instanceof Function&&se.attributeNameCheck(F))||F==="is"&&se.allowCustomizedBuiltInElements&&(se.tagNameCheck instanceof RegExp&&ze(se.tagNameCheck,X)||se.tagNameCheck instanceof Function&&se.tagNameCheck(X))))return!1}else if(!Fo[F]){if(!ze(ee,$n(X,Z,""))){if(!((F==="src"||F==="xlink:href"||F==="href")&&x!=="script"&&z_(X,"data:")===0&&Cu[x])){if(!(bu&&!ze($,$n(X,Z,"")))){if(X)return!1}}}}}}return!0},Bu=function(x){return x!=="annotation-xml"&&Rl(x,j)},Uu=function(x){Et(B.beforeSanitizeAttributes,x,null);const{attributes:F}=x;if(!F||Uo(x))return;const X={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ue,forceKeepAttr:void 0};let me=F.length;for(;me--;){const Ne=F[me],{name:Ie,namespaceURI:Ye,value:Rt}=Ne,ai=Ee(Ie),zo=Rt;let Oe=Ie==="value"?zo:L_(zo);if(X.attrName=ai,X.attrValue=Oe,X.keepAttr=!0,X.forceKeepAttr=void 0,Et(B.uponSanitizeAttribute,x,X),Oe=X.attrValue,wu&&(ai==="id"||ai==="name")&&(Cn(Ie,x),Oe=qv+Oe),Or&&ze(/((--!?|])>)|<\/(style|title)/i,Oe)){Cn(Ie,x);continue}if(X.forceKeepAttr)continue;if(!X.keepAttr){Cn(Ie,x);continue}if(!Su&&ze(/\/>/i,Oe)){Cn(Ie,x);continue}vn&&Hi([he,ie,C],Lu=>{Oe=$n(Oe,Lu," ")});const zu=Ee(x.nodeName);if(!Ou(zu,ai,Oe)){Cn(Ie,x);continue}if(y&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!Ye)switch(d.getAttributeType(zu,ai)){case"TrustedHTML":{Oe=y.createHTML(Oe);break}case"TrustedScriptURL":{Oe=y.createScriptURL(Oe);break}}if(Oe!==zo)try{Ye?x.setAttributeNS(Ye,Ie,Oe):x.setAttribute(Ie,Oe),Uo(x)?yt(x):El(e.removed)}catch{Cn(Ie,x)}}Et(B.afterSanitizeAttributes,x,null)},eb=function Y(x){let F=null;const X=Mu(x);for(Et(B.beforeSanitizeShadowDOM,x,null);F=X.nextNode();)Et(B.uponSanitizeShadowNode,F,null),Nu(F),Uu(F),F.content instanceof s&&Y(F.content);Et(B.afterSanitizeShadowDOM,x,null)};return e.sanitize=function(Y){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,X=null,me=null,Ne=null;if(No=!Y,No&&(Y="<!-->"),typeof Y!="string"&&!Fu(Y))if(typeof Y.toString=="function"){if(Y=Y.toString(),typeof Y!="string")throw Xn("dirty is not a string, aborting")}else throw Xn("toString is not a function");if(!e.isSupported)return Y;if(ko||Bo(x),e.removed=[],typeof Y=="string"&&(si=!1),si){if(Y.nodeName){const Rt=Ee(Y.nodeName);if(!J[Rt]||He[Rt])throw Xn("root node is forbidden and cannot be sanitized in-place")}}else if(Y instanceof a)F=Du("<!---->"),X=F.ownerDocument.importNode(Y,!0),X.nodeType===qn.element&&X.nodeName==="BODY"||X.nodeName==="HTML"?F=X:F.appendChild(X);else{if(!bn&&!vn&&!en&&Y.indexOf("<")===-1)return y&&Ur?y.createHTML(Y):Y;if(F=Du(Y),!F)return bn?null:Ur?R:""}F&&Do&&yt(F.firstChild);const Ie=Mu(si?Y:F);for(;me=Ie.nextNode();)Nu(me),Uu(me),me.content instanceof s&&eb(me.content);if(si)return Y;if(bn){if(Br)for(Ne=W.call(F.ownerDocument);F.firstChild;)Ne.appendChild(F.firstChild);else Ne=F;return(ue.shadowroot||ue.shadowrootmode)&&(Ne=G.call(i,Ne,!0)),Ne}let Ye=en?F.outerHTML:F.innerHTML;return en&&J["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&ze(Ol,F.ownerDocument.doctype.name)&&(Ye="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
|
|
13
|
-
`+Ye),vn&&Hi([he,ie,C],Rt=>{Ye=$n(Ye,Rt," ")}),y&&Ur?y.createHTML(Ye):Ye},e.setConfig=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bo(Y),ko=!0},e.clearConfig=function(){An=null,ko=!1},e.isValidAttribute=function(Y,x,F){An||Bo({});const X=Ee(Y),me=Ee(x);return Ou(X,me,F)},e.addHook=function(Y,x){typeof x=="function"&&Wn(B[Y],x)},e.removeHook=function(Y,x){if(x!==void 0){const F=B_(B[Y],x);return F===-1?void 0:U_(B[Y],F,1)[0]}return El(B[Y])},e.removeHooks=function(Y){B[Y]=[]},e.removeAllHooks=function(){B=Ul()},e}var ty=zl();function Xi(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function ny(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function Ll(n){let e,t,i;n.length!==2?(e=Xi,t=(a,l)=>Xi(n(a),l),i=(a,l)=>n(a)-l):(e=n===Xi||n===ny?n:iy,t=n,i=n);function r(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<0?c=f+1:u=f}while(c<u)}return c}function s(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<=0?c=f+1:u=f}while(c<u)}return c}function o(a,l,c=0,u=a.length){const f=r(a,l,c,u-1);return f>c&&i(a[f-1],l)>-i(a[f],l)?f-1:f}return{left:r,center:o,right:s}}function iy(){return 0}function ry(n){return n===null?NaN:+n}const sy=Ll(Xi).right;Ll(ry).center;var Vs=Math.sqrt(50),Hs=Math.sqrt(10),Ws=Math.sqrt(2);function oy(n,e,t){var i,r=-1,s,o,a;if(e=+e,n=+n,t=+t,n===e&&t>0)return[n];if((i=e<n)&&(s=n,n=e,e=s),(a=Vl(n,e,t))===0||!isFinite(a))return[];if(a>0){let l=Math.round(n/a),c=Math.round(e/a);for(l*a<n&&++l,c*a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)*a}else{a=-a;let l=Math.round(n*a),c=Math.round(e*a);for(l/a<n&&++l,c/a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)/a}return i&&o.reverse(),o}function Vl(n,e,t){var i=(e-n)/Math.max(0,t),r=Math.floor(Math.log(i)/Math.LN10),s=i/Math.pow(10,r);return r>=0?(s>=Vs?10:s>=Hs?5:s>=Ws?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(s>=Vs?10:s>=Hs?5:s>=Ws?2:1)}function ay(n,e,t){var i=Math.abs(e-n)/Math.max(0,t),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=i/r;return s>=Vs?r*=10:s>=Hs?r*=5:s>=Ws&&(r*=2),e<n?-r:r}function ly(n,e,t){n=+n,e=+e,t=(r=arguments.length)<2?(e=n,n=0,1):r<3?1:+t;for(var i=-1,r=Math.max(0,Math.ceil((e-n)/t))|0,s=new Array(r);++i<r;)s[i]=n+i*t;return s}function Hl(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function cy(n){return function(){return n}}function uy(n){return+n}var Wl=[0,1];function gt(n){return n}function $s(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:cy(isNaN(e)?NaN:.5)}function fy(n,e){var t;return n>e&&(t=n,n=e,e=t),function(i){return Math.max(n,Math.min(e,i))}}function hy(n,e,t){var i=n[0],r=n[1],s=e[0],o=e[1];return r<i?(i=$s(r,i),s=t(o,s)):(i=$s(i,r),s=t(s,o)),function(a){return s(i(a))}}function dy(n,e,t){var i=Math.min(n.length,e.length)-1,r=new Array(i),s=new Array(i),o=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++o<i;)r[o]=$s(n[o],n[o+1]),s[o]=t(e[o],e[o+1]);return function(a){var l=sy(n,a,1,i)-1;return s[l](r[l](a))}}function $l(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Xl(){var n=Wl,e=Wl,t=ns,i,r,s,o=gt,a,l,c;function u(){var h=Math.min(n.length,e.length);return o!==gt&&(o=fy(n[0],n[h-1])),a=h>2?dy:hy,l=c=null,f}function f(h){return h==null||isNaN(h=+h)?s:(l||(l=a(n.map(i),e,t)))(i(o(h)))}return f.invert=function(h){return o(r((c||(c=a(e,n.map(i),st)))(h)))},f.domain=function(h){return arguments.length?(n=Array.from(h,uy),u()):n.slice()},f.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},f.rangeRound=function(h){return e=Array.from(h),t=ed,u()},f.clamp=function(h){return arguments.length?(o=h?!0:gt,u()):o!==gt},f.interpolate=function(h){return arguments.length?(t=h,u()):t},f.unknown=function(h){return arguments.length?(s=h,f):s},function(h,d){return i=h,r=d,u()}}function py(){return Xl()(gt,gt)}function gy(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function Yi(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,i=n.slice(0,t);return[i.length>1?i[0]+i.slice(2):i,+n.slice(t+1)]}function gn(n){return n=Yi(Math.abs(n)),n?n[1]:NaN}function my(n,e){return function(t,i){for(var r=t.length,s=[],o=0,a=n[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),s.push(t.substring(r-=a,r+a)),!((l+=a+1)>i));)a=n[o=(o+1)%n.length];return s.reverse().join(e)}}function _y(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var yy=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function qi(n){if(!(e=yy.exec(n)))throw new Error("invalid format: "+n);var e;return new Xs({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}qi.prototype=Xs.prototype;function Xs(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Xs.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function xy(n){e:for(var e=n.length,t=1,i=-1,r;t<e;++t)switch(n[t]){case".":i=r=t;break;case"0":i===0&&(i=t),r=t;break;default:if(!+n[t])break e;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var Yl;function vy(n,e){var t=Yi(n,e);if(!t)return n+"";var i=t[0],r=t[1],s=r-(Yl=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+Yi(n,Math.max(0,e+s-1))[0]}function ql(n,e){var t=Yi(n,e);if(!t)return n+"";var i=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const jl={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:gy,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>ql(n*100,e),r:ql,s:vy,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Kl(n){return n}var Zl=Array.prototype.map,Ql=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function by(n){var e=n.grouping===void 0||n.thousands===void 0?Kl:my(Zl.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?Kl:_y(Zl.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function c(f){f=qi(f);var h=f.fill,d=f.align,_=f.sign,I=f.symbol,P=f.zero,A=f.width,O=f.comma,E=f.precision,y=f.trim,R=f.type;R==="n"?(O=!0,R="g"):jl[R]||(E===void 0&&(E=12),y=!0,R="g"),(P||h==="0"&&d==="=")&&(P=!0,h="0",d="=");var N=I==="$"?t:I==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",U=I==="$"?i:/[%p]/.test(R)?o:"",W=jl[R],q=/[defgprs%]/.test(R);E=E===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function G(B){var he=N,ie=U,C,H,M;if(R==="c")ie=W(B)+ie,B="";else{B=+B;var $=B<0||1/B<0;if(B=isNaN(B)?l:W(Math.abs(B),E),y&&(B=xy(B)),$&&+B==0&&_!=="+"&&($=!1),he=($?_==="("?_:a:_==="-"||_==="("?"":_)+he,ie=(R==="s"?Ql[8+Yl/3]:"")+ie+($&&_==="("?")":""),q){for(C=-1,H=B.length;++C<H;)if(M=B.charCodeAt(C),48>M||M>57){ie=(M===46?r+B.slice(C+1):B.slice(C))+ie,B=B.slice(0,C);break}}}O&&!P&&(B=e(B,1/0));var Z=he.length+B.length+ie.length,j=Z<A?new Array(A-Z+1).join(h):"";switch(O&&P&&(B=e(j+B,j.length?A-ie.length:1/0),j=""),d){case"<":B=he+B+ie+j;break;case"=":B=he+j+B+ie;break;case"^":B=j.slice(0,Z=j.length>>1)+he+B+ie+j.slice(Z);break;default:B=j+he+B+ie;break}return s(B)}return G.toString=function(){return f+""},G}function u(f,h){var d=c((f=qi(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(gn(h)/3)))*3,I=Math.pow(10,-_),P=Ql[8+_/3];return function(A){return d(I*A)+P}}return{format:c,formatPrefix:u}}var ji,Jl,Gl;Sy({thousands:",",grouping:[3],currency:["$",""]});function Sy(n){return ji=by(n),Jl=ji.format,Gl=ji.formatPrefix,ji}function Ty(n){return Math.max(0,-gn(Math.abs(n)))}function wy(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(gn(e)/3)))*3-gn(Math.abs(n)))}function Ay(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,gn(e)-gn(n))+1}function Cy(n,e,t,i){var r=ay(n,e,t),s;switch(i=qi(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return i.precision==null&&!isNaN(s=wy(r,o))&&(i.precision=s),Gl(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Ay(r,Math.max(Math.abs(n),Math.abs(e))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=Ty(r))&&(i.precision=s-(i.type==="%")*2);break}}return Jl(i)}function ec(n){var e=n.domain;return n.ticks=function(t){var i=e();return oy(i[0],i[i.length-1],t??10)},n.tickFormat=function(t,i){var r=e();return Cy(r[0],r[r.length-1],t??10,i)},n.nice=function(t){t==null&&(t=10);var i=e(),r=0,s=i.length-1,o=i[r],a=i[s],l,c,u=10;for(a<o&&(c=o,o=a,a=c,c=r,r=s,s=c);u-- >0;){if(c=Vl(o,a,t),c===l)return i[r]=o,i[s]=a,e(i);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return n},n}function Ys(){var n=py();return n.copy=function(){return $l(n,Ys())},Hl.apply(n,arguments),ec(n)}function tc(n){return function(e){return e<0?-Math.pow(-e,n):Math.pow(e,n)}}function Iy(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function Py(n){return n<0?-n*n:n*n}function Ey(n){var e=n(gt,gt),t=1;function i(){return t===1?n(gt,gt):t===.5?n(Iy,Py):n(tc(t),tc(1/t))}return e.exponent=function(r){return arguments.length?(t=+r,i()):t},ec(e)}function nc(){var n=Ey(Xl());return n.copy=function(){return $l(n,nc()).exponent(n.exponent())},Hl.apply(n,arguments),n}var ic=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});function Ry(){var n=new ic(9);return ic!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function rc(n,e,t){var i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=o,n[4]=a,n[5]=l,n[6]=h*i+d*o+c,n[7]=h*r+d*a+u,n[8]=h*s+d*l+f,n}function qs(n,e,t){var i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function ky(n,e,t){return n[0]=2/e,n[1]=0,n[2]=0,n[3]=0,n[4]=-2/t,n[5]=0,n[6]=-1,n[7]=1,n[8]=1,n}function Dy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function My(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var Ki={exports:{}},Fy=Ki.exports,sc;function Ny(){return sc||(sc=1,function(n){(function(e,t,i){function r(l){var c=this,u=a();c.next=function(){var f=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=f-(c.c=f|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(l),c.s0<0&&(c.s0+=1),c.s1-=u(l),c.s1<0&&(c.s1+=1),c.s2-=u(l),c.s2<0&&(c.s2+=1),u=null}function s(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var u=new r(l),f=c&&c.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,f&&(typeof f=="object"&&s(f,u),h.state=function(){return s(u,{})}),h}function a(){var l=4022871197,c=function(u){u=String(u);for(var f=0;f<u.length;f++){l+=u.charCodeAt(f);var h=.02519603282416938*l;l=h>>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=o:this.alea=o})(Fy,n)}(Ki)),Ki.exports}var Zi={exports:{}},Oy=Zi.exports,oc;function By(){return oc||(oc=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var f=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^f^f>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,l.next()}function s(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(Oy,n)}(Zi)),Zi.exports}var Qi={exports:{}},Uy=Qi.exports,ac;function zy(){return ac||(ac=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(f^f<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,u==c.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function s(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(Uy,n)}(Qi)),Qi.exports}var Ji={exports:{}},Ly=Ji.exports,lc;function Vy(){return lc||(lc=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.x,f=l.i,h,d;return h=u[f],h^=h>>>7,d=h^h<<24,h=u[f+1&7],d^=h^h>>>10,h=u[f+3&7],d^=h^h>>>3,h=u[f+4&7],d^=h^h<<7,h=u[f+7&7],h=h^h<<13,d^=h^h<<9,u[f]=d,l.i=f+1&7,d};function c(u,f){var h,d=[];if(f===(f|0))d[0]=f;else for(f=""+f,h=0;h<f.length;++h)d[h&7]=d[h&7]<<15^f.charCodeAt(h)+d[h+1&7]<<13;for(;d.length<8;)d.push(0);for(h=0;h<8&&d[h]===0;++h);for(h==8?d[7]=-1:d[h],u.x=d,u.i=0,h=256;h>0;--h)u.next()}c(l,a)}function s(a,l){return l.x=a.x.slice(),l.i=a.i,l}function o(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.x&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(Ly,n)}(Ji)),Ji.exports}var Gi={exports:{}},Hy=Gi.exports,cc;function Wy(){return cc||(cc=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.w,f=l.X,h=l.i,d,_;return l.w=u=u+1640531527|0,_=f[h+34&127],d=f[h=h+1&127],_^=_<<13,d^=d<<17,_^=_>>>15,d^=d>>>12,_=f[h]=_^d,l.i=h,_+(u^u>>>16)|0};function c(u,f){var h,d,_,I,P,A=[],O=128;for(f===(f|0)?(d=f,f=null):(f=f+"\0",d=0,O=Math.max(O,f.length)),_=0,I=-32;I<O;++I)f&&(d^=f.charCodeAt((I+32)%f.length)),I===0&&(P=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,I>=0&&(P=P+1640531527|0,h=A[I&127]^=d+P,_=h==0?_+1:0);for(_>=128&&(A[(f&&f.length||0)&127]=-1),_=127,I=4*128;I>0;--I)d=A[_+34&127],h=A[_=_+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,A[_]=d^h;u.w=P,u.X=A,u.i=_}c(l,a)}function s(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function o(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.X&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(Hy,n)}(Gi)),Gi.exports}var er={exports:{}},$y=er.exports,uc;function Xy(){return uc||(uc=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=l.b,h=l.c,d=l.d,_=l.a;return f=f<<25^f>>>7^h,h=h-d|0,d=d<<24^d>>>8^_,_=_-f|0,l.b=f=f<<20^f>>>12^h,l.c=h=h-d|0,l.d=d<<16^h>>>16^_,l.a=_-f|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u<c.length+20;u++)l.b^=c.charCodeAt(u)|0,l.next()}function s(a,l){return l.a=a.a,l.b=a.b,l.c=a.c,l.d=a.d,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})($y,n)}(er)),er.exports}var tr={exports:{}};const Yy=My(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var qy=tr.exports,fc;function jy(){return fc||(fc=1,function(n){(function(e,t,i){var r=256,s=6,o=52,a="random",l=i.pow(r,s),c=i.pow(2,o),u=c*2,f=r-1,h;function d(y,R,N){var U=[];R=R==!0?{entropy:!0}:R||{};var W=A(P(R.entropy?[y,E(t)]:y??O(),3),U),q=new _(U),G=function(){for(var B=q.g(s),he=l,ie=0;B<c;)B=(B+ie)*r,he*=r,ie=q.g(1);for(;B>=u;)B/=2,he/=2,ie>>>=1;return(B+ie)/he};return G.int32=function(){return q.g(4)|0},G.quick=function(){return q.g(4)/4294967296},G.double=G,A(E(q.S),t),(R.pass||N||function(B,he,ie,C){return C&&(C.S&&I(C,q),B.state=function(){return I(q,{})}),ie?(i[a]=B,he):B})(G,W,"global"in R?R.global:this==i,R.state)}function _(y){var R,N=y.length,U=this,W=0,q=U.i=U.j=0,G=U.S=[];for(N||(y=[N++]);W<r;)G[W]=W++;for(W=0;W<r;W++)G[W]=G[q=f&q+y[W%N]+(R=G[W])],G[q]=R;(U.g=function(B){for(var he,ie=0,C=U.i,H=U.j,M=U.S;B--;)he=M[C=f&C+1],ie=ie*r+M[f&(M[C]=M[H=f&H+he])+(M[H]=he)];return U.i=C,U.j=H,ie})(r)}function I(y,R){return R.i=y.i,R.j=y.j,R.S=y.S.slice(),R}function P(y,R){var N=[],U=typeof y,W;if(R&&U=="object")for(W in y)try{N.push(P(y[W],R-1))}catch{}return N.length?N:U=="string"?y:y+"\0"}function A(y,R){for(var N=y+"",U,W=0;W<N.length;)R[f&W]=f&(U^=R[f&W]*19)+N.charCodeAt(W++);return E(R)}function O(){try{var y;return h&&(y=h.randomBytes)?y=y(r):(y=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(y)),E(y)}catch{var R=e.navigator,N=R&&R.plugins;return[+new Date,e,N,e.screen,E(t)]}}function E(y){return String.fromCharCode.apply(0,y)}if(A(i.random(),t),n.exports){n.exports=d;try{h=Yy}catch{}}else i["seed"+a]=d})(typeof self<"u"?self:qy,[],Math)}(tr)),tr.exports}var js,hc;function Ky(){if(hc)return js;hc=1;var n=Ny(),e=By(),t=zy(),i=Vy(),r=Wy(),s=Xy(),o=jy();return o.alea=n,o.xor128=e,o.xorwow=t,o.xorshift7=i,o.xor4096=r,o.tychei=s,js=o,js}var Zy=Ky();const Qy=Dy(Zy);function Jy(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,ex(i.key),i)}}function Ks(n,e,t){return e&&Jy(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function dc(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,Zs(n,e)}function Zs(n,e){return Zs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},Zs(n,e)}function Gy(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ex(n){var e=Gy(n,"string");return typeof e=="symbol"?e:String(e)}var nr=function(){function n(){}var e=n.prototype;return e._seed=function(i,r){if(i===(i||0))return i;for(var s=""+i,o=0,a=0;a<s.length;++a)o^=s.charCodeAt(a)|0;return o},n}(),pc=function(n){dc(e,n);function e(i,r){var s;return s=n.call(this)||this,s._rng=void 0,s.seed(i,r),s}var t=e.prototype;return t.next=function(){return this._rng()},t.seed=function(r,s){this._rng=r},t.clone=function(r,s){return new e(this._rng,s)},Ks(e,[{key:"name",get:function(){return"function"}}]),e}(nr),gc=function(){var n=[].slice.call(arguments),e=n,t=e[0],i=t===void 0?"default":t;switch(typeof i){case"object":if(i instanceof nr)return i;break;case"function":return new pc(i);case"number":case"string":default:return new pc(Qy.apply(void 0,n))}throw new Error('invalid RNG "'+i+'"')},tx=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){return n.next()*(t-e)+e}};function at(n){return new nx(n)}var nx=function(e){var t=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(t.n))return t;throw new Error("Expected number to be an integer, got "+t.n)},this.isPositive=function(){if(t.n>0)return t;throw new Error("Expected number to be positive, got "+t.n)},this.lessThan=function(i){if(t.n<i)return t;throw new Error("Expected number to be less than "+i+", got "+t.n)},this.greaterThanOrEqual=function(i){if(t.n>=i)return t;throw new Error("Expected number to be greater than or equal to "+i+", got "+t.n)},this.greaterThan=function(i){if(t.n>i)return t;throw new Error("Expected number to be greater than "+i+", got "+t.n)},this.n=e},ix=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),t===void 0&&(t=e===void 0?1:e,e=0),at(e).isInt(),at(t).isInt(),function(){return Math.floor(n.next()*(t-e+1)+e)}},rx=function(n){return function(){return n.next()>=.5}},sx=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){var i,r,s;do i=n.next()*2-1,r=n.next()*2-1,s=i*i+r*r;while(!s||s>1);return e+t*r*Math.sqrt(-2*Math.log(s)/s)}},ox=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=1);var i=n.normal(e,t);return function(){return Math.exp(i())}},ax=function(n,e){return e===void 0&&(e=.5),at(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(n.next()+e)}},lx=function(n,e,t){return e===void 0&&(e=1),t===void 0&&(t=.5),at(e).isInt().isPositive(),at(t).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<e;)n.next()<t&&r++;return r}},cx=function(n,e){e===void 0&&(e=.5),at(e).greaterThan(0).lessThan(1);var t=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(n.next())*t)}},ux=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],fx=function(e){return ux[e]},hx=.9189385332046727,dx=function(n,e){if(e===void 0&&(e=1),at(e).isPositive(),e<10){var t=Math.exp(-e);return function(){for(var l=t,c=0,u=n.next();u>l;)u=u-l,l=e*l/++c;return c}}else{var i=Math.sqrt(e),r=.931+2.53*i,s=-.059+.02483*r,o=1.1239+1.1328/(r-3.4),a=.9277-3.6224/(r-2);return function(){for(;;){var l=void 0,c=n.next();if(c<=.86*a)return l=c/a-.43,Math.floor((2*s/(.5-Math.abs(l))+r)*l+e+.445);c>=a?l=n.next()-.5:(l=c/a-.93,l=(l<0?-.5:.5)-l,c=n.next()*a);var u=.5-Math.abs(l);if(!(u<.013&&c>u)){var f=Math.floor((2*s/u+r)*l+e+.445);if(c=c*o/(s/(u*u)+r),f>=10){var h=(f+.5)*Math.log(e/f)-e-hx+f-(.08333333333333333-(.002777777777777778-1/(1260*f*f))/(f*f))/f;if(Math.log(c*i)<=h)return f}else if(f>=0){var d,_=(d=fx(f))!=null?d:0;if(Math.log(c)<=f*Math.log(e)-e-_)return f}}}}}},px=function(n,e){return e===void 0&&(e=1),at(e).isPositive(),function(){return-Math.log(1-n.next())/e}},gx=function(n,e){return e===void 0&&(e=1),at(e).isInt().greaterThanOrEqual(0),function(){for(var t=0,i=0;i<e;++i)t+=n.next();return t}},mx=function(n,e){e===void 0&&(e=1),at(e).isInt().isPositive();var t=n.irwinHall(e);return function(){return t()/e}},_x=function(n,e){e===void 0&&(e=1),at(e).greaterThanOrEqual(0);var t=1/e;return function(){return 1/Math.pow(1-n.next(),t)}},yx=function(n){dc(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.next=function(){return Math.random()},t.seed=function(r,s){},t.clone=function(){return new e},Ks(e,[{key:"name",get:function(){return"default"}}]),e}(nr),mc=function(){function n(t){var i=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return i._rng.next()},this.float=function(r,s){return i.uniform(r,s)()},this.int=function(r,s){return i.uniformInt(r,s)()},this.integer=function(r,s){return i.uniformInt(r,s)()},this.bool=function(){return i.uniformBoolean()()},this.boolean=function(){return i.uniformBoolean()()},this.uniform=function(r,s){return i._memoize("uniform",tx,r,s)},this.uniformInt=function(r,s){return i._memoize("uniformInt",ix,r,s)},this.uniformBoolean=function(){return i._memoize("uniformBoolean",rx)},this.normal=function(r,s){return sx(i,r,s)},this.logNormal=function(r,s){return ox(i,r,s)},this.bernoulli=function(r){return ax(i,r)},this.binomial=function(r,s){return lx(i,r,s)},this.geometric=function(r){return cx(i,r)},this.poisson=function(r){return dx(i,r)},this.exponential=function(r){return px(i,r)},this.irwinHall=function(r){return gx(i,r)},this.bates=function(r){return mx(i,r)},this.pareto=function(r){return _x(i,r)},t&&t instanceof nr?this.use(t):this.use(new yx),this._cache={}}var e=n.prototype;return e.clone=function(){var i=[].slice.call(arguments);return i.length?new n(gc.apply(void 0,i)):new n(this.rng.clone())},e.use=function(){this._rng=gc.apply(void 0,[].slice.call(arguments))},e.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},e.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},e.choice=function(i){if(!Array.isArray(i))throw new Error("Random.choice expected input to be an array, got "+typeof i);var r=i==null?void 0:i.length;if(r>0){var s=this.uniformInt(0,r-1)();return i[s]}else return},e._memoize=function(i,r){var s=[].slice.call(arguments,2),o=""+s.join(";"),a=this._cache[i];return(a===void 0||a.key!==o)&&(a={key:o,distribution:r.apply(void 0,[this].concat(s))},this._cache[i]=a),a.distribution},Ks(n,[{key:"rng",get:function(){return this._rng}}]),n}();new mc;const Qs=.001,ir=64,xx=4,_c=2;class vx{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=Ry(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=ir,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=V.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,k_],this.focusedPointRingColor=[1,1,1,D_],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=Ys(),this.scalePointY=Ys(),this.random=new mc,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Qs,1/e)}get backgroundColor(){return this._backgroundColor}get transformationMatrix4x4(){const e=this.transform;if(e.length!==9)throw new Error(`Transform must be a 9-element array (3x3 matrix), got ${e.length} elements`);return[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]}set backgroundColor(e){this._backgroundColor=e;const t=bc(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",t>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",t>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=t<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,t){return this.random.float(e,t)}adjustSpaceSize(e,t){(e<=0||!isFinite(e))&&(console.error(`Invalid spaceSize value: ${e}. Using default value of ${V.spaceSize}`),e=V.spaceSize);const i=2;if(e<i&&(console.warn(`spaceSize (${e}) is too small. Using minimum value of ${i}`),e=i),!Number.isFinite(t)||t<=0||t<i){console.warn(`Invalid webglMaxTextureSize: ${t}. Using configSpaceSize without WebGL limit adjustment.`),this.adjustedSpaceSize=e;return}e>=t?(this.adjustedSpaceSize=Math.max(t/2,i),console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}setWebGLMaxTextureSize(e){this.webglMaxTextureSize=e}updateScreenSize(e,t){const{adjustedSpaceSize:i}=this;this.screenSize=[e,t],this.scalePointX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scalePointY.domain([i,0]).range([(t-i)/2,(t+i)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=Tt(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=Tt(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const t=Tt(e);this.greyoutPointColor[0]=t[0],this.greyoutPointColor[1]=t[1],this.greyoutPointColor[2]=t[2],this.greyoutPointColor[3]=t[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkContextMenu||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const t=Tt(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const yc=n=>typeof n=="function",Js=n=>Array.isArray(n),xc=n=>n instanceof Object,vc=n=>n instanceof Object?n.constructor.name!=="Function"&&n.constructor.name!=="Object":!1,Gs=n=>xc(n)&&!Js(n)&&!yc(n)&&!vc(n);function Tt(n){let e;if(Js(n))e=n;else{const t=kt(n),i=t==null?void 0:t.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function bc(n,e,t){return .2126*n+.7152*e+.0722*t}function Xe(n,e,t=0,i=0,r,s){return n.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:i,sourceWidth:r,sourceHeight:s})}function eo(n,e){switch(n.info.type){case"webgl":{const t=n.gl.getParameter($t.ALIASED_POINT_SIZE_RANGE);return((t==null?void 0:t[1])??ir)/e}case"webgpu":return ir/e;default:return ir/e}}function Sc(n,e,t){return Math.min(Math.max(n,e),t)}function Ke(n){return n!=null&&!Number.isNaN(n)}function Tc(n,e){return ty.sanitize(n,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class bx{constructor(){this.enableSimulation=V.enableSimulation,this.backgroundColor=Al,this.spaceSize=V.spaceSize,this.pointColor=T_,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=w_,this.pointGreyoutColor=Ms,this.pointSize=C_,this.pointDefaultSize=void 0,this.pointOpacity=A_,this.pointSizeScale=V.pointSizeScale,this.hoveredPointCursor=V.hoveredPointCursor,this.hoveredLinkCursor=V.hoveredLinkCursor,this.renderHoveredPointRing=V.renderHoveredPointRing,this.hoveredPointRingColor=V.hoveredPointRingColor,this.focusedPointRingColor=V.focusedPointRingColor,this.focusedPointIndex=V.focusedPointIndex,this.linkColor=I_,this.linkDefaultColor=void 0,this.linkOpacity=E_,this.linkGreyoutOpacity=P_,this.linkWidth=R_,this.linkDefaultWidth=void 0,this.linkWidthScale=V.linkWidthScale,this.hoveredLinkColor=V.hoveredLinkColor,this.hoveredLinkWidthIncrease=V.hoveredLinkWidthIncrease,this.renderLinks=V.renderLinks,this.curvedLinks=V.curvedLinks,this.curvedLinkSegments=V.curvedLinkSegments,this.curvedLinkWeight=V.curvedLinkWeight,this.curvedLinkControlPointDistance=V.curvedLinkControlPointDistance,this.linkArrows=V.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=V.linkArrowsSizeScale,this.scaleLinksOnZoom=V.scaleLinksOnZoom,this.linkVisibilityDistanceRange=V.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=V.linkVisibilityMinTransparency,this.simulationDecay=V.simulation.decay,this.simulationGravity=V.simulation.gravity,this.simulationCenter=V.simulation.center,this.simulationRepulsion=V.simulation.repulsion,this.simulationRepulsionTheta=V.simulation.repulsionTheta,this.simulationLinkSpring=V.simulation.linkSpring,this.simulationLinkDistance=V.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=V.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=V.simulation.repulsionFromMouse,this.enableRightClickRepulsion=V.enableRightClickRepulsion,this.simulationFriction=V.simulation.friction,this.simulationCluster=V.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onContextMenu=void 0,this.onPointContextMenu=void 0,this.onLinkContextMenu=void 0,this.onBackgroundContextMenu=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=V.showFPSMonitor,this.pixelRatio=V.pixelRatio,this.scalePointsOnZoom=V.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=V.enableZoom,this.enableSimulationDuringZoom=V.enableSimulationDuringZoom,this.enableDrag=V.enableDrag,this.fitViewOnInit=V.fitViewOnInit,this.fitViewDelay=V.fitViewDelay,this.fitViewPadding=V.fitViewPadding,this.fitViewDuration=V.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=V.pointSamplingDistance,this.attribution=V.attribution,this.rescalePositions=V.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,i){Gs(e[i])&&Gs(t[i])?Object.keys(t[i]).forEach(r=>{this.deepMergeConfig(e[i],t[i],r)}):e[i]=t[i]}getConfig(){return this}}function to(n,e){if(!n)throw new Error(e||"shadertools: assertion failed.")}const no={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}};function Sx(n){const e={};for(const[t,i]of Object.entries(n))e[t]=Tx(i);return e}function Tx(n){let e=wc(n);if(e!=="object")return{value:n,...no[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...no[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=wc(n.value),{...n,...no[e],type:e}):{type:"object",value:null};throw new Error("props")}function wc(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}const wx={vertex:`#ifdef MODULE_LOGDEPTH
|
|
11
|
+
</pre></code>`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(u=document.getElementsByClassName("luma-compiler-log-error")[0])==null||u.scrollIntoView(),l.onclick=()=>{const f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}};m(wr,"defaultProps",{...ce.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Ni=wr;function bm(n){return Sm(n.source)||n.id||Pi(`unnamed ${n.stage}-shader`)}function Sm(n,e="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n);return i?i[1]:e}const Ar=class Ar extends ce{constructor(t,i={}){super(t,i,Ar.defaultProps);m(this,"width");m(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(t){const i=this.colorAttachments.map(s=>s.texture.clone(t)),r=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(t);return this.device.createFramebuffer({...this.props,colorAttachments:i,depthStencilAttachment:r})}resize(t){let i=!t;if(t){const[r,s]=Array.isArray(t)?t:[t.width,t.height];i=i||s!==this.height||r!==this.width,this.width=r,this.height=s}i&&(D.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((i,r)=>{if(typeof i=="string"){const s=this.createColorTexture(i,r);return this.attachResource(s),s.view}return i instanceof Q?i.view:i});const t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){const i=this.createDepthStencilTexture(t);this.attachResource(i),this.depthStencilAttachment=i.view}else t instanceof Q?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t,i){return this.device.createTexture({id:`${this.id}-color-attachment-${i}`,usage:Q.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(t){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Q.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,i){for(let r=0;r<this.colorAttachments.length;++r)if(this.colorAttachments[r]){const s=this.colorAttachments[r].texture.clone({width:t,height:i});this.destroyAttachedResource(this.colorAttachments[r]),this.colorAttachments[r]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){const r=this.depthStencilAttachment.texture.clone({width:t,height:i});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=r.view,this.attachResource(r)}this.updateAttachments()}};m(Ar,"defaultProps",{...ce.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let Oi=Ar;const Cr=class Cr extends ce{constructor(t,i){super(t,i,Cr.defaultProps);m(this,"shaderLayout");m(this,"bufferLayout");m(this,"linkStatus","pending");m(this,"hash","");this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};m(Cr,"defaultProps",{...ce.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Wt=Cr;const ut=class ut extends ce{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=ut.normalizeProps(e,t),super(e,t,ut.defaultProps)}static normalizeProps(e,t){return t}};m(ut,"defaultClearColor",[0,0,0,1]),m(ut,"defaultClearDepth",1),m(ut,"defaultClearStencil",0),m(ut,"defaultProps",{...ce.defaultProps,framebuffer:null,parameters:void 0,clearColor:ut.defaultClearColor,clearColors:void 0,clearDepth:ut.defaultClearDepth,clearStencil:ut.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let gs=ut;const Ir=class Ir extends ce{constructor(t,i){super(t,i,Ir.defaultProps);m(this,"hash","");m(this,"shaderLayout");this.shaderLayout=i.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};m(Ir,"defaultProps",{...ce.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Bi=Ir;const Pr=class Pr extends ce{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Pr.defaultProps)}};m(Pr,"defaultProps",{...ce.defaultProps,measureExecutionTime:void 0});let _s=Pr;const Er=class Er extends ce{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Er.defaultProps)}};m(Er,"defaultProps",{...ce.defaultProps});let xs=Er;function ja(n){return Cm[n]}function Tm(n){const[e,t]=Am[n],i=e==="i32"||e==="u32",r=e!=="u32",s=wm[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:r}}const wm={f32:4,f16:2,i32:4,u32:4},Am={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Cm={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function Ka(n,e){const t={};for(const i of n.attributes){const r=Pm(n,e,i.name);r&&(t[i.name]=r)}return t}function Im(n,e,t=16){const i=Ka(n,e),r=new Array(t).fill(null);for(const s of Object.values(i))r[s.location]=s;return r}function Pm(n,e,t){const i=Em(n,t),r=Rm(e,t);if(!i)return null;const s=Tm(i.type),o=Yp(s),a=(r==null?void 0:r.vertexFormat)||o,l=cs(a);return{attributeName:(r==null?void 0:r.attributeName)||i.name,bufferName:(r==null?void 0:r.bufferName)||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:s.integer,stepMode:(r==null?void 0:r.stepMode)||i.stepMode||"vertex",byteOffset:(r==null?void 0:r.byteOffset)||0,byteStride:(r==null?void 0:r.byteStride)||0}}function Em(n,e){const t=n.attributes.find(i=>i.name===e);return t||D.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Rm(n,e){km(n);let t=Dm(n,e);return t||(t=Mm(n,e),t)?t:(D.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function km(n){for(const e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&D.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Dm(n,e){for(const t of n)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Mm(n,e){var t;for(const i of n){let r=i.byteStride;if(typeof i.byteStride!="number")for(const o of i.attributes||[]){const a=cs(o.format);r+=a.byteLength}const s=(t=i.attributes)==null?void 0:t.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:r}}return null}const Rr=class Rr extends ce{constructor(t,i){super(t,i,Rr.defaultProps);m(this,"maxVertexAttributes");m(this,"attributeInfos");m(this,"indexBuffer",null);m(this,"attributes");this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Im(i.shaderLayout,i.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(t,i){this.device.reportError(new Error("constant attributes not supported"),this)()}};m(Rr,"defaultProps",{...ce.defaultProps,shaderLayout:void 0,bufferLayout:[]});let ys=Rr;const kr=class kr extends ce{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,kr.defaultProps)}};m(kr,"defaultProps",{...ce.defaultProps,layout:void 0,buffers:{}});let vs=kr;const Dr=class Dr extends ce{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Dr.defaultProps)}};m(Dr,"defaultProps",{...ce.defaultProps,type:void 0,count:void 0});let bs=Dr,Ui;function Za(n){return(!Ui||Ui.byteLength<n)&&(Ui=new ArrayBuffer(n)),Ui}function Fm(n,e){const t=Za(n.BYTES_PER_ELEMENT*e);return new n(t,0,e)}function Nm(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function zi(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":Nm(n)}const Om=1024;class Bm{constructor(e,t={}){m(this,"layout",{});m(this,"byteLength");let i=0;for(const[s,o]of Object.entries(e)){const a=ja(o),{type:l,components:c}=a,u=c*((t==null?void 0:t[s])??1);i=Wp(i,u);const f=i;i+=u,this.layout[s]={type:l,size:u,offset:f}}i+=(4-i%4)%4;const r=i*4;this.byteLength=Math.max(r,Om)}getData(e){const t=Za(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[r,s]of Object.entries(e)){const o=this.layout[r];if(!o){D.warn(`Supplied uniform value ${r} not present in uniform block layout`)();continue}const{type:a,size:l,offset:c}=o,u=i[a];if(l===1){if(typeof s!="number"&&typeof s!="boolean"){D.warn(`Supplied value for single component uniform ${r} is not a number: ${s}`)();continue}u[c]=Number(s)}else{if(!zi(s)){D.warn(`Supplied value for multi component / array uniform ${r} is not a numeric array: ${s}`)();continue}u.set(s,c)}}return new Uint8Array(t,0,this.byteLength)}has(e){return!!this.layout[e]}get(e){return this.layout[e]}}function Um(n,e,t=16){if(n!==e)return!1;const i=n,r=e;if(!zi(i))return!1;if(zi(r)&&i.length===r.length){for(let s=0;s<i.length;++s)if(r[s]!==i[s])return!1}return!0}function zm(n){return zi(n)?n.slice():n}class Lm{constructor(e){m(this,"name");m(this,"uniforms",{});m(this,"modifiedUniforms",{});m(this,"modified",!0);m(this,"bindingLayout",{});m(this,"needsRedraw","initialized");var t;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&(e!=null&&e.shaderLayout)){const i=(t=e==null?void 0:e.shaderLayout.bindings)==null?void 0:t.find(s=>s.type==="uniform"&&s.name===(e==null?void 0:e.name));if(!i)throw new Error(e==null?void 0:e.name);const r=i;for(const s of r.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Um(this.uniforms[e],t)||(this.uniforms[e]=zm(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}class xe{constructor(e){m(this,"uniformBlocks",new Map);m(this,"uniformBufferLayouts",new Map);m(this,"uniformBuffers",new Map);for(const[t,i]of Object.entries(e)){const r=t,s=new Bm(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(r,s);const o=new Lm({name:t});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(r,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[i,r]of Object.entries(e))(t=this.uniformBlocks.get(i))==null||t.setUniforms(r);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var i,r;const t=((i=this.uniformBlocks.get(e))==null?void 0:i.getAllUniforms())||{};return(r=this.uniformBufferLayouts.get(e))==null?void 0:r.getData(t)}createUniformBuffer(e,t,i){i&&this.setUniforms(i);const r=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:L.UNIFORM|L.COPY_DST,byteLength:r}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const i=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:L.UNIFORM|L.COPY_DST,byteLength:i});this.uniformBuffers.set(t,r)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(t);e||(e=i)}return e&&D.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var s;const t=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),r=!1;if(i&&(t!=null&&t.needsRedraw)){r||(r=t.needsRedraw);const o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i==null||i.write(o);const a=(s=this.uniformBlocks.get(e))==null?void 0:s.getAllUniforms();D.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}}var $t;(function(n){n[n.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",n[n.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",n[n.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n[n.ZERO=0]="ZERO",n[n.ONE=1]="ONE",n[n.SRC_COLOR=768]="SRC_COLOR",n[n.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.DST_ALPHA=772]="DST_ALPHA",n[n.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",n[n.DST_COLOR=774]="DST_COLOR",n[n.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",n[n.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",n[n.CONSTANT_COLOR=32769]="CONSTANT_COLOR",n[n.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",n[n.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",n[n.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",n[n.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",n[n.BLEND_EQUATION=32777]="BLEND_EQUATION",n[n.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",n[n.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",n[n.BLEND_DST_RGB=32968]="BLEND_DST_RGB",n[n.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",n[n.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",n[n.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",n[n.BLEND_COLOR=32773]="BLEND_COLOR",n[n.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",n[n.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",n[n.LINE_WIDTH=2849]="LINE_WIDTH",n[n.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",n[n.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",n[n.CULL_FACE_MODE=2885]="CULL_FACE_MODE",n[n.FRONT_FACE=2886]="FRONT_FACE",n[n.DEPTH_RANGE=2928]="DEPTH_RANGE",n[n.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",n[n.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",n[n.DEPTH_FUNC=2932]="DEPTH_FUNC",n[n.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",n[n.STENCIL_FUNC=2962]="STENCIL_FUNC",n[n.STENCIL_FAIL=2964]="STENCIL_FAIL",n[n.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",n[n.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",n[n.STENCIL_REF=2967]="STENCIL_REF",n[n.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",n[n.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",n[n.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",n[n.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",n[n.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",n[n.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",n[n.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",n[n.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",n[n.VIEWPORT=2978]="VIEWPORT",n[n.SCISSOR_BOX=3088]="SCISSOR_BOX",n[n.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",n[n.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",n[n.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",n[n.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",n[n.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",n[n.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",n[n.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",n[n.RED_BITS=3410]="RED_BITS",n[n.GREEN_BITS=3411]="GREEN_BITS",n[n.BLUE_BITS=3412]="BLUE_BITS",n[n.ALPHA_BITS=3413]="ALPHA_BITS",n[n.DEPTH_BITS=3414]="DEPTH_BITS",n[n.STENCIL_BITS=3415]="STENCIL_BITS",n[n.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",n[n.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",n[n.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",n[n.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",n[n.SAMPLES=32937]="SAMPLES",n[n.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",n[n.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",n[n.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",n[n.VENDOR=7936]="VENDOR",n[n.RENDERER=7937]="RENDERER",n[n.VERSION=7938]="VERSION",n[n.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",n[n.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",n[n.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",n[n.STATIC_DRAW=35044]="STATIC_DRAW",n[n.STREAM_DRAW=35040]="STREAM_DRAW",n[n.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BUFFER_SIZE=34660]="BUFFER_SIZE",n[n.BUFFER_USAGE=34661]="BUFFER_USAGE",n[n.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",n[n.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",n[n.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",n[n.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",n[n.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",n[n.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",n[n.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",n[n.CULL_FACE=2884]="CULL_FACE",n[n.FRONT=1028]="FRONT",n[n.BACK=1029]="BACK",n[n.FRONT_AND_BACK=1032]="FRONT_AND_BACK",n[n.BLEND=3042]="BLEND",n[n.DEPTH_TEST=2929]="DEPTH_TEST",n[n.DITHER=3024]="DITHER",n[n.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",n[n.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",n[n.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",n[n.SCISSOR_TEST=3089]="SCISSOR_TEST",n[n.STENCIL_TEST=2960]="STENCIL_TEST",n[n.NO_ERROR=0]="NO_ERROR",n[n.INVALID_ENUM=1280]="INVALID_ENUM",n[n.INVALID_VALUE=1281]="INVALID_VALUE",n[n.INVALID_OPERATION=1282]="INVALID_OPERATION",n[n.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",n[n.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",n[n.CW=2304]="CW",n[n.CCW=2305]="CCW",n[n.DONT_CARE=4352]="DONT_CARE",n[n.FASTEST=4353]="FASTEST",n[n.NICEST=4354]="NICEST",n[n.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.INT=5124]="INT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.DOUBLE=5130]="DOUBLE",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.ALPHA=6406]="ALPHA",n[n.RGB=6407]="RGB",n[n.RGBA=6408]="RGBA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",n[n.VERTEX_SHADER=35633]="VERTEX_SHADER",n[n.COMPILE_STATUS=35713]="COMPILE_STATUS",n[n.DELETE_STATUS=35712]="DELETE_STATUS",n[n.LINK_STATUS=35714]="LINK_STATUS",n[n.VALIDATE_STATUS=35715]="VALIDATE_STATUS",n[n.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",n[n.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",n[n.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",n[n.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",n[n.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",n[n.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",n[n.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",n[n.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",n[n.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",n[n.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",n[n.SHADER_TYPE=35663]="SHADER_TYPE",n[n.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",n[n.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",n[n.NEVER=512]="NEVER",n[n.LESS=513]="LESS",n[n.EQUAL=514]="EQUAL",n[n.LEQUAL=515]="LEQUAL",n[n.GREATER=516]="GREATER",n[n.NOTEQUAL=517]="NOTEQUAL",n[n.GEQUAL=518]="GEQUAL",n[n.ALWAYS=519]="ALWAYS",n[n.KEEP=7680]="KEEP",n[n.REPLACE=7681]="REPLACE",n[n.INCR=7682]="INCR",n[n.DECR=7683]="DECR",n[n.INVERT=5386]="INVERT",n[n.INCR_WRAP=34055]="INCR_WRAP",n[n.DECR_WRAP=34056]="DECR_WRAP",n[n.NEAREST=9728]="NEAREST",n[n.LINEAR=9729]="LINEAR",n[n.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",n[n.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",n[n.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",n[n.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE=5890]="TEXTURE",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n[n.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",n[n.TEXTURE0=33984]="TEXTURE0",n[n.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",n[n.REPEAT=10497]="REPEAT",n[n.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n[n.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",n[n.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_CUBE=35680]="SAMPLER_CUBE",n[n.LOW_FLOAT=36336]="LOW_FLOAT",n[n.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",n[n.HIGH_FLOAT=36338]="HIGH_FLOAT",n[n.LOW_INT=36339]="LOW_INT",n[n.MEDIUM_INT=36340]="MEDIUM_INT",n[n.HIGH_INT=36341]="HIGH_INT",n[n.FRAMEBUFFER=36160]="FRAMEBUFFER",n[n.RENDERBUFFER=36161]="RENDERBUFFER",n[n.RGBA4=32854]="RGBA4",n[n.RGB5_A1=32855]="RGB5_A1",n[n.RGB565=36194]="RGB565",n[n.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",n[n.STENCIL_INDEX=6401]="STENCIL_INDEX",n[n.STENCIL_INDEX8=36168]="STENCIL_INDEX8",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n[n.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",n[n.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",n[n.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",n[n.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",n[n.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",n[n.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",n[n.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",n[n.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",n[n.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",n[n.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",n[n.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",n[n.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",n[n.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",n[n.NONE=0]="NONE",n[n.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",n[n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",n[n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",n[n.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",n[n.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",n[n.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",n[n.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",n[n.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",n[n.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",n[n.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",n[n.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",n[n.READ_BUFFER=3074]="READ_BUFFER",n[n.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",n[n.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",n[n.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",n[n.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",n[n.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",n[n.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",n[n.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",n[n.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",n[n.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",n[n.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",n[n.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",n[n.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",n[n.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",n[n.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",n[n.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",n[n.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",n[n.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",n[n.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",n[n.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",n[n.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",n[n.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",n[n.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",n[n.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",n[n.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",n[n.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",n[n.RED=6403]="RED",n[n.RGB8=32849]="RGB8",n[n.RGBA8=32856]="RGBA8",n[n.RGB10_A2=32857]="RGB10_A2",n[n.TEXTURE_3D=32879]="TEXTURE_3D",n[n.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",n[n.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",n[n.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",n[n.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",n[n.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",n[n.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",n[n.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",n[n.SRGB=35904]="SRGB",n[n.SRGB8=35905]="SRGB8",n[n.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",n[n.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",n[n.RGBA32F=34836]="RGBA32F",n[n.RGB32F=34837]="RGB32F",n[n.RGBA16F=34842]="RGBA16F",n[n.RGB16F=34843]="RGB16F",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",n[n.R11F_G11F_B10F=35898]="R11F_G11F_B10F",n[n.RGB9_E5=35901]="RGB9_E5",n[n.RGBA32UI=36208]="RGBA32UI",n[n.RGB32UI=36209]="RGB32UI",n[n.RGBA16UI=36214]="RGBA16UI",n[n.RGB16UI=36215]="RGB16UI",n[n.RGBA8UI=36220]="RGBA8UI",n[n.RGB8UI=36221]="RGB8UI",n[n.RGBA32I=36226]="RGBA32I",n[n.RGB32I=36227]="RGB32I",n[n.RGBA16I=36232]="RGBA16I",n[n.RGB16I=36233]="RGB16I",n[n.RGBA8I=36238]="RGBA8I",n[n.RGB8I=36239]="RGB8I",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.R8=33321]="R8",n[n.RG8=33323]="RG8",n[n.R16F=33325]="R16F",n[n.R32F=33326]="R32F",n[n.RG16F=33327]="RG16F",n[n.RG32F=33328]="RG32F",n[n.R8I=33329]="R8I",n[n.R8UI=33330]="R8UI",n[n.R16I=33331]="R16I",n[n.R16UI=33332]="R16UI",n[n.R32I=33333]="R32I",n[n.R32UI=33334]="R32UI",n[n.RG8I=33335]="RG8I",n[n.RG8UI=33336]="RG8UI",n[n.RG16I=33337]="RG16I",n[n.RG16UI=33338]="RG16UI",n[n.RG32I=33339]="RG32I",n[n.RG32UI=33340]="RG32UI",n[n.R8_SNORM=36756]="R8_SNORM",n[n.RG8_SNORM=36757]="RG8_SNORM",n[n.RGB8_SNORM=36758]="RGB8_SNORM",n[n.RGBA8_SNORM=36759]="RGBA8_SNORM",n[n.RGB10_A2UI=36975]="RGB10_A2UI",n[n.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",n[n.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.HALF_FLOAT=5131]="HALF_FLOAT",n[n.RG=33319]="RG",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",n[n.CURRENT_QUERY=34917]="CURRENT_QUERY",n[n.QUERY_RESULT=34918]="QUERY_RESULT",n[n.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",n[n.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",n[n.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",n[n.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",n[n.DRAW_BUFFER0=34853]="DRAW_BUFFER0",n[n.DRAW_BUFFER1=34854]="DRAW_BUFFER1",n[n.DRAW_BUFFER2=34855]="DRAW_BUFFER2",n[n.DRAW_BUFFER3=34856]="DRAW_BUFFER3",n[n.DRAW_BUFFER4=34857]="DRAW_BUFFER4",n[n.DRAW_BUFFER5=34858]="DRAW_BUFFER5",n[n.DRAW_BUFFER6=34859]="DRAW_BUFFER6",n[n.DRAW_BUFFER7=34860]="DRAW_BUFFER7",n[n.DRAW_BUFFER8=34861]="DRAW_BUFFER8",n[n.DRAW_BUFFER9=34862]="DRAW_BUFFER9",n[n.DRAW_BUFFER10=34863]="DRAW_BUFFER10",n[n.DRAW_BUFFER11=34864]="DRAW_BUFFER11",n[n.DRAW_BUFFER12=34865]="DRAW_BUFFER12",n[n.DRAW_BUFFER13=34866]="DRAW_BUFFER13",n[n.DRAW_BUFFER14=34867]="DRAW_BUFFER14",n[n.DRAW_BUFFER15=34868]="DRAW_BUFFER15",n[n.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",n[n.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",n[n.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",n[n.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",n[n.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",n[n.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",n[n.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",n[n.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",n[n.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",n[n.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",n[n.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",n[n.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",n[n.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",n[n.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",n[n.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",n[n.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",n[n.SAMPLER_3D=35679]="SAMPLER_3D",n[n.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",n[n.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",n[n.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",n[n.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",n[n.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",n[n.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",n[n.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",n[n.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",n[n.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",n[n.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",n[n.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",n[n.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",n[n.MAX_SAMPLES=36183]="MAX_SAMPLES",n[n.SAMPLER_BINDING=35097]="SAMPLER_BINDING",n[n.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",n[n.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",n[n.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",n[n.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",n[n.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",n[n.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",n[n.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",n[n.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",n[n.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",n[n.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",n[n.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",n[n.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",n[n.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",n[n.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",n[n.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",n[n.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",n[n.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",n[n.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",n[n.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",n[n.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",n[n.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",n[n.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",n[n.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",n[n.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",n[n.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",n[n.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",n[n.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",n[n.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",n[n.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",n[n.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",n[n.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",n[n.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",n[n.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",n[n.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",n[n.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",n[n.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",n[n.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",n[n.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",n[n.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",n[n.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",n[n.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",n[n.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",n[n.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",n[n.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",n[n.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",n[n.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",n[n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n[n.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",n[n.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",n[n.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",n[n.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",n[n.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",n[n.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",n[n.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",n[n.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",n[n.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",n[n.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",n[n.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",n[n.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",n[n.UNIFORM_TYPE=35383]="UNIFORM_TYPE",n[n.UNIFORM_SIZE=35384]="UNIFORM_SIZE",n[n.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",n[n.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",n[n.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",n[n.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",n[n.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",n[n.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",n[n.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",n[n.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",n[n.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",n[n.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",n[n.OBJECT_TYPE=37138]="OBJECT_TYPE",n[n.SYNC_CONDITION=37139]="SYNC_CONDITION",n[n.SYNC_STATUS=37140]="SYNC_STATUS",n[n.SYNC_FLAGS=37141]="SYNC_FLAGS",n[n.SYNC_FENCE=37142]="SYNC_FENCE",n[n.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",n[n.UNSIGNALED=37144]="UNSIGNALED",n[n.SIGNALED=37145]="SIGNALED",n[n.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",n[n.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",n[n.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",n[n.WAIT_FAILED=37149]="WAIT_FAILED",n[n.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",n[n.COLOR=6144]="COLOR",n[n.DEPTH=6145]="DEPTH",n[n.STENCIL=6146]="STENCIL",n[n.MIN=32775]="MIN",n[n.MAX=32776]="MAX",n[n.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",n[n.STREAM_READ=35041]="STREAM_READ",n[n.STREAM_COPY=35042]="STREAM_COPY",n[n.STATIC_READ=35045]="STATIC_READ",n[n.STATIC_COPY=35046]="STATIC_COPY",n[n.DYNAMIC_READ=35049]="DYNAMIC_READ",n[n.DYNAMIC_COPY=35050]="DYNAMIC_COPY",n[n.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",n[n.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",n[n.INVALID_INDEX=4294967295]="INVALID_INDEX",n[n.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",n[n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",n[n.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",n[n.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",n[n.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",n[n.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",n[n.R16_EXT=33322]="R16_EXT",n[n.RG16_EXT=33324]="RG16_EXT",n[n.RGB16_EXT=32852]="RGB16_EXT",n[n.RGBA16_EXT=32859]="RGBA16_EXT",n[n.R16_SNORM_EXT=36760]="R16_SNORM_EXT",n[n.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",n[n.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",n[n.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",n[n.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",n[n.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",n[n.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",n[n.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",n[n.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",n[n.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",n[n.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",n[n.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",n[n.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",n[n.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",n[n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",n[n.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",n[n.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",n[n.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",n[n.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",n[n.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",n[n.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",n[n.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",n[n.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",n[n.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",n[n.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",n[n.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",n[n.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",n[n.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",n[n.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",n[n.LINE_WEBGL=6913]="LINE_WEBGL",n[n.FILL_WEBGL=6914]="FILL_WEBGL",n[n.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",n[n.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",n[n.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",n[n.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",n[n.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",n[n.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",n[n.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",n[n.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",n[n.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",n[n.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",n[n.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",n[n.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",n[n.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",n[n.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",n[n.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",n[n.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",n[n.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",n[n.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",n[n.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",n[n.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",n[n.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",n[n.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",n[n.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",n[n.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})($t||($t={}));const Vm={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},Hm=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Wm=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),$m=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}});function Xm(n=!0){const e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){const r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&Ym(r),r}return this.originalGetContext(t,i)}}function Ym(n){n.getExtension("EXT_color_buffer_float");const e={...Vm,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Hm(n),OES_vertex_array_object:Wm(n),ANGLE_instanced_arrays:$m(n)},t=n.getExtension;n.getExtension=function(r){const s=t.call(n,r);return s||(r in e?e[r]:null)};const i=n.getSupportedExtensions;n.getSupportedExtensions=function(){const r=i.apply(n)||[];return r==null?void 0:r.concat(Object.keys(e))}}async function Qa(n,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",n),new Promise((r,s)=>{i.onload=r,i.onerror=o=>s(new Error(`Unable to load script '${n}': ${o}`)),t.appendChild(i)})}const qm=1;let he=null,Ja=!1;const Ss={debugSpectorJS:D.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function jm(n){if(!globalThis.SPECTOR)try{await Qa(n.debugSpectorJSUrl||Ss.debugSpectorJSUrl)}catch(e){D.warn(String(e))}}function Km(n){var e;if(n={...Ss,...n},!n.debugSpectorJS)return null;if(!he&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){D.probe(qm,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;he=new t,globalThis.luma&&(globalThis.luma.spector=he)}if(!he)return null;if(Ja||(Ja=!0,he.spyCanvases(),he==null||he.onCaptureStarted.add(t=>D.info("Spector capture started:",t)()),he==null||he.onCapture.add(t=>{D.info("Spector capture complete:",t)(),he==null||he.getResultUI(),he==null||he.resultView.display(),he==null||he.resultView.addCapture(t)})),n.gl){const t=n.gl,i=t.device;he==null||he.startCapture(n.gl,500),t.device=i,new Promise(r=>setTimeout(r,2e3)).then(r=>{D.info("Spector capture stopped after 2 seconds")(),he==null||he.stopCapture()})}return he}const Zm="https://unpkg.com/webgl-debug@2.0.1/index.js";function Ga(n){return n.luma=n.luma||{},n.luma}async function Qm(){Lt()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Qa(Zm))}function Jm(n,e={}){return e.debugWebGL||e.traceWebGL?eg(n,e):Gm(n)}function Gm(n){const e=Ga(n);return e.realContext?e.realContext:n}function eg(n,e){if(!globalThis.WebGLDebugUtils)return D.warn("webgl-debug not loaded")(),n;const t=Ga(n);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...$t,...n});const i=globalThis.WebGLDebugUtils.makeDebugContext(n,tg.bind(null,e),ng.bind(null,e));for(const o in $t)!(o in i)&&typeof $t[o]=="number"&&(i[o]=$t[o]);class r{}Object.setPrototypeOf(i,Object.getPrototypeOf(n)),Object.setPrototypeOf(r,i);const s=Object.create(r);return t.realContext=n,t.debugContext=s,s.debug=!0,s}function el(n,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(n,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${n}(${t})`}function tg(n,e,t,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);const r=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,i),o=`${r} in gl.${t}(${s})`;D.error(o)();debugger}function ng(n,e,t){let i="";D.level>=1&&(i=el(e,t),n.traceWebGL&&D.log(1,i)());for(const r of t)if(r===void 0){i=i||el(e,t);debugger}}const Li=1;class ig extends am{constructor(){super();m(this,"type","webgl");Ht.defaultProps={...Ht.defaultProps,...Ss}}enforceWebGL2(t){Xm(t)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&t instanceof WebGLRenderingContext&&D.warn("WebGL1 is not supported",t)(),!1)}async attach(t,i={}){const{WebGLDevice:r}=await Promise.resolve().then(()=>Al);if(t instanceof r)return t;if((t==null?void 0:t.device)instanceof r)return t.device;if(!rg(t))throw new Error("Invalid WebGL2RenderingContext");const s=i.createCanvasContext===!0?{}:i.createCanvasContext;return new r({...i,_handle:t,createCanvasContext:{canvas:t.canvas,autoResize:!1,...s}})}async create(t={}){const{WebGLDevice:i}=await Promise.resolve().then(()=>Al);D.groupCollapsed(Li,"WebGLDevice created")();try{const r=[];(t.debugWebGL||t.debug)&&r.push(Qm()),t.debugSpectorJS&&r.push(jm(t));const s=await Promise.allSettled(r);for(const l of s)l.status==="rejected"&&D.error(`Failed to initialize debug libraries ${l.reason}`)();const o=new i(t),a=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return D.probe(Li,a)(),D.table(Li,o.info)(),o}finally{D.groupEnd(Li)()}}}function rg(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&Number.isFinite(n._version))}const sg=new ig,Ts={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},be=(n,e,t)=>e?n.enable(t):n.disable(t),tl=(n,e,t)=>n.hint(t,e),je=(n,e,t)=>n.pixelStorei(t,e),nl=(n,e,t)=>{const i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},On=(n,e,t)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};function ws(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}const og={3042:be,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:be,2885:(n,e)=>n.cullFace(e),2929:be,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:be,35723:tl,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>{var t;return(t=n.bindTransformFeedback)==null?void 0:t.call(n,36386,e)},34229:(n,e)=>n.bindVertexArray(e),36006:nl,36010:nl,34964:On,36662:On,36663:On,35053:On,35055:On,2886:(n,e)=>n.frontFace(e),33170:tl,2849:(n,e)=>n.lineWidth(e),32823:be,32824:"polygonOffset",10752:"polygonOffset",35977:be,32926:be,32928:be,32938:"sampleCoverage",32939:"sampleCoverage",3089:be,3088:(n,e)=>n.scissor(...e),2960:be,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:be,10754:be,12288:be,12289:be,12290:be,12291:be,12292:be,12293:be,12294:be,12295:be,3333:je,3317:je,37440:je,37441:je,37443:je,3330:je,3332:je,3331:je,3314:je,32878:je,3316:je,3315:je,32877:je,framebuffer:(n,e)=>{const t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{const t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{const t=(e==null?void 0:e.length)===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=ws(e)?e:[e,e];const[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=ws(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=ws(e)&&e.length===3?[...e,...e]:e;const[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};function ye(n,e,t){return e[n]!==void 0?e[n]:t[n]}const ag={blendEquation:(n,e,t)=>n.blendEquationSeparate(ye(32777,e,t),ye(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(ye(32969,e,t),ye(32968,e,t),ye(32971,e,t),ye(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(ye(32824,e,t),ye(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(ye(32938,e,t),ye(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,ye(2962,e,t),ye(2967,e,t),ye(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,ye(34816,e,t),ye(36003,e,t),ye(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,ye(2964,e,t),ye(2965,e,t),ye(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,ye(34817,e,t),ye(34818,e,t),ye(34819,e,t))},il={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},pt=(n,e)=>n.isEnabled(e),rl={3042:pt,2884:pt,2929:pt,3024:pt,32823:pt,32926:pt,32928:pt,3089:pt,2960:pt,35977:pt},lg=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function un(n,e){if(ug(e))return;const t={};for(const r in e){const s=Number(r),o=og[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}const i=n.state&&n.state.cache;if(i)for(const r in t){const s=ag[r];s(n,e,i)}}function sl(n,e=Ts){if(typeof e=="number"){const r=e,s=rl[r];return s?s(n,r):n.getParameter(r)}const t=Array.isArray(e)?e:Object.keys(e),i={};for(const r of t){const s=rl[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function cg(n){un(n,Ts)}function ug(n){for(const e in n)return!1;return!0}function fg(n,e){if(n===e)return!0;if(ol(n)&&ol(e)&&n.length===e.length){for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}return!1}function ol(n){return Array.isArray(n)||ArrayBuffer.isView(n)}class Xt{constructor(e,t){m(this,"gl");m(this,"program",null);m(this,"stateStack",[]);m(this,"enable",!0);m(this,"cache",null);m(this,"log");m(this,"initialized",!1);this.gl=e,this.log=(t==null?void 0:t.log)||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];un(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t!=null&&t.copyState?sl(e):Object.assign({},Ts),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,dg(e);for(const i in il){const r=il[i];hg(e,i,r)}al(e,"getParameter"),al(e,"isEnabled")}_updateCache(e){let t=!1,i;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const s in e){const o=e[s],a=this.cache[s];fg(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}function al(n,e){const t=n[e].bind(n);n[e]=function(r){if(r===void 0||lg.has(r))return t(r);const s=Xt.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function hg(n,e,t){if(!n[e])return;const i=n[e].bind(n);n[e]=function(...s){const o=Xt.get(n),{valueChanged:a,oldValue:l}=t(o._updateCache,...s);return a&&i(...s),l},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function dg(n){const e=n.useProgram.bind(n);n.useProgram=function(i){const r=Xt.get(n);r.program!==i&&(e(i),r.program=i)}}function pg(n,e,t){let i="";const r={preserveDrawingBuffer:!0,...t};let s=null;if(s||(s=n.getContext("webgl2",r)),r.failIfMajorPerformanceCaveat&&(i||(i="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),!s&&!t.failIfMajorPerformanceCaveat&&(r.failIfMajorPerformanceCaveat=!1,s=n.getContext("webgl2",r),s.luma||(s.luma={}),s.luma.softwareRenderer=!0),s||(s=n.getContext("webgl",{}),s&&(s=null,i||(i="Your browser only supports WebGL1"))),!s)throw i||(i="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${i}`);const{onContextLost:o,onContextRestored:a}=e;return n.addEventListener("webglcontextlost",l=>o(l),!1),n.addEventListener("webglcontextrestored",l=>a(l),!1),s.luma||(s.luma={}),s}function fn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}function mg(n,e){const t=n.getParameter(7936),i=n.getParameter(7937);fn(n,"WEBGL_debug_renderer_info",e);const r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,l=o||i,c=n.getParameter(7938),u=ll(a,l),f=gg(a,l),h=_g(a,l);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:l,version:c,shadingLanguage:"glsl",shadingLanguageVersion:300}}function ll(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function gg(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function _g(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(ll(n,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function cl(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}const Bn="WEBGL_compressed_texture_s3tc",Un="WEBGL_compressed_texture_s3tc_srgb",hn="EXT_texture_compression_rgtc",dn="EXT_texture_compression_bptc",xg="WEBGL_compressed_texture_etc",yg="WEBGL_compressed_texture_astc",vg="WEBGL_compressed_texture_etc1",bg="WEBGL_compressed_texture_pvrtc",Sg="WEBGL_compressed_texture_atc",ul="EXT_texture_norm16",fl="EXT_render_snorm",Tg="EXT_color_buffer_float",As={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[fl],"norm16-renderable-webgl":[ul],"snorm16-renderable-webgl":[ul,fl],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Bn,Un,hn,dn],"texture-compression-bc5-webgl":[hn],"texture-compression-bc7-webgl":[dn],"texture-compression-etc2":[xg],"texture-compression-astc":[yg],"texture-compression-etc1-webgl":[vg],"texture-compression-pvrtc-webgl":[bg],"texture-compression-atc-webgl":[Sg]};function wg(n){return n in As}function Ag(n,e,t){return(As[e]||[]).every(r=>fn(n,r,t))}const Cs={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:Tg,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Bn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Un},"bc1-rgba-unorm":{gl:33777,x:Bn},"bc1-rgba-unorm-srgb":{gl:35916,x:Un},"bc2-rgba-unorm":{gl:33778,x:Bn},"bc2-rgba-unorm-srgb":{gl:35918,x:Un},"bc3-rgba-unorm":{gl:33779,x:Bn},"bc3-rgba-unorm-srgb":{gl:35919,x:Un},"bc4-r-unorm":{gl:36283,x:hn},"bc4-r-snorm":{gl:36284,x:hn},"bc5-rg-unorm":{gl:36285,x:hn},"bc5-rg-snorm":{gl:36286,x:hn},"bc6h-rgb-ufloat":{gl:36495,x:dn},"bc6h-rgb-float":{gl:36494,x:dn},"bc7-rgba-unorm":{gl:36492,x:dn},"bc7-rgba-unorm-srgb":{gl:36493,x:dn},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function Cg(n,e,t){let i=e.create;const r=Cs[e.format];return(r==null?void 0:r.gl)===void 0&&(i=!1),r!=null&&r.x&&(i=i&&!!fn(n,r.x,t)),{format:e.format,create:i&&e.create,render:i&&e.render,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function hl(n){var r;const e=Cs[n],t=Eg(n),i=Vt.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:(e==null?void 0:e.dataFormat)||Pg(i.channels,i.integer,i.normalized,t),type:i.dataType?cl(i.dataType):((r=e==null?void 0:e.types)==null?void 0:r[0])||5121,compressed:i.compressed||!1}}function Ig(n){switch(Vt.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function Pg(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Eg(n){const e=Cs[n],t=e==null?void 0:e.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}const dl={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Rg extends rm{constructor(t,i,r){super([],r);m(this,"gl");m(this,"extensions");m(this,"testedFeatures",new Set);this.gl=t,this.extensions=i,fn(t,"EXT_color_buffer_float",i)}*[Symbol.iterator](){const t=this.getFeatures();for(const i of t)this.has(i)&&(yield i);return[]}has(t){var i;return(i=this.disabledFeatures)!=null&&i[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),wg(t)&&Ag(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){const t=this.getFeatures().filter(i=>i!=="polygon-mode-webgl");for(const i of t)this.has(i)}getFeatures(){return[...Object.keys(dl),...Object.keys(As)]}getWebGLFeature(t){const i=dl[t];return typeof i=="string"?!!fn(this.gl,i,this.extensions):!!i}}class kg extends im{constructor(t){super();m(this,"gl");m(this,"limits",{});this.gl=t}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}class zn extends Oi{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"colorAttachments",[]);m(this,"depthStencilAttachment",null);const r=i.handle===null;this.device=t,this.gl=t.gl,this.handle=this.props.handle||r?this.props.handle:this.gl.createFramebuffer(),r||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const t=this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i<this.colorAttachments.length;++i){const r=this.colorAttachments[i];if(r){const s=36064+i;this._attachTextureView(s,r)}}if(this.depthStencilAttachment){const i=Ig(this.depthStencilAttachment.props.format);this._attachTextureView(i,this.depthStencilAttachment)}if(this.device.props.debug){const i=this.gl.checkFramebufferStatus(36160);if(i!==36053)throw new Error(`Framebuffer ${Mg(i)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,i){const{gl:r}=this.device,{texture:s}=i,o=i.props.baseMipLevel,a=i.props.baseArrayLayer;switch(r.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:r.framebufferTextureLayer(36160,t,s.handle,o,a);break;case 34067:const l=Dg(a);r.framebufferTexture2D(36160,t,l,s.handle,o);break;case 3553:r.framebufferTexture2D(36160,t,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}r.bindTexture(s.glTarget,null)}}function Dg(n){return n<34069?n+34069:n}function Mg(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}class Fg extends Mi{constructor(t,i){super(i);m(this,"device");m(this,"handle",null);m(this,"_framebuffer",null);this.device=t,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._updateDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new zn(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}const Is={};function Ng(n="id"){Is[n]=Is[n]||1;const e=Is[n]++;return`${n}-${e}`}class Ln extends L{constructor(t,i={}){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"glTarget");m(this,"glUsage");m(this,"glIndexType",5123);m(this,"byteLength",0);m(this,"bytesUsed",0);this.device=t,this.gl=this.device.gl;const r=typeof i=="object"?i.handle:void 0;this.handle=r||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Og(this.props.usage),this.glUsage=Bg(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,i.data?this._initWithData(i.data,i.byteOffset,i.byteLength):this._initWithByteLength(i.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(t,i=0,r=t.byteLength+i){const s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bufferSubData(s,i,t),this.gl.bindBuffer(s,null),this.bytesUsed=r,this.byteLength=r,this._setDebugData(t,i,r),this.trackAllocatedMemory(r)}_initWithByteLength(t){let i=t;t===0&&(i=new Float32Array(0));const r=this.glTarget;return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bindBuffer(r,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}write(t,i=0){const r=ArrayBuffer.isView(t)?t:new Uint8Array(t),s=36663;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,i,r),this.gl.bindBuffer(s,null),this._setDebugData(t,i,t.byteLength)}async mapAndWriteAsync(t,i=0,r=this.byteLength-i){const s=new ArrayBuffer(r);await t(s,"copied"),this.write(s,i)}async readAsync(t=0,i){return this.readSyncWebGL(t,i)}async mapAndReadAsync(t,i=0,r){const s=await this.readAsync(i,r);return await t(s.buffer,"copied")}readSyncWebGL(t=0,i){i=i??this.byteLength-t;const r=new Uint8Array(i),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,r,s,i),this.gl.bindBuffer(36662,null),this._setDebugData(r,t,i),r}}function Og(n){return n&L.INDEX?34963:n&L.VERTEX?34962:n&L.UNIFORM?35345:34962}function Bg(n){return n&L.INDEX||n&L.VERTEX?35044:n&L.UNIFORM?35048:35044}function Ug(n){const e=n.split(/\r?\n/),t=[];for(const i of e){if(i.length<=1)continue;const r=i.split(":");if(r.length===2){const[f,h]=r;t.push({message:h.trim(),type:pl(f),lineNum:0,linePos:0});continue}const[s,o,a,...l]=r;let c=parseInt(a,10);isNaN(c)&&(c=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:l.join(":").trim(),type:pl(s),lineNum:c,linePos:u})}return t}function pl(n){const e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}class zg extends Ni{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");switch(this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const t=this.device.gl.getShaderInfoLog(this.handle);return t?Ug(t):[]}getTranslatedSource(){const i=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(i==null?void 0:i.getTranslatedShaderSource(this.handle))||null}async _compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
12
|
+
${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}D.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),D.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function Lg(n,e,t,i){if($g(e))return i(n);const r=n;r.pushState();try{return Vg(n,e),un(r.gl,t),i(n)}finally{r.popState()}}function Vg(n,e){const t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Yt("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){const s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Yt("provokingVertex",e.provokingVertex,{first:36429,last:36430});s==null||s.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){const s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Yt("polygonMode",e.polygonMode,{fill:6914,line:6913});s==null||s.polygonModeWEBGL(1028,o),s==null||s.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(Wg("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(Ps("depthCompare",e.depthCompare))),e.stencilWriteMask){const r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&D.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const r=e.stencilReadMask||4294967295,s=Ps("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const r=Es("stencilPassOperation",e.stencilPassOperation),s=Es("stencilFailOperation",e.stencilFailOperation),o=Es("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const r=ml("blendColorOperation",e.blendColorOperation||"add"),s=ml("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);const o=Vi("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Vi("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=Vi("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),c=Vi("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,l,c)}}function Ps(n,e){return Yt(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Es(n,e){return Yt(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function ml(n,e){return Yt(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Vi(n,e,t="color"){return Yt(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Hg(n,e){return`Illegal parameter ${e} for ${n}`}function Yt(n,e,t){if(!(e in t))throw new Error(Hg(n,e));return t[e]}function Wg(n,e){return e}function $g(n){let e=!0;for(const t in n){e=!1;break}return e}function gl(n){const e={};return n.addressModeU&&(e[10242]=Rs(n.addressModeU)),n.addressModeV&&(e[10243]=Rs(n.addressModeV)),n.addressModeW&&(e[32882]=Rs(n.addressModeW)),n.magFilter&&(e[10240]=ks(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=Xg(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=Ps("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function Rs(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function ks(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function Xg(n,e="none"){if(!e)return ks(n);switch(e){case"none":return ks(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}class Yg extends cn{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"parameters");this.device=t,this.parameters=gl(i),this.handle=i.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(const[i,r]of Object.entries(t)){const s=Number(i);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,r);break;default:this.device.gl.samplerParameteri(this.handle,s,r);break}}}}function Vn(n,e,t){if(qg(e))return t(n);const{nocatch:i=!0}=e,r=Xt.get(n);r.push(),un(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function qg(n){for(const e in n)return!1;return!0}class pn extends Fi{constructor(t,i){super(t,{...Q.defaultProps,...i});m(this,"device");m(this,"gl");m(this,"handle");m(this,"texture");this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=i.texture}}class Hn extends Q{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"sampler");m(this,"view");m(this,"glTarget");m(this,"glFormat");m(this,"glType");m(this,"glInternalFormat");m(this,"compressed");m(this,"_textureUnit",0);this.device=t,this.gl=this.device.gl;const r=hl(this.props.format);this.glTarget=jg(this.props.dimension),this.glInternalFormat=r.internalFormat,this.glFormat=r.format,this.glType=r.type,this.compressed=r.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:s,width:o,height:a,depth:l,mipLevels:c,glTarget:u,glInternalFormat:f}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(u,c,f,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,c,f,o,a,l);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(i.data),this.setSampler(this.props.sampler),this.view=new pn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(t){return new pn(this.device,{...t,texture:this})}setSampler(t={}){super.setSampler(t);const i=gl(this.sampler.props);this._setSamplerParameters(i)}copyImageData(t){const i=this._normalizeCopyImageDataOptions(t),r=i.data,{width:s,height:o,depth:a}=this,{mipLevel:l=0,byteOffset:c=0,x:u=0,y:f=0,z:h=0}=i,{glFormat:d,glType:_,compressed:I}=this,P=_l(this.glTarget,this.dimension,h);let A;if(!this.compressed){const{bytesPerPixel:E}=this.device.getTextureFormatInfo(this.format);if(E){if(i.bytesPerRow%E!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${E}) for ${this.format}`);A=i.bytesPerRow/E}}const O=this.compressed?{}:{...A!==void 0?{3314:A}:{},32878:i.rowsPerImage};this.gl.bindTexture(P,this.handle),Vn(this.gl,O,()=>{switch(this.dimension){case"2d":case"cube":I?this.gl.compressedTexSubImage2D(P,l,u,f,s,o,d,r,c):this.gl.texSubImage2D(P,l,u,f,s,o,d,_,r,c);break;case"2d-array":case"3d":I?this.gl.compressedTexSubImage3D(P,l,u,f,h,s,o,a,d,r,c):this.gl.texSubImage3D(P,l,u,f,h,s,o,a,d,_,r,c);break;default:}}),this.gl.bindTexture(P,null)}copyExternalImage(t){const i=this._normalizeCopyExternalImageOptions(t);if(i.sourceX||i.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:r,glType:s}=this,{image:o,depth:a,mipLevel:l,x:c,y:u,z:f,width:h,height:d}=i,_=_l(this.glTarget,this.dimension,a),I=i.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Vn(this.gl,I,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(_,l,c,u,h,d,r,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(_,l,c,u,f,h,d,a,r,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:i.width,height:i.height}}generateMipmapsWebGL(t){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(D.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(t!=null&&t.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(r){D.warn(`Error generating mipmap for ${this}: ${r.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){D.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[i,r]of Object.entries(t)){const s=Number(i),o=r;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,this.handle),t}_unbind(t){const{gl:i}=this;return t!==void 0&&(this._textureUnit=t,i.activeTexture(33984+t)),i.bindTexture(this.glTarget,null),t}}function jg(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(n)}function _l(n,e,t){return e==="cube"?34069+t:n}function Kg(n){return Gg[n]}function Ds(n){return Jg[n]}function Zg(n){return!!xl[n]}function Qg(n){return xl[n]}const Jg={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},xl={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Gg={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function e_(n,e){const t={attributes:[],bindings:[]};t.attributes=t_(n,e);const i=r_(n,e);for(const a of i){const l=a.uniforms.map(c=>({name:c.name,format:c.format,byteOffset:c.byteOffset,byteStride:c.byteStride,arrayLength:c.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:l})}const r=i_(n,e);let s=0;for(const a of r)if(Zg(a.type)){const{viewDimension:l,sampleType:c}=Qg(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:l,sampleType:c}),a.textureUnit=s,s+=1}r.length&&(t.uniforms=r);const o=n_(n,e);return o!=null&&o.length&&(t.varyings=o),t}function t_(n,e){const t=[],i=n.getProgramParameter(e,35721);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a}=s,l=n.getAttribLocation(e,o);if(l>=0){const c=Ds(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:l,stepMode:u,type:c})}}return t.sort((r,s)=>r.location-s.location),t}function n_(n,e){const t=[],i=n.getProgramParameter(e,35971);for(let r=0;r<i;r++){const s=n.getTransformFeedbackVarying(e,r);if(!s)throw new Error("activeInfo");const{name:o,type:a,size:l}=s,c=Ds(a),{type:u,components:f}=ja(c);t.push({location:r,name:o,type:u,size:l*f})}return t.sort((r,s)=>r.location-s.location),t}function i_(n,e){const t=[],i=n.getProgramParameter(e,35718);for(let r=0;r<i;r++){const s=n.getActiveUniform(e,r);if(!s)throw new Error("activeInfo");const{name:o,size:a,type:l}=s,{name:c,isArray:u}=s_(o);let f=n.getUniformLocation(e,c);const h={location:f,name:c,size:a,type:l,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){const _=`${c}[${d}]`;f=n.getUniformLocation(e,_);const I={...h,name:_,location:f};t.push(I)}}return t}function r_(n,e){const t=(s,o)=>n.getActiveUniformBlockParameter(e,s,o),i=[],r=n.getProgramParameter(e,35382);for(let s=0;s<r;s++){const o={name:n.getActiveUniformBlockName(e,s)||"",location:t(s,35391),byteLength:t(s,35392),vertex:t(s,35396),fragment:t(s,35398),uniformCount:t(s,35394),uniforms:[]},a=t(s,35395)||[],l=n.getActiveUniforms(e,a,35383),c=n.getActiveUniforms(e,a,35384),u=n.getActiveUniforms(e,a,35387),f=n.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){const d=n.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");const _=Ds(l[h]);o.uniforms.push({name:d.name,format:_,type:l[h],arrayLength:c[h],byteOffset:u[h],byteStride:f[h]})}i.push(o)}return i.sort((s,o)=>s.location-o.location),i}function s_(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(n);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${n}`);return{name:t[1],length:t[2]?1:0,isArray:!!t[2]}}function o_(n,e,t,i){const r=n;let s=i;s===!0&&(s=1),s===!1&&(s=0);const o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function a_(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function l_(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}const yl=4;class c_ extends Wt{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"vs");m(this,"fs");m(this,"introspectedLayout");m(this,"uniforms",{});m(this,"bindings",{});m(this,"varyings",null);m(this,"_uniformCount",0);m(this,"_uniformSetters",{});this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=i.vs,this.fs=i.fs;const{varyings:r,bufferMode:s=35981}=i;r&&r.length>0&&(this.varyings=r,this.device.gl.transformFeedbackVaryings(this.handle,r,s)),this._linkShaders(),D.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=e_(this.device.gl,this.handle),D.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=i.shaderLayout?u_(this.introspectedLayout,i.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(t,i){for(const[r,s]of Object.entries(t)){const o=this.shaderLayout.bindings.find(a=>a.name===r)||this.shaderLayout.bindings.find(a=>a.name===`${r}Uniforms`);if(!o){const a=this.shaderLayout.bindings.map(l=>`"${l.name}"`).join(", ");i!=null&&i.disableWarnings||D.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)();continue}switch(s||D.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof Ln)&&!(s.buffer instanceof Ln))throw new Error("buffer value");break;case"texture":if(!(s instanceof pn||s instanceof Hn||s instanceof zn))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":D.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}}draw(t){var P;const{renderPass:i,parameters:r=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:l,isInstanced:c=!1,firstVertex:u=0,transformFeedback:f}=t,h=a_(s),d=!!o.indexBuffer,_=(P=o.indexBuffer)==null?void 0:P.glIndexType;if(this.linkStatus!=="success")return D.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return D.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(i),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const I=i;return Lg(this.device,r,I.glParameters,()=>{d&&c?this.device.gl.drawElementsInstanced(h,a||0,_,u,l||0):d?this.device.gl.drawElements(h,a||0,_,u):c?this.device.gl.drawArraysInstanced(h,u,a||0,l||0):this.device.gl.drawArrays(h,u,a||0),f&&f.end()}),o.unbindAfterRender(i),!0}async _linkShaders(){const{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),D.time(yl,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),D.timeEnd(yl,`linkProgram for ${this.id}`)(),D.level,!this.device.features.has("compilation-status-async-webgl")){const r=this._getLinkStatus();this._reportLinkStatus(r);return}D.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),D.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const i=this._getLinkStatus();this._reportLinkStatus(i)}async _reportLinkStatus(t){var i;switch(t){case"success":return;default:const r=t==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((i=this.fs)==null?void 0:i.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const s=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${s}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}const{gl:r}=this.device;for(;;){if(r.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(const i of this.shaderLayout.bindings)!this.bindings[i.name]&&!this.bindings[i.name.replace(/Uniforms$/,"")]&&(D.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:t}=this.device;t.useProgram(this.handle);let i=0,r=0;for(const s of this.shaderLayout.bindings){const o=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":const{name:a}=s,l=t.getUniformBlockIndex(this.handle,a);if(l===4294967295)throw new Error(`Invalid uniform block name ${a}`);t.uniformBlockBinding(this.handle,r,l),o instanceof Ln?t.bindBufferBase(35345,r,o.handle):t.bindBufferRange(35345,r,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),r+=1;break;case"texture":if(!(o instanceof pn||o instanceof Hn||o instanceof zn))throw new Error("texture");let c;if(o instanceof pn)c=o.texture;else if(o instanceof Hn)c=o;else if(o instanceof zn&&o.colorAttachments[0]instanceof pn)D.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=o.colorAttachments[0].texture;else throw new Error("No texture");t.activeTexture(33984+i),t.bindTexture(c.glTarget,c.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(const t of this.shaderLayout.uniforms||[]){const{name:i,location:r,type:s,textureUnit:o}=t,a=this.uniforms[i]??o;a!==void 0&&o_(this.device.gl,r,s,a)}}}function u_(n,e){const t={...n,attributes:n.attributes.map(i=>({...i}))};for(const i of(e==null?void 0:e.attributes)||[]){const r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):D.warn(`shader layout attribute ${i.name} not present in shader`)}return t}class f_ extends xs{constructor(t){super(t,{});m(this,"device");m(this,"handle",null);m(this,"commands",[]);this.device=t}_executeCommands(t=this.commands){for(const i of t)switch(i.name){case"copy-buffer-to-buffer":h_(this.device,i.options);break;case"copy-buffer-to-texture":d_(this.device,i.options);break;case"copy-texture-to-buffer":p_(this.device,i.options);break;case"copy-texture-to-texture":m_(this.device,i.options);break;default:throw new Error(i.name)}}}function h_(n,e){const t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function d_(n,e){throw new Error("Not implemented")}function p_(n,e){const{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:l=[0,0],destinationBuffer:c,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==0||f||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:_}=vl(t);let I;try{const P=c,A=s||d.width,O=o||d.height,E=hl(d.colorAttachments[0].texture.props.format),x=E.format,R=E.type;n.gl.bindBuffer(35051,P.handle),I=n.gl.bindFramebuffer(36160,d.handle),n.gl.readPixels(l[0],l[1],A,O,x,R,u)}finally{n.gl.bindBuffer(35051,null),I!==void 0&&n.gl.bindFramebuffer(36160,I),_&&d.destroy()}}function m_(n,e){const{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0],destinationTexture:o}=e;let{width:a=e.destinationTexture.width,height:l=e.destinationTexture.height}=e;const{framebuffer:c,destroyFramebuffer:u}=vl(t),[f,h]=r,[d,_,I]=s,P=n.gl.bindFramebuffer(36160,c.handle);let A,O;if(o instanceof Hn)A=o,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A._bind(0),O=A.glTarget;else throw new Error("invalid destination");switch(O){case 3553:case 34067:n.gl.copyTexSubImage2D(O,i,d,_,f,h,a,l);break;case 35866:case 32879:n.gl.copyTexSubImage3D(O,i,d,_,I,f,h,a,l);break}A&&A._unbind(),n.gl.bindFramebuffer(36160,P),u&&c.destroy()}function vl(n){if(n instanceof Q){const{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}const g_=[1,2,4,8];class __ extends gs{constructor(t,i){var o;super(t,i);m(this,"device");m(this,"handle",null);m(this,"glParameters",{});this.device=t;let r;if(!((o=i==null?void 0:i.parameters)!=null&&o.viewport))if(i!=null&&i.framebuffer){const{width:a,height:l}=i.framebuffer;r=[0,0,a,l]}else{const[a,l]=t.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,a,l]}this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters});const s=this.props.framebuffer;if(this.props.framebuffer&&(s!=null&&s.handle)){const a=this.props.framebuffer.colorAttachments.map((l,c)=>36064+c);this.device.gl.drawBuffers(a)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){const i={...this.glParameters};i.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(i.depthMask=!this.props.depthReadOnly),i.stencilMask=this.props.stencilReadOnly?0:1,i[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(i.viewport=t.viewport.slice(0,4),i.depthRange=[t.viewport[4],t.viewport[5]]):i.viewport=t.viewport),t.scissorRect&&(i.scissorTest=!0,i.scissor=t.scissorRect),t.blendConstant&&(i.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),i[2967]=t.stencilReference),"colorMask"in t&&(i.colorMask=g_.map(r=>!!(r&t.colorMask))),this.glParameters=i,un(this.device.gl,i)}beginOcclusionQuery(t){const i=this.props.occlusionQuerySet;i==null||i.beginOcclusionQuery()}endOcclusionQuery(){const t=this.props.occlusionQuerySet;t==null||t.endOcclusionQuery()}clear(){const t={...this.glParameters};let i=0;this.props.clearColors&&this.props.clearColors.forEach((r,s)=>{r&&this.clearColorBuffer(s,r)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(i|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(i|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(i|=1024,t.clearStencil=this.props.clearStencil),i!==0&&Vn(this.device.gl,t,()=>{this.device.gl.clear(i)})}clearColorBuffer(t=0,i=[0,0,0,0]){Vn(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(i.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,i);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,i);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,i);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class bl extends _s{constructor(t,i){super(t,i);m(this,"device");m(this,"handle",null);m(this,"commandBuffer");this.device=t,this.commandBuffer=new f_(t)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(t){return new __(this.device,t)}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,i,r){}}function x_(n){const{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s;let a=0;for(let l=i;a<s;a++)e[l++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+o-a),a=o);return n.target}class Ms extends ys{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"buffer",null);m(this,"bufferValue",null);this.device=t,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return Rp()==="Chrome"}destroy(){var t;super.destroy(),this.buffer&&((t=this.buffer)==null||t.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){const i=t;if(i&&i.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,i?i.handle:null),this.indexBuffer=i,this.device.gl.bindVertexArray(null)}setBuffer(t,i){const r=i;if(r.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:s,type:o,stride:a,offset:l,normalized:c,integer:u,divisor:f}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,r.handle),u?this.device.gl.vertexAttribIPointer(t,s,o,a,l):this.device.gl.vertexAttribPointer(t,s,o,c,a,l),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,f||0),this.attributes[t]=r,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,i){this._enable(t,!1),this.attributes[t]=i}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){const i=this.attributes[t];ArrayBuffer.isView(i)&&this.device.setConstantAttributeWebGL(t,i)}}_getAccessor(t){const i=this.attributeInfos[t];if(!i)throw new Error(`Unknown attribute location ${t}`);const r=cl(i.bufferDataType);return{size:i.bufferComponents,type:r,stride:i.byteStride,offset:i.byteOffset,normalized:i.normalized,integer:i.integer,divisor:i.stepMode==="instance"?1:0}}_enable(t,i=!0){const s=Ms.isConstantAttributeZeroSupported(this.device)||t!==0;(i||s)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),i?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,i){const r=y_(i),s=r.byteLength*t,o=r.length*t;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),a||(a=!v_(r,this.bufferValue)),a){const l=Fm(i.constructor,o);x_({target:l,source:r,start:0,count:o}),this.buffer.write(l),this.bufferValue=i}return this.buffer}}function y_(n){return Array.isArray(n)?new Float32Array(n):n}function v_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}class b_ extends vs{constructor(t,i){super(t,i);m(this,"device");m(this,"gl");m(this,"handle");m(this,"layout");m(this,"buffers",{});m(this,"unusedBuffers",{});m(this,"bindOnUse",!0);m(this,"_bound",!1);this.device=t,this.gl=t.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,i.buffers&&this.setBuffers(i.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(l_(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const i in t)this.setBuffer(i,t[i])})}setBuffer(t,i){const r=this._getVaryingIndex(t),{buffer:s,byteLength:o,byteOffset:a}=this._getBufferRange(i);if(r<0){this.unusedBuffers[t]=s,D.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[r]={buffer:s,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(r,s,a,o)}getBuffer(t){if(Sl(t))return this.buffers[t]||null;const i=this._getVaryingIndex(t);return i>=0?this.buffers[i]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let i;return this._bound?i=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,i=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),i}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof Ln)return{buffer:t,byteOffset:0,byteLength:t.byteLength};const{buffer:i,byteOffset:r=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:i,byteOffset:r,byteLength:s}}_getVaryingIndex(t){if(Sl(t))return Number(t);for(const i of this.layout.varyings||[])if(t===i.name)return i.location;return-1}_bindBuffers(){for(const t in this.buffers){const{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),i,s,r)}}_unbindBuffers(){for(const t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,i,r=0,s){const o=i&&i.handle;!o||s===void 0?this.gl.bindBufferBase(35982,t,o):this.gl.bindBufferRange(35982,t,o,r,s)}}function Sl(n){return typeof n=="number"?Number.isInteger(n):/^\d+$/.test(n)}class S_ extends bs{constructor(t,i){super(t,i);m(this,"device");m(this,"handle");m(this,"target",null);m(this,"_queryPending",!1);m(this,"_pollingPromise",null);if(this.device=t,i.count>1)throw new Error("WebGL QuerySet can only have one value");const r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");this.handle=r,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(t){return this._begin(t!=null&&t.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let i=0;return this._pollingPromise=new Promise((r,s)=>{const o=()=>{this.isResultAvailable()?(r(this.getResult()),this._pollingPromise=null):i++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}}function Tl(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function T_(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function w_(n){return A_[n]}const A_={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function C_(n,e){var O;const{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{};let{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:l,sourceFormat:c,sourceType:u}=e||{};const{framebuffer:f,deleteFramebuffer:h}=wl(n),{gl:d,handle:_}=f;o||(o=f.width),a||(a=f.height);const I=(O=f.colorAttachments[r])==null?void 0:O.texture;if(!I)throw new Error(`Invalid framebuffer attachment ${r}`);l=(I==null?void 0:I.depth)||1,c||(c=(I==null?void 0:I.glFormat)||6408),u||(u=(I==null?void 0:I.glType)||5121),s=E_(s,u,c,o,a);const P=za(s);u=u||Kg(P);const A=d.bindFramebuffer(36160,_);return d.readBuffer(36064+r),d.readPixels(t,i,o,a,c,u,s),d.readBuffer(36064),d.bindFramebuffer(36160,A||null),h&&f.destroy(),s}function I_(n,e){const{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=e||{};const{framebuffer:u,deleteFramebuffer:f}=wl(n);a=a||u.width,l=l||u.height;const h=u;c=c||5121;let d=t;if(!d){const I=Tl(s),P=T_(c),A=o+a*l*I*P;d=h.device.createBuffer({byteLength:A})}const _=n.device.createCommandEncoder();return _.copyTextureToBuffer({sourceTexture:n,width:a,height:l,origin:[i,r],destinationBuffer:d,byteOffset:o}),_.destroy(),f&&u.destroy(),d}function wl(n){return n instanceof Oi?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:P_(n),deleteFramebuffer:!0}}function P_(n,e){const{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function E_(n,e,t,i,r,s){if(n)return n;e||(e=5121);const o=w_(e),a=La(o),l=Tl(t);return new a(i*r*l)}class R_ extends Ht{constructor(t){var f,h;super({...t,id:t.id||Ng("webgl-device")});m(this,"type","webgl");m(this,"handle");m(this,"features");m(this,"limits");m(this,"info");m(this,"canvasContext");m(this,"preferredColorFormat","rgba8unorm");m(this,"preferredDepthFormat","depth24plus");m(this,"commandEncoder");m(this,"lost");m(this,"_resolveContextLost");m(this,"gl");m(this,"_constants");m(this,"_extensions",{});m(this,"_polyfilled",!1);m(this,"spectorJS");const i=Ht._getCanvasContextProps(t);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let r=(h=(f=i.canvas)==null?void 0:f.gl)==null?void 0:h.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Fg(this,i),this.lost=new Promise(d=>{this._resolveContextLost=d});const s={...t.webgl};i.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference);const a=this.props._handle||pg(this.canvasContext.canvas,{onContextLost:d=>{var _;return(_=this._resolveContextLost)==null?void 0:_.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:d=>console.log("WebGL context restored")},s);if(!a)throw new Error("WebGL context creation failed");if(r=a.device,r){if(t._reuseDevices)return D.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=Km({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=mg(this.gl,this._extensions),this.limits=new kg(this.gl),this.features=new Rg(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Xt(this.gl,{log:(...d)=>D.log(1,...d)()}).trackState(this.gl,{copyState:!1});const c=t.debugWebGL||t.debug,u=t.debugWebGL;c&&(this.gl=Jm(this.gl,{debugWebGL:c,traceWebGL:u}),D.warn("WebGL debug mode activated. Performance reduced.")(),t.debugWebGL&&(D.level=Math.max(D.level,1))),this.commandEncoder=new bl(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){switch(t){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){const i=this._normalizeBufferProps(t);return new Ln(this,i)}createTexture(t){return new Hn(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Yg(this,t)}createShader(t){return new zg(this,t)}createFramebuffer(t){return new zn(this,t)}createVertexArray(t){return new Ms(this,t)}createTransformFeedback(t){return new b_(this,t)}createQuerySet(t){return new S_(this,t)}createRenderPipeline(t){return new c_(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(t={}){return new bl(this,t)}submit(t){t||(t=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),t._executeCommands()}readPixelsToArrayWebGL(t,i){return C_(t,i)}readPixelsToBufferWebGL(t,i){return I_(t,i)}setParametersWebGL(t){un(this.gl,t)}getParametersWebGL(t){return sl(this.gl,t)}withParametersWebGL(t,i){return Vn(this.gl,t,i)}resetWebGL(){D.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),cg(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return Cg(this.gl,t,this._extensions)}loseDevice(){var s;let t=!1;const r=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return r&&(t=!0,r.loseContext()),(s=this._resolveContextLost)==null||s.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){Xt.get(this.gl).push()}popState(){Xt.get(this.gl).pop()}getGLKey(t,i){const r=Number(t);for(const s in this.gl)if(this.gl[s]===r)return`GL.${s}`;return i!=null&&i.emptyIfUnknown?"":String(t)}getGLKeys(t){const i={emptyIfUnknown:!0};return Object.entries(t).reduce((r,[s,o])=>(r[`${s}:${this.getGLKey(s,i)}`]=`${o}:${this.getGLKey(o,i)}`,r),{})}setConstantAttributeWebGL(t,i){const r=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(r).fill(null);const s=this._constants[t];switch(s&&F_(s,i)&&D.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=i,i.constructor){case Float32Array:k_(this,t,i);break;case Int32Array:D_(this,t,i);break;case Uint32Array:M_(this,t,i);break;default:throw new Error("constant")}}getExtension(t){return fn(this.gl,t,this._extensions),this._extensions}_setWebGLDebugMetadata(t,i,r){t.luma=i;const s={props:r.spector,id:r.spector.id};t.__SPECTOR_Metadata=s}}function k_(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break}}function D_(n,e,t){n.gl.vertexAttribI4iv(e,t)}function M_(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function F_(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}const Al=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:R_},Symbol.toStringTag,{value:"Module"})),Cl="#b3b3b3",Il=void 0,Hi=void 0,Pl=1,El=4,Rl="#666666",kl=.1,Dl=1,Ml=1,Fs="#222222",V={enableSimulation:!0,spaceSize:4096,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:100,linkSamplingDistance:100,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},Fl=.7,Nl=.95,Ol=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:Bl,setPrototypeOf:Ul,isFrozen:N_,getPrototypeOf:O_,getOwnPropertyDescriptor:B_}=Object;let{freeze:ze,seal:Qe,create:zl}=Object,{apply:Ns,construct:Os}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e}),Qe||(Qe=function(e){return e}),Ns||(Ns=function(e,t,i){return e.apply(t,i)}),Os||(Os=function(e,t){return new e(...t)});const Wi=Ve(Array.prototype.forEach),U_=Ve(Array.prototype.lastIndexOf),Ll=Ve(Array.prototype.pop),Wn=Ve(Array.prototype.push),z_=Ve(Array.prototype.splice),$i=Ve(String.prototype.toLowerCase),Bs=Ve(String.prototype.toString),Vl=Ve(String.prototype.match),$n=Ve(String.prototype.replace),L_=Ve(String.prototype.indexOf),V_=Ve(String.prototype.trim),ot=Ve(Object.prototype.hasOwnProperty),Le=Ve(RegExp.prototype.test),Xn=H_(TypeError);function Ve(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ns(n,e,i)}}function H_(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Os(n,t)}}function ne(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$i;Ul&&Ul(n,null);let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){const s=t(r);s!==r&&(N_(e)||(e[i]=s),r=s)}n[r]=!0}return n}function W_(n){for(let e=0;e<n.length;e++)ot(n,e)||(n[e]=null);return n}function St(n){const e=zl(null);for(const[t,i]of Bl(n))ot(n,t)&&(Array.isArray(i)?e[t]=W_(i):i&&typeof i=="object"&&i.constructor===Object?e[t]=St(i):e[t]=i);return e}function Yn(n,e){for(;n!==null;){const i=B_(n,e);if(i){if(i.get)return Ve(i.get);if(typeof i.value=="function")return Ve(i.value)}n=O_(n)}function t(){return null}return t}const Hl=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Us=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zs=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$_=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ls=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),X_=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Wl=ze(["#text"]),$l=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Vs=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Xl=ze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xi=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y_=Qe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),q_=Qe(/<%[\w\W]*|[\w\W]*%>/gm),j_=Qe(/\$\{[\w\W]*/gm),K_=Qe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Z_=Qe(/^aria-[\-\w]+$/),Yl=Qe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q_=Qe(/^(?:\w+script|data):/i),J_=Qe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ql=Qe(/^html$/i),G_=Qe(/^[a-z][.\w]*(-[.\w]+)+$/i);var jl=Object.freeze({__proto__:null,ARIA_ATTR:Z_,ATTR_WHITESPACE:J_,CUSTOM_ELEMENT:G_,DATA_ATTR:K_,DOCTYPE_NAME:ql,ERB_EXPR:q_,IS_ALLOWED_URI:Yl,IS_SCRIPT_OR_DATA:Q_,MUSTACHE_EXPR:Y_,TMPLIT_EXPR:j_});const qn={element:1,text:3,progressingInstruction:7,comment:8,document:9},ex=function(){return typeof window>"u"?null:window},tx=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Kl=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Zl(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ex();const e=Y=>Zl(Y);if(e.version="3.2.6",e.removed=[],!n||!n.document||n.document.nodeType!==qn.document||!n.Element)return e.isSupported=!1,e;let{document:t}=n;const i=t,r=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:h,trustedTypes:d}=n,_=l.prototype,I=Yn(_,"cloneNode"),P=Yn(_,"remove"),A=Yn(_,"nextSibling"),O=Yn(_,"childNodes"),E=Yn(_,"parentNode");if(typeof o=="function"){const Y=t.createElement("template");Y.content&&Y.content.ownerDocument&&(t=Y.content.ownerDocument)}let x,R="";const{implementation:N,createNodeIterator:U,createDocumentFragment:W,getElementsByTagName:q}=t,{importNode:G}=i;let B=Kl();e.isSupported=typeof Bl=="function"&&typeof E=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:de,ERB_EXPR:se,TMPLIT_EXPR:C,DATA_ATTR:H,ARIA_ATTR:M,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:Z,CUSTOM_ELEMENT:j}=jl;let{IS_ALLOWED_URI:ee}=jl,J=null;const ge=ne({},[...Hl,...Us,...zs,...Ls,...Wl]);let fe=null;const Te=ne({},[...$l,...Vs,...Xl,...Xi]);let oe=Object.seal(zl(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),We=null,$e=null,nt=!0,Gt=!0,Mu=!1,Fu=!0,vn=!1,Br=!0,en=!1,Do=!1,Mo=!1,bn=!1,Ur=!1,zr=!1,Nu=!0,Ou=!1;const Zv="user-content-";let Fo=!0,si=!1,Sn={},Tn=null;const Bu=ne({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Uu=null;const zu=ne({},["audio","video","img","source","image","track"]);let No=null;const Lu=ne({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Lr="http://www.w3.org/1998/Math/MathML",Vr="http://www.w3.org/2000/svg",Pt="http://www.w3.org/1999/xhtml";let wn=Pt,Oo=!1,Bo=null;const Qv=ne({},[Lr,Vr,Pt],Bs);let Hr=ne({},["mi","mo","mn","ms","mtext"]),Wr=ne({},["annotation-xml"]);const Jv=ne({},["title","style","font","a","script"]);let oi=null;const Gv=["application/xhtml+xml","text/html"],eb="text/html";let Ee=null,An=null;const tb=t.createElement("form"),Vu=function(y){return y instanceof RegExp||y instanceof Function},Uo=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(An&&An===y)){if((!y||typeof y!="object")&&(y={}),y=St(y),oi=Gv.indexOf(y.PARSER_MEDIA_TYPE)===-1?eb:y.PARSER_MEDIA_TYPE,Ee=oi==="application/xhtml+xml"?Bs:$i,J=ot(y,"ALLOWED_TAGS")?ne({},y.ALLOWED_TAGS,Ee):ge,fe=ot(y,"ALLOWED_ATTR")?ne({},y.ALLOWED_ATTR,Ee):Te,Bo=ot(y,"ALLOWED_NAMESPACES")?ne({},y.ALLOWED_NAMESPACES,Bs):Qv,No=ot(y,"ADD_URI_SAFE_ATTR")?ne(St(Lu),y.ADD_URI_SAFE_ATTR,Ee):Lu,Uu=ot(y,"ADD_DATA_URI_TAGS")?ne(St(zu),y.ADD_DATA_URI_TAGS,Ee):zu,Tn=ot(y,"FORBID_CONTENTS")?ne({},y.FORBID_CONTENTS,Ee):Bu,We=ot(y,"FORBID_TAGS")?ne({},y.FORBID_TAGS,Ee):St({}),$e=ot(y,"FORBID_ATTR")?ne({},y.FORBID_ATTR,Ee):St({}),Sn=ot(y,"USE_PROFILES")?y.USE_PROFILES:!1,nt=y.ALLOW_ARIA_ATTR!==!1,Gt=y.ALLOW_DATA_ATTR!==!1,Mu=y.ALLOW_UNKNOWN_PROTOCOLS||!1,Fu=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,vn=y.SAFE_FOR_TEMPLATES||!1,Br=y.SAFE_FOR_XML!==!1,en=y.WHOLE_DOCUMENT||!1,bn=y.RETURN_DOM||!1,Ur=y.RETURN_DOM_FRAGMENT||!1,zr=y.RETURN_TRUSTED_TYPE||!1,Mo=y.FORCE_BODY||!1,Nu=y.SANITIZE_DOM!==!1,Ou=y.SANITIZE_NAMED_PROPS||!1,Fo=y.KEEP_CONTENT!==!1,si=y.IN_PLACE||!1,ee=y.ALLOWED_URI_REGEXP||Yl,wn=y.NAMESPACE||Pt,Hr=y.MATHML_TEXT_INTEGRATION_POINTS||Hr,Wr=y.HTML_INTEGRATION_POINTS||Wr,oe=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Vu(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(oe.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Vu(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(oe.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(oe.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),vn&&(Gt=!1),Ur&&(bn=!0),Sn&&(J=ne({},Wl),fe=[],Sn.html===!0&&(ne(J,Hl),ne(fe,$l)),Sn.svg===!0&&(ne(J,Us),ne(fe,Vs),ne(fe,Xi)),Sn.svgFilters===!0&&(ne(J,zs),ne(fe,Vs),ne(fe,Xi)),Sn.mathMl===!0&&(ne(J,Ls),ne(fe,Xl),ne(fe,Xi))),y.ADD_TAGS&&(J===ge&&(J=St(J)),ne(J,y.ADD_TAGS,Ee)),y.ADD_ATTR&&(fe===Te&&(fe=St(fe)),ne(fe,y.ADD_ATTR,Ee)),y.ADD_URI_SAFE_ATTR&&ne(No,y.ADD_URI_SAFE_ATTR,Ee),y.FORBID_CONTENTS&&(Tn===Bu&&(Tn=St(Tn)),ne(Tn,y.FORBID_CONTENTS,Ee)),Fo&&(J["#text"]=!0),en&&ne(J,["html","head","body"]),J.table&&(ne(J,["tbody"]),delete We.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=y.TRUSTED_TYPES_POLICY,R=x.createHTML("")}else x===void 0&&(x=tx(d,r)),x!==null&&typeof R=="string"&&(R=x.createHTML(""));ze&&ze(y),An=y}},Hu=ne({},[...Us,...zs,...$_]),Wu=ne({},[...Ls,...X_]),nb=function(y){let F=E(y);(!F||!F.tagName)&&(F={namespaceURI:wn,tagName:"template"});const X=$i(y.tagName),_e=$i(F.tagName);return Bo[y.namespaceURI]?y.namespaceURI===Vr?F.namespaceURI===Pt?X==="svg":F.namespaceURI===Lr?X==="svg"&&(_e==="annotation-xml"||Hr[_e]):!!Hu[X]:y.namespaceURI===Lr?F.namespaceURI===Pt?X==="math":F.namespaceURI===Vr?X==="math"&&Wr[_e]:!!Wu[X]:y.namespaceURI===Pt?F.namespaceURI===Vr&&!Wr[_e]||F.namespaceURI===Lr&&!Hr[_e]?!1:!Wu[X]&&(Jv[X]||!Hu[X]):!!(oi==="application/xhtml+xml"&&Bo[y.namespaceURI]):!1},xt=function(y){Wn(e.removed,{element:y});try{E(y).removeChild(y)}catch{P(y)}},Cn=function(y,F){try{Wn(e.removed,{attribute:F.getAttributeNode(y),from:F})}catch{Wn(e.removed,{attribute:null,from:F})}if(F.removeAttribute(y),y==="is")if(bn||Ur)try{xt(F)}catch{}else try{F.setAttribute(y,"")}catch{}},$u=function(y){let F=null,X=null;if(Mo)y="<remove></remove>"+y;else{const Ie=Vl(y,/^[\r\n\t ]+/);X=Ie&&Ie[0]}oi==="application/xhtml+xml"&&wn===Pt&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const _e=x?x.createHTML(y):y;if(wn===Pt)try{F=new h().parseFromString(_e,oi)}catch{}if(!F||!F.documentElement){F=N.createDocument(wn,"template",null);try{F.documentElement.innerHTML=Oo?R:_e}catch{}}const Oe=F.body||F.documentElement;return y&&X&&Oe.insertBefore(t.createTextNode(X),Oe.childNodes[0]||null),wn===Pt?q.call(F,en?"html":"body")[0]:en?F.documentElement:Oe},Xu=function(y){return U.call(y.ownerDocument||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},zo=function(y){return y instanceof f&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof u)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Yu=function(y){return typeof a=="function"&&y instanceof a};function Et(Y,y,F){Wi(Y,X=>{X.call(e,y,F,An)})}const qu=function(y){let F=null;if(Et(B.beforeSanitizeElements,y,null),zo(y))return xt(y),!0;const X=Ee(y.nodeName);if(Et(B.uponSanitizeElement,y,{tagName:X,allowedTags:J}),Br&&y.hasChildNodes()&&!Yu(y.firstElementChild)&&Le(/<[/\w!]/g,y.innerHTML)&&Le(/<[/\w!]/g,y.textContent)||y.nodeType===qn.progressingInstruction||Br&&y.nodeType===qn.comment&&Le(/<[/\w]/g,y.data))return xt(y),!0;if(!J[X]||We[X]){if(!We[X]&&Ku(X)&&(oe.tagNameCheck instanceof RegExp&&Le(oe.tagNameCheck,X)||oe.tagNameCheck instanceof Function&&oe.tagNameCheck(X)))return!1;if(Fo&&!Tn[X]){const _e=E(y)||y.parentNode,Oe=O(y)||y.childNodes;if(Oe&&_e){const Ie=Oe.length;for(let Ye=Ie-1;Ye>=0;--Ye){const Rt=I(Oe[Ye],!0);Rt.__removalCount=(y.__removalCount||0)+1,_e.insertBefore(Rt,A(y))}}}return xt(y),!0}return y instanceof l&&!nb(y)||(X==="noscript"||X==="noembed"||X==="noframes")&&Le(/<\/no(script|embed|frames)/i,y.innerHTML)?(xt(y),!0):(vn&&y.nodeType===qn.text&&(F=y.textContent,Wi([de,se,C],_e=>{F=$n(F,_e," ")}),y.textContent!==F&&(Wn(e.removed,{element:y.cloneNode()}),y.textContent=F)),Et(B.afterSanitizeElements,y,null),!1)},ju=function(y,F,X){if(Nu&&(F==="id"||F==="name")&&(X in t||X in tb))return!1;if(!(Gt&&!$e[F]&&Le(H,F))){if(!(nt&&Le(M,F))){if(!fe[F]||$e[F]){if(!(Ku(y)&&(oe.tagNameCheck instanceof RegExp&&Le(oe.tagNameCheck,y)||oe.tagNameCheck instanceof Function&&oe.tagNameCheck(y))&&(oe.attributeNameCheck instanceof RegExp&&Le(oe.attributeNameCheck,F)||oe.attributeNameCheck instanceof Function&&oe.attributeNameCheck(F))||F==="is"&&oe.allowCustomizedBuiltInElements&&(oe.tagNameCheck instanceof RegExp&&Le(oe.tagNameCheck,X)||oe.tagNameCheck instanceof Function&&oe.tagNameCheck(X))))return!1}else if(!No[F]){if(!Le(ee,$n(X,Z,""))){if(!((F==="src"||F==="xlink:href"||F==="href")&&y!=="script"&&L_(X,"data:")===0&&Uu[y])){if(!(Mu&&!Le($,$n(X,Z,"")))){if(X)return!1}}}}}}return!0},Ku=function(y){return y!=="annotation-xml"&&Vl(y,j)},Zu=function(y){Et(B.beforeSanitizeAttributes,y,null);const{attributes:F}=y;if(!F||zo(y))return;const X={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:fe,forceKeepAttr:void 0};let _e=F.length;for(;_e--;){const Oe=F[_e],{name:Ie,namespaceURI:Ye,value:Rt}=Oe,ai=Ee(Ie),Lo=Rt;let Be=Ie==="value"?Lo:V_(Lo);if(X.attrName=ai,X.attrValue=Be,X.keepAttr=!0,X.forceKeepAttr=void 0,Et(B.uponSanitizeAttribute,y,X),Be=X.attrValue,Ou&&(ai==="id"||ai==="name")&&(Cn(Ie,y),Be=Zv+Be),Br&&Le(/((--!?|])>)|<\/(style|title)/i,Be)){Cn(Ie,y);continue}if(X.forceKeepAttr)continue;if(!X.keepAttr){Cn(Ie,y);continue}if(!Fu&&Le(/\/>/i,Be)){Cn(Ie,y);continue}vn&&Wi([de,se,C],Ju=>{Be=$n(Be,Ju," ")});const Qu=Ee(y.nodeName);if(!ju(Qu,ai,Be)){Cn(Ie,y);continue}if(x&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!Ye)switch(d.getAttributeType(Qu,ai)){case"TrustedHTML":{Be=x.createHTML(Be);break}case"TrustedScriptURL":{Be=x.createScriptURL(Be);break}}if(Be!==Lo)try{Ye?y.setAttributeNS(Ye,Ie,Be):y.setAttribute(Ie,Be),zo(y)?xt(y):Ll(e.removed)}catch{Cn(Ie,y)}}Et(B.afterSanitizeAttributes,y,null)},ib=function Y(y){let F=null;const X=Xu(y);for(Et(B.beforeSanitizeShadowDOM,y,null);F=X.nextNode();)Et(B.uponSanitizeShadowNode,F,null),qu(F),Zu(F),F.content instanceof s&&Y(F.content);Et(B.afterSanitizeShadowDOM,y,null)};return e.sanitize=function(Y){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,X=null,_e=null,Oe=null;if(Oo=!Y,Oo&&(Y="<!-->"),typeof Y!="string"&&!Yu(Y))if(typeof Y.toString=="function"){if(Y=Y.toString(),typeof Y!="string")throw Xn("dirty is not a string, aborting")}else throw Xn("toString is not a function");if(!e.isSupported)return Y;if(Do||Uo(y),e.removed=[],typeof Y=="string"&&(si=!1),si){if(Y.nodeName){const Rt=Ee(Y.nodeName);if(!J[Rt]||We[Rt])throw Xn("root node is forbidden and cannot be sanitized in-place")}}else if(Y instanceof a)F=$u("<!---->"),X=F.ownerDocument.importNode(Y,!0),X.nodeType===qn.element&&X.nodeName==="BODY"||X.nodeName==="HTML"?F=X:F.appendChild(X);else{if(!bn&&!vn&&!en&&Y.indexOf("<")===-1)return x&&zr?x.createHTML(Y):Y;if(F=$u(Y),!F)return bn?null:zr?R:""}F&&Mo&&xt(F.firstChild);const Ie=Xu(si?Y:F);for(;_e=Ie.nextNode();)qu(_e),Zu(_e),_e.content instanceof s&&ib(_e.content);if(si)return Y;if(bn){if(Ur)for(Oe=W.call(F.ownerDocument);F.firstChild;)Oe.appendChild(F.firstChild);else Oe=F;return(fe.shadowroot||fe.shadowrootmode)&&(Oe=G.call(i,Oe,!0)),Oe}let Ye=en?F.outerHTML:F.innerHTML;return en&&J["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&Le(ql,F.ownerDocument.doctype.name)&&(Ye="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
|
|
13
|
+
`+Ye),vn&&Wi([de,se,C],Rt=>{Ye=$n(Ye,Rt," ")}),x&&zr?x.createHTML(Ye):Ye},e.setConfig=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Uo(Y),Do=!0},e.clearConfig=function(){An=null,Do=!1},e.isValidAttribute=function(Y,y,F){An||Uo({});const X=Ee(Y),_e=Ee(y);return ju(X,_e,F)},e.addHook=function(Y,y){typeof y=="function"&&Wn(B[Y],y)},e.removeHook=function(Y,y){if(y!==void 0){const F=U_(B[Y],y);return F===-1?void 0:z_(B[Y],F,1)[0]}return Ll(B[Y])},e.removeHooks=function(Y){B[Y]=[]},e.removeAllHooks=function(){B=Kl()},e}var nx=Zl();function Yi(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function ix(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function Ql(n){let e,t,i;n.length!==2?(e=Yi,t=(a,l)=>Yi(n(a),l),i=(a,l)=>n(a)-l):(e=n===Yi||n===ix?n:rx,t=n,i=n);function r(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<0?c=f+1:u=f}while(c<u)}return c}function s(a,l,c=0,u=a.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;t(a[f],l)<=0?c=f+1:u=f}while(c<u)}return c}function o(a,l,c=0,u=a.length){const f=r(a,l,c,u-1);return f>c&&i(a[f-1],l)>-i(a[f],l)?f-1:f}return{left:r,center:o,right:s}}function rx(){return 0}function sx(n){return n===null?NaN:+n}const ox=Ql(Yi).right;Ql(sx).center;var Hs=Math.sqrt(50),Ws=Math.sqrt(10),$s=Math.sqrt(2);function ax(n,e,t){var i,r=-1,s,o,a;if(e=+e,n=+n,t=+t,n===e&&t>0)return[n];if((i=e<n)&&(s=n,n=e,e=s),(a=Jl(n,e,t))===0||!isFinite(a))return[];if(a>0){let l=Math.round(n/a),c=Math.round(e/a);for(l*a<n&&++l,c*a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)*a}else{a=-a;let l=Math.round(n*a),c=Math.round(e*a);for(l/a<n&&++l,c/a>e&&--c,o=new Array(s=c-l+1);++r<s;)o[r]=(l+r)/a}return i&&o.reverse(),o}function Jl(n,e,t){var i=(e-n)/Math.max(0,t),r=Math.floor(Math.log(i)/Math.LN10),s=i/Math.pow(10,r);return r>=0?(s>=Hs?10:s>=Ws?5:s>=$s?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(s>=Hs?10:s>=Ws?5:s>=$s?2:1)}function lx(n,e,t){var i=Math.abs(e-n)/Math.max(0,t),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),s=i/r;return s>=Hs?r*=10:s>=Ws?r*=5:s>=$s&&(r*=2),e<n?-r:r}function cx(n,e,t){n=+n,e=+e,t=(r=arguments.length)<2?(e=n,n=0,1):r<3?1:+t;for(var i=-1,r=Math.max(0,Math.ceil((e-n)/t))|0,s=new Array(r);++i<r;)s[i]=n+i*t;return s}function Gl(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function ux(n){return function(){return n}}function fx(n){return+n}var ec=[0,1];function mt(n){return n}function Xs(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:ux(isNaN(e)?NaN:.5)}function hx(n,e){var t;return n>e&&(t=n,n=e,e=t),function(i){return Math.max(n,Math.min(e,i))}}function dx(n,e,t){var i=n[0],r=n[1],s=e[0],o=e[1];return r<i?(i=Xs(r,i),s=t(o,s)):(i=Xs(i,r),s=t(s,o)),function(a){return s(i(a))}}function px(n,e,t){var i=Math.min(n.length,e.length)-1,r=new Array(i),s=new Array(i),o=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++o<i;)r[o]=Xs(n[o],n[o+1]),s[o]=t(e[o],e[o+1]);return function(a){var l=ox(n,a,1,i)-1;return s[l](r[l](a))}}function tc(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function nc(){var n=ec,e=ec,t=is,i,r,s,o=mt,a,l,c;function u(){var h=Math.min(n.length,e.length);return o!==mt&&(o=hx(n[0],n[h-1])),a=h>2?px:dx,l=c=null,f}function f(h){return h==null||isNaN(h=+h)?s:(l||(l=a(n.map(i),e,t)))(i(o(h)))}return f.invert=function(h){return o(r((c||(c=a(e,n.map(i),st)))(h)))},f.domain=function(h){return arguments.length?(n=Array.from(h,fx),u()):n.slice()},f.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},f.rangeRound=function(h){return e=Array.from(h),t=hd,u()},f.clamp=function(h){return arguments.length?(o=h?!0:mt,u()):o!==mt},f.interpolate=function(h){return arguments.length?(t=h,u()):t},f.unknown=function(h){return arguments.length?(s=h,f):s},function(h,d){return i=h,r=d,u()}}function mx(){return nc()(mt,mt)}function gx(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function qi(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,i=n.slice(0,t);return[i.length>1?i[0]+i.slice(2):i,+n.slice(t+1)]}function mn(n){return n=qi(Math.abs(n)),n?n[1]:NaN}function _x(n,e){return function(t,i){for(var r=t.length,s=[],o=0,a=n[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),s.push(t.substring(r-=a,r+a)),!((l+=a+1)>i));)a=n[o=(o+1)%n.length];return s.reverse().join(e)}}function xx(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var yx=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ji(n){if(!(e=yx.exec(n)))throw new Error("invalid format: "+n);var e;return new Ys({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ji.prototype=Ys.prototype;function Ys(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Ys.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function vx(n){e:for(var e=n.length,t=1,i=-1,r;t<e;++t)switch(n[t]){case".":i=r=t;break;case"0":i===0&&(i=t),r=t;break;default:if(!+n[t])break e;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var ic;function bx(n,e){var t=qi(n,e);if(!t)return n+"";var i=t[0],r=t[1],s=r-(ic=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+qi(n,Math.max(0,e+s-1))[0]}function rc(n,e){var t=qi(n,e);if(!t)return n+"";var i=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const sc={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:gx,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>rc(n*100,e),r:rc,s:bx,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function oc(n){return n}var ac=Array.prototype.map,lc=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Sx(n){var e=n.grouping===void 0||n.thousands===void 0?oc:_x(ac.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?oc:xx(ac.call(n.numerals,String)),o=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function c(f){f=ji(f);var h=f.fill,d=f.align,_=f.sign,I=f.symbol,P=f.zero,A=f.width,O=f.comma,E=f.precision,x=f.trim,R=f.type;R==="n"?(O=!0,R="g"):sc[R]||(E===void 0&&(E=12),x=!0,R="g"),(P||h==="0"&&d==="=")&&(P=!0,h="0",d="=");var N=I==="$"?t:I==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",U=I==="$"?i:/[%p]/.test(R)?o:"",W=sc[R],q=/[defgprs%]/.test(R);E=E===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function G(B){var de=N,se=U,C,H,M;if(R==="c")se=W(B)+se,B="";else{B=+B;var $=B<0||1/B<0;if(B=isNaN(B)?l:W(Math.abs(B),E),x&&(B=vx(B)),$&&+B==0&&_!=="+"&&($=!1),de=($?_==="("?_:a:_==="-"||_==="("?"":_)+de,se=(R==="s"?lc[8+ic/3]:"")+se+($&&_==="("?")":""),q){for(C=-1,H=B.length;++C<H;)if(M=B.charCodeAt(C),48>M||M>57){se=(M===46?r+B.slice(C+1):B.slice(C))+se,B=B.slice(0,C);break}}}O&&!P&&(B=e(B,1/0));var Z=de.length+B.length+se.length,j=Z<A?new Array(A-Z+1).join(h):"";switch(O&&P&&(B=e(j+B,j.length?A-se.length:1/0),j=""),d){case"<":B=de+B+se+j;break;case"=":B=de+j+B+se;break;case"^":B=j.slice(0,Z=j.length>>1)+de+B+se+j.slice(Z);break;default:B=j+de+B+se;break}return s(B)}return G.toString=function(){return f+""},G}function u(f,h){var d=c((f=ji(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(mn(h)/3)))*3,I=Math.pow(10,-_),P=lc[8+_/3];return function(A){return d(I*A)+P}}return{format:c,formatPrefix:u}}var Ki,cc,uc;Tx({thousands:",",grouping:[3],currency:["$",""]});function Tx(n){return Ki=Sx(n),cc=Ki.format,uc=Ki.formatPrefix,Ki}function wx(n){return Math.max(0,-mn(Math.abs(n)))}function Ax(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(mn(e)/3)))*3-mn(Math.abs(n)))}function Cx(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,mn(e)-mn(n))+1}function Ix(n,e,t,i){var r=lx(n,e,t),s;switch(i=ji(i??",f"),i.type){case"s":{var o=Math.max(Math.abs(n),Math.abs(e));return i.precision==null&&!isNaN(s=Ax(r,o))&&(i.precision=s),uc(i,o)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(s=Cx(r,Math.max(Math.abs(n),Math.abs(e))))&&(i.precision=s-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(s=wx(r))&&(i.precision=s-(i.type==="%")*2);break}}return cc(i)}function fc(n){var e=n.domain;return n.ticks=function(t){var i=e();return ax(i[0],i[i.length-1],t??10)},n.tickFormat=function(t,i){var r=e();return Ix(r[0],r[r.length-1],t??10,i)},n.nice=function(t){t==null&&(t=10);var i=e(),r=0,s=i.length-1,o=i[r],a=i[s],l,c,u=10;for(a<o&&(c=o,o=a,a=c,c=r,r=s,s=c);u-- >0;){if(c=Jl(o,a,t),c===l)return i[r]=o,i[s]=a,e(i);if(c>0)o=Math.floor(o/c)*c,a=Math.ceil(a/c)*c;else if(c<0)o=Math.ceil(o*c)/c,a=Math.floor(a*c)/c;else break;l=c}return n},n}function qs(){var n=mx();return n.copy=function(){return tc(n,qs())},Gl.apply(n,arguments),fc(n)}function hc(n){return function(e){return e<0?-Math.pow(-e,n):Math.pow(e,n)}}function Px(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function Ex(n){return n<0?-n*n:n*n}function Rx(n){var e=n(mt,mt),t=1;function i(){return t===1?n(mt,mt):t===.5?n(Px,Ex):n(hc(t),hc(1/t))}return e.exponent=function(r){return arguments.length?(t=+r,i()):t},fc(e)}function dc(){var n=Rx(nc());return n.copy=function(){return tc(n,dc()).exponent(n.exponent())},Gl.apply(n,arguments),n}var pc=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});function kx(){var n=new pc(9);return pc!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function mc(n,e,t){var i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=t[0],d=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=o,n[4]=a,n[5]=l,n[6]=h*i+d*o+c,n[7]=h*r+d*a+u,n[8]=h*s+d*l+f,n}function js(n,e,t){var i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Dx(n,e,t){return n[0]=2/e,n[1]=0,n[2]=0,n[3]=0,n[4]=-2/t,n[5]=0,n[6]=-1,n[7]=1,n[8]=1,n}function Mx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Fx(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var Zi={exports:{}},Nx=Zi.exports,gc;function Ox(){return gc||(gc=1,function(n){(function(e,t,i){function r(l){var c=this,u=a();c.next=function(){var f=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=f-(c.c=f|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(l),c.s0<0&&(c.s0+=1),c.s1-=u(l),c.s1<0&&(c.s1+=1),c.s2-=u(l),c.s2<0&&(c.s2+=1),u=null}function s(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var u=new r(l),f=c&&c.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,f&&(typeof f=="object"&&s(f,u),h.state=function(){return s(u,{})}),h}function a(){var l=4022871197,c=function(u){u=String(u);for(var f=0;f<u.length;f++){l+=u.charCodeAt(f);var h=.02519603282416938*l;l=h>>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=o:this.alea=o})(Nx,n)}(Zi)),Zi.exports}var Qi={exports:{}},Bx=Qi.exports,_c;function Ux(){return _c||(_c=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var f=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^f^f>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,l.next()}function s(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor128=o})(Bx,n)}(Qi)),Qi.exports}var Ji={exports:{}},zx=Ji.exports,xc;function Lx(){return xc||(xc=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(f^f<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u<c.length+64;u++)l.x^=c.charCodeAt(u)|0,u==c.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function s(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorwow=o})(zx,n)}(Ji)),Ji.exports}var Gi={exports:{}},Vx=Gi.exports,yc;function Hx(){return yc||(yc=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.x,f=l.i,h,d;return h=u[f],h^=h>>>7,d=h^h<<24,h=u[f+1&7],d^=h^h>>>10,h=u[f+3&7],d^=h^h>>>3,h=u[f+4&7],d^=h^h<<7,h=u[f+7&7],h=h^h<<13,d^=h^h<<9,u[f]=d,l.i=f+1&7,d};function c(u,f){var h,d=[];if(f===(f|0))d[0]=f;else for(f=""+f,h=0;h<f.length;++h)d[h&7]=d[h&7]<<15^f.charCodeAt(h)+d[h+1&7]<<13;for(;d.length<8;)d.push(0);for(h=0;h<8&&d[h]===0;++h);for(h==8?d[7]=-1:d[h],u.x=d,u.i=0,h=256;h>0;--h)u.next()}c(l,a)}function s(a,l){return l.x=a.x.slice(),l.i=a.i,l}function o(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.x&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xorshift7=o})(Vx,n)}(Gi)),Gi.exports}var er={exports:{}},Wx=er.exports,vc;function $x(){return vc||(vc=1,function(n){(function(e,t,i){function r(a){var l=this;l.next=function(){var u=l.w,f=l.X,h=l.i,d,_;return l.w=u=u+1640531527|0,_=f[h+34&127],d=f[h=h+1&127],_^=_<<13,d^=d<<17,_^=_>>>15,d^=d>>>12,_=f[h]=_^d,l.i=h,_+(u^u>>>16)|0};function c(u,f){var h,d,_,I,P,A=[],O=128;for(f===(f|0)?(d=f,f=null):(f=f+"\0",d=0,O=Math.max(O,f.length)),_=0,I=-32;I<O;++I)f&&(d^=f.charCodeAt((I+32)%f.length)),I===0&&(P=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,I>=0&&(P=P+1640531527|0,h=A[I&127]^=d+P,_=h==0?_+1:0);for(_>=128&&(A[(f&&f.length||0)&127]=-1),_=127,I=4*128;I>0;--I)d=A[_+34&127],h=A[_=_+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,A[_]=d^h;u.w=P,u.X=A,u.i=_}c(l,a)}function s(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function o(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(u.X&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.xor4096=o})(Wx,n)}(er)),er.exports}var tr={exports:{}},Xx=tr.exports,bc;function Yx(){return bc||(bc=1,function(n){(function(e,t,i){function r(a){var l=this,c="";l.next=function(){var f=l.b,h=l.c,d=l.d,_=l.a;return f=f<<25^f>>>7^h,h=h-d|0,d=d<<24^d>>>8^_,_=_-f|0,l.b=f=f<<20^f>>>12^h,l.c=h=h-d|0,l.d=d<<16^h>>>16^_,l.a=_-f|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u<c.length+20;u++)l.b^=c.charCodeAt(u)|0,l.next()}function s(a,l){return l.a=a.a,l.b=a.b,l.c=a.c,l.d=a.d,l}function o(a,l){var c=new r(a),u=l&&l.state,f=function(){return(c.next()>>>0)/4294967296};return f.double=function(){do var h=c.next()>>>11,d=(c.next()>>>0)/4294967296,_=(h+d)/(1<<21);while(_===0);return _},f.int32=c.next,f.quick=f,u&&(typeof u=="object"&&s(u,c),f.state=function(){return s(c,{})}),f}t&&t.exports?t.exports=o:this.tychei=o})(Xx,n)}(tr)),tr.exports}var nr={exports:{}};const qx=Fx(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var jx=nr.exports,Sc;function Kx(){return Sc||(Sc=1,function(n){(function(e,t,i){var r=256,s=6,o=52,a="random",l=i.pow(r,s),c=i.pow(2,o),u=c*2,f=r-1,h;function d(x,R,N){var U=[];R=R==!0?{entropy:!0}:R||{};var W=A(P(R.entropy?[x,E(t)]:x??O(),3),U),q=new _(U),G=function(){for(var B=q.g(s),de=l,se=0;B<c;)B=(B+se)*r,de*=r,se=q.g(1);for(;B>=u;)B/=2,de/=2,se>>>=1;return(B+se)/de};return G.int32=function(){return q.g(4)|0},G.quick=function(){return q.g(4)/4294967296},G.double=G,A(E(q.S),t),(R.pass||N||function(B,de,se,C){return C&&(C.S&&I(C,q),B.state=function(){return I(q,{})}),se?(i[a]=B,de):B})(G,W,"global"in R?R.global:this==i,R.state)}function _(x){var R,N=x.length,U=this,W=0,q=U.i=U.j=0,G=U.S=[];for(N||(x=[N++]);W<r;)G[W]=W++;for(W=0;W<r;W++)G[W]=G[q=f&q+x[W%N]+(R=G[W])],G[q]=R;(U.g=function(B){for(var de,se=0,C=U.i,H=U.j,M=U.S;B--;)de=M[C=f&C+1],se=se*r+M[f&(M[C]=M[H=f&H+de])+(M[H]=de)];return U.i=C,U.j=H,se})(r)}function I(x,R){return R.i=x.i,R.j=x.j,R.S=x.S.slice(),R}function P(x,R){var N=[],U=typeof x,W;if(R&&U=="object")for(W in x)try{N.push(P(x[W],R-1))}catch{}return N.length?N:U=="string"?x:x+"\0"}function A(x,R){for(var N=x+"",U,W=0;W<N.length;)R[f&W]=f&(U^=R[f&W]*19)+N.charCodeAt(W++);return E(R)}function O(){try{var x;return h&&(x=h.randomBytes)?x=x(r):(x=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(x)),E(x)}catch{var R=e.navigator,N=R&&R.plugins;return[+new Date,e,N,e.screen,E(t)]}}function E(x){return String.fromCharCode.apply(0,x)}if(A(i.random(),t),n.exports){n.exports=d;try{h=qx}catch{}}else i["seed"+a]=d})(typeof self<"u"?self:jx,[],Math)}(nr)),nr.exports}var Ks,Tc;function Zx(){if(Tc)return Ks;Tc=1;var n=Ox(),e=Ux(),t=Lx(),i=Hx(),r=$x(),s=Yx(),o=Kx();return o.alea=n,o.xor128=e,o.xorwow=t,o.xorshift7=i,o.xor4096=r,o.tychei=s,Ks=o,Ks}var Qx=Zx();const Jx=Mx(Qx);function Gx(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,ty(i.key),i)}}function Zs(n,e,t){return e&&Gx(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function wc(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,Qs(n,e)}function Qs(n,e){return Qs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},Qs(n,e)}function ey(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ty(n){var e=ey(n,"string");return typeof e=="symbol"?e:String(e)}var ir=function(){function n(){}var e=n.prototype;return e._seed=function(i,r){if(i===(i||0))return i;for(var s=""+i,o=0,a=0;a<s.length;++a)o^=s.charCodeAt(a)|0;return o},n}(),Ac=function(n){wc(e,n);function e(i,r){var s;return s=n.call(this)||this,s._rng=void 0,s.seed(i,r),s}var t=e.prototype;return t.next=function(){return this._rng()},t.seed=function(r,s){this._rng=r},t.clone=function(r,s){return new e(this._rng,s)},Zs(e,[{key:"name",get:function(){return"function"}}]),e}(ir),Cc=function(){var n=[].slice.call(arguments),e=n,t=e[0],i=t===void 0?"default":t;switch(typeof i){case"object":if(i instanceof ir)return i;break;case"function":return new Ac(i);case"number":case"string":default:return new Ac(Jx.apply(void 0,n))}throw new Error('invalid RNG "'+i+'"')},ny=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){return n.next()*(t-e)+e}};function at(n){return new iy(n)}var iy=function(e){var t=this;this.n=void 0,this.isInt=function(){if(Number.isInteger(t.n))return t;throw new Error("Expected number to be an integer, got "+t.n)},this.isPositive=function(){if(t.n>0)return t;throw new Error("Expected number to be positive, got "+t.n)},this.lessThan=function(i){if(t.n<i)return t;throw new Error("Expected number to be less than "+i+", got "+t.n)},this.greaterThanOrEqual=function(i){if(t.n>=i)return t;throw new Error("Expected number to be greater than or equal to "+i+", got "+t.n)},this.greaterThan=function(i){if(t.n>i)return t;throw new Error("Expected number to be greater than "+i+", got "+t.n)},this.n=e},ry=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),t===void 0&&(t=e===void 0?1:e,e=0),at(e).isInt(),at(t).isInt(),function(){return Math.floor(n.next()*(t-e+1)+e)}},sy=function(n){return function(){return n.next()>=.5}},oy=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),function(){var i,r,s;do i=n.next()*2-1,r=n.next()*2-1,s=i*i+r*r;while(!s||s>1);return e+t*r*Math.sqrt(-2*Math.log(s)/s)}},ay=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=1);var i=n.normal(e,t);return function(){return Math.exp(i())}},ly=function(n,e){return e===void 0&&(e=.5),at(e).greaterThanOrEqual(0).lessThan(1),function(){return Math.floor(n.next()+e)}},cy=function(n,e,t){return e===void 0&&(e=1),t===void 0&&(t=.5),at(e).isInt().isPositive(),at(t).greaterThanOrEqual(0).lessThan(1),function(){for(var i=0,r=0;i++<e;)n.next()<t&&r++;return r}},uy=function(n,e){e===void 0&&(e=.5),at(e).greaterThan(0).lessThan(1);var t=1/Math.log(1-e);return function(){return Math.floor(1+Math.log(n.next())*t)}},fy=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415,10.60460290274525,12.801827480081469],hy=function(e){return fy[e]},dy=.9189385332046727,py=function(n,e){if(e===void 0&&(e=1),at(e).isPositive(),e<10){var t=Math.exp(-e);return function(){for(var l=t,c=0,u=n.next();u>l;)u=u-l,l=e*l/++c;return c}}else{var i=Math.sqrt(e),r=.931+2.53*i,s=-.059+.02483*r,o=1.1239+1.1328/(r-3.4),a=.9277-3.6224/(r-2);return function(){for(;;){var l=void 0,c=n.next();if(c<=.86*a)return l=c/a-.43,Math.floor((2*s/(.5-Math.abs(l))+r)*l+e+.445);c>=a?l=n.next()-.5:(l=c/a-.93,l=(l<0?-.5:.5)-l,c=n.next()*a);var u=.5-Math.abs(l);if(!(u<.013&&c>u)){var f=Math.floor((2*s/u+r)*l+e+.445);if(c=c*o/(s/(u*u)+r),f>=10){var h=(f+.5)*Math.log(e/f)-e-dy+f-(.08333333333333333-(.002777777777777778-1/(1260*f*f))/(f*f))/f;if(Math.log(c*i)<=h)return f}else if(f>=0){var d,_=(d=hy(f))!=null?d:0;if(Math.log(c)<=f*Math.log(e)-e-_)return f}}}}}},my=function(n,e){return e===void 0&&(e=1),at(e).isPositive(),function(){return-Math.log(1-n.next())/e}},gy=function(n,e){return e===void 0&&(e=1),at(e).isInt().greaterThanOrEqual(0),function(){for(var t=0,i=0;i<e;++i)t+=n.next();return t}},_y=function(n,e){e===void 0&&(e=1),at(e).isInt().isPositive();var t=n.irwinHall(e);return function(){return t()/e}},xy=function(n,e){e===void 0&&(e=1),at(e).greaterThanOrEqual(0);var t=1/e;return function(){return 1/Math.pow(1-n.next(),t)}},yy=function(n){wc(e,n);function e(){return n.apply(this,arguments)||this}var t=e.prototype;return t.next=function(){return Math.random()},t.seed=function(r,s){},t.clone=function(){return new e},Zs(e,[{key:"name",get:function(){return"default"}}]),e}(ir),Ic=function(){function n(t){var i=this;this._rng=void 0,this._patch=void 0,this._cache={},this.next=function(){return i._rng.next()},this.float=function(r,s){return i.uniform(r,s)()},this.int=function(r,s){return i.uniformInt(r,s)()},this.integer=function(r,s){return i.uniformInt(r,s)()},this.bool=function(){return i.uniformBoolean()()},this.boolean=function(){return i.uniformBoolean()()},this.uniform=function(r,s){return i._memoize("uniform",ny,r,s)},this.uniformInt=function(r,s){return i._memoize("uniformInt",ry,r,s)},this.uniformBoolean=function(){return i._memoize("uniformBoolean",sy)},this.normal=function(r,s){return oy(i,r,s)},this.logNormal=function(r,s){return ay(i,r,s)},this.bernoulli=function(r){return ly(i,r)},this.binomial=function(r,s){return cy(i,r,s)},this.geometric=function(r){return uy(i,r)},this.poisson=function(r){return py(i,r)},this.exponential=function(r){return my(i,r)},this.irwinHall=function(r){return gy(i,r)},this.bates=function(r){return _y(i,r)},this.pareto=function(r){return xy(i,r)},t&&t instanceof ir?this.use(t):this.use(new yy),this._cache={}}var e=n.prototype;return e.clone=function(){var i=[].slice.call(arguments);return i.length?new n(Cc.apply(void 0,i)):new n(this.rng.clone())},e.use=function(){this._rng=Cc.apply(void 0,[].slice.call(arguments))},e.patch=function(){if(this._patch)throw new Error("Math.random already patched");this._patch=Math.random,Math.random=this.uniform()},e.unpatch=function(){this._patch&&(Math.random=this._patch,delete this._patch)},e.choice=function(i){if(!Array.isArray(i))throw new Error("Random.choice expected input to be an array, got "+typeof i);var r=i==null?void 0:i.length;if(r>0){var s=this.uniformInt(0,r-1)();return i[s]}else return},e._memoize=function(i,r){var s=[].slice.call(arguments,2),o=""+s.join(";"),a=this._cache[i];return(a===void 0||a.key!==o)&&(a={key:o,distribution:r.apply(void 0,[this].concat(s))},this._cache[i]=a),a.distribution},Zs(n,[{key:"rng",get:function(){return this._rng}}]),n}();new Ic;const Js=.001,rr=64,vy=4,Pc=2;class by{constructor(){this.pointsTextureSize=0,this.linksTextureSize=0,this.alpha=1,this.transform=kx(),this.screenSize=[0,0],this.mousePosition=[0,0],this.screenMousePosition=[0,0],this.selectedArea=[[0,0],[0,0]],this.isSimulationRunning=!1,this.simulationProgress=0,this.selectedIndices=null,this.maxPointSize=rr,this.hoveredPoint=void 0,this.focusedPoint=void 0,this.draggingPointIndex=void 0,this.hoveredLinkIndex=void 0,this.adjustedSpaceSize=V.spaceSize,this.isSpaceKeyPressed=!1,this.webglMaxTextureSize=16384,this.hoveredPointRingColor=[1,1,1,Fl],this.focusedPointRingColor=[1,1,1,Nl],this.hoveredLinkColor=[-1,-1,-1,-1],this.greyoutPointColor=[-1,-1,-1,-1],this.isDarkenGreyout=!1,this.isLinkHoveringEnabled=!1,this.alphaTarget=0,this.scalePointX=qs(),this.scalePointY=qs(),this.random=new Ic,this._backgroundColor=[0,0,0,0],this.alphaDecay=e=>1-Math.pow(Js,1/e)}get backgroundColor(){return this._backgroundColor}get transformationMatrix4x4(){const e=this.transform;if(e.length!==9)throw new Error(`Transform must be a 9-element array (3x3 matrix), got ${e.length} elements`);return[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]}set backgroundColor(e){this._backgroundColor=e;const t=Dc(e[0],e[1],e[2]);document.documentElement.style.setProperty("--cosmosgl-attribution-color",t>.65?"black":"white"),document.documentElement.style.setProperty("--cosmosgl-error-message-color",t>.65?"black":"white"),this.div&&(this.div.style.backgroundColor=`rgba(${e[0]*255}, ${e[1]*255}, ${e[2]*255}, ${e[3]})`),this.isDarkenGreyout=t<.65}addRandomSeed(e){this.random=this.random.clone(e)}getRandomFloat(e,t){return this.random.float(e,t)}adjustSpaceSize(e,t){(e<=0||!isFinite(e))&&(console.error(`Invalid spaceSize value: ${e}. Using default value of ${V.spaceSize}`),e=V.spaceSize);const i=2;if(e<i&&(console.warn(`spaceSize (${e}) is too small. Using minimum value of ${i}`),e=i),!Number.isFinite(t)||t<=0||t<i){console.warn(`Invalid webglMaxTextureSize: ${t}. Using configSpaceSize without WebGL limit adjustment.`),this.adjustedSpaceSize=e;return}e>=t?(this.adjustedSpaceSize=Math.max(t/2,i),console.warn(`The \`spaceSize\` has been reduced to ${this.adjustedSpaceSize} due to WebGL limits`)):this.adjustedSpaceSize=e}setWebGLMaxTextureSize(e){this.webglMaxTextureSize=e}updateScreenSize(e,t){const{adjustedSpaceSize:i}=this;this.screenSize=[e,t],this.scalePointX.domain([0,i]).range([(e-i)/2,(e+i)/2]),this.scalePointY.domain([i,0]).range([(t-i)/2,(t+i)/2])}scaleX(e){return this.scalePointX(e)}scaleY(e){return this.scalePointY(e)}setHoveredPointRingColor(e){const t=Tt(e);this.hoveredPointRingColor[0]=t[0],this.hoveredPointRingColor[1]=t[1],this.hoveredPointRingColor[2]=t[2]}setFocusedPointRingColor(e){const t=Tt(e);this.focusedPointRingColor[0]=t[0],this.focusedPointRingColor[1]=t[1],this.focusedPointRingColor[2]=t[2]}setGreyoutPointColor(e){if(e===void 0){this.greyoutPointColor=[-1,-1,-1,-1];return}const t=Tt(e);this.greyoutPointColor[0]=t[0],this.greyoutPointColor[1]=t[1],this.greyoutPointColor[2]=t[2],this.greyoutPointColor[3]=t[3]}updateLinkHoveringEnabled(e){this.isLinkHoveringEnabled=!!(e.onLinkClick||e.onLinkContextMenu||e.onLinkMouseOver||e.onLinkMouseOut),this.isLinkHoveringEnabled||(this.hoveredLinkIndex=void 0)}setHoveredLinkColor(e){if(e===void 0){this.hoveredLinkColor=[-1,-1,-1,-1];return}const t=Tt(e);this.hoveredLinkColor[0]=t[0],this.hoveredLinkColor[1]=t[1],this.hoveredLinkColor[2]=t[2],this.hoveredLinkColor[3]=t[3]}setFocusedPoint(e){e!==void 0?this.focusedPoint={index:e}:this.focusedPoint=void 0}addAlpha(e){return(this.alphaTarget-this.alpha)*this.alphaDecay(e)}}const Ec=n=>typeof n=="function",Gs=n=>Array.isArray(n),Rc=n=>n instanceof Object,kc=n=>n instanceof Object?n.constructor.name!=="Function"&&n.constructor.name!=="Object":!1,eo=n=>Rc(n)&&!Gs(n)&&!Ec(n)&&!kc(n);function Tt(n){let e;if(Gs(n))e=n;else{const t=kt(n),i=t==null?void 0:t.rgb();e=[(i==null?void 0:i.r)||0,(i==null?void 0:i.g)||0,(i==null?void 0:i.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function Dc(n,e,t){return .2126*n+.7152*e+.0722*t}function Me(n,e,t=0,i=0,r,s){return n.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:i,sourceWidth:r,sourceHeight:s})}function to(n,e){switch(n.info.type){case"webgl":{const t=n.gl.getParameter($t.ALIASED_POINT_SIZE_RANGE);return((t==null?void 0:t[1])??rr)/e}case"webgpu":return rr/e;default:return rr/e}}function Mc(n,e,t){return Math.min(Math.max(n,e),t)}function Ke(n){return n!=null&&!Number.isNaN(n)}function Fc(n,e){return nx.sanitize(n,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class Sy{constructor(){this.enableSimulation=V.enableSimulation,this.backgroundColor=Fs,this.spaceSize=V.spaceSize,this.pointDefaultColor=Cl,this.pointGreyoutOpacity=Il,this.pointGreyoutColor=Hi,this.pointDefaultSize=El,this.pointOpacity=Pl,this.pointSizeScale=V.pointSizeScale,this.hoveredPointCursor=V.hoveredPointCursor,this.hoveredLinkCursor=V.hoveredLinkCursor,this.renderHoveredPointRing=V.renderHoveredPointRing,this.hoveredPointRingColor=V.hoveredPointRingColor,this.focusedPointRingColor=V.focusedPointRingColor,this.focusedPointIndex=V.focusedPointIndex,this.linkDefaultColor=Rl,this.linkOpacity=Dl,this.linkGreyoutOpacity=kl,this.linkDefaultWidth=Ml,this.linkWidthScale=V.linkWidthScale,this.hoveredLinkColor=V.hoveredLinkColor,this.hoveredLinkWidthIncrease=V.hoveredLinkWidthIncrease,this.renderLinks=V.renderLinks,this.curvedLinks=V.curvedLinks,this.curvedLinkSegments=V.curvedLinkSegments,this.curvedLinkWeight=V.curvedLinkWeight,this.curvedLinkControlPointDistance=V.curvedLinkControlPointDistance,this.linkDefaultArrows=V.linkArrows,this.linkArrowsSizeScale=V.linkArrowsSizeScale,this.scaleLinksOnZoom=V.scaleLinksOnZoom,this.linkVisibilityDistanceRange=V.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=V.linkVisibilityMinTransparency,this.simulationDecay=V.simulation.decay,this.simulationGravity=V.simulation.gravity,this.simulationCenter=V.simulation.center,this.simulationRepulsion=V.simulation.repulsion,this.simulationRepulsionTheta=V.simulation.repulsionTheta,this.simulationLinkSpring=V.simulation.linkSpring,this.simulationLinkDistance=V.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=V.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=V.simulation.repulsionFromMouse,this.enableRightClickRepulsion=V.enableRightClickRepulsion,this.simulationFriction=V.simulation.friction,this.simulationCluster=V.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onContextMenu=void 0,this.onPointContextMenu=void 0,this.onLinkContextMenu=void 0,this.onBackgroundContextMenu=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=V.showFPSMonitor,this.pixelRatio=V.pixelRatio,this.scalePointsOnZoom=V.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=V.enableZoom,this.enableSimulationDuringZoom=V.enableSimulationDuringZoom,this.enableDrag=V.enableDrag,this.fitViewOnInit=V.fitViewOnInit,this.fitViewDelay=V.fitViewDelay,this.fitViewPadding=V.fitViewPadding,this.fitViewDuration=V.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=V.pointSamplingDistance,this.linkSamplingDistance=V.linkSamplingDistance,this.attribution=V.attribution,this.rescalePositions=V.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,i){eo(e[i])&&eo(t[i])?Object.keys(t[i]).forEach(r=>{this.deepMergeConfig(e[i],t[i],r)}):e[i]=t[i]}getConfig(){return this}}function no(n,e){if(!n)throw new Error(e||"shadertools: assertion failed.")}const io={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}};function Ty(n){const e={};for(const[t,i]of Object.entries(n))e[t]=wy(i);return e}function wy(n){let e=Nc(n);if(e!=="object")return{value:n,...io[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...io[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=Nc(n.value),{...n,...io[e],type:e}):{type:"object",value:null};throw new Error("props")}function Nc(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}const Ay={vertex:`#ifdef MODULE_LOGDEPTH
|
|
14
14
|
logdepth_adjustPosition(gl_Position);
|
|
15
15
|
#endif
|
|
16
16
|
`,fragment:`#ifdef MODULE_MATERIAL
|
|
@@ -33,9 +33,9 @@ ${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(t
|
|
|
33
33
|
#ifdef MODULE_LOGDEPTH
|
|
34
34
|
logdepth_setFragDepth();
|
|
35
35
|
#endif
|
|
36
|
-
`},
|
|
36
|
+
`},Oc=/void\s+main\s*\([^)]*\)\s*\{\n?/,Bc=/}\n?[^{}]*$/,ro=[],sr="__LUMA_INJECT_DECLARATIONS__";function Cy(n){const e={vertex:{},fragment:{}};for(const t in n){let i=n[t];const r=Iy(t);typeof i=="string"&&(i={order:0,injection:i}),e[r][t]=i}return e}function Iy(n){const e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function or(n,e,t,i=!1){const r=e==="vertex";for(const s in t){const o=t[s];o.sort((l,c)=>l.order-c.order),ro.length=o.length;for(let l=0,c=o.length;l<c;++l)ro[l]=o[l].injection;const a=`${ro.join(`
|
|
37
37
|
`)}
|
|
38
|
-
`;switch(s){case"vs:#decl":r&&(n=n.replace(
|
|
38
|
+
`;switch(s){case"vs:#decl":r&&(n=n.replace(sr,a));break;case"vs:#main-start":r&&(n=n.replace(Oc,l=>l+a));break;case"vs:#main-end":r&&(n=n.replace(Bc,l=>a+l));break;case"fs:#decl":r||(n=n.replace(sr,a));break;case"fs:#main-start":r||(n=n.replace(Oc,l=>l+a));break;case"fs:#main-end":r||(n=n.replace(Bc,l=>a+l));break;default:n=n.replace(s,l=>l+a)}}return n=n.replace(sr,""),i&&(n=n.replace(/\}\s*$/,s=>s+Ay[e])),n}function ar(n){n.map(e=>Py(e))}function Py(n){if(n.instance)return;ar(n.dependencies||[]);const{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Cy(i),parsedDeprecations:Ey(t)};e&&(r.propValidators=Ty(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,l])=>{const c=l==null?void 0:l.value;return c&&(o[a]=c),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function Uc(n,e,t){var i;(i=n.deprecations)==null||i.forEach(r=>{var s;(s=r.regex)!=null&&s.test(e)&&(r.deprecated?t.deprecated(r.old,r.new)():t.removed(r.old,r.new)())})}function Ey(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}function so(n){ar(n);const e={},t={};zc({modules:n,level:0,moduleMap:e,moduleDepth:t});const i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return ar(i),i}function zc(n){const{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(const s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]<t)&&(r[s.name]=t);for(const s of e)s.dependencies&&zc({modules:s.dependencies,level:t+1,moduleMap:i,moduleDepth:r})}function Ry(n){switch(n==null?void 0:n.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
39
39
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
40
40
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
41
41
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -59,41 +59,41 @@ ${t}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(t
|
|
|
59
59
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
60
60
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
61
61
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
62
|
-
`}}function
|
|
63
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
62
|
+
`}}function ky(n,e){var i;if(Number(((i=n.match(/^#version[ \t]+(\d+)/m))==null?void 0:i[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=Vc(n,Dy),n;case"fragment":return n=Vc(n,My),n;default:throw new Error(e)}}const Lc=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
63
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Dy=[...Lc,[oo("attribute"),"in $1"],[oo("varying"),"out $1"]],My=[...Lc,[oo("varying"),"in $1"]];function Vc(n,e){for(const[t,i]of e)n=n.replace(t,i);return n}function oo(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Hc(n,e){let t="";for(const i in n){const r=n[i];if(t+=`void ${r.signature} {
|
|
64
64
|
`,r.header&&(t+=` ${r.header}`),e[i]){const s=e[i];s.sort((o,a)=>o.order-a.order);for(const o of s)t+=` ${o.injection}
|
|
65
65
|
`}r.footer&&(t+=` ${r.footer}`),t+=`}
|
|
66
|
-
`}return t}function
|
|
66
|
+
`}return t}function Wc(n){const e={vertex:{},fragment:{}};for(const t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();const[s,o]=r.split(":"),a=r.replace(/\(.+/,""),l=Object.assign(i,{signature:o});switch(s){case"vs":e.vertex[a]=l;break;case"fs":e.fragment[a]=l;break;default:throw new Error(s)}}return e}function Fy(n,e){return{name:Ny(n,e),language:"glsl",version:Oy(n)}}function Ny(n,e="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function Oy(n){let e=100;const t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){const i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}const $c=`
|
|
67
67
|
|
|
68
|
-
${
|
|
69
|
-
`,
|
|
70
|
-
`;function
|
|
68
|
+
${sr}
|
|
69
|
+
`,By=`precision highp float;
|
|
70
|
+
`;function Uy(n){const e=so(n.modules||[]);return{source:Ly(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e}),getUniforms:Yc(e)}}function zy(n){const{vs:e,fs:t}=n,i=so(n.modules||[]);return{vs:Xc(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Xc(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:Yc(i)}}function Ly(n,e){var I;const{source:t,stage:i,modules:r,hookFunctions:s=[],inject:o={},log:a}=e;no(typeof t=="string","shader source must be a string");const l=t;let c="";const u=Wc(s),f={},h={},d={};for(const P in o){const A=typeof o[P]=="string"?{injection:o[P],order:0}:o[P],O=/^(v|f)s:(#)?([\w-]+)$/.exec(P);if(O){const E=O[2],x=O[3];E?x==="decl"?h[P]=[A]:d[P]=[A]:f[P]=[A]}else d[P]=[A]}const _=r;for(const P of _){a&&Uc(P,l,a);const A=qc(P,"wgsl");c+=A;const O=((I=P.injections)==null?void 0:I[i])||{};for(const E in O){const x=/^(v|f)s:#([\w-]+)$/.exec(E);if(x){const N=x[2]==="decl"?h:d;N[E]=N[E]||[],N[E].push(O[E])}else f[E]=f[E]||[],f[E].push(O[E])}}return c+=$c,c=or(c,i,h),c+=Hc(u[i],f),c+=l,c=or(c,i,d),c}function Xc(n,e){var N;const{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:l={},prologue:c=!0,log:u}=e;no(typeof t=="string","shader source must be a string");const f=r==="glsl"?Fy(t).version:-1,h=n.shaderLanguageVersion,d=f===100?"#version 100":"#version 300 es",I=t.split(`
|
|
71
71
|
`).slice(1).join(`
|
|
72
72
|
`),P={};s.forEach(U=>{Object.assign(P,U.defines)}),Object.assign(P,o);let A="";switch(r){case"wgsl":break;case"glsl":A=c?`${d}
|
|
73
73
|
|
|
74
74
|
// ----- PROLOGUE -------------------------
|
|
75
75
|
${`#define SHADER_TYPE_${i.toUpperCase()}`}
|
|
76
76
|
|
|
77
|
-
${
|
|
78
|
-
${i==="fragment"?
|
|
77
|
+
${Ry(n)}
|
|
78
|
+
${i==="fragment"?By:""}
|
|
79
79
|
|
|
80
80
|
// ----- APPLICATION DEFINES -------------------------
|
|
81
81
|
|
|
82
|
-
${
|
|
82
|
+
${Vy(P)}
|
|
83
83
|
|
|
84
84
|
`:`${d}
|
|
85
|
-
`;break}const O=
|
|
86
|
-
`)}return e}function
|
|
85
|
+
`;break}const O=Wc(a),E={},x={},R={};for(const U in l){const W=typeof l[U]=="string"?{injection:l[U],order:0}:l[U],q=/^(v|f)s:(#)?([\w-]+)$/.exec(U);if(q){const G=q[2],B=q[3];G?B==="decl"?x[U]=[W]:R[U]=[W]:E[U]=[W]}else R[U]=[W]}for(const U of s){u&&Uc(U,I,u);const W=qc(U,i);A+=W;const q=((N=U.instance)==null?void 0:N.normalizedInjections[i])||{};for(const G in q){const B=/^(v|f)s:#([\w-]+)$/.exec(G);if(B){const se=B[2]==="decl"?x:R;se[G]=se[G]||[],se[G].push(q[G])}else E[G]=E[G]||[],E[G].push(q[G])}}return A+="// ----- MAIN SHADER SOURCE -------------------------",A+=$c,A=or(A,i,x),A+=Hc(O[i],E),A+=I,A=or(A,i,R),r==="glsl"&&f!==h&&(A=ky(A,i)),A.trim()}function Yc(n){return function(t){var r;const i={};for(const s of n){const o=(r=s.getUniforms)==null?void 0:r.call(s,t,i);Object.assign(i,o)}return i}}function Vy(n={}){let e="";for(const t in n){const i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]}
|
|
86
|
+
`)}return e}function qc(n,e){let t;switch(e){case"vertex":t=n.vs||"";break;case"fragment":t=n.fs||"";break;case"wgsl":t=n.source||"";break;default:no(!1)}if(!n.name)throw new Error("Shader module must have a name");const i=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let r=`// ----- MODULE ${n.name} ---------------
|
|
87
87
|
|
|
88
88
|
`;return e!=="wgsl"&&(r+=`#define MODULE_${i}
|
|
89
89
|
`),r+=`${t}
|
|
90
|
-
`,r}const
|
|
91
|
-
`),i=[];let r=!0,s=null;for(const a of t){const l=a.match(
|
|
92
|
-
`)}const Jt=class Jt{constructor(){g(this,"_hookFunctions",[]);g(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return Jt.defaultShaderAssembler=Jt.defaultShaderAssembler||new Jt,Jt.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,{source:r,getUniforms:s}=Bx({...e,source:e.source,modules:t,hookFunctions:i});return{source:e.platformInfo.shaderLanguage==="wgsl"?Wx(r):r,getUniforms:s,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),i=this._hookFunctions;return{...Ux({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:i}),modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let r=0;for(let s=0,o=this._defaultModules.length;s<o;++s){const a=this._defaultModules[s],l=a.name;t[r++]=a,i[l]=!0}for(let s=0,o=e.length;s<o;++s){const a=e[s],l=a.name;i[l]||(t[r++]=a,i[l]=!0)}return t.length=r,or(t),t}};g(Jt,"defaultShaderAssembler");let oo=Jt;class Je{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class Bc{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Dt extends Je{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Mt extends Je{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class ao extends Je{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class qt extends Je{constructor(e,t,i,r){super(e,i),this.format=t,this.access=r}get isTemplate(){return!0}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}}var Ft;(n=>{n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(Ft||(Ft={}));class ar{constructor(e,t,i,r,s,o,a){this.name=e,this.type=t,this.group=i,this.binding=r,this.attributes=s,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class $x{constructor(e,t){this.name=e,this.type=t}}class Xx{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r,this.interpolation=null}}class Uc{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r}}class Yx{constructor(e,t,i,r){this.name=e,this.type=t,this.attributes=i,this.id=r}}class qx{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class jx{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class Kx{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function Zx(n){var e=(32768&n)>>15,t=(31744&n)>>10,i=1023&n;return t==0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):t==31?i?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,t-15)*(1+i/Math.pow(2,10))}const zc=new Float32Array(1),Qx=new Int32Array(zc.buffer),Me=new Uint16Array(1);function Jx(n){zc[0]=n;const e=Qx[0],t=e>>31&1;let i=e>>23&255,r=8388607&e;if(i===255)return Me[0]=t<<15|31744|(r!==0?512:0),Me[0];if(i===0){if(r===0)return Me[0]=t<<15,Me[0];r|=8388608;let s=113;for(;!(8388608&r);)r<<=1,s--;return i=127-s,r&=8388607,i>0?(r=(r>>126-i)+(r>>127-i&1),Me[0]=t<<15|i<<10|r>>13,Me[0]):(Me[0]=t<<15,Me[0])}return i=i-127+15,i>=31?(Me[0]=t<<15|31744,Me[0]):i<=0?i<-10?(Me[0]=t<<15,Me[0]):(r=(8388608|r)>>1-i,Me[0]=t<<15|r>>13,Me[0]):(r>>=13,Me[0]=t<<15|i<<10|r,Me[0])}const lo=new Uint32Array(1),Lc=new Float32Array(lo.buffer,0,1);function Vc(n){const e=112+(n>>6&31)<<23|(63&n)<<17;return lo[0]=e,Lc[0]}function Gx(n,e,t,i,r,s,o,a,l){const c=i*(o>>=r)*(s>>=r)+t*o+e*a;switch(l){case"r8unorm":return[oe(n,c,"8unorm",1)[0]];case"r8snorm":return[oe(n,c,"8snorm",1)[0]];case"r8uint":return[oe(n,c,"8uint",1)[0]];case"r8sint":return[oe(n,c,"8sint",1)[0]];case"rg8unorm":{const u=oe(n,c,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=oe(n,c,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=oe(n,c,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=oe(n,c,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=oe(n,c,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=oe(n,c,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=oe(n,c,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=oe(n,c,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=oe(n,c,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[oe(n,c,"16uint",1)[0]];case"r16sint":return[oe(n,c,"16sint",1)[0]];case"r16float":return[oe(n,c,"16float",1)[0]];case"rg16uint":{const u=oe(n,c,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=oe(n,c,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=oe(n,c,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=oe(n,c,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=oe(n,c,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=oe(n,c,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[oe(n,c,"32uint",1)[0]];case"r32sint":return[oe(n,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[oe(n,c,"32float",1)[0]];case"rg32uint":{const u=oe(n,c,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=oe(n,c,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=oe(n,c,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=oe(n,c,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=oe(n,c,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=oe(n,c,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(n.buffer,c,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[Vc(2047&u),Vc(f),function(d){const _=112+(d>>5&31)<<23|(31&d)<<18;return lo[0]=_,Lc[0]}(h),1]}}return null}function oe(n,e,t,i){const r=[0,0,0,0];for(let s=0;s<i;++s)switch(t){case"8unorm":r[s]=n[e]/255,e++;break;case"8snorm":r[s]=n[e]/255*2-1,e++;break;case"8uint":r[s]=n[e],e++;break;case"8sint":r[s]=n[e]-127,e++;break;case"16uint":r[s]=n[e]|n[e+1]<<8,e+=2;break;case"16sint":r[s]=(n[e]|n[e+1]<<8)-32768,e+=2;break;case"16float":r[s]=Zx(n[e]|n[e+1]<<8),e+=2;break;case"32uint":case"32sint":r[s]=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24,e+=4;break;case"32float":r[s]=new Float32Array(n.buffer,e,1)[0],e+=4}return r}function ae(n,e,t,i,r){for(let s=0;s<i;++s)switch(t){case"8unorm":n[e]=255*r[s],e++;break;case"8snorm":n[e]=.5*(r[s]+1)*255,e++;break;case"8uint":n[e]=r[s],e++;break;case"8sint":n[e]=r[s]+127,e++;break;case"16uint":new Uint16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16sint":new Int16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16float":{const o=Jx(r[s]);new Uint16Array(n.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32sint":new Int32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32float":new Float32Array(n.buffer,e,1)[0]=r[s],e+=4}return r}const co={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class Ge{constructor(){this.id=Ge._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(lr.instance);for(const i of e)i instanceof Array?this.searchBlock(i,t):i.search(t);t(cr.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}Ge._id=0;class lr extends Ge{}lr.instance=new lr;class cr extends Ge{}cr.instance=new cr;const Hc=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class pe extends Ge{constructor(){super()}}class jn extends pe{constructor(e,t,i,r,s,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=i,this.body=r,this.startLine=s,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class e0 extends pe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class Wc extends pe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class uo extends pe{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class $c extends pe{constructor(e,t,i,r){super(),this.init=e,this.condition=t,this.increment=i,this.body=r}get astNodeType(){return"for"}search(e){var t,i,r;(t=this.init)===null||t===void 0||t.search(e),(i=this.condition)===null||i===void 0||i.search(e),(r=this.increment)===null||r===void 0||r.search(e),this.searchBlock(this.body,e)}}class wt extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class fo extends pe{constructor(e,t,i){super(),this.attributes=null,this.name=e,this.type=t,this.value=i}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Kn extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class ur extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}var mn,Zn,w,b;(n=>{n.increment="++",n.decrement="--"})(mn||(mn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return n[t]}})(mn||(mn={}));class Xc extends pe{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(n=>{n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(Zn||(Zn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(Zn||(Zn={}));class Yc extends pe{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class ho extends pe{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Hc.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class qc extends pe{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),(t=this.continuing)===null||t===void 0||t.search(e)}}class jc extends pe{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class Kc extends pe{constructor(e,t,i,r){super(),this.condition=e,this.body=t,this.elseif=i,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class Zc extends pe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class t0 extends pe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class n0 extends pe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class Qc extends pe{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class po extends pe{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class i0 extends pe{constructor(){super()}get astNodeType(){return"discard"}}class Jc extends pe{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class Gc extends pe{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class k extends pe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=k._priority.get(t.name);k._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?k.i32:t}getTypeName(){return this.name}}k.x32=new k("x32"),k.f32=new k("f32"),k.i32=new k("i32"),k.u32=new k("u32"),k.f16=new k("f16"),k.bool=new k("bool"),k.void=new k("void"),k._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class eu extends k{constructor(e){super(e)}}class At extends k{constructor(e,t,i,r){super(e),this.members=t,this.startLine=i,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class T extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}}T.vec2f=new T("vec2",k.f32,null),T.vec3f=new T("vec3",k.f32,null),T.vec4f=new T("vec4",k.f32,null),T.vec2i=new T("vec2",k.i32,null),T.vec3i=new T("vec3",k.i32,null),T.vec4i=new T("vec4",k.i32,null),T.vec2u=new T("vec2",k.u32,null),T.vec3u=new T("vec3",k.u32,null),T.vec4u=new T("vec4",k.u32,null),T.vec2h=new T("vec2",k.f16,null),T.vec3h=new T("vec3",k.f16,null),T.vec4h=new T("vec4",k.f16,null),T.vec2b=new T("vec2",k.bool,null),T.vec3b=new T("vec3",k.bool,null),T.vec4b=new T("vec4",k.bool,null),T.mat2x2f=new T("mat2x2",k.f32,null),T.mat2x3f=new T("mat2x3",k.f32,null),T.mat2x4f=new T("mat2x4",k.f32,null),T.mat3x2f=new T("mat3x2",k.f32,null),T.mat3x3f=new T("mat3x3",k.f32,null),T.mat3x4f=new T("mat3x4",k.f32,null),T.mat4x2f=new T("mat4x2",k.f32,null),T.mat4x3f=new T("mat4x3",k.f32,null),T.mat4x4f=new T("mat4x4",k.f32,null),T.mat2x2h=new T("mat2x2",k.f16,null),T.mat2x3h=new T("mat2x3",k.f16,null),T.mat2x4h=new T("mat2x4",k.f16,null),T.mat3x2h=new T("mat3x2",k.f16,null),T.mat3x3h=new T("mat3x3",k.f16,null),T.mat3x4h=new T("mat3x4",k.f16,null),T.mat4x2h=new T("mat4x2",k.f16,null),T.mat4x3h=new T("mat4x3",k.f16,null),T.mat4x4h=new T("mat4x4",k.f16,null),T.mat2x2i=new T("mat2x2",k.i32,null),T.mat2x3i=new T("mat2x3",k.i32,null),T.mat2x4i=new T("mat2x4",k.i32,null),T.mat3x2i=new T("mat3x2",k.i32,null),T.mat3x3i=new T("mat3x3",k.i32,null),T.mat3x4i=new T("mat3x4",k.i32,null),T.mat4x2i=new T("mat4x2",k.i32,null),T.mat4x3i=new T("mat4x3",k.i32,null),T.mat4x4i=new T("mat4x4",k.i32,null),T.mat2x2u=new T("mat2x2",k.u32,null),T.mat2x3u=new T("mat2x3",k.u32,null),T.mat2x4u=new T("mat2x4",k.u32,null),T.mat3x2u=new T("mat3x2",k.u32,null),T.mat3x3u=new T("mat3x3",k.u32,null),T.mat3x4u=new T("mat3x4",k.u32,null),T.mat4x2u=new T("mat4x2",k.u32,null),T.mat4x3u=new T("mat4x3",k.u32,null),T.mat4x4u=new T("mat4x4",k.u32,null);class fr extends k{constructor(e,t,i,r){super(e),this.storage=t,this.type=i,this.access=r}get astNodeType(){return"pointer"}}class Qn extends k{constructor(e,t,i,r){super(e),this.attributes=t,this.format=i,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class Jn extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class lt extends Ge{constructor(){super(),this.postfix=null}}class jt extends lt{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class mt extends lt{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class go extends lt{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Hc.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class Ze extends lt{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class tu extends lt{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const i=e.evalExpression(this.initializer,e.context);return i!==null&&this.postfix?i.getSubData(e,this.postfix,e.context):i}return null}search(e){this.initializer.search(e)}}class Ae extends lt{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof v}get isVector(){return this.value instanceof m||this.value instanceof K}get scalarValue(){return this.value instanceof v?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof m||this.value instanceof K?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class nu extends lt{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class _n extends lt{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class iu extends lt{constructor(){super()}}class Se extends iu{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class ct extends iu{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?k.f32:e.name==="u32"||t.name==="u32"?k.u32:k.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class ru extends Ge{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class hr extends lt{constructor(){super()}get astNodeType(){return"default"}}class su extends ru{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class ou extends ru{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class au extends Ge{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class r0 extends Ge{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class lu extends Ge{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class cu extends Ge{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class et{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=et._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}et._id=0;class mo extends et{constructor(){super(new Je("void",null),null)}toString(){return"void"}}mo.void=new mo;class yn extends et{constructor(e){super(new ao("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,r){this.reference.setDataValue(e,t,i,r)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class v extends et{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new v(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new v(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new v(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,r){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);let s=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?s=Math.floor(s):this.typeInfo.name==="bool"&&(s=s?1:0),this.data[0]=s}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function s0(n,e,t){const i=e.length;return i===2?t==="f32"?new m(new Float32Array(e),n.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new m(new Int32Array(e),n.getTypeInfo("vec2i")):t==="u32"?new m(new Uint32Array(e),n.getTypeInfo("vec2u")):t==="f16"?new m(new Float32Array(e),n.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):i===3?t==="f32"?new m(new Float32Array(e),n.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new m(new Int32Array(e),n.getTypeInfo("vec3i")):t==="u32"?new m(new Uint32Array(e),n.getTypeInfo("vec3u")):t==="f16"?new m(new Float32Array(e),n.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):i===4?t==="f32"?new m(new Float32Array(e),n.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new m(new Int32Array(e),n.getTypeInfo("vec4i")):t==="u32"?new m(new Uint32Array(e),n.getTypeInfo("vec4u")):t==="f16"?new m(new Float32Array(e),n.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}class m extends et{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const r=this.typeInfo.name;r==="vec2f"||r==="vec3f"||r==="vec4f"?this.data=new Float32Array(e):r==="vec2i"||r==="vec3i"||r==="vec4i"?this.data=new Int32Array(e):r==="vec2u"||r==="vec3u"||r==="vec4u"?this.data=new Uint32Array(e):r==="vec2h"||r==="vec3h"||r==="vec4h"?this.data=new Float32Array(e):r==="vec2b"||r==="vec3b"||r==="vec4b"?this.data=new Int32Array(e):r==="vec2"||r==="vec3"||r==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${r}`)}}clone(){if(this.data instanceof Float32Array)return new m(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new m(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new m(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,r){i instanceof jt?console.error("TODO: Set vector postfix"):t instanceof m?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof qt)r=this.typeInfo.format||r;else{const o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?r=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?r=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?r=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?r=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let s=this;for(;t!==null&&s!==null;){if(t instanceof _n){const o=t.index;let a=-1;if(o instanceof Ae){if(!(o.value instanceof v))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const l=e.evalExpression(o,i);if(!(l instanceof v))return console.error("GetSubData: Unknown index type",o),null;a=l.value}if(a<0||a>=s.data.length)return console.error("GetSubData: Index out of range",a),null;if(s.data instanceof Float32Array){const l=new Float32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Int32Array){const l=new Int32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Uint32Array){const l=new Uint32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof jt))return console.error("GetSubData: Unknown postfix",t),null;{const o=t.value.toLowerCase();if(o.length===1){let l=0;if(o==="x"||o==="r")l=0;else if(o==="y"||o==="g")l=1;else if(o==="z"||o==="b")l=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;l=3}if(this.data instanceof Float32Array){let c=new Float32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Int32Array){let c=new Int32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Uint32Array){let c=new Uint32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}}const a=[];for(const l of o)l==="x"||l==="r"?a.push(this.data[0]):l==="y"||l==="g"?a.push(this.data[1]):l==="z"||l==="b"?a.push(this.data[2]):l==="w"||l==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${l}`);s=s0(e,a,r.name)}t=t.postfix}return s}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class K extends et{constructor(e,t,i=null){super(t,i),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new K(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,i,r){i instanceof jt?console.error("TODO: Set matrix postfix"):t instanceof K?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;const r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof qt)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return console.error(`GetDataValue: Unknown type ${r}`),null;e.getTypeInfo("f16")}if(t instanceof _n){const s=t.index;let o=-1;if(s instanceof Ae){if(!(s.value instanceof v))return console.error(`GetDataValue: Invalid array index ${s.value}`),null;o=s.value.value}else{const c=e.evalExpression(s,i);if(!(c instanceof v))return console.error("GetDataValue: Unknown index type",s),null;o=c.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const a=r.endsWith("h")?"h":"f";let l;if(r==="mat2x2"||r==="mat2x2f"||r==="mat2x2h"||r==="mat3x2"||r==="mat3x2f"||r==="mat3x2h"||r==="mat4x2"||r==="mat4x2f"||r==="mat4x2h")l=new m(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(r==="mat2x3"||r==="mat2x3f"||r==="mat2x3h"||r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h"||r==="mat4x3"||r==="mat4x3f"||r==="mat4x3h")l=new m(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(r!=="mat2x4"&&r!=="mat2x4f"&&r!=="mat2x4h"&&r!=="mat3x4"&&r!=="mat3x4f"&&r!=="mat3x4h"&&r!=="mat4x4"&&r!=="mat4x4f"&&r!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${r}`),null;l=new m(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?l.getSubData(e,t.postfix,i):l}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class ve extends et{constructor(e,t,i=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=i}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new ve(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,i,r){if(t===null)return void console.log("setDataValue: NULL data.");let s=this.offset,o=this.typeInfo;for(;i;){if(i instanceof _n)if(o instanceof Mt){const a=i.index;if(a instanceof Ae){if(!(a.value instanceof v))return void console.error(`SetDataValue: Invalid index type ${a.value}`);s+=a.value.value*o.stride}else{const l=e.evalExpression(a,r);if(!(l instanceof v))return void console.error("SetDataValue: Unknown index type",a);s+=l.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(i instanceof jt))return void console.error("SetDataValue: Unknown postfix type",i);{const a=i.value;if(o instanceof Dt){let l=!1;for(const c of o.members)if(c.name===a){s+=c.offset,o=c.type,l=!0;break}if(!l)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Je){const l=o.getTypeName();let c=0;if(a==="x"||a==="r")c=0;else if(a==="y"||a==="g")c=1;else if(a==="z"||a==="b")c=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);c=3}if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);const u=t.value;return l==="vec2f"?void(new Float32Array(this.buffer,s,2)[c]=u):l==="vec3f"?void(new Float32Array(this.buffer,s,3)[c]=u):l==="vec4f"?void(new Float32Array(this.buffer,s,4)[c]=u):l==="vec2i"?void(new Int32Array(this.buffer,s,2)[c]=u):l==="vec3i"?void(new Int32Array(this.buffer,s,3)[c]=u):l==="vec4i"?void(new Int32Array(this.buffer,s,4)[c]=u):l==="vec2u"?void(new Uint32Array(this.buffer,s,2)[c]=u):l==="vec3u"?void(new Uint32Array(this.buffer,s,3)[c]=u):l==="vec4u"?void(new Uint32Array(this.buffer,s,4)[c]=u):void console.error(`SetDataValue: Type ${l} is not a struct`)}}}i=i.postfix}this.setData(e,t,o,s,r)}setData(e,t,i,r,s){const o=i.getTypeName();if(o!=="f32"&&o!=="f16")if(o!=="i32"&&o!=="atomic<i32>"&&o!=="x32")if(o!=="u32"&&o!=="atomic<u32>")if(o!=="bool"){if(o==="vec2f"||o==="vec2h"){const a=new Float32Array(this.buffer,r,2);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,r,3);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,r,2);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,r,3);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,r,4);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof m?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,r,9);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,r,16);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]))}if(t instanceof ve){if(i===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,i){var r,s,o;if(t===null)return this;let a=this.offset,l=this.typeInfo;for(;t;){if(t instanceof _n){const u=t.index,f=u instanceof lt?e.evalExpression(u,i):u;let h=0;if(f instanceof v?h=f.value:typeof f=="number"?h=f:console.error("GetDataValue: Invalid index type",u),l instanceof Mt)a+=h*l.stride,l=l.format;else{const d=l.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,l=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${l.getTypeName()} is not an array`)}}else{if(!(t instanceof jt))return console.error("GetDataValue: Unknown postfix type",t),null;{const u=t.value;if(l instanceof Dt){let f=!1;for(const h of l.members)if(h.name===u){a+=h.offset,l=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(l instanceof Je){const f=l.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f";const d=[];for(let _=0;_<u.length;++_){const I=u[_].toLowerCase();let P=0;if(I==="x"||I==="r")P=0;else if(I==="y"||I==="g")P=1;else if(I==="z"||I==="b")P=2;else{if(I!=="w"&&I!=="a")return console.error(`Unknown member ${u}`),null;P=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*P+4?(console.log("Insufficient buffer data"),null):new v(new Float32Array(this.buffer,a+4*P,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new v(new Float32Array(this.buffer,a+4*P,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new v(new Int32Array(this.buffer,a+4*P,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new v(new Int32Array(this.buffer,a+4*P,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new v(new Uint32Array(this.buffer,a+4*P,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[P]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const A=new Float32Array(this.buffer,a,3);d.push(A[P])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[P]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[P]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[P]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[P]);else if(f==="vec2u"){h="u";const A=new Uint32Array(this.buffer,a,2);d.push(A[P])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[P])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[P]))}return d.length===2?l=e.getTypeInfo(`vec2${h}`):d.length===3?l=e.getTypeInfo(`vec3${h}`):d.length===4?l=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new m(d,l,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}const c=l.getTypeName();return c==="f32"?new v(new Float32Array(this.buffer,a,1),l,this):c==="i32"?new v(new Int32Array(this.buffer,a,1),l,this):c==="u32"?new v(new Uint32Array(this.buffer,a,1),l,this):c==="vec2f"?new m(new Float32Array(this.buffer,a,2),l,this):c==="vec3f"?new m(new Float32Array(this.buffer,a,3),l,this):c==="vec4f"?new m(new Float32Array(this.buffer,a,4),l,this):c==="vec2i"?new m(new Int32Array(this.buffer,a,2),l,this):c==="vec3i"?new m(new Int32Array(this.buffer,a,3),l,this):c==="vec4i"?new m(new Int32Array(this.buffer,a,4),l,this):c==="vec2u"?new m(new Uint32Array(this.buffer,a,2),l,this):c==="vec3u"?new m(new Uint32Array(this.buffer,a,3),l,this):c==="vec4u"?new m(new Uint32Array(this.buffer,a,4),l,this):l instanceof qt&&l.name==="atomic"?((r=l.format)===null||r===void 0?void 0:r.name)==="u32"?new v(new Uint32Array(this.buffer,a,1)[0],l.format,this):((s=l.format)===null||s===void 0?void 0:s.name)==="i32"?new v(new Int32Array(this.buffer,a,1)[0],l.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=l.format)===null||o===void 0?void 0:o.name}`),null):new ve(this.buffer,l,a,this)}toString(){let e="";if(this.typeInfo instanceof Mt)if(this.typeInfo.format.name==="f32"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="i32"){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="u32"){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="vec2f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let i=1;i<t.length/2;++i)e+=`, [${t[2*i]}, ${t[2*i+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}, ${t[i+3]}]`}else e="[...]";else this.typeInfo instanceof Dt?e+="{...}":e="[...]";return e}}class Ct extends et{constructor(e,t,i,r){super(t,null),this.data=e,this.descriptor=i,this.view=r}clone(){return new Ct(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>0?(e=i[0])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.width)!==null&&t!==void 0?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?(e=i[1])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?(e=i[2])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i<t.length;++i)t[i]=Math.max(1,t[i]>>e);return t}get texelByteSize(){const e=this.format,t=co[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=co[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=co[e],i=this.width;if(!e||i<=0||!t)return-1;const r=this.height,s=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*(o==="1d"?1:r/t.blockHeight)*t.bytesPerBlock*s}getPixel(e,t,i=0,r=0){const s=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[r];return Gx(new Uint8Array(l),e,t,i,r,a,o,s,this.format)}setPixel(e,t,i,r,s){const o=this.texelByteSize,a=this.bytesPerRow,l=this.height,c=this.data[r];(function(u,f,h,d,_,I,P,A,O,E){const y=d*(P>>=_)*(I>>=_)+h*P+f*A;switch(O){case"r8unorm":return void ae(u,y,"8unorm",1,E);case"r8snorm":return void ae(u,y,"8snorm",1,E);case"r8uint":return void ae(u,y,"8uint",1,E);case"r8sint":return void ae(u,y,"8sint",1,E);case"rg8unorm":return void ae(u,y,"8unorm",2,E);case"rg8snorm":return void ae(u,y,"8snorm",2,E);case"rg8uint":return void ae(u,y,"8uint",2,E);case"rg8sint":return void ae(u,y,"8sint",2,E);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void ae(u,y,"8unorm",4,E);case"rgba8snorm":return void ae(u,y,"8snorm",4,E);case"rgba8uint":return void ae(u,y,"8uint",4,E);case"rgba8sint":return void ae(u,y,"8sint",4,E);case"r16uint":return void ae(u,y,"16uint",1,E);case"r16sint":return void ae(u,y,"16sint",1,E);case"r16float":return void ae(u,y,"16float",1,E);case"rg16uint":return void ae(u,y,"16uint",2,E);case"rg16sint":return void ae(u,y,"16sint",2,E);case"rg16float":return void ae(u,y,"16float",2,E);case"rgba16uint":return void ae(u,y,"16uint",4,E);case"rgba16sint":return void ae(u,y,"16sint",4,E);case"rgba16float":return void ae(u,y,"16float",4,E);case"r32uint":return void ae(u,y,"32uint",1,E);case"r32sint":return void ae(u,y,"32sint",1,E);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void ae(u,y,"32float",1,E);case"rg32uint":return void ae(u,y,"32uint",2,E);case"rg32sint":return void ae(u,y,"32sint",2,E);case"rg32float":return void ae(u,y,"32float",2,E);case"rgba32uint":return void ae(u,y,"32uint",4,E);case"rgba32sint":return void ae(u,y,"32sint",4,E);case"rgba32float":return void ae(u,y,"32float",4,E);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(c),e,t,i,r,l,a,o,this.format,s)}}(n=>{n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(b||(b={}));class S{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class p{}w=p,p.none=new S("",b.reserved,""),p.eof=new S("EOF",b.token,""),p.reserved={asm:new S("asm",b.reserved,"asm"),bf16:new S("bf16",b.reserved,"bf16"),do:new S("do",b.reserved,"do"),enum:new S("enum",b.reserved,"enum"),f16:new S("f16",b.reserved,"f16"),f64:new S("f64",b.reserved,"f64"),handle:new S("handle",b.reserved,"handle"),i8:new S("i8",b.reserved,"i8"),i16:new S("i16",b.reserved,"i16"),i64:new S("i64",b.reserved,"i64"),mat:new S("mat",b.reserved,"mat"),premerge:new S("premerge",b.reserved,"premerge"),regardless:new S("regardless",b.reserved,"regardless"),typedef:new S("typedef",b.reserved,"typedef"),u8:new S("u8",b.reserved,"u8"),u16:new S("u16",b.reserved,"u16"),u64:new S("u64",b.reserved,"u64"),unless:new S("unless",b.reserved,"unless"),using:new S("using",b.reserved,"using"),vec:new S("vec",b.reserved,"vec"),void:new S("void",b.reserved,"void")},p.keywords={array:new S("array",b.keyword,"array"),atomic:new S("atomic",b.keyword,"atomic"),bool:new S("bool",b.keyword,"bool"),f32:new S("f32",b.keyword,"f32"),i32:new S("i32",b.keyword,"i32"),mat2x2:new S("mat2x2",b.keyword,"mat2x2"),mat2x3:new S("mat2x3",b.keyword,"mat2x3"),mat2x4:new S("mat2x4",b.keyword,"mat2x4"),mat3x2:new S("mat3x2",b.keyword,"mat3x2"),mat3x3:new S("mat3x3",b.keyword,"mat3x3"),mat3x4:new S("mat3x4",b.keyword,"mat3x4"),mat4x2:new S("mat4x2",b.keyword,"mat4x2"),mat4x3:new S("mat4x3",b.keyword,"mat4x3"),mat4x4:new S("mat4x4",b.keyword,"mat4x4"),ptr:new S("ptr",b.keyword,"ptr"),sampler:new S("sampler",b.keyword,"sampler"),sampler_comparison:new S("sampler_comparison",b.keyword,"sampler_comparison"),struct:new S("struct",b.keyword,"struct"),texture_1d:new S("texture_1d",b.keyword,"texture_1d"),texture_2d:new S("texture_2d",b.keyword,"texture_2d"),texture_2d_array:new S("texture_2d_array",b.keyword,"texture_2d_array"),texture_3d:new S("texture_3d",b.keyword,"texture_3d"),texture_cube:new S("texture_cube",b.keyword,"texture_cube"),texture_cube_array:new S("texture_cube_array",b.keyword,"texture_cube_array"),texture_multisampled_2d:new S("texture_multisampled_2d",b.keyword,"texture_multisampled_2d"),texture_storage_1d:new S("texture_storage_1d",b.keyword,"texture_storage_1d"),texture_storage_2d:new S("texture_storage_2d",b.keyword,"texture_storage_2d"),texture_storage_2d_array:new S("texture_storage_2d_array",b.keyword,"texture_storage_2d_array"),texture_storage_3d:new S("texture_storage_3d",b.keyword,"texture_storage_3d"),texture_depth_2d:new S("texture_depth_2d",b.keyword,"texture_depth_2d"),texture_depth_2d_array:new S("texture_depth_2d_array",b.keyword,"texture_depth_2d_array"),texture_depth_cube:new S("texture_depth_cube",b.keyword,"texture_depth_cube"),texture_depth_cube_array:new S("texture_depth_cube_array",b.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new S("texture_depth_multisampled_2d",b.keyword,"texture_depth_multisampled_2d"),texture_external:new S("texture_external",b.keyword,"texture_external"),u32:new S("u32",b.keyword,"u32"),vec2:new S("vec2",b.keyword,"vec2"),vec3:new S("vec3",b.keyword,"vec3"),vec4:new S("vec4",b.keyword,"vec4"),bitcast:new S("bitcast",b.keyword,"bitcast"),block:new S("block",b.keyword,"block"),break:new S("break",b.keyword,"break"),case:new S("case",b.keyword,"case"),continue:new S("continue",b.keyword,"continue"),continuing:new S("continuing",b.keyword,"continuing"),default:new S("default",b.keyword,"default"),diagnostic:new S("diagnostic",b.keyword,"diagnostic"),discard:new S("discard",b.keyword,"discard"),else:new S("else",b.keyword,"else"),enable:new S("enable",b.keyword,"enable"),fallthrough:new S("fallthrough",b.keyword,"fallthrough"),false:new S("false",b.keyword,"false"),fn:new S("fn",b.keyword,"fn"),for:new S("for",b.keyword,"for"),function:new S("function",b.keyword,"function"),if:new S("if",b.keyword,"if"),let:new S("let",b.keyword,"let"),const:new S("const",b.keyword,"const"),loop:new S("loop",b.keyword,"loop"),while:new S("while",b.keyword,"while"),private:new S("private",b.keyword,"private"),read:new S("read",b.keyword,"read"),read_write:new S("read_write",b.keyword,"read_write"),return:new S("return",b.keyword,"return"),requires:new S("requires",b.keyword,"requires"),storage:new S("storage",b.keyword,"storage"),switch:new S("switch",b.keyword,"switch"),true:new S("true",b.keyword,"true"),alias:new S("alias",b.keyword,"alias"),type:new S("type",b.keyword,"type"),uniform:new S("uniform",b.keyword,"uniform"),var:new S("var",b.keyword,"var"),override:new S("override",b.keyword,"override"),workgroup:new S("workgroup",b.keyword,"workgroup"),write:new S("write",b.keyword,"write"),r8unorm:new S("r8unorm",b.keyword,"r8unorm"),r8snorm:new S("r8snorm",b.keyword,"r8snorm"),r8uint:new S("r8uint",b.keyword,"r8uint"),r8sint:new S("r8sint",b.keyword,"r8sint"),r16uint:new S("r16uint",b.keyword,"r16uint"),r16sint:new S("r16sint",b.keyword,"r16sint"),r16float:new S("r16float",b.keyword,"r16float"),rg8unorm:new S("rg8unorm",b.keyword,"rg8unorm"),rg8snorm:new S("rg8snorm",b.keyword,"rg8snorm"),rg8uint:new S("rg8uint",b.keyword,"rg8uint"),rg8sint:new S("rg8sint",b.keyword,"rg8sint"),r32uint:new S("r32uint",b.keyword,"r32uint"),r32sint:new S("r32sint",b.keyword,"r32sint"),r32float:new S("r32float",b.keyword,"r32float"),rg16uint:new S("rg16uint",b.keyword,"rg16uint"),rg16sint:new S("rg16sint",b.keyword,"rg16sint"),rg16float:new S("rg16float",b.keyword,"rg16float"),rgba8unorm:new S("rgba8unorm",b.keyword,"rgba8unorm"),rgba8unorm_srgb:new S("rgba8unorm_srgb",b.keyword,"rgba8unorm_srgb"),rgba8snorm:new S("rgba8snorm",b.keyword,"rgba8snorm"),rgba8uint:new S("rgba8uint",b.keyword,"rgba8uint"),rgba8sint:new S("rgba8sint",b.keyword,"rgba8sint"),bgra8unorm:new S("bgra8unorm",b.keyword,"bgra8unorm"),bgra8unorm_srgb:new S("bgra8unorm_srgb",b.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new S("rgb10a2unorm",b.keyword,"rgb10a2unorm"),rg11b10float:new S("rg11b10float",b.keyword,"rg11b10float"),rg32uint:new S("rg32uint",b.keyword,"rg32uint"),rg32sint:new S("rg32sint",b.keyword,"rg32sint"),rg32float:new S("rg32float",b.keyword,"rg32float"),rgba16uint:new S("rgba16uint",b.keyword,"rgba16uint"),rgba16sint:new S("rgba16sint",b.keyword,"rgba16sint"),rgba16float:new S("rgba16float",b.keyword,"rgba16float"),rgba32uint:new S("rgba32uint",b.keyword,"rgba32uint"),rgba32sint:new S("rgba32sint",b.keyword,"rgba32sint"),rgba32float:new S("rgba32float",b.keyword,"rgba32float"),static_assert:new S("static_assert",b.keyword,"static_assert")},p.tokens={decimal_float_literal:new S("decimal_float_literal",b.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new S("hex_float_literal",b.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new S("int_literal",b.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new S("uint_literal",b.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new S("name",b.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new S("ident",b.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new S("and",b.token,"&"),and_and:new S("and_and",b.token,"&&"),arrow:new S("arrow ",b.token,"->"),attr:new S("attr",b.token,"@"),forward_slash:new S("forward_slash",b.token,"/"),bang:new S("bang",b.token,"!"),bracket_left:new S("bracket_left",b.token,"["),bracket_right:new S("bracket_right",b.token,"]"),brace_left:new S("brace_left",b.token,"{"),brace_right:new S("brace_right",b.token,"}"),colon:new S("colon",b.token,":"),comma:new S("comma",b.token,","),equal:new S("equal",b.token,"="),equal_equal:new S("equal_equal",b.token,"=="),not_equal:new S("not_equal",b.token,"!="),greater_than:new S("greater_than",b.token,">"),greater_than_equal:new S("greater_than_equal",b.token,">="),shift_right:new S("shift_right",b.token,">>"),less_than:new S("less_than",b.token,"<"),less_than_equal:new S("less_than_equal",b.token,"<="),shift_left:new S("shift_left",b.token,"<<"),modulo:new S("modulo",b.token,"%"),minus:new S("minus",b.token,"-"),minus_minus:new S("minus_minus",b.token,"--"),period:new S("period",b.token,"."),plus:new S("plus",b.token,"+"),plus_plus:new S("plus_plus",b.token,"++"),or:new S("or",b.token,"|"),or_or:new S("or_or",b.token,"||"),paren_left:new S("paren_left",b.token,"("),paren_right:new S("paren_right",b.token,")"),semicolon:new S("semicolon",b.token,";"),star:new S("star",b.token,"*"),tilde:new S("tilde",b.token,"~"),underscore:new S("underscore",b.token,"_"),xor:new S("xor",b.token,"^"),plus_equal:new S("plus_equal",b.token,"+="),minus_equal:new S("minus_equal",b.token,"-="),times_equal:new S("times_equal",b.token,"*="),division_equal:new S("division_equal",b.token,"/="),modulo_equal:new S("modulo_equal",b.token,"%="),and_equal:new S("and_equal",b.token,"&="),or_equal:new S("or_equal",b.token,"|="),xor_equal:new S("xor_equal",b.token,"^="),shift_right_equal:new S("shift_right_equal",b.token,">>="),shift_left_equal:new S("shift_left_equal",b.token,"<<=")},p.simpleTokens={"@":w.tokens.attr,"{":w.tokens.brace_left,"}":w.tokens.brace_right,":":w.tokens.colon,",":w.tokens.comma,"(":w.tokens.paren_left,")":w.tokens.paren_right,";":w.tokens.semicolon},p.literalTokens={"&":w.tokens.and,"&&":w.tokens.and_and,"->":w.tokens.arrow,"/":w.tokens.forward_slash,"!":w.tokens.bang,"[":w.tokens.bracket_left,"]":w.tokens.bracket_right,"=":w.tokens.equal,"==":w.tokens.equal_equal,"!=":w.tokens.not_equal,">":w.tokens.greater_than,">=":w.tokens.greater_than_equal,">>":w.tokens.shift_right,"<":w.tokens.less_than,"<=":w.tokens.less_than_equal,"<<":w.tokens.shift_left,"%":w.tokens.modulo,"-":w.tokens.minus,"--":w.tokens.minus_minus,".":w.tokens.period,"+":w.tokens.plus,"++":w.tokens.plus_plus,"|":w.tokens.or,"||":w.tokens.or_or,"*":w.tokens.star,"~":w.tokens.tilde,_:w.tokens.underscore,"^":w.tokens.xor,"+=":w.tokens.plus_equal,"-=":w.tokens.minus_equal,"*=":w.tokens.times_equal,"/=":w.tokens.division_equal,"%=":w.tokens.modulo_equal,"&=":w.tokens.and_equal,"|=":w.tokens.or_equal,"^=":w.tokens.xor_equal,">>=":w.tokens.shift_right_equal,"<<=":w.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:w.tokens.decimal_float_literal,hex_float_literal:w.tokens.hex_float_literal,int_literal:w.tokens.int_literal,uint_literal:w.tokens.uint_literal,ident:w.tokens.ident},p.storage_class=[w.keywords.function,w.keywords.private,w.keywords.workgroup,w.keywords.uniform,w.keywords.storage],p.access_mode=[w.keywords.read,w.keywords.write,w.keywords.read_write],p.sampler_type=[w.keywords.sampler,w.keywords.sampler_comparison],p.sampled_texture_type=[w.keywords.texture_1d,w.keywords.texture_2d,w.keywords.texture_2d_array,w.keywords.texture_3d,w.keywords.texture_cube,w.keywords.texture_cube_array],p.multisampled_texture_type=[w.keywords.texture_multisampled_2d],p.storage_texture_type=[w.keywords.texture_storage_1d,w.keywords.texture_storage_2d,w.keywords.texture_storage_2d_array,w.keywords.texture_storage_3d],p.depth_texture_type=[w.keywords.texture_depth_2d,w.keywords.texture_depth_2d_array,w.keywords.texture_depth_cube,w.keywords.texture_depth_cube_array,w.keywords.texture_depth_multisampled_2d],p.texture_external_type=[w.keywords.texture_external],p.any_texture_type=[...w.sampled_texture_type,...w.multisampled_texture_type,...w.storage_texture_type,...w.depth_texture_type,...w.texture_external_type],p.texel_format=[w.keywords.r8unorm,w.keywords.r8snorm,w.keywords.r8uint,w.keywords.r8sint,w.keywords.r16uint,w.keywords.r16sint,w.keywords.r16float,w.keywords.rg8unorm,w.keywords.rg8snorm,w.keywords.rg8uint,w.keywords.rg8sint,w.keywords.r32uint,w.keywords.r32sint,w.keywords.r32float,w.keywords.rg16uint,w.keywords.rg16sint,w.keywords.rg16float,w.keywords.rgba8unorm,w.keywords.rgba8unorm_srgb,w.keywords.rgba8snorm,w.keywords.rgba8uint,w.keywords.rgba8sint,w.keywords.bgra8unorm,w.keywords.bgra8unorm_srgb,w.keywords.rgb10a2unorm,w.keywords.rg11b10float,w.keywords.rg32uint,w.keywords.rg32sint,w.keywords.rg32float,w.keywords.rgba16uint,w.keywords.rgba16sint,w.keywords.rgba16float,w.keywords.rgba32uint,w.keywords.rgba32sint,w.keywords.rgba32float],p.const_literal=[w.tokens.int_literal,w.tokens.uint_literal,w.tokens.decimal_float_literal,w.tokens.hex_float_literal,w.keywords.true,w.keywords.false],p.literal_or_ident=[w.tokens.ident,w.tokens.int_literal,w.tokens.uint_literal,w.tokens.decimal_float_literal,w.tokens.hex_float_literal,w.tokens.name],p.element_count_expression=[w.tokens.int_literal,w.tokens.uint_literal,w.tokens.ident],p.template_types=[w.keywords.vec2,w.keywords.vec3,w.keywords.vec4,w.keywords.mat2x2,w.keywords.mat2x3,w.keywords.mat2x4,w.keywords.mat3x2,w.keywords.mat3x3,w.keywords.mat3x4,w.keywords.mat4x2,w.keywords.mat4x3,w.keywords.mat4x4,w.keywords.atomic,w.keywords.bitcast,...w.any_texture_type],p.attribute_name=[w.tokens.ident,w.keywords.block,w.keywords.diagnostic],p.assignment_operators=[w.tokens.equal,w.tokens.plus_equal,w.tokens.minus_equal,w.tokens.times_equal,w.tokens.division_equal,w.tokens.modulo_equal,w.tokens.and_equal,w.tokens.or_equal,w.tokens.xor_equal,w.tokens.shift_right_equal,w.tokens.shift_left_equal],p.increment_operators=[w.tokens.plus_plus,w.tokens.minus_minus];class uu{constructor(e,t,i,r,s){this.type=e,this.lexeme=t,this.line=i,this.start=r,this.end=s}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class o0{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new uu(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
90
|
+
`,r}const Hy=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Wy=/^\s*\#\s*endif\s*$/;function $y(n,e){var o;const t=n.split(`
|
|
91
|
+
`),i=[];let r=!0,s=null;for(const a of t){const l=a.match(Hy),c=a.match(Wy);l?(s=l[1],r=!!((o=e==null?void 0:e.defines)!=null&&o[s])):c?r=!0:r&&i.push(a)}return i.join(`
|
|
92
|
+
`)}const Jt=class Jt{constructor(){m(this,"_hookFunctions",[]);m(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return Jt.defaultShaderAssembler=Jt.defaultShaderAssembler||new Jt,Jt.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,{source:r,getUniforms:s}=Uy({...e,source:e.source,modules:t,hookFunctions:i});return{source:e.platformInfo.shaderLanguage==="wgsl"?$y(r):r,getUniforms:s,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),i=this._hookFunctions;return{...zy({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:i}),modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let r=0;for(let s=0,o=this._defaultModules.length;s<o;++s){const a=this._defaultModules[s],l=a.name;t[r++]=a,i[l]=!0}for(let s=0,o=e.length;s<o;++s){const a=e[s],l=a.name;i[l]||(t[r++]=a,i[l]=!0)}return t.length=r,ar(t),t}};m(Jt,"defaultShaderAssembler");let ao=Jt;class Je{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class jc{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Dt extends Je{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class Mt extends Je{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class lo extends Je{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class qt extends Je{constructor(e,t,i,r){super(e,i),this.format=t,this.access=r}get isTemplate(){return!0}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}}var Ft;(n=>{n[n.Uniform=0]="Uniform",n[n.Storage=1]="Storage",n[n.Texture=2]="Texture",n[n.Sampler=3]="Sampler",n[n.StorageTexture=4]="StorageTexture"})(Ft||(Ft={}));class lr{constructor(e,t,i,r,s,o,a){this.name=e,this.type=t,this.group=i,this.binding=r,this.attributes=s,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class Xy{constructor(e,t){this.name=e,this.type=t}}class Yy{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r,this.interpolation=null}}class Kc{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r}}class qy{constructor(e,t,i,r){this.name=e,this.type=t,this.attributes=i,this.id=r}}class jy{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Ky{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class Zy{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function Qy(n){var e=(32768&n)>>15,t=(31744&n)>>10,i=1023&n;return t==0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):t==31?i?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,t-15)*(1+i/Math.pow(2,10))}const Zc=new Float32Array(1),Jy=new Int32Array(Zc.buffer),Fe=new Uint16Array(1);function Gy(n){Zc[0]=n;const e=Jy[0],t=e>>31&1;let i=e>>23&255,r=8388607&e;if(i===255)return Fe[0]=t<<15|31744|(r!==0?512:0),Fe[0];if(i===0){if(r===0)return Fe[0]=t<<15,Fe[0];r|=8388608;let s=113;for(;!(8388608&r);)r<<=1,s--;return i=127-s,r&=8388607,i>0?(r=(r>>126-i)+(r>>127-i&1),Fe[0]=t<<15|i<<10|r>>13,Fe[0]):(Fe[0]=t<<15,Fe[0])}return i=i-127+15,i>=31?(Fe[0]=t<<15|31744,Fe[0]):i<=0?i<-10?(Fe[0]=t<<15,Fe[0]):(r=(8388608|r)>>1-i,Fe[0]=t<<15|r>>13,Fe[0]):(r>>=13,Fe[0]=t<<15|i<<10|r,Fe[0])}const co=new Uint32Array(1),Qc=new Float32Array(co.buffer,0,1);function Jc(n){const e=112+(n>>6&31)<<23|(63&n)<<17;return co[0]=e,Qc[0]}function e0(n,e,t,i,r,s,o,a,l){const c=i*(o>>=r)*(s>>=r)+t*o+e*a;switch(l){case"r8unorm":return[ae(n,c,"8unorm",1)[0]];case"r8snorm":return[ae(n,c,"8snorm",1)[0]];case"r8uint":return[ae(n,c,"8uint",1)[0]];case"r8sint":return[ae(n,c,"8sint",1)[0]];case"rg8unorm":{const u=ae(n,c,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{const u=ae(n,c,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{const u=ae(n,c,"8uint",2);return[u[0],u[1]]}case"rg8sint":{const u=ae(n,c,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const u=ae(n,c,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{const u=ae(n,c,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{const u=ae(n,c,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{const u=ae(n,c,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const u=ae(n,c,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[ae(n,c,"16uint",1)[0]];case"r16sint":return[ae(n,c,"16sint",1)[0]];case"r16float":return[ae(n,c,"16float",1)[0]];case"rg16uint":{const u=ae(n,c,"16uint",2);return[u[0],u[1]]}case"rg16sint":{const u=ae(n,c,"16sint",2);return[u[0],u[1]]}case"rg16float":{const u=ae(n,c,"16float",2);return[u[0],u[1]]}case"rgba16uint":{const u=ae(n,c,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{const u=ae(n,c,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{const u=ae(n,c,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[ae(n,c,"32uint",1)[0]];case"r32sint":return[ae(n,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[ae(n,c,"32float",1)[0]];case"rg32uint":{const u=ae(n,c,"32uint",2);return[u[0],u[1]]}case"rg32sint":{const u=ae(n,c,"32sint",2);return[u[0],u[1]]}case"rg32float":{const u=ae(n,c,"32float",2);return[u[0],u[1]]}case"rgba32uint":{const u=ae(n,c,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{const u=ae(n,c,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{const u=ae(n,c,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{const u=new Uint32Array(n.buffer,c,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[Jc(2047&u),Jc(f),function(d){const _=112+(d>>5&31)<<23|(31&d)<<18;return co[0]=_,Qc[0]}(h),1]}}return null}function ae(n,e,t,i){const r=[0,0,0,0];for(let s=0;s<i;++s)switch(t){case"8unorm":r[s]=n[e]/255,e++;break;case"8snorm":r[s]=n[e]/255*2-1,e++;break;case"8uint":r[s]=n[e],e++;break;case"8sint":r[s]=n[e]-127,e++;break;case"16uint":r[s]=n[e]|n[e+1]<<8,e+=2;break;case"16sint":r[s]=(n[e]|n[e+1]<<8)-32768,e+=2;break;case"16float":r[s]=Qy(n[e]|n[e+1]<<8),e+=2;break;case"32uint":case"32sint":r[s]=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24,e+=4;break;case"32float":r[s]=new Float32Array(n.buffer,e,1)[0],e+=4}return r}function le(n,e,t,i,r){for(let s=0;s<i;++s)switch(t){case"8unorm":n[e]=255*r[s],e++;break;case"8snorm":n[e]=.5*(r[s]+1)*255,e++;break;case"8uint":n[e]=r[s],e++;break;case"8sint":n[e]=r[s]+127,e++;break;case"16uint":new Uint16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16sint":new Int16Array(n.buffer,e,1)[0]=r[s],e+=2;break;case"16float":{const o=Gy(r[s]);new Uint16Array(n.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32sint":new Int32Array(n.buffer,e,1)[0]=r[s],e+=4;break;case"32float":new Float32Array(n.buffer,e,1)[0]=r[s],e+=4}return r}const uo={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class Ge{constructor(){this.id=Ge._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(cr.instance);for(const i of e)i instanceof Array?this.searchBlock(i,t):i.search(t);t(ur.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}Ge._id=0;class cr extends Ge{}cr.instance=new cr;class ur extends Ge{}ur.instance=new ur;const Gc=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class pe extends Ge{constructor(){super()}}class jn extends pe{constructor(e,t,i,r,s,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=i,this.body=r,this.startLine=s,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class t0 extends pe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class eu extends pe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class fo extends pe{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class tu extends pe{constructor(e,t,i,r){super(),this.init=e,this.condition=t,this.increment=i,this.body=r}get astNodeType(){return"for"}search(e){var t,i,r;(t=this.init)===null||t===void 0||t.search(e),(i=this.condition)===null||i===void 0||i.search(e),(r=this.increment)===null||r===void 0||r.search(e),this.searchBlock(this.body,e)}}class wt extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class ho extends pe{constructor(e,t,i){super(),this.attributes=null,this.name=e,this.type=t,this.value=i}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class Kn extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}class fr extends pe{constructor(e,t,i,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=i,this.access=r,this.value=s}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}}var gn,Zn,w,b;(n=>{n.increment="++",n.decrement="--"})(gn||(gn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return n[t]}})(gn||(gn={}));class nu extends pe{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(n=>{n.assign="=",n.addAssign="+=",n.subtractAssin="-=",n.multiplyAssign="*=",n.divideAssign="/=",n.moduloAssign="%=",n.andAssign="&=",n.orAssign="|=",n.xorAssign="^=",n.shiftLeftAssign="<<=",n.shiftRightAssign=">>="})(Zn||(Zn={})),(n=>{n.parse=function(e){const t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(Zn||(Zn={}));class iu extends pe{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class po extends pe{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Gc.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class ru extends pe{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),(t=this.continuing)===null||t===void 0||t.search(e)}}class su extends pe{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class ou extends pe{constructor(e,t,i,r){super(),this.condition=e,this.body=t,this.elseif=i,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class au extends pe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}}class n0 extends pe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class i0 extends pe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class lu extends pe{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class mo extends pe{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class r0 extends pe{constructor(){super()}get astNodeType(){return"discard"}}class cu extends pe{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class uu extends pe{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class k extends pe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=k._priority.get(t.name);k._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?k.i32:t}getTypeName(){return this.name}}k.x32=new k("x32"),k.f32=new k("f32"),k.i32=new k("i32"),k.u32=new k("u32"),k.f16=new k("f16"),k.bool=new k("bool"),k.void=new k("void"),k._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class fu extends k{constructor(e){super(e)}}class At extends k{constructor(e,t,i,r){super(e),this.members=t,this.startLine=i,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class T extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}}T.vec2f=new T("vec2",k.f32,null),T.vec3f=new T("vec3",k.f32,null),T.vec4f=new T("vec4",k.f32,null),T.vec2i=new T("vec2",k.i32,null),T.vec3i=new T("vec3",k.i32,null),T.vec4i=new T("vec4",k.i32,null),T.vec2u=new T("vec2",k.u32,null),T.vec3u=new T("vec3",k.u32,null),T.vec4u=new T("vec4",k.u32,null),T.vec2h=new T("vec2",k.f16,null),T.vec3h=new T("vec3",k.f16,null),T.vec4h=new T("vec4",k.f16,null),T.vec2b=new T("vec2",k.bool,null),T.vec3b=new T("vec3",k.bool,null),T.vec4b=new T("vec4",k.bool,null),T.mat2x2f=new T("mat2x2",k.f32,null),T.mat2x3f=new T("mat2x3",k.f32,null),T.mat2x4f=new T("mat2x4",k.f32,null),T.mat3x2f=new T("mat3x2",k.f32,null),T.mat3x3f=new T("mat3x3",k.f32,null),T.mat3x4f=new T("mat3x4",k.f32,null),T.mat4x2f=new T("mat4x2",k.f32,null),T.mat4x3f=new T("mat4x3",k.f32,null),T.mat4x4f=new T("mat4x4",k.f32,null),T.mat2x2h=new T("mat2x2",k.f16,null),T.mat2x3h=new T("mat2x3",k.f16,null),T.mat2x4h=new T("mat2x4",k.f16,null),T.mat3x2h=new T("mat3x2",k.f16,null),T.mat3x3h=new T("mat3x3",k.f16,null),T.mat3x4h=new T("mat3x4",k.f16,null),T.mat4x2h=new T("mat4x2",k.f16,null),T.mat4x3h=new T("mat4x3",k.f16,null),T.mat4x4h=new T("mat4x4",k.f16,null),T.mat2x2i=new T("mat2x2",k.i32,null),T.mat2x3i=new T("mat2x3",k.i32,null),T.mat2x4i=new T("mat2x4",k.i32,null),T.mat3x2i=new T("mat3x2",k.i32,null),T.mat3x3i=new T("mat3x3",k.i32,null),T.mat3x4i=new T("mat3x4",k.i32,null),T.mat4x2i=new T("mat4x2",k.i32,null),T.mat4x3i=new T("mat4x3",k.i32,null),T.mat4x4i=new T("mat4x4",k.i32,null),T.mat2x2u=new T("mat2x2",k.u32,null),T.mat2x3u=new T("mat2x3",k.u32,null),T.mat2x4u=new T("mat2x4",k.u32,null),T.mat3x2u=new T("mat3x2",k.u32,null),T.mat3x3u=new T("mat3x3",k.u32,null),T.mat3x4u=new T("mat3x4",k.u32,null),T.mat4x2u=new T("mat4x2",k.u32,null),T.mat4x3u=new T("mat4x3",k.u32,null),T.mat4x4u=new T("mat4x4",k.u32,null);class hr extends k{constructor(e,t,i,r){super(e),this.storage=t,this.type=i,this.access=r}get astNodeType(){return"pointer"}}class Qn extends k{constructor(e,t,i,r){super(e),this.attributes=t,this.format=i,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class Jn extends k{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class lt extends Ge{constructor(){super(),this.postfix=null}}class jt extends lt{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class gt extends lt{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class go extends lt{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Gc.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class Ze extends lt{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class hu extends lt{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const i=e.evalExpression(this.initializer,e.context);return i!==null&&this.postfix?i.getSubData(e,this.postfix,e.context):i}return null}search(e){this.initializer.search(e)}}class Ae extends lt{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof v}get isVector(){return this.value instanceof g||this.value instanceof K}get scalarValue(){return this.value instanceof v?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof g||this.value instanceof K?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class du extends lt{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class _n extends lt{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class pu extends lt{constructor(){super()}}class Se extends pu{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class ct extends pu{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?k.f32:e.name==="u32"||t.name==="u32"?k.u32:k.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class mu extends Ge{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class dr extends lt{constructor(){super()}get astNodeType(){return"default"}}class gu extends mu{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class _u extends mu{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class xu extends Ge{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class s0 extends Ge{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class yu extends Ge{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class vu extends Ge{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class et{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=et._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}et._id=0;class _o extends et{constructor(){super(new Je("void",null),null)}toString(){return"void"}}_o.void=new _o;class xn extends et{constructor(e){super(new lo("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,r){this.reference.setDataValue(e,t,i,r)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class v extends et{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new v(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new v(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new v(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,r){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);let s=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?s=Math.floor(s):this.typeInfo.name==="bool"&&(s=s?1:0),this.data[0]=s}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function o0(n,e,t){const i=e.length;return i===2?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec2i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec2u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):i===3?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec3i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec3u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):i===4?t==="f32"?new g(new Float32Array(e),n.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new g(new Int32Array(e),n.getTypeInfo("vec4i")):t==="u32"?new g(new Uint32Array(e),n.getTypeInfo("vec4u")):t==="f16"?new g(new Float32Array(e),n.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}class g extends et{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const r=this.typeInfo.name;r==="vec2f"||r==="vec3f"||r==="vec4f"?this.data=new Float32Array(e):r==="vec2i"||r==="vec3i"||r==="vec4i"?this.data=new Int32Array(e):r==="vec2u"||r==="vec3u"||r==="vec4u"?this.data=new Uint32Array(e):r==="vec2h"||r==="vec3h"||r==="vec4h"?this.data=new Float32Array(e):r==="vec2b"||r==="vec3b"||r==="vec4b"?this.data=new Int32Array(e):r==="vec2"||r==="vec3"||r==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${r}`)}}clone(){if(this.data instanceof Float32Array)return new g(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new g(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new g(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,r){i instanceof jt?console.error("TODO: Set vector postfix"):t instanceof g?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof qt)r=this.typeInfo.format||r;else{const o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?r=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?r=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?r=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?r=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let s=this;for(;t!==null&&s!==null;){if(t instanceof _n){const o=t.index;let a=-1;if(o instanceof Ae){if(!(o.value instanceof v))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{const l=e.evalExpression(o,i);if(!(l instanceof v))return console.error("GetSubData: Unknown index type",o),null;a=l.value}if(a<0||a>=s.data.length)return console.error("GetSubData: Index out of range",a),null;if(s.data instanceof Float32Array){const l=new Float32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Int32Array){const l=new Int32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}if(s.data instanceof Uint32Array){const l=new Uint32Array(s.data.buffer,s.data.byteOffset+4*a,1);return new v(l,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof jt))return console.error("GetSubData: Unknown postfix",t),null;{const o=t.value.toLowerCase();if(o.length===1){let l=0;if(o==="x"||o==="r")l=0;else if(o==="y"||o==="g")l=1;else if(o==="z"||o==="b")l=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;l=3}if(this.data instanceof Float32Array){let c=new Float32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Int32Array){let c=new Int32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}if(this.data instanceof Uint32Array){let c=new Uint32Array(this.data.buffer,this.data.byteOffset+4*l,1);return new v(c,r,this)}}const a=[];for(const l of o)l==="x"||l==="r"?a.push(this.data[0]):l==="y"||l==="g"?a.push(this.data[1]):l==="z"||l==="b"?a.push(this.data[2]):l==="w"||l==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${l}`);s=o0(e,a,r.name)}t=t.postfix}return s}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class K extends et{constructor(e,t,i=null){super(t,i),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new K(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,i,r){i instanceof jt?console.error("TODO: Set matrix postfix"):t instanceof K?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(t===null)return this;const r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof qt)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return console.error(`GetDataValue: Unknown type ${r}`),null;e.getTypeInfo("f16")}if(t instanceof _n){const s=t.index;let o=-1;if(s instanceof Ae){if(!(s.value instanceof v))return console.error(`GetDataValue: Invalid array index ${s.value}`),null;o=s.value.value}else{const c=e.evalExpression(s,i);if(!(c instanceof v))return console.error("GetDataValue: Unknown index type",s),null;o=c.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const a=r.endsWith("h")?"h":"f";let l;if(r==="mat2x2"||r==="mat2x2f"||r==="mat2x2h"||r==="mat3x2"||r==="mat3x2f"||r==="mat3x2h"||r==="mat4x2"||r==="mat4x2f"||r==="mat4x2h")l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(r==="mat2x3"||r==="mat2x3f"||r==="mat2x3h"||r==="mat3x3"||r==="mat3x3f"||r==="mat3x3h"||r==="mat4x3"||r==="mat4x3f"||r==="mat4x3h")l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(r!=="mat2x4"&&r!=="mat2x4f"&&r!=="mat2x4h"&&r!=="mat3x4"&&r!=="mat3x4f"&&r!=="mat3x4h"&&r!=="mat4x4"&&r!=="mat4x4f"&&r!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${r}`),null;l=new g(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?l.getSubData(e,t.postfix,i):l}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class ve extends et{constructor(e,t,i=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=i}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new ve(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,i,r){if(t===null)return void console.log("setDataValue: NULL data.");let s=this.offset,o=this.typeInfo;for(;i;){if(i instanceof _n)if(o instanceof Mt){const a=i.index;if(a instanceof Ae){if(!(a.value instanceof v))return void console.error(`SetDataValue: Invalid index type ${a.value}`);s+=a.value.value*o.stride}else{const l=e.evalExpression(a,r);if(!(l instanceof v))return void console.error("SetDataValue: Unknown index type",a);s+=l.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(i instanceof jt))return void console.error("SetDataValue: Unknown postfix type",i);{const a=i.value;if(o instanceof Dt){let l=!1;for(const c of o.members)if(c.name===a){s+=c.offset,o=c.type,l=!0;break}if(!l)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Je){const l=o.getTypeName();let c=0;if(a==="x"||a==="r")c=0;else if(a==="y"||a==="g")c=1;else if(a==="z"||a==="b")c=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);c=3}if(!(t instanceof v))return void console.error("SetDataValue: Invalid value",t);const u=t.value;return l==="vec2f"?void(new Float32Array(this.buffer,s,2)[c]=u):l==="vec3f"?void(new Float32Array(this.buffer,s,3)[c]=u):l==="vec4f"?void(new Float32Array(this.buffer,s,4)[c]=u):l==="vec2i"?void(new Int32Array(this.buffer,s,2)[c]=u):l==="vec3i"?void(new Int32Array(this.buffer,s,3)[c]=u):l==="vec4i"?void(new Int32Array(this.buffer,s,4)[c]=u):l==="vec2u"?void(new Uint32Array(this.buffer,s,2)[c]=u):l==="vec3u"?void(new Uint32Array(this.buffer,s,3)[c]=u):l==="vec4u"?void(new Uint32Array(this.buffer,s,4)[c]=u):void console.error(`SetDataValue: Type ${l} is not a struct`)}}}i=i.postfix}this.setData(e,t,o,s,r)}setData(e,t,i,r,s){const o=i.getTypeName();if(o!=="f32"&&o!=="f16")if(o!=="i32"&&o!=="atomic<i32>"&&o!=="x32")if(o!=="u32"&&o!=="atomic<u32>")if(o!=="bool"){if(o==="vec2f"||o==="vec2h"){const a=new Float32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3f"||o==="vec3h"){const a=new Float32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4f"||o==="vec4h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2i"){const a=new Int32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3i"){const a=new Int32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4i"){const a=new Int32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2u"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3u"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4u"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="vec2b"){const a=new Uint32Array(this.buffer,r,2);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1]))}if(o==="vec3b"){const a=new Uint32Array(this.buffer,r,3);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2]))}if(o==="vec4b"){const a=new Uint32Array(this.buffer,r,4);return void(t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x2f"||o==="mat2x2h"){const a=new Float32Array(this.buffer,r,4);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3]))}if(o==="mat2x3f"||o==="mat2x3h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat2x4f"||o==="mat2x4h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat3x2f"||o==="mat3x2h"){const a=new Float32Array(this.buffer,r,6);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5]))}if(o==="mat3x3f"||o==="mat3x3h"){const a=new Float32Array(this.buffer,r,9);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8]))}if(o==="mat3x4f"||o==="mat3x4h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x2f"||o==="mat4x2h"){const a=new Float32Array(this.buffer,r,8);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7]))}if(o==="mat4x3f"||o==="mat4x3h"){const a=new Float32Array(this.buffer,r,12);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11]))}if(o==="mat4x4f"||o==="mat4x4h"){const a=new Float32Array(this.buffer,r,16);return void(t instanceof K?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]))}if(t instanceof ve){if(i===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof v&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,i){var r,s,o;if(t===null)return this;let a=this.offset,l=this.typeInfo;for(;t;){if(t instanceof _n){const u=t.index,f=u instanceof lt?e.evalExpression(u,i):u;let h=0;if(f instanceof v?h=f.value:typeof f=="number"?h=f:console.error("GetDataValue: Invalid index type",u),l instanceof Mt)a+=h*l.stride,l=l.format;else{const d=l.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,l=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${l.getTypeName()} is not an array`)}}else{if(!(t instanceof jt))return console.error("GetDataValue: Unknown postfix type",t),null;{const u=t.value;if(l instanceof Dt){let f=!1;for(const h of l.members)if(h.name===u){a+=h.offset,l=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(l instanceof Je){const f=l.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f";const d=[];for(let _=0;_<u.length;++_){const I=u[_].toLowerCase();let P=0;if(I==="x"||I==="r")P=0;else if(I==="y"||I==="g")P=1;else if(I==="z"||I==="b")P=2;else{if(I!=="w"&&I!=="a")return console.error(`Unknown member ${u}`),null;P=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*P+4?(console.log("Insufficient buffer data"),null):new v(new Float32Array(this.buffer,a+4*P,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new v(new Float32Array(this.buffer,a+4*P,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new v(new Int32Array(this.buffer,a+4*P,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new v(new Int32Array(this.buffer,a+4*P,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new v(new Uint32Array(this.buffer,a+4*P,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[P]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const A=new Float32Array(this.buffer,a,3);d.push(A[P])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[P]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[P]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[P]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[P]);else if(f==="vec2u"){h="u";const A=new Uint32Array(this.buffer,a,2);d.push(A[P])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[P])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[P]))}return d.length===2?l=e.getTypeInfo(`vec2${h}`):d.length===3?l=e.getTypeInfo(`vec3${h}`):d.length===4?l=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new g(d,l,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}const c=l.getTypeName();return c==="f32"?new v(new Float32Array(this.buffer,a,1),l,this):c==="i32"?new v(new Int32Array(this.buffer,a,1),l,this):c==="u32"?new v(new Uint32Array(this.buffer,a,1),l,this):c==="vec2f"?new g(new Float32Array(this.buffer,a,2),l,this):c==="vec3f"?new g(new Float32Array(this.buffer,a,3),l,this):c==="vec4f"?new g(new Float32Array(this.buffer,a,4),l,this):c==="vec2i"?new g(new Int32Array(this.buffer,a,2),l,this):c==="vec3i"?new g(new Int32Array(this.buffer,a,3),l,this):c==="vec4i"?new g(new Int32Array(this.buffer,a,4),l,this):c==="vec2u"?new g(new Uint32Array(this.buffer,a,2),l,this):c==="vec3u"?new g(new Uint32Array(this.buffer,a,3),l,this):c==="vec4u"?new g(new Uint32Array(this.buffer,a,4),l,this):l instanceof qt&&l.name==="atomic"?((r=l.format)===null||r===void 0?void 0:r.name)==="u32"?new v(new Uint32Array(this.buffer,a,1)[0],l.format,this):((s=l.format)===null||s===void 0?void 0:s.name)==="i32"?new v(new Int32Array(this.buffer,a,1)[0],l.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=l.format)===null||o===void 0?void 0:o.name}`),null):new ve(this.buffer,l,a,this)}toString(){let e="";if(this.typeInfo instanceof Mt)if(this.typeInfo.format.name==="f32"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="i32"){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="u32"){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i<t.length;++i)e+=`, ${t[i]}`}else if(this.typeInfo.format.name==="vec2f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let i=1;i<t.length/2;++i)e+=`, [${t[2*i]}, ${t[2*i+1]}]`}else if(this.typeInfo.format.name==="vec3f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}]`}else if(this.typeInfo.format.name==="vec4f"){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let i=4;i<t.length;i+=4)e+=`, [${t[i]}, ${t[i+1]}, ${t[i+2]}, ${t[i+3]}]`}else e="[...]";else this.typeInfo instanceof Dt?e+="{...}":e="[...]";return e}}class Ct extends et{constructor(e,t,i,r){super(t,null),this.data=e,this.descriptor=i,this.view=r}clone(){return new Ct(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>0?(e=i[0])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.width)!==null&&t!==void 0?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?(e=i[1])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?(e=i[2])!==null&&e!==void 0?e:0:i instanceof Object&&(t=i.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i<t.length;++i)t[i]=Math.max(1,t[i]>>e);return t}get texelByteSize(){const e=this.format,t=uo[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=uo[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=uo[e],i=this.width;if(!e||i<=0||!t)return-1;const r=this.height,s=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*(o==="1d"?1:r/t.blockHeight)*t.bytesPerBlock*s}getPixel(e,t,i=0,r=0){const s=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[r];return e0(new Uint8Array(l),e,t,i,r,a,o,s,this.format)}setPixel(e,t,i,r,s){const o=this.texelByteSize,a=this.bytesPerRow,l=this.height,c=this.data[r];(function(u,f,h,d,_,I,P,A,O,E){const x=d*(P>>=_)*(I>>=_)+h*P+f*A;switch(O){case"r8unorm":return void le(u,x,"8unorm",1,E);case"r8snorm":return void le(u,x,"8snorm",1,E);case"r8uint":return void le(u,x,"8uint",1,E);case"r8sint":return void le(u,x,"8sint",1,E);case"rg8unorm":return void le(u,x,"8unorm",2,E);case"rg8snorm":return void le(u,x,"8snorm",2,E);case"rg8uint":return void le(u,x,"8uint",2,E);case"rg8sint":return void le(u,x,"8sint",2,E);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void le(u,x,"8unorm",4,E);case"rgba8snorm":return void le(u,x,"8snorm",4,E);case"rgba8uint":return void le(u,x,"8uint",4,E);case"rgba8sint":return void le(u,x,"8sint",4,E);case"r16uint":return void le(u,x,"16uint",1,E);case"r16sint":return void le(u,x,"16sint",1,E);case"r16float":return void le(u,x,"16float",1,E);case"rg16uint":return void le(u,x,"16uint",2,E);case"rg16sint":return void le(u,x,"16sint",2,E);case"rg16float":return void le(u,x,"16float",2,E);case"rgba16uint":return void le(u,x,"16uint",4,E);case"rgba16sint":return void le(u,x,"16sint",4,E);case"rgba16float":return void le(u,x,"16float",4,E);case"r32uint":return void le(u,x,"32uint",1,E);case"r32sint":return void le(u,x,"32sint",1,E);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void le(u,x,"32float",1,E);case"rg32uint":return void le(u,x,"32uint",2,E);case"rg32sint":return void le(u,x,"32sint",2,E);case"rg32float":return void le(u,x,"32float",2,E);case"rgba32uint":return void le(u,x,"32uint",4,E);case"rgba32sint":return void le(u,x,"32sint",4,E);case"rgba32float":return void le(u,x,"32float",4,E);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(c),e,t,i,r,l,a,o,this.format,s)}}(n=>{n[n.token=0]="token",n[n.keyword=1]="keyword",n[n.reserved=2]="reserved"})(b||(b={}));class S{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class p{}w=p,p.none=new S("",b.reserved,""),p.eof=new S("EOF",b.token,""),p.reserved={asm:new S("asm",b.reserved,"asm"),bf16:new S("bf16",b.reserved,"bf16"),do:new S("do",b.reserved,"do"),enum:new S("enum",b.reserved,"enum"),f16:new S("f16",b.reserved,"f16"),f64:new S("f64",b.reserved,"f64"),handle:new S("handle",b.reserved,"handle"),i8:new S("i8",b.reserved,"i8"),i16:new S("i16",b.reserved,"i16"),i64:new S("i64",b.reserved,"i64"),mat:new S("mat",b.reserved,"mat"),premerge:new S("premerge",b.reserved,"premerge"),regardless:new S("regardless",b.reserved,"regardless"),typedef:new S("typedef",b.reserved,"typedef"),u8:new S("u8",b.reserved,"u8"),u16:new S("u16",b.reserved,"u16"),u64:new S("u64",b.reserved,"u64"),unless:new S("unless",b.reserved,"unless"),using:new S("using",b.reserved,"using"),vec:new S("vec",b.reserved,"vec"),void:new S("void",b.reserved,"void")},p.keywords={array:new S("array",b.keyword,"array"),atomic:new S("atomic",b.keyword,"atomic"),bool:new S("bool",b.keyword,"bool"),f32:new S("f32",b.keyword,"f32"),i32:new S("i32",b.keyword,"i32"),mat2x2:new S("mat2x2",b.keyword,"mat2x2"),mat2x3:new S("mat2x3",b.keyword,"mat2x3"),mat2x4:new S("mat2x4",b.keyword,"mat2x4"),mat3x2:new S("mat3x2",b.keyword,"mat3x2"),mat3x3:new S("mat3x3",b.keyword,"mat3x3"),mat3x4:new S("mat3x4",b.keyword,"mat3x4"),mat4x2:new S("mat4x2",b.keyword,"mat4x2"),mat4x3:new S("mat4x3",b.keyword,"mat4x3"),mat4x4:new S("mat4x4",b.keyword,"mat4x4"),ptr:new S("ptr",b.keyword,"ptr"),sampler:new S("sampler",b.keyword,"sampler"),sampler_comparison:new S("sampler_comparison",b.keyword,"sampler_comparison"),struct:new S("struct",b.keyword,"struct"),texture_1d:new S("texture_1d",b.keyword,"texture_1d"),texture_2d:new S("texture_2d",b.keyword,"texture_2d"),texture_2d_array:new S("texture_2d_array",b.keyword,"texture_2d_array"),texture_3d:new S("texture_3d",b.keyword,"texture_3d"),texture_cube:new S("texture_cube",b.keyword,"texture_cube"),texture_cube_array:new S("texture_cube_array",b.keyword,"texture_cube_array"),texture_multisampled_2d:new S("texture_multisampled_2d",b.keyword,"texture_multisampled_2d"),texture_storage_1d:new S("texture_storage_1d",b.keyword,"texture_storage_1d"),texture_storage_2d:new S("texture_storage_2d",b.keyword,"texture_storage_2d"),texture_storage_2d_array:new S("texture_storage_2d_array",b.keyword,"texture_storage_2d_array"),texture_storage_3d:new S("texture_storage_3d",b.keyword,"texture_storage_3d"),texture_depth_2d:new S("texture_depth_2d",b.keyword,"texture_depth_2d"),texture_depth_2d_array:new S("texture_depth_2d_array",b.keyword,"texture_depth_2d_array"),texture_depth_cube:new S("texture_depth_cube",b.keyword,"texture_depth_cube"),texture_depth_cube_array:new S("texture_depth_cube_array",b.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new S("texture_depth_multisampled_2d",b.keyword,"texture_depth_multisampled_2d"),texture_external:new S("texture_external",b.keyword,"texture_external"),u32:new S("u32",b.keyword,"u32"),vec2:new S("vec2",b.keyword,"vec2"),vec3:new S("vec3",b.keyword,"vec3"),vec4:new S("vec4",b.keyword,"vec4"),bitcast:new S("bitcast",b.keyword,"bitcast"),block:new S("block",b.keyword,"block"),break:new S("break",b.keyword,"break"),case:new S("case",b.keyword,"case"),continue:new S("continue",b.keyword,"continue"),continuing:new S("continuing",b.keyword,"continuing"),default:new S("default",b.keyword,"default"),diagnostic:new S("diagnostic",b.keyword,"diagnostic"),discard:new S("discard",b.keyword,"discard"),else:new S("else",b.keyword,"else"),enable:new S("enable",b.keyword,"enable"),fallthrough:new S("fallthrough",b.keyword,"fallthrough"),false:new S("false",b.keyword,"false"),fn:new S("fn",b.keyword,"fn"),for:new S("for",b.keyword,"for"),function:new S("function",b.keyword,"function"),if:new S("if",b.keyword,"if"),let:new S("let",b.keyword,"let"),const:new S("const",b.keyword,"const"),loop:new S("loop",b.keyword,"loop"),while:new S("while",b.keyword,"while"),private:new S("private",b.keyword,"private"),read:new S("read",b.keyword,"read"),read_write:new S("read_write",b.keyword,"read_write"),return:new S("return",b.keyword,"return"),requires:new S("requires",b.keyword,"requires"),storage:new S("storage",b.keyword,"storage"),switch:new S("switch",b.keyword,"switch"),true:new S("true",b.keyword,"true"),alias:new S("alias",b.keyword,"alias"),type:new S("type",b.keyword,"type"),uniform:new S("uniform",b.keyword,"uniform"),var:new S("var",b.keyword,"var"),override:new S("override",b.keyword,"override"),workgroup:new S("workgroup",b.keyword,"workgroup"),write:new S("write",b.keyword,"write"),r8unorm:new S("r8unorm",b.keyword,"r8unorm"),r8snorm:new S("r8snorm",b.keyword,"r8snorm"),r8uint:new S("r8uint",b.keyword,"r8uint"),r8sint:new S("r8sint",b.keyword,"r8sint"),r16uint:new S("r16uint",b.keyword,"r16uint"),r16sint:new S("r16sint",b.keyword,"r16sint"),r16float:new S("r16float",b.keyword,"r16float"),rg8unorm:new S("rg8unorm",b.keyword,"rg8unorm"),rg8snorm:new S("rg8snorm",b.keyword,"rg8snorm"),rg8uint:new S("rg8uint",b.keyword,"rg8uint"),rg8sint:new S("rg8sint",b.keyword,"rg8sint"),r32uint:new S("r32uint",b.keyword,"r32uint"),r32sint:new S("r32sint",b.keyword,"r32sint"),r32float:new S("r32float",b.keyword,"r32float"),rg16uint:new S("rg16uint",b.keyword,"rg16uint"),rg16sint:new S("rg16sint",b.keyword,"rg16sint"),rg16float:new S("rg16float",b.keyword,"rg16float"),rgba8unorm:new S("rgba8unorm",b.keyword,"rgba8unorm"),rgba8unorm_srgb:new S("rgba8unorm_srgb",b.keyword,"rgba8unorm_srgb"),rgba8snorm:new S("rgba8snorm",b.keyword,"rgba8snorm"),rgba8uint:new S("rgba8uint",b.keyword,"rgba8uint"),rgba8sint:new S("rgba8sint",b.keyword,"rgba8sint"),bgra8unorm:new S("bgra8unorm",b.keyword,"bgra8unorm"),bgra8unorm_srgb:new S("bgra8unorm_srgb",b.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new S("rgb10a2unorm",b.keyword,"rgb10a2unorm"),rg11b10float:new S("rg11b10float",b.keyword,"rg11b10float"),rg32uint:new S("rg32uint",b.keyword,"rg32uint"),rg32sint:new S("rg32sint",b.keyword,"rg32sint"),rg32float:new S("rg32float",b.keyword,"rg32float"),rgba16uint:new S("rgba16uint",b.keyword,"rgba16uint"),rgba16sint:new S("rgba16sint",b.keyword,"rgba16sint"),rgba16float:new S("rgba16float",b.keyword,"rgba16float"),rgba32uint:new S("rgba32uint",b.keyword,"rgba32uint"),rgba32sint:new S("rgba32sint",b.keyword,"rgba32sint"),rgba32float:new S("rgba32float",b.keyword,"rgba32float"),static_assert:new S("static_assert",b.keyword,"static_assert")},p.tokens={decimal_float_literal:new S("decimal_float_literal",b.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new S("hex_float_literal",b.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new S("int_literal",b.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new S("uint_literal",b.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new S("name",b.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new S("ident",b.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new S("and",b.token,"&"),and_and:new S("and_and",b.token,"&&"),arrow:new S("arrow ",b.token,"->"),attr:new S("attr",b.token,"@"),forward_slash:new S("forward_slash",b.token,"/"),bang:new S("bang",b.token,"!"),bracket_left:new S("bracket_left",b.token,"["),bracket_right:new S("bracket_right",b.token,"]"),brace_left:new S("brace_left",b.token,"{"),brace_right:new S("brace_right",b.token,"}"),colon:new S("colon",b.token,":"),comma:new S("comma",b.token,","),equal:new S("equal",b.token,"="),equal_equal:new S("equal_equal",b.token,"=="),not_equal:new S("not_equal",b.token,"!="),greater_than:new S("greater_than",b.token,">"),greater_than_equal:new S("greater_than_equal",b.token,">="),shift_right:new S("shift_right",b.token,">>"),less_than:new S("less_than",b.token,"<"),less_than_equal:new S("less_than_equal",b.token,"<="),shift_left:new S("shift_left",b.token,"<<"),modulo:new S("modulo",b.token,"%"),minus:new S("minus",b.token,"-"),minus_minus:new S("minus_minus",b.token,"--"),period:new S("period",b.token,"."),plus:new S("plus",b.token,"+"),plus_plus:new S("plus_plus",b.token,"++"),or:new S("or",b.token,"|"),or_or:new S("or_or",b.token,"||"),paren_left:new S("paren_left",b.token,"("),paren_right:new S("paren_right",b.token,")"),semicolon:new S("semicolon",b.token,";"),star:new S("star",b.token,"*"),tilde:new S("tilde",b.token,"~"),underscore:new S("underscore",b.token,"_"),xor:new S("xor",b.token,"^"),plus_equal:new S("plus_equal",b.token,"+="),minus_equal:new S("minus_equal",b.token,"-="),times_equal:new S("times_equal",b.token,"*="),division_equal:new S("division_equal",b.token,"/="),modulo_equal:new S("modulo_equal",b.token,"%="),and_equal:new S("and_equal",b.token,"&="),or_equal:new S("or_equal",b.token,"|="),xor_equal:new S("xor_equal",b.token,"^="),shift_right_equal:new S("shift_right_equal",b.token,">>="),shift_left_equal:new S("shift_left_equal",b.token,"<<=")},p.simpleTokens={"@":w.tokens.attr,"{":w.tokens.brace_left,"}":w.tokens.brace_right,":":w.tokens.colon,",":w.tokens.comma,"(":w.tokens.paren_left,")":w.tokens.paren_right,";":w.tokens.semicolon},p.literalTokens={"&":w.tokens.and,"&&":w.tokens.and_and,"->":w.tokens.arrow,"/":w.tokens.forward_slash,"!":w.tokens.bang,"[":w.tokens.bracket_left,"]":w.tokens.bracket_right,"=":w.tokens.equal,"==":w.tokens.equal_equal,"!=":w.tokens.not_equal,">":w.tokens.greater_than,">=":w.tokens.greater_than_equal,">>":w.tokens.shift_right,"<":w.tokens.less_than,"<=":w.tokens.less_than_equal,"<<":w.tokens.shift_left,"%":w.tokens.modulo,"-":w.tokens.minus,"--":w.tokens.minus_minus,".":w.tokens.period,"+":w.tokens.plus,"++":w.tokens.plus_plus,"|":w.tokens.or,"||":w.tokens.or_or,"*":w.tokens.star,"~":w.tokens.tilde,_:w.tokens.underscore,"^":w.tokens.xor,"+=":w.tokens.plus_equal,"-=":w.tokens.minus_equal,"*=":w.tokens.times_equal,"/=":w.tokens.division_equal,"%=":w.tokens.modulo_equal,"&=":w.tokens.and_equal,"|=":w.tokens.or_equal,"^=":w.tokens.xor_equal,">>=":w.tokens.shift_right_equal,"<<=":w.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:w.tokens.decimal_float_literal,hex_float_literal:w.tokens.hex_float_literal,int_literal:w.tokens.int_literal,uint_literal:w.tokens.uint_literal,ident:w.tokens.ident},p.storage_class=[w.keywords.function,w.keywords.private,w.keywords.workgroup,w.keywords.uniform,w.keywords.storage],p.access_mode=[w.keywords.read,w.keywords.write,w.keywords.read_write],p.sampler_type=[w.keywords.sampler,w.keywords.sampler_comparison],p.sampled_texture_type=[w.keywords.texture_1d,w.keywords.texture_2d,w.keywords.texture_2d_array,w.keywords.texture_3d,w.keywords.texture_cube,w.keywords.texture_cube_array],p.multisampled_texture_type=[w.keywords.texture_multisampled_2d],p.storage_texture_type=[w.keywords.texture_storage_1d,w.keywords.texture_storage_2d,w.keywords.texture_storage_2d_array,w.keywords.texture_storage_3d],p.depth_texture_type=[w.keywords.texture_depth_2d,w.keywords.texture_depth_2d_array,w.keywords.texture_depth_cube,w.keywords.texture_depth_cube_array,w.keywords.texture_depth_multisampled_2d],p.texture_external_type=[w.keywords.texture_external],p.any_texture_type=[...w.sampled_texture_type,...w.multisampled_texture_type,...w.storage_texture_type,...w.depth_texture_type,...w.texture_external_type],p.texel_format=[w.keywords.r8unorm,w.keywords.r8snorm,w.keywords.r8uint,w.keywords.r8sint,w.keywords.r16uint,w.keywords.r16sint,w.keywords.r16float,w.keywords.rg8unorm,w.keywords.rg8snorm,w.keywords.rg8uint,w.keywords.rg8sint,w.keywords.r32uint,w.keywords.r32sint,w.keywords.r32float,w.keywords.rg16uint,w.keywords.rg16sint,w.keywords.rg16float,w.keywords.rgba8unorm,w.keywords.rgba8unorm_srgb,w.keywords.rgba8snorm,w.keywords.rgba8uint,w.keywords.rgba8sint,w.keywords.bgra8unorm,w.keywords.bgra8unorm_srgb,w.keywords.rgb10a2unorm,w.keywords.rg11b10float,w.keywords.rg32uint,w.keywords.rg32sint,w.keywords.rg32float,w.keywords.rgba16uint,w.keywords.rgba16sint,w.keywords.rgba16float,w.keywords.rgba32uint,w.keywords.rgba32sint,w.keywords.rgba32float],p.const_literal=[w.tokens.int_literal,w.tokens.uint_literal,w.tokens.decimal_float_literal,w.tokens.hex_float_literal,w.keywords.true,w.keywords.false],p.literal_or_ident=[w.tokens.ident,w.tokens.int_literal,w.tokens.uint_literal,w.tokens.decimal_float_literal,w.tokens.hex_float_literal,w.tokens.name],p.element_count_expression=[w.tokens.int_literal,w.tokens.uint_literal,w.tokens.ident],p.template_types=[w.keywords.vec2,w.keywords.vec3,w.keywords.vec4,w.keywords.mat2x2,w.keywords.mat2x3,w.keywords.mat2x4,w.keywords.mat3x2,w.keywords.mat3x3,w.keywords.mat3x4,w.keywords.mat4x2,w.keywords.mat4x3,w.keywords.mat4x4,w.keywords.atomic,w.keywords.bitcast,...w.any_texture_type],p.attribute_name=[w.tokens.ident,w.keywords.block,w.keywords.diagnostic],p.assignment_operators=[w.tokens.equal,w.tokens.plus_equal,w.tokens.minus_equal,w.tokens.times_equal,w.tokens.division_equal,w.tokens.modulo_equal,w.tokens.and_equal,w.tokens.or_equal,w.tokens.xor_equal,w.tokens.shift_right_equal,w.tokens.shift_left_equal],p.increment_operators=[w.tokens.plus_plus,w.tokens.minus_minus];class bu{constructor(e,t,i,r,s){this.type=e,this.lexeme=t,this.line=i,this.start=r,this.end=s}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class a0{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new bu(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
|
|
93
93
|
`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
|
|
94
94
|
`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if(this._peekAhead()=="*"){this._advance();let o=1;for(;o>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
|
|
95
95
|
`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}const t=p.simpleTokens[e];if(t)return this._addToken(t),!0;let i=p.none;const r=this._isAlpha(e),s=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(r){const o=p.keywords[e];if(o)return this._addToken(o),!0}if(r||s)return this._addToken(p.tokens.ident),!0;for(;;){let o=this._findType(e);const a=this._peekAhead();if(e=="-"&&this._tokens.length>0){if(a=="=")return this._current++,e+=a,this._addToken(p.tokens.minus_equal),!0;if(a=="-")return this._current++,e+=a,this._addToken(p.tokens.minus_minus),!0;const l=this._tokens.length-1;if((p.literal_or_ident.indexOf(this._tokens[l].type)!=-1||this._tokens[l].type==p.tokens.paren_right)&&a!=">")return this._addToken(o),!0}if(e==">"&&(a==">"||a=="=")){let l=!1,c=this._tokens.length-1;for(let u=0;u<5&&c>=0&&p.assignment_operators.indexOf(this._tokens[c].type)===-1;++u,--c)if(this._tokens[c].type===p.tokens.less_than){c>0&&this._tokens[c-1].isArrayOrTemplateType()&&(l=!0);break}if(l)return this._addToken(o),!0}if(o===p.none){let l=e,c=0;const u=2;for(let f=0;f<u;++f)if(l+=this._peekAhead(f),o=this._findType(l),o!==p.none){c=f;break}if(o===p.none)return i!==p.none&&(this._current--,this._addToken(i),!0);e=l,this._current+=c+1}if(i=o,this._isAtEnd())break;e+=this._advance()}return i!==p.none&&(this._addToken(i),!0)}_findType(e){for(const i in p.regexTokens){const r=p.regexTokens[i];if(this._match(e,r.rule))return r}return p.literalTokens[e]||p.none}_match(e,t){const i=t.exec(e);return i&&i.index==0&&i[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&e!=="_"&&e!=="."&&e!=="("&&e!==")"&&e!=="["&&e!=="]"&&e!=="{"&&e!=="}"&&e!==","&&e!==";"&&e!==":"&&e!=="="&&e!=="!"&&e!=="<"&&e!==">"&&e!=="+"&&e!=="-"&&e!=="*"&&e!=="/"&&e!=="%"&&e!=="&"&&e!=="|"&&e!=="^"&&e!=="~"&&e!=="@"&&e!=="#"&&e!=="?"&&e!=="'"&&e!=="`"&&e!=='"'&&e!=="\\"&&e!==`
|
|
96
|
-
`&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new uu(e,t,this._line,this._start,this._current))}}function z(n){return Array.isArray(n)||(n==null?void 0:n.buffer)instanceof ArrayBuffer}const dr=new Float32Array(1),a0=new Uint32Array(dr.buffer),l0=new Uint32Array(dr.buffer),pr=new Int32Array(1),c0=new Float32Array(pr.buffer),u0=new Uint32Array(pr.buffer),gr=new Uint32Array(1),f0=new Float32Array(gr.buffer),h0=new Int32Array(gr.buffer);function fu(n,e,t){if(e===t)return n;if(e==="f32"){if(t==="i32"||t==="x32")return dr[0]=n,a0[0];if(t==="u32")return dr[0]=n,l0[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return pr[0]=n,c0[0];if(t==="u32")return pr[0]=n,u0[0]}else if(e==="u32"){if(t==="f32")return gr[0]=n,f0[0];if(t==="i32"||t==="x32")return gr[0]=n,h0[0]}return console.error(`Unsupported cast from ${e} to ${t}`),n}class d0{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class mr{constructor(e,t){this.align=e,this.size=t}}class _t{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Kx,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(const t of e)t instanceof jn&&this._functions.set(t.name,new d0(t));for(const t of e)if(t instanceof At){const i=this.getTypeInfo(t,null);i instanceof Dt&&this.structs.push(i)}for(const t of e)if(t instanceof po)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof fo){const i=t,r=this._getAttributeNum(i.attributes,"id",0),s=i.type!=null?this.getTypeInfo(i.type,i.attributes):null;this.overrides.push(new Yx(i.name,s,i.attributes,r));continue}if(this._isUniformVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new ar(i.name,o,r,s,i.attributes,Ft.Uniform,i.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new ar(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Storage,i.access);l.access||(l.access="read"),this.storage.push(l);continue}if(this._isTextureVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new ar(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Texture,i.access);l.access||(l.access="read"),a?this.storage.push(l):this.textures.push(l);continue}if(this._isSamplerVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new ar(i.name,o,r,s,i.attributes,Ft.Sampler,i.access);this.samplers.push(a);continue}}for(const t of e)if(t instanceof jn){const i=this._getAttribute(t,"vertex"),r=this._getAttribute(t,"fragment"),s=this._getAttribute(t,"compute"),o=i||r||s,a=new jx(t.name,o==null?void 0:o.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(l=>new qx(l.name,this.getTypeInfo(l.type,l.attributes),l.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(i=>{var r,s,o;if(i instanceof cu){if(i.value)if(z(i.value))for(const a of i.value)for(const l of this.overrides)a===l.name&&((r=t.info)===null||r===void 0||r.overrides.push(l));else for(const a of this.overrides)i.value===a.name&&((s=t.info)===null||s===void 0||s.overrides.push(a))}else if(i instanceof Ze)for(const a of this.overrides)i.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const r of e.calls){const s=(i=this._functions.get(r.name))===null||i===void 0?void 0:i.info;s&&t.add(s)}}findResource(e,t,i){if(i){for(const r of this.entry.compute)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.vertex)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.fragment)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}}for(const r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(const r of this.storage)if(r.group==e&&r.binding==t)return r;for(const r of this.textures)if(r.group==e&&r.binding==t)return r;for(const r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],r=this,s=[];return e.search(o=>{if(o instanceof lr)s.push({});else if(o instanceof cr)s.pop();else if(o instanceof wt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof mt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Kn){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof Ze){const a=o;if(s.length>0&&s[s.length-1][a.name])return;const l=r._findResource(a.name);l&&i.push(l)}else if(o instanceof go){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}else if(o instanceof ho){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}}),[...new Map(i.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function t(i,r){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),r>=e[i].length&&(e[i].length=r+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof At)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);i!==null&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof At)this._getStructOutputs(i.type,t);else{const r=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(r!==null){const s=this.getTypeInfo(i.type,i.type.attributes),o=this._parseInt(r.value),a=new Uc(i.name,s,r.name,o);t.push(a)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new Uc("",i,t.name,r)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(const i of e)if(i.type instanceof At)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof At)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),s=this._parseInt(t.value),o=new Xx(e.name,r,t.name,s);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new $x(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof fr){const r=e.type?this.getTypeInfo(e.type,e.attributes):null,s=new ao(e.name,r,t);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Qn){const r=e,s=r.format?this.getTypeInfo(r.format,r.attributes):null,o=new Mt(r.name,t);return o.format=s,o.count=r.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof At){const r=e,s=new Dt(r.name,t);s.startLine=r.startLine,s.endLine=r.endLine;for(const o of r.members){const a=this.getTypeInfo(o.type,o.attributes);s.members.push(new Bc(o.name,a,o.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Jn){const r=e,s=r.format instanceof k,o=r.format?s?this.getTypeInfo(r.format,null):new Je(r.format,null):null,a=new qt(r.name,o,t,r.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof T){const r=e,s=r.format?this.getTypeInfo(r.format,null):null,o=new qt(r.name,s,t,r.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const i=new Je(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,r;const s=this._getTypeSize(e);if(e.size=(t=s==null?void 0:s.size)!==null&&t!==void 0?t:0,e instanceof Mt&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,(r=o==null?void 0:o.align)!==null&&r!==void 0?r:0),this._updateTypeInfo(e.format)}e instanceof ao&&this._updateTypeInfo(e.format),e instanceof Dt&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,r=0,s=0,o=0;for(let a=0,l=e.members.length;a<l;++a){const c=e.members[a],u=this._getTypeSize(c);if(!u)continue;(t=this._getAlias(c.type.name))!==null&&t!==void 0||c.type;const f=u.align,h=u.size;i=this._roundUp(f,i+r),r=h,s=i,o=Math.max(o,f),c.offset=i,c.size=h,this._updateTypeInfo(c.type)}e.size=this._roundUp(o,s+r),e.align=o}_getTypeSize(e){var t,i;if(e==null)return null;const r=this._getAttributeNum(e.attributes,"size",0),s=this._getAttributeNum(e.attributes,"align",0);if(e instanceof Bc&&(e=e.type),e instanceof Je){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=_t._typeInfo[e.name];if(o!==void 0){const a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new mr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}{const o=_t._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new mr(Math.max(s,o.align/a),Math.max(r,o.size/a))}}if(e instanceof Mt){let o=e,a=8,l=8;const c=this._getTypeSize(o.format);return c!==null&&(l=c.size,a=c.align),l=o.count*this._getAttributeNum((i=e==null?void 0:e.attributes)!==null&&i!==void 0?i:null,"stride",this._roundUp(a,l)),r&&(l=r),new mr(Math.max(s,a),Math.max(r,l))}if(e instanceof Dt){let o=0,a=0,l=0,c=0,u=0;for(const f of e.members){const h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),l=this._roundUp(h.align,l+c),c=h.size,u=l)}return a=this._roundUp(o,u+c),new mr(Math.max(s,o),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof wt&&e.storage=="uniform"}_isStorageVar(e){return e instanceof wt&&e.storage=="storage"}_isTextureVar(e){return e instanceof wt&&e.type!==null&&_t._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof wt&&e.type!==null&&_t._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){const i=e;if(!i||!i.attributes)return null;const r=i.attributes;for(let s of r)if(s.name==t)return s;return null}_getAttributeNum(e,t,i){if(e===null)return i;for(let r of e)if(r.name==t){let s=r!==null&&r.value!==null?r.value:i;return s instanceof Array&&(s=s[0]),typeof s=="number"?s:typeof s=="string"?parseInt(s):i}return i}_roundUp(e,t){return Math.ceil(t/e)*e}}_t._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},_t._textureTypes=p.any_texture_type.map(n=>n.name),_t._samplerTypes=p.sampler_type.map(n=>n.name);let _o=0;class yo{constructor(e,t,i){this.id=_o++,this.name=e,this.value=t,this.node=i}clone(){return new yo(this.name,this.value,this.node)}}class xo{constructor(e){this.id=_o++,this.name=e.name,this.node=e}clone(){return new xo(this.node)}}class vo{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=_o++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new yo(e,t,i??null))}setVariable(e,t,i){const r=this.getVariable(e);r!==null?r.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return(t=i==null?void 0:i.value)!==null&&t!==void 0?t:null}clone(){return new vo(this)}}class p0{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class g0{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let r=!0;if(i instanceof m)return i.data.forEach(s=>{s||(r=!1)}),new v(r?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m){const r=i.data.some(s=>s);return new v(r?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof v))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.evalExpression(i,t);if(r instanceof ve&&r.typeInfo.size===0){const s=r.typeInfo,o=r.buffer.byteLength/s.stride;return new v(o,this.getTypeInfo("u32"))}return new v(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.abs(s)),i.typeInfo);const r=i;return new v(Math.abs(r.value),r.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.acos(s)),i.typeInfo);const r=i;return new v(Math.acos(r.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.acosh(s)),i.typeInfo);const r=i;return new v(Math.acosh(r.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.asin(s)),i.typeInfo);const r=i;return new v(Math.asin(r.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.asinh(s)),i.typeInfo);const r=i;return new v(Math.asinh(r.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.atan(s)),i.typeInfo);const r=i;return new v(Math.atan(r.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.atanh(s)),i.typeInfo);const r=i;return new v(Math.atanh(r.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m)return new m(i.data.map((a,l)=>Math.atan2(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.atan2(s.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.ceil(s)),i.typeInfo);const r=i;return new v(Math.ceil(r.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof m&&r instanceof m&&s instanceof m)return new m(i.data.map((c,u)=>this._clamp(c,r.data[u],s.data[u])),i.typeInfo);const o=i,a=r,l=s;return new v(this._clamp(o.value,a.value,l.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.cos(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.cosh(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.clz32(s)),i.typeInfo);const r=i;return new v(Math.clz32(r.value),i.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>this._countOneBits(s)),i.typeInfo);const r=i;return new v(this._countOneBits(r.value),i.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>this._countTrailingZeros(s)),i.typeInfo);const r=i;return new v(this._countTrailingZeros(r.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m){if(i.data.length!==3||r.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const s=i.data,o=r.data;return new m([s[1]*o[2]-o[1]*s[2],s[2]*o[0]-o[2]*s[0],s[0]*o[1]-o[0]*s[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return i instanceof m?new m(i.data.map(s=>s*r),i.typeInfo):new v(i.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof K){const r=i.data,s=i.typeInfo.getTypeName(),o=s.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h")return new v(r[0]*r[3]-r[1]*r[2],o);if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);if(s==="mat2x4"||s==="mat2x4f"||s==="mat2x4h")console.error(`TODO: Determinant for ${s}`);else if(s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h")console.error(`TODO: Determinant for ${s}`);else{if(s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);s==="mat3x4"||s==="mat3x4f"||s==="mat3x4h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h"?console.error(`TODO: Determinant for ${s}`):s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h"||console.error(`TODO: Determinant for ${s}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m){let a=0;for(let l=0;l<i.data.length;++l)a+=(i.data[l]-r.data[l])*(i.data[l]-r.data[l]);return new v(Math.sqrt(a),this.getTypeInfo("f32"))}const s=i,o=r;return new v(Math.abs(s.value-o.value),i.typeInfo)}_dot(e,t){let i=0;for(let r=0;r<e.length;++r)i+=t[r]*e[r];return i}Dot(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return i instanceof m&&r instanceof m?new v(this._dot(i.data,r.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.exp(s)),i.typeInfo);const r=i;return new v(Math.exp(r.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.pow(2,s)),i.typeInfo);const r=i;return new v(Math.pow(2,r.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=r.value,a=s.value;if(i instanceof m)return new m(i.data.map(c=>c>>o&(1<<a)-1),i.typeInfo);if(i.typeInfo.name!=="i32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;const l=i.value;return new v(l>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof m&&r instanceof m&&s instanceof m){const o=this._dot(r.data,s.data);return new m(o<0?Array.from(i.data):i.data.map(a=>-a),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>this._firstLeadingBit(s)),i.typeInfo);const r=i;return new v(this._firstLeadingBit(r.value),i.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>this._firstTrailingBit(s)),i.typeInfo);const r=i;return new v(this._firstTrailingBit(r.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.floor(s)),i.typeInfo);const r=i;return new v(Math.floor(r.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof m&&r instanceof m&&s instanceof m)return i.data.length!==r.data.length||i.data.length!==s.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new m(i.data.map((c,u)=>c*r.data[u]+s.data[u]),i.typeInfo);const o=i,a=r,l=s;return new v(o.value*a.value+l.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>s-Math.floor(s)),i.typeInfo);const r=i;return new v(r.value-Math.floor(r.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const a=s.value,l=(1<<o.value)-1<<a,c=~l;if(i instanceof m&&r instanceof m)return new m(i.data.map((h,d)=>h&c|r.data[d]<<a&l),i.typeInfo);const u=i.value,f=r.value;return new v(u&c|f<<a&l,i.typeInfo)}InverseSqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>1/Math.sqrt(s)),i.typeInfo);const r=i;return new v(1/Math.sqrt(r.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m){let s=0;return i.data.forEach(o=>{s+=o*o}),new v(Math.sqrt(s),this.getTypeInfo("f32"))}const r=i;return new v(Math.abs(r.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.log(s)),i.typeInfo);const r=i;return new v(Math.log(r.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.log2(s)),i.typeInfo);const r=i;return new v(Math.log2(r.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m)return new m(i.data.map((a,l)=>Math.max(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.max(s.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m)return new m(i.data.map((a,l)=>Math.min(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.min(s.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof m&&r instanceof m&&s instanceof m)return new m(i.data.map((l,c)=>i.data[c]*(1-s.data[c])+r.data[c]*s.data[c]),i.typeInfo);const o=r,a=s;return new v(i.value*(1-a.value)+o.value*a.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m)return new m(i.data.map((o,a)=>o%r.data[a]),i.typeInfo);const s=r;return new v(i.value%s.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m){const r=this.Length(e,t).value;return new m(i.data.map(s=>s/r),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m)return new m(i.data.map((a,l)=>Math.pow(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.pow(s.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof m?new m(i.data.map(r=>r),i.typeInfo):new v(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof m?new m(i.data.map(r=>r*Math.PI/180),i.typeInfo):new v(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof m&&r instanceof m){const s=this._dot(i.data,r.data);return new m(i.data.map((o,a)=>o-2*s*r.data[a]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof m&&r instanceof m&&s instanceof v){const o=this._dot(r.data,i.data);return new m(i.data.map((a,l)=>{const c=1-s.value*s.value*(1-o*o);if(c<0)return 0;const u=Math.sqrt(c);return s.value*a-(s.value*o+u)*r.data[l]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.round(s)),i.typeInfo);const r=i;return new v(Math.round(r.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.min(Math.max(s,0),1)),i.typeInfo);const r=i;return new v(Math.min(Math.max(r.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.sign(s)),i.typeInfo);const r=i;return new v(Math.sign(r.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.sin(s)),i.typeInfo);const r=i;return new v(Math.sin(r.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.sinh(s)),i.typeInfo);const r=i;return new v(Math.sinh(r.value),i.typeInfo)}_smoothstep(e,t,i){const r=Math.min(Math.max((i-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(s instanceof m&&i instanceof m&&r instanceof m)return new m(s.data.map((c,u)=>this._smoothstep(i.data[u],r.data[u],c)),s.typeInfo);const o=i,a=r,l=s;return new v(this._smoothstep(o.value,a.value,l.value),s.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.sqrt(s)),i.typeInfo);const r=i;return new v(Math.sqrt(r.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof m&&i instanceof m)return new m(r.data.map((o,a)=>o<i.data[a]?0:1),r.typeInfo);const s=i;return new v(r.value<s.value?0:1,s.typeInfo)}Tan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.tan(s)),i.typeInfo);const r=i;return new v(Math.tan(r.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.tanh(s)),i.typeInfo);const r=i;return new v(Math.tanh(r.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof K))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const r=this._getTransposeType(i.typeInfo);if(i.typeInfo.name==="mat2x2"||i.typeInfo.name==="mat2x2f"||i.typeInfo.name==="mat2x2h"){const s=i.data;return new K([s[0],s[2],s[1],s[3]],r)}if(i.typeInfo.name==="mat2x3"||i.typeInfo.name==="mat2x3f"||i.typeInfo.name==="mat2x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7]],r)}if(i.typeInfo.name==="mat2x4"||i.typeInfo.name==="mat2x4f"||i.typeInfo.name==="mat2x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13]],r)}if(i.typeInfo.name==="mat3x2"||i.typeInfo.name==="mat3x2f"||i.typeInfo.name==="mat3x2h"){const s=i.data;return new K([s[0],s[3],s[1],s[4],s[2],s[5]],r)}if(i.typeInfo.name==="mat3x3"||i.typeInfo.name==="mat3x3f"||i.typeInfo.name==="mat3x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7],s[2],s[5],s[8]],r)}if(i.typeInfo.name==="mat3x4"||i.typeInfo.name==="mat3x4f"||i.typeInfo.name==="mat3x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14]],r)}if(i.typeInfo.name==="mat4x2"||i.typeInfo.name==="mat4x2f"||i.typeInfo.name==="mat4x2h"){const s=i.data;return new K([s[0],s[4],s[1],s[5],s[2],s[6]],r)}if(i.typeInfo.name==="mat4x3"||i.typeInfo.name==="mat4x3f"||i.typeInfo.name==="mat4x3h"){const s=i.data;return new K([s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]],r)}if(i.typeInfo.name==="mat4x4"||i.typeInfo.name==="mat4x4f"||i.typeInfo.name==="mat4x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]],r)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof m)return new m(i.data.map(s=>Math.trunc(s)),i.typeInfo);const r=i;return new v(Math.trunc(r.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof Ze){const s=i.name,o=t.getVariableValue(s);if(o instanceof Ct){if(r<0||r>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const a=o.getMipLevelSize(r),l=o.dimension;return l==="1d"?new v(a[0],this.getTypeInfo("u32")):l==="3d"?new m(a,this.getTypeInfo("vec3u")):l==="2d"?new m(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${l} not found. Line ${e.line}`),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof m)||r.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof Ze){const o=i.name,a=t.getVariableValue(o);if(a instanceof Ct){const l=Math.floor(r.data[0]),c=Math.floor(r.data[1]);if(l<0||l>=a.width||c<0||c>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const u=a.getPixel(l,c,0,s);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new m(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof m)||r.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof Ze){const a=i.name,l=t.getVariableValue(a);if(l instanceof Ct){const c=l.getMipLevelSize(0),u=Math.floor(r.data[0]),f=Math.floor(r.data[1]);return u<0||u>=c[0]||f<0||f>=c[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(l.setPixel(u,f,0,s,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t);return t.getVariable(r).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value+=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicSub(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value-=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMax(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.max(l.value,a.value)),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMin(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.min(l.value,a.value)),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicAnd(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value&a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicOr(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value|a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicXor(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value^a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicExchange(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const bo={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},Ve={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class Fe extends p0{constructor(e,t){var i;super(),this.ast=e??[],this.reflection=new _t,this.reflection.updateAST(this.ast),this.context=(i=t==null?void 0:t.clone())!==null&&i!==void 0?i:new vo,this.builtins=new g0(this),this.typeInfo={bool:this.getTypeInfo(k.bool),i32:this.getTypeInfo(k.i32),u32:this.getTypeInfo(k.u32),f32:this.getTypeInfo(k.f32),f16:this.getTypeInfo(k.f16),vec2f:this.getTypeInfo(T.vec2f),vec2u:this.getTypeInfo(T.vec2u),vec2i:this.getTypeInfo(T.vec2i),vec2h:this.getTypeInfo(T.vec2h),vec3f:this.getTypeInfo(T.vec3f),vec3u:this.getTypeInfo(T.vec3u),vec3i:this.getTypeInfo(T.vec3i),vec3h:this.getTypeInfo(T.vec3h),vec4f:this.getTypeInfo(T.vec4f),vec4u:this.getTypeInfo(T.vec4u),vec4i:this.getTypeInfo(T.vec4i),vec4h:this.getTypeInfo(T.vec4h),mat2x2f:this.getTypeInfo(T.mat2x2f),mat2x3f:this.getTypeInfo(T.mat2x3f),mat2x4f:this.getTypeInfo(T.mat2x4f),mat3x2f:this.getTypeInfo(T.mat3x2f),mat3x3f:this.getTypeInfo(T.mat3x3f),mat3x4f:this.getTypeInfo(T.mat3x4f),mat4x2f:this.getTypeInfo(T.mat4x2f),mat4x3f:this.getTypeInfo(T.mat4x3f),mat4x4f:this.getTypeInfo(T.mat4x4f)}}getVariableValue(e){var t,i;const r=(i=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&i!==void 0?i:null;if(r===null)return null;if(r instanceof v)return r.value;if(r instanceof m||r instanceof K)return Array.from(r.data);if(r instanceof ve&&r.typeInfo instanceof Mt){if(r.typeInfo.format.name==="u32")return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="i32")return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="f32")return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,r){const s=this.context.clone();(r=r??{}).constants&&this._setOverrides(r.constants,s),this._execStatements(this.ast,s);const o=s.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const a=t[0],l=t[1],c=t[2],u=this.getTypeInfo("vec3u");s.setVariable("@num_workgroups",new m(t,u));const f=this.reflection.getFunctionInfo(e);f===null&&console.error(`Function ${e} not found in reflection data`);for(const h in i)for(const d in i[h]){const _=i[h][d];s.variables.forEach(I=>{var P;const A=I.node;if(A!=null&&A.attributes){let O=null,E=null;for(const y of A.attributes)y.name==="binding"?O=y.value:y.name==="group"&&(E=y.value);if(d==O&&h==E){let y=!1;for(const R of f.resources)if(R.name===I.name&&R.group===parseInt(h)&&R.binding===parseInt(d)){y=!0;break}if(y)if(_.texture!==void 0&&_.descriptor!==void 0){const R=new Ct(_.texture,this.getTypeInfo(A.type),_.descriptor,(P=_.texture.view)!==null&&P!==void 0?P:null);I.value=R}else _.uniform!==void 0?I.value=new ve(_.uniform,this.getTypeInfo(A.type)):I.value=new ve(_,this.getTypeInfo(A.type))}}})}for(let h=0;h<c;++h)for(let d=0;d<l;++d)for(let _=0;_<a;++_)s.setVariable("@workgroup_id",new m([_,d,h],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[_,d,h],s)}execStatement(e,t){if(e instanceof Zc)return this.evalExpression(e.value,t);if(e instanceof Jc){if(e.condition){const i=this.evalExpression(e.condition,t);if(!(i instanceof v))throw new Error("Invalid break-if condition");if(!i.value)return null}return Fe._breakObj}if(e instanceof Gc)return Fe._continueObj;if(e instanceof Kn)this._let(e,t);else if(e instanceof wt)this._var(e,t);else if(e instanceof ur)this._const(e,t);else if(e instanceof jn)this._function(e,t);else{if(e instanceof Kc)return this._if(e,t);if(e instanceof jc)return this._switch(e,t);if(e instanceof $c)return this._for(e,t);if(e instanceof Wc)return this._while(e,t);if(e instanceof qc)return this._loop(e,t);if(e instanceof uo){const i=t.clone();return i.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,i)}if(e instanceof Yc)this._assign(e,t);else if(e instanceof Xc)this._increment(e,t);else{if(e instanceof At)return null;if(e instanceof fo){const i=e.name;t.getVariable(i)===null&&t.setVariable(i,new v(0,this.getTypeInfo("u32")))}else if(e instanceof ho)this._call(e,t);else{if(e instanceof Qc||e instanceof po)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof ct?this._evalBinaryOp(e,t):e instanceof Ae?this._evalLiteral(e,t):e instanceof Ze?this._evalVariable(e,t):e instanceof go?this._evalCall(e,t):e instanceof mt?this._evalCreate(e,t):e instanceof tu?this._evalConst(e,t):e instanceof nu?this._evalBitcast(e,t):e instanceof Se?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof k){const r=this.reflection.getTypeInfo(e);if(r!==null)return r}let i=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return i!==null||(i=this.reflection.getTypeInfoByName(e)),i}_setOverrides(e,t){for(const i in e){const r=e[i],s=this.reflection.getOverrideInfo(i);s!==null?(s.type===null&&(s.type=this.getTypeInfo("u32")),s.type.name==="u32"||s.type.name==="i32"||s.type.name==="f32"||s.type.name==="f16"?t.setVariable(i,new v(r,s.type)):s.type.name==="bool"?t.setVariable(i,new v(r?1:0,s.type)):s.type.name==="vec2"||s.type.name==="vec3"||s.type.name==="vec4"||s.type.name==="vec2f"||s.type.name==="vec3f"||s.type.name==="vec4f"||s.type.name==="vec2i"||s.type.name==="vec3i"||s.type.name==="vec4i"||s.type.name==="vec2u"||s.type.name==="vec3u"||s.type.name==="vec4u"||s.type.name==="vec2h"||s.type.name==="vec3h"||s.type.name==="vec4h"?t.setVariable(i,new m(r,s.type)):console.error(`Invalid constant type for ${i}`)):console.error(`Override ${i} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,i){const r=[1,1,1];for(const u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){const f=i.getVariableValue(u.value[0]);r[0]=f instanceof v?f.value:parseInt(u.value[0])}if(u.value.length>1){const f=i.getVariableValue(u.value[1]);r[1]=f instanceof v?f.value:parseInt(u.value[1])}if(u.value.length>2){const f=i.getVariableValue(u.value[2]);r[2]=f instanceof v?f.value:parseInt(u.value[2])}}const s=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new m(r,s));const a=r[0],l=r[1],c=r[2];for(let u=0,f=0;u<c;++u)for(let h=0;h<l;++h)for(let d=0;d<a;++d,++f){const _=[d,h,u],I=[d+t[0]*r[0],h+t[1]*r[1],u+t[2]*r[2]];i.setVariable("@local_invocation_id",new m(_,s)),i.setVariable("@global_invocation_id",new m(I,s)),i.setVariable("@local_invocation_index",new v(f,o)),this._dispatchExec(e,i)}}_dispatchExec(e,t){for(const i of e.node.args)for(const r of i.attributes)if(r.name==="builtin"){const s=`@${r.value}`,o=t.getVariable(s);o!==void 0&&t.variables.set(i.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof Se;)e=e.right;return e instanceof Ze?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(const i of e){if(i instanceof Array){const s=t.clone(),o=this._execStatements(i,s);if(o)return o;continue}const r=this.execStatement(i,t);if(r)return r}return null}_call(e,t){const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(r){for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.setVariable(o.name,a,o)}this._execStatements(r.node.body,i)}else e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const i=this.getVariableName(e.variable,t),r=t.getVariable(i);r?e.operator==="++"?r.value instanceof v?r.value.value++:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):e.operator==="--"?r.value instanceof v?r.value.value--:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${i} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof Ze){const i=this.getVariableName(e,t),r=t.getVariable(i);return r===null?(console.error(`Variable ${i} not found. Line ${e.line}`),null):r.value.getSubData(this,e.postfix,t)}if(e instanceof Se){if(e.operator==="*"){const i=this._getVariableData(e.right,t);return i instanceof yn?i.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const i=this._getVariableData(e.right,t);return new yn(i)}}return null}_assign(e,t){let i=null,r="<var>",s=null;if(e.variable instanceof Se){const l=this._getVariableData(e.variable,t),c=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(l instanceof v||l instanceof m||l instanceof K){if(c instanceof v||c instanceof m||c instanceof K&&l.data.length===c.data.length)return void l.data.set(c.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(l instanceof ve&&c instanceof ve&&l.buffer.byteLength-l.offset>=c.buffer.byteLength-c.offset)return void(l.buffer.byteLength%4==0?new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4).set(new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4)):new Uint8Array(l.buffer,l.offset,l.typeInfo.size).set(new Uint8Array(c.buffer,c.offset,c.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return l instanceof v||l instanceof m||l instanceof K?c instanceof v||c instanceof m||c instanceof K?void l.data.set(c.data.map((f,h)=>l.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(l instanceof v||l instanceof m||l instanceof K)&&(c instanceof v||c instanceof m||c instanceof K)?void l.data.set(c.data.map((f,h)=>l.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Se){if(e.variable.operator==="*"){r=this.getVariableName(e.variable.right,t);const l=t.getVariable(r);if(!(l&&l.value instanceof yn))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);i=l.value.reference;let c=e.variable.postfix;if(!c){let u=e.variable.right;for(;u instanceof Se;){if(u.postfix){c=u.postfix;break}u=u.right}}c&&(i=i.getSubData(this,c,t))}}else{s=e.variable.postfix,r=this.getVariableName(e.variable,t);const l=t.getVariable(r);if(l===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);i=l.value}if(i instanceof yn&&(i=i.reference),i===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),a=e.operator;if(a!=="="){const l=i.getSubData(this,s,t);if(l instanceof m&&o instanceof v){const c=l.data,u=o.value;if(a==="+=")for(let f=0;f<c.length;++f)c[f]+=u;else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u;else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u;else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u;else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u;else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u;else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u;else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u;else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u;else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(l instanceof m&&o instanceof m){const c=l.data,u=o.data;if(c.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let f=0;f<c.length;++f)c[f]+=u[f];else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u[f];else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u[f];else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u[f];else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u[f];else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u[f];else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u[f];else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u[f];else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u[f];else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(l instanceof v&&o instanceof v))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?l.value+=o.value:a==="-="?l.value-=o.value:a==="*="?l.value*=o.value:a==="/="?l.value/=o.value:a==="%="?l.value%=o.value:a==="&="?l.value&=o.value:a==="|="?l.value|=o.value:a==="^="?l.value^=o.value:a==="<<="?l.value<<=o.value:a===">>="?l.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}return void(i instanceof ve&&i.setDataValue(this,l,s,t))}if(i instanceof ve)i.setDataValue(this,o,s,t);else if(s){if(!(i instanceof m||i instanceof K))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(s instanceof _n){const l=this.evalExpression(s.index,t).value;if(i instanceof m){if(!(o instanceof v))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[l]=o.value}else{if(!(i instanceof K))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const c=this.evalExpression(s.index,t).value;if(c<0)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(o instanceof m))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const u=i.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(c<2&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(c<2&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(c<2&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(c<3&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(c<3&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(c<3&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(c<4&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(c<4&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(c<4&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}}}}}else if(s instanceof jt){const l=s.value;if(!(i instanceof m))return void console.error(`Invalid assignment to ${l}. Variable ${r} is not a vector. Line ${e.line}`);if(o instanceof v){if(l.length>1)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);if(l==="x")i.data[0]=o.value;else if(l==="y"){if(i.data.length<2)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[1]=o.value}else if(l==="z"){if(i.data.length<3)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[2]=o.value}else if(l==="w"){if(i.data.length<4)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof m))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(l.length!==o.data.length)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);for(let c=0;c<l.length;++c){const u=l[c];if(u==="x"||u==="r")i.data[0]=o.data[c];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[1]=o.data[c]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[2]=o.data[c]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[3]=o.data[c]}}}}}else i instanceof v&&o instanceof v?i.value=o.value:i instanceof m&&o instanceof m||i instanceof K&&o instanceof K?i.data.set(o.data):console.error(`Invalid assignment to ${r}. Line ${e.line}`)}_function(e,t){const i=new xo(e);t.functions.set(e.name,i)}_const(e,t){let i=null;e.value!==null&&(i=this.evalExpression(e.value,t)),t.createVariable(e.name,i,e)}_let(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Se||(i=i.clone())}else{const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||r==="array"){const s=new mt(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_var(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Se||(i=i.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||e.type instanceof Qn||e.type instanceof At||e.type instanceof T){const s=new mt(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_switch(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;let r=null;for(const s of e.cases)if(s instanceof su)for(const o of s.selectors){if(o instanceof hr){r=s;continue}const a=this.evalExpression(o,t);if(!(a instanceof v))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===i.value)return this._execStatements(s.body,t)}else s instanceof ou&&(r=s);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(e.body,t);for(const r of e.elseif){const s=this.evalExpression(r.condition,t);if(!(s instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(s.value)return this._execStatements(r.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof v?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i!==null&&i!==Fe._continueObj)return i;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i===Fe._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===Fe._breakObj)break}else if(i!==null)return i}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Fe._breakObj)break;if(i!==Fe._continueObj&&i!==null)return i}return null}_evalBitcast(e,t){const i=this.evalExpression(e.value,t),r=e.type;if(i instanceof v){const s=fu(i.value,i.typeInfo.name,r.name);return new v(s,this.getTypeInfo(r))}if(i instanceof m){const s=i.typeInfo.getTypeName();let o="";if(s.endsWith("f"))o="f32";else if(s.endsWith("i"))o="i32";else if(s.endsWith("u"))o="u32";else if(s.endsWith("b"))o="bool";else{if(!s.endsWith("h"))return console.error(`Unknown vector type ${s}. Line ${e.line}`),null;o="f16"}const a=r.getTypeName();let l="";if(a.endsWith("f"))l="f32";else if(a.endsWith("i"))l="i32";else if(a.endsWith("u"))l="u32";else if(a.endsWith("b"))l="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${l}. Line ${e.line}`),null;l="f16"}const c=function(u,f,h){if(f===h)return u;const d=new Array(u.length);for(let _=0;_<u.length;_++)d[_]=fu(u[_],f,h);return d}(Array.from(i.data),o,l);return new m(c,this.getTypeInfo(r))}return console.error(`TODO: bitcast for ${i.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var i;if(e instanceof mt){if(e.type===null)return mo.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}const r=e instanceof mt?e.type.name:e.name,s=e instanceof mt?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(s===null)return console.error(`Unknown type ${r}. Line ${e.line}`),null;if(s.size===0)return null;const o=new ve(new ArrayBuffer(s.size),s,0);if(s instanceof Dt){if(e.args)for(let a=0;a<e.args.length;++a){const l=s.members[a],c=e.args[a],u=this.evalExpression(c,t);o.setData(this,u,l.type,l.offset,t)}}else if(s instanceof Mt){let a=0;if(e.args)for(let l=0;l<e.args.length;++l){const c=e.args[l],u=this.evalExpression(c,t);s.format===null&&(((i=u.typeInfo)===null||i===void 0?void 0:i.name)==="x32"?s.format=this.getTypeInfo("i32"):s.format=u.typeInfo),o.setData(this,u,s.format,a,t),a+=s.stride}}else console.error(`Unknown type "${r}". Line ${e.line}`);return e instanceof mt?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){const i=this.getTypeInfo(e.type),r=i.name;return r==="x32"||r==="u32"||r==="f32"||r==="f16"||r==="i32"||r==="bool"?new v(e.scalarValue,i):r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"?this._callConstructorVec(e,t):r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const i=t.getVariableValue(e.name);return i===null?i:i.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=Fe._priority.get(t.name);Fe._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const i=this.evalExpression(e.right,t);if(e.operator==="&")return new yn(i);if(e.operator==="*")return i instanceof yn?i.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);const r=i instanceof v?i.value:i instanceof m?Array.from(i.data):null;switch(e.operator){case"+":{if(z(r)){const a=r.map((l,c)=>+l);return new m(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(+s,o)}case"-":{if(z(r)){const a=r.map((l,c)=>-l);return new m(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(-s,o)}case"!":{if(z(r)){const a=r.map((l,c)=>l?0:1);return new m(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(s?0:1,o)}case"~":{if(z(r)){const a=r.map((l,c)=>~l);return new m(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(~s,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),s=i instanceof v?i.value:i instanceof m||i instanceof K?Array.from(i.data):null,o=r instanceof v?r.value:r instanceof m||r instanceof K?Array.from(r.data):null;switch(e.operator){case"+":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d+f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h+u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u+h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a+l,c)}case"-":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d-f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h-u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u-h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a-l,c)}case"*":{if(z(s)&&z(o)){const u=s,f=o;if(i instanceof K&&r instanceof K){const h=function(P,A,O,E){if(Ve[A.name]===void 0||Ve[E.name]===void 0)return null;const y=Ve[A.name][0],R=Ve[A.name][1],N=Ve[E.name][0];if(y!==Ve[E.name][1])return null;const U=new Array(N*R);for(let W=0;W<R;W++)for(let q=0;q<N;q++){let G=0;for(let B=0;B<y;B++)G+=P[B*R+W]*O[q*y+B];U[W*N+q]=G}return U}(u,i.typeInfo,f,r.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const d=Ve[r.typeInfo.name][0],_=Ve[i.typeInfo.name][1],I=this.getTypeInfo(`mat${d}x${_}f`);return new K(h,I)}if(i instanceof K&&r instanceof m){const h=function(d,_,I,P){if(Ve[_.name]===void 0||bo[P.name]===void 0)return null;const A=Ve[_.name][0],O=Ve[_.name][1];if(A!==I.length)return null;const E=new Array(O);for(let y=0;y<O;y++){let R=0;for(let N=0;N<A;N++)R+=d[N*O+y]*I[N];E[y]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new m(h,r.typeInfo)}if(i instanceof m&&r instanceof K){const h=function(d,_,I,P){if(bo[_.name]===void 0||Ve[P.name]===void 0)return null;const A=Ve[P.name][0],O=Ve[P.name][1];if(O!==d.length)return null;const E=[];for(let y=0;y<A;y++){let R=0;for(let N=0;N<O;N++)R+=d[N]*I[N*A+y];E[y]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new m(h,i.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d*f[_]);return new m(h,i.typeInfo)}}if(z(s)){const u=o,f=s.map((h,d)=>h*u);return i instanceof K?new K(f,i.typeInfo):new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u*h);return r instanceof K?new K(f,r.typeInfo):new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a*l,c)}case"%":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d%f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h%u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u%h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a%l,c)}case"/":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d/f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h/u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u/h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a/l,c)}case"&":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d&f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h&u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u&h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a&l,c)}case"|":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d|f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h|u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u|h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a|l,c)}case"^":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d^f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h^u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u^h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a^l,c)}case"<<":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d<<f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h<<u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u<<h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a<<l,c)}case">>":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d>>f[_]);return new m(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h>>u);return new m(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u>>h);return new m(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a>>l,c)}case">":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c>a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a>c?1:0);return new m(l,r.typeInfo)}return new v(s>o?1:0,this.getTypeInfo("bool"));case"<":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c<a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a<c?1:0);return new m(l,r.typeInfo)}return new v(s<o?1:0,this.getTypeInfo("bool"));case"==":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u===l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c==a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a==c?1:0);return new m(l,r.typeInfo)}return new v(s===o?1:0,this.getTypeInfo("bool"));case"!=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u!==l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c!==a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a!==c?1:0);return new m(l,r.typeInfo)}return new v(s!==o?1:0,this.getTypeInfo("bool"));case">=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>=l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c>=a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a>=c?1:0);return new m(l,r.typeInfo)}return new v(s>=o?1:0,this.getTypeInfo("bool"));case"<=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<=l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c<=a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a<=c?1:0);return new m(l,r.typeInfo)}return new v(s<=o?1:0,this.getTypeInfo("bool"));case"&&":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u&&l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c&&a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a&&c?1:0);return new m(l,r.typeInfo)}return new v(s&&o?1:0,this.getTypeInfo("bool"));case"||":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u||l[f]?1:0);return new m(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c||a?1:0);return new m(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a||c?1:0);return new m(l,r.typeInfo)}return new v(s||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.createVariable(o.name,a,o)}return this._execStatements(r.node.body,i)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const i=t.getFunction(e.name);if(i){const r=t.clone();for(let s=0;s<i.node.args.length;++s){const o=i.node.args[s],a=this.evalExpression(e.args[s],r);r.setVariable(o.name,a,o)}return this._execStatements(i.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new v(0,this.getTypeInfo(e.type));const i=this.evalExpression(e.args[0],t);return i.typeInfo=this.getTypeInfo(e.type),i.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=bo[r];if(s===void 0)return console.error(`Invalid vec constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Ae)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);if(l instanceof m){const c=l.data;for(let u=0;u<c.length;++u){let f=c[u];o.push(f)}}else if(l instanceof v){let c=l.value;o.push(c)}}if(e.type instanceof T&&e.type.format===null&&(e.type.format=T.f32),o.length===0){const a=new Array(s).fill(0);return new m(a,i).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<s;)o.push(o[0]);return o.length<s?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new m(o.length>s?o.slice(0,s):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=Ve[r];if(s===void 0)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Ae)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);l instanceof m?o.push(...l.data):l instanceof v?o.push(l.value):l instanceof K&&o.push(...l.data)}if(i instanceof qt&&i.format===null&&(i.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(s[2]).fill(0);return new K(a,i).getSubData(this,e.postfix,t)}return o.length!==s[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new K(o,i).getSubData(this,e.postfix,t)}}Fe._breakObj=new et(new Je("BREAK",null),null),Fe._continueObj=new et(new Je("CONTINUE",null),null),Fe._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class m0{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class _0{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new m0,this._exec=new Fe,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const i=this._global_decl_or_directive();if(!i)break;t.push(i)}if(this._deferArrayCountEval.length>0){for(const i of this._deferArrayCountEval){const r=i.arrayType,s=i.countNode;if(s instanceof Ze){const o=s.name,a=this._context.constants.get(o);if(a)try{const l=a.constEvaluate(this._exec);r.count=l}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const i of t)i.search(r=>{r instanceof lu||r instanceof fr?r.type=this._forwardType(r.type):r instanceof Qn?r.format=this._forwardType(r.format):r instanceof wt||r instanceof Kn||r instanceof ur?r.type=this._forwardType(r.type):r instanceof jn?r.returnType=this._forwardType(r.returnType):r instanceof au&&(r.type=this._forwardType(r.type))});return t}_forwardType(e){if(e instanceof eu){const t=this._getType(e.name);if(t)return t}else e instanceof fr?e.type=this._forwardType(e.type):e instanceof Qn&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const t=new o0(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof S)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t<i;++t){const r=e[t];if(this._check(r))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const i=t.type;let r=!1;for(const s of e){if(i===s)return!0;s===p.tokens.name&&(r=!0)}if(r){const s=p.tokens.name.rule.exec(t.lexeme);if(s&&s.index==0&&s[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){const i=p.tokens.name.rule.exec(t.lexeme);return i&&i.index==0&&i[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){const t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){const t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){const t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){const t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}const e=this._attribute();if(this._check(p.keywords.var)){const t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){const t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){const t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){const t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){const t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){const t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");const i=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;const a=this._attribute(),l=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");const c=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=c,i.push(this._updateNode(new au(l,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(p.tokens.arrow)){const a=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=a)}const s=this._compound_statement(),o=this._currentLine;return this._updateNode(new jn(t,i,r,s,e,o),e)}_compound_statement(){const e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){const t=this._statement();t!==null&&e.push(t)}return this._consume(p.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._check(p.tokens.attr)&&this._attribute(),this._check(p.keywords.if))return this._if_statement();if(this._check(p.keywords.switch))return this._switch_statement();if(this._check(p.keywords.loop))return this._loop_statement();if(this._check(p.keywords.for))return this._for_statement();if(this._check(p.keywords.while))return this._while_statement();if(this._check(p.keywords.continuing))return this._continuing_statement();if(this._check(p.keywords.static_assert))return this._static_assert_statement();if(this._check(p.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(p.keywords.return))e=this._return_statement();else if(this._check([p.keywords.var,p.keywords.let,p.keywords.const]))e=this._variable_statement();else if(this._match(p.keywords.discard))e=this._updateNode(new i0);else if(this._match(p.keywords.break)){const t=this._updateNode(new Jc);if(this._currentLoop.length>0){const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){const t=this._updateNode(new Gc);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(p.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(p.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new e0(t),e)}_while_statement(){if(!this._match(p.keywords.while))return null;const e=this._updateNode(new Wc(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(p.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new uo(i,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");const e=this._updateNode(new $c(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(p.tokens.semicolon)?null:this._for_init(),this._consume(p.tokens.semicolon,"Expected ';'."),e.condition=this._check(p.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(p.tokens.semicolon,"Expected ';'."),e.increment=this._check(p.tokens.paren_right)?null:this._for_increment(),this._consume(p.tokens.paren_right,"Expected ')'."),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(p.keywords.var)){const e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new wt(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new Kn(t,i,null,null,r),e)}if(this._match(p.keywords.const)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return i===null&&r instanceof Ae&&(i=r.type),this._updateNode(new ur(t,i,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;const i=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new Xc(i.type===p.tokens.plus_plus?mn.increment:mn.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let i=this._match(p.tokens.underscore);if(i||(e=this._unary_expression()),!i&&e==null)return null;const r=this._consume(p.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return this._updateNode(new Yc(Zn.parse(r.lexeme),e,s),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume(p.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=t,null):this._updateNode(new ho(i.lexeme,r),e)}_loop_statement(){if(!this._match(p.keywords.loop))return null;this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new qc([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof uo){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(p.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(p.keywords.switch))return null;const e=this._updateNode(new jc(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),e.cases==null||e.cases.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(p.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){const i=this._case_selectors();for(const s of i)if(s instanceof hr){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch case.");const r=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new su(i,r)))}if(this._match(p.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new ou(i)))}}return e}_case_selectors(){const e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new hr)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new hr)):e.push(this._shift_expression());return e}_case_body(){if(this._match(p.keywords.fallthrough))return this._consume(p.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);const t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();const i=this._compound_statement();let r=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let s=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),s=this._compound_statement()),this._updateNode(new Kc(t,i,r,s),e)}_match_elseif(){return this._tokens[this._current].type===p.keywords.else&&this._tokens[this._current+1].type===p.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new r0(t,i))),this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(p.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new Zc(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new ct(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(p.tokens.and_and);)e=this._updateNode(new ct(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(p.tokens.or);)e=this._updateNode(new ct(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(p.tokens.xor);)e=this._updateNode(new ct(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(p.tokens.and);)e=this._updateNode(new ct(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([p.tokens.equal_equal,p.tokens.not_equal])?this._updateNode(new ct(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([p.tokens.less_than,p.tokens.greater_than,p.tokens.less_than_equal,p.tokens.greater_than_equal]);)e=this._updateNode(new ct(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([p.tokens.shift_left,p.tokens.shift_right]);)e=this._updateNode(new ct(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([p.tokens.plus,p.tokens.minus]);)e=this._updateNode(new ct(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([p.tokens.star,p.tokens.forward_slash,p.tokens.modulo]);)e=this._updateNode(new ct(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([p.tokens.minus,p.tokens.bang,p.tokens.tilde,p.tokens.star,p.tokens.and])?this._updateNode(new Se(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new _n(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match(p.tokens.period)){const e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new jt(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return k.void;case"bool":return k.bool;case"i32":return k.i32;case"u32":return k.u32;case"f32":return k.f32;case"f16":return k.f16;case"vec2f":return T.vec2f;case"vec3f":return T.vec3f;case"vec4f":return T.vec4f;case"vec2i":return T.vec2i;case"vec3i":return T.vec3i;case"vec4i":return T.vec4i;case"vec2u":return T.vec2u;case"vec3u":return T.vec3u;case"vec4u":return T.vec4u;case"vec2h":return T.vec2h;case"vec3h":return T.vec3h;case"vec4h":return T.vec4h;case"mat2x2f":return T.mat2x2f;case"mat2x3f":return T.mat2x3f;case"mat2x4f":return T.mat2x4f;case"mat3x2f":return T.mat3x2f;case"mat3x3f":return T.mat3x3f;case"mat3x4f":return T.mat3x4f;case"mat4x2f":return T.mat4x2f;case"mat4x3f":return T.mat4x3f;case"mat4x4f":return T.mat4x4f;case"mat2x2h":return T.mat2x2h;case"mat2x3h":return T.mat2x3h;case"mat2x4h":return T.mat2x4h;case"mat3x2h":return T.mat3x2h;case"mat3x3h":return T.mat3x3h;case"mat3x4h":return T.mat3x4h;case"mat4x2h":return T.mat4x2h;case"mat4x3h":return T.mat4x3h;case"mat4x4h":return T.mat4x4h;case"mat2x2i":return T.mat2x2i;case"mat2x3i":return T.mat2x3i;case"mat2x4i":return T.mat2x4i;case"mat3x2i":return T.mat3x2i;case"mat3x3i":return T.mat3x3i;case"mat3x4i":return T.mat3x4i;case"mat4x2i":return T.mat4x2i;case"mat4x3i":return T.mat4x3i;case"mat4x4i":return T.mat4x4i;case"mat2x2u":return T.mat2x2u;case"mat2x3u":return T.mat2x3u;case"mat2x4u":return T.mat2x4u;case"mat3x2u":return T.mat3x2u;case"mat3x3u":return T.mat3x3u;case"mat3x4u":return T.mat3x4u;case"mat4x2u":return T.mat4x2u;case"mat4x3u":return T.mat4x3u;case"mat4x4u":return T.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){const i=this._previous().toString();if(this._check(p.tokens.paren_left)){const r=this._argument_expression_list(),s=this._getType(i);return s!==null?this._updateNode(new mt(s,r)):this._updateNode(new go(i,r))}if(this._context.constants.has(i)){const r=this._context.constants.get(i);return this._updateNode(new tu(i,r.value))}return this._updateNode(new Ze(i))}if(this._match(p.tokens.int_literal)){const i=this._previous().toString();let r=i.endsWith("i")||i.endsWith("i")?k.i32:i.endsWith("u")||i.endsWith("U")?k.u32:k.x32;const s=parseInt(i);return this._validateTypeRange(s,r),this._updateNode(new Ae(new v(s,this._exec.getTypeInfo(r)),r))}if(this._match(p.tokens.uint_literal)){const i=parseInt(this._previous().toString());return this._validateTypeRange(i,k.u32),this._updateNode(new Ae(new v(i,this._exec.getTypeInfo(k.u32)),k.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let i=this._previous().toString(),r=i.endsWith("h");r&&(i=i.substring(0,i.length-1));const s=parseFloat(i);this._validateTypeRange(s,r?k.f16:k.f32);const o=r?k.f16:k.f32;return this._updateNode(new Ae(new v(s,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let i=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new Ae(new v(i?1:0,this._exec.getTypeInfo(k.bool)),k.bool))}if(this._check(p.tokens.paren_left))return this._paren_expression();if(this._match(p.keywords.bitcast)){this._consume(p.tokens.less_than,"Expected '<'.");const i=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");const r=this._paren_expression();return this._updateNode(new nu(i,r))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new mt(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;const e=[];do{if(this._check(p.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_paren_expression(){this._consume(p.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(p.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(p.keywords.struct))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check(p.tokens.brace_right);){const o=this._attribute(),a=this._consume(p.tokens.name,"Expected variable name.").toString();this._consume(p.tokens.colon,"Expected ':' for struct member type.");const l=this._attribute(),c=this._type_decl();c!=null&&(c.attributes=l),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new lu(a,c,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,s=this._updateNode(new At(t,i,e,r),e);return this._context.structs.set(t,s),s}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){const t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof Ae){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof Ae&&(e.type=e.value.type.name==="x32"?k.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(p.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(p.keywords.const))return null;const t=this._consume(p.tokens.name,"Expected variable name"),i=this._currentLine;let r=null;if(this._match(p.tokens.colon)){const l=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=l)}let s=null;this._consume(p.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let l=[k.f32],c=o.constEvaluate(this._exec,l);c instanceof v&&this._validateTypeRange(c.value,l[0]),l[0]instanceof T&&l[0].format===null&&c.typeInfo instanceof qt&&c.typeInfo.format!==null&&(c.typeInfo.format.name==="f16"?l[0].format=k.f16:c.typeInfo.format.name==="f32"?l[0].format=k.f32:c.typeInfo.format.name==="i32"?l[0].format=k.i32:c.typeInfo.format.name==="u32"?l[0].format=k.u32:c.typeInfo.format.name==="bool"?l[0].format=k.bool:console.error(`TODO: impelement template format type ${c.typeInfo.format.name}`)),s=this._updateNode(new Ae(c,l[0])),this._exec.context.setVariable(t.toString(),c)}catch{s=o}if(r!==null&&s instanceof Ae){if(s.type.name!=="x32"&&r.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${r.name}. Line:${this._currentLine}`);s.type=r,s.isScalar&&this._validateTypeRange(s.scalarValue,s.type)}else r===null&&s instanceof Ae&&(r=(e=s==null?void 0:s.type)!==null&&e!==void 0?e:k.f32,r===k.x32&&(r=k.i32));const a=this._updateNode(new ur(t.toString(),r,"","",s),i);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;const e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name");let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}let r=null;if(this._match(p.tokens.equal)&&(r=this._const_expression()),i!==null&&r instanceof Ae){if(r.type.name!=="x32"&&i.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${i.name}. Line:${this._currentLine}`);r.type=i}else i===null&&r instanceof Ae&&(i=r.type.name==="x32"?k.i32:r.type);return r instanceof Ae&&r.isScalar&&this._validateTypeRange(r.scalarValue,i),this._updateNode(new Kn(t.toString(),i,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));const r=this._consume(p.tokens.name,"Expected variable name");let s=null;if(this._match(p.tokens.colon)){const o=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=o)}return this._updateNode(new wt(r.toString(),s,t,i,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;const e=this._consume(p.tokens.name,"Expected variable name");let t=null;if(this._match(p.tokens.colon)){const i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}return this._updateNode(new fo(e.toString(),t,null))}_diagnostic(){this._consume(p.tokens.paren_left,"Expected '('");const e=this._consume(p.tokens.ident,"Expected severity control name.");this._consume(p.tokens.comma,"Expected ','");let t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new Qc(e.toString(),t))}_enable_directive(){const e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new t0(e.toString()))}_requires_directive(){const e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){const t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new n0(e))}_type_alias(){const e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new po(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){const i=this._advance().toString();if(this._context.structs.has(i))return this._context.structs.get(i);if(this._context.aliases.has(i))return this._context.aliases.get(i).type;if(!this._getType(i)){const r=this._updateNode(new eu(i));return this._forwardTypeCount++,r}return this._updateNode(new k(i))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let i=this._advance().toString(),r=null,s=null;return this._match(p.tokens.less_than)&&(r=this._type_decl(),s=null,this._match(p.tokens.comma)&&(s=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new T(i,r,s))}if(this._match(p.keywords.ptr)){let i=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");const r=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");const s=this._type_decl();let o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new fr(i,r.toString(),s,o))}const t=this._attribute();if(this._match(p.keywords.array)){let i=null,r=-1;const s=this._previous();let o=null;if(this._match(p.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let l="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{l=o.constEvaluate(this._exec).toString(),o=null}catch{l="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),r=l?parseInt(l):0}const a=this._updateNode(new Qn(s.toString(),t,i,r));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Jn(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Jn(this._previous().toString(),null,null));if(this._match(p.sampled_texture_type)||this._match(p.multisampled_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Jn(e.toString(),t,null))}if(this._match(p.storage_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");const i=this._consume(p.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Jn(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){const t=this._consume(p.attribute_name,"Expected attribute name"),i=this._updateNode(new cu(t.toString(),null));if(this._match(p.tokens.paren_left)){if(i.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{const r=this._consume(p.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(r)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(i)}return e.length==0?null:e}}class y0 extends _t{constructor(e){super(),e&&this.update(e)}update(e){const t=new _0().parse(e);this.updateAST(t)}}function x0(n){var s;const e={attributes:[],bindings:[]};let t;try{t=v0(n)}catch(o){return D.error(o.message)(),e}for(const o of t.uniforms){const a=[];for(const l of((s=o.type)==null?void 0:s.members)||[])a.push({name:l.name,type:hu(l.type)});e.bindings.push({type:"uniform",name:o.name,group:o.group,location:o.binding,members:a})}for(const o of t.textures)e.bindings.push({type:"texture",name:o.name,group:o.group,location:o.binding});for(const o of t.samplers)e.bindings.push({type:"sampler",name:o.name,group:o.group,location:o.binding});const i=t.entry.vertex[0],r=(i==null?void 0:i.inputs.length)||0;for(let o=0;o<r;o++){const a=i.inputs[o];if(a.locationType==="location"){const l=hu(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:l})}}return e}function hu(n){return n!=null&&n.format?`${n.name}<${n.format.name}>`:n.name}function v0(n){try{return new y0(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(t+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(t+=e.token.line||""),new Error(t,{cause:e})}}const So={};function _r(n="id"){So[n]=So[n]||1;const e=So[n]++;return`${n}-${e}`}class du{constructor(e){g(this,"id");g(this,"userData",{});g(this,"topology");g(this,"bufferLayout",[]);g(this,"vertexCount");g(this,"indices");g(this,"attributes");if(this.id=e.id||_r("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&L.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function b0(n,e){if(e instanceof du)return e;const t=S0(n,e),{attributes:i,bufferLayout:r}=T0(n,e);return new du({topology:e.topology||"triangle-list",bufferLayout:r,vertexCount:e.vertexCount,indices:t,attributes:i})}function S0(n,e){if(!e.indices)return;const t=e.indices.value;return n.createBuffer({usage:L.INDEX,data:t})}function T0(n,e){const t=[],i={};for(const[s,o]of Object.entries(e.attributes)){let a=s;switch(s){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){i[a]=n.createBuffer({data:o.value,id:`${s}-buffer`});const{value:l,size:c,normalized:u}=o;t.push({name:a,format:Mp(l,c,u)})}}const r=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:t,vertexCount:r}}const Dr=class Dr{constructor(e){g(this,"device");g(this,"cachingEnabled");g(this,"destroyPolicy");g(this,"debug");g(this,"_hashCounter",0);g(this,"_hashes",{});g(this,"_renderPipelineCache",{});g(this,"_computePipelineCache",{});this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Dr(e),e._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var o;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const t={...Wt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.log(3,`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:_r("unnamed-cached")}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}createComputePipeline(e){var o;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const t={...Bi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.log(3,`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.debug&&D.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(D.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.debug&&D.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Bi&&(t=this._computePipelineCache),e instanceof Wt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device,i=this._getHash(e.shader.source);return`${t}/C/${i}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r="-",s=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${i}V${r}BL${s}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${i}V${r}T${e.topology}P${a}BL${s}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};g(Dr,"defaultProps",{...Wt.defaultProps});let To=Dr;const Mr=class Mr{constructor(e){g(this,"device");g(this,"cachingEnabled");g(this,"destroyPolicy");g(this,"debug");g(this,"_cache",{});this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(e){var t;return(t=e._lumaData).defaultShaderFactory||(t.defaultShaderFactory=new Mr(e)),e._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let i=this._cache[t];if(i)i.useCount++,this.debug&&D.log(3,`${this}: Reusing shader ${i.shader.id} count=${i.useCount}`)();else{const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:r,useCount:1},this.debug&&D.log(3,`${this}: Created new shader ${r.id}`)()}return i.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],i.shader.destroy(),this.debug&&D.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&D.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};g(Mr,"defaultProps",{...Ni.defaultProps});let wo=Mr;function w0(n,e){var r;const t={},i="Values";if(n.attributes.length===0&&!((r=n.varyings)!=null&&r.length))return{"No attributes or varyings":{[i]:"N/A"}};for(const s of n.attributes)if(s){const o=`${s.location} ${s.name}: ${s.type}`;t[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(const s of n.varyings||[]){const o=`${s.location} ${s.name}`;t[`out ${o}`]={[i]:JSON.stringify(s)}}return t}let Pe=null,Kt=null;function A0(n,{id:e,minimap:t,opaque:i,top:r="0",left:s="0",rgbaScale:o=1}){Pe||(Pe=document.createElement("canvas"),Pe.id=e,Pe.title=e,Pe.style.zIndex="100",Pe.style.position="absolute",Pe.style.top=r,Pe.style.left=s,Pe.style.border="blue 5px solid",Pe.style.transform="scaleY(-1)",document.body.appendChild(Pe),Kt=Pe.getContext("2d")),(Pe.width!==n.width||Pe.height!==n.height)&&(Pe.width=n.width/2,Pe.height=n.height/2,Pe.style.width="400px",Pe.style.height="400px");const a=n.device.readPixelsToArrayWebGL(n),l=Kt==null?void 0:Kt.createImageData(n.width,n.height);if(l){for(let u=0;u<a.length;u+=4)l.data[0+u+0]=a[u+0]*o,l.data[0+u+1]=a[u+1]*o,l.data[0+u+2]=a[u+2]*o,l.data[0+u+3]=i?255:a[u+3]*o;Kt==null||Kt.putImageData(l,0,0)}}function Ao(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!Ao(n[i],e[i],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof n=="object"&&typeof e=="object"){const i=Object.keys(n),r=Object.keys(e);if(i.length!==r.length)return!1;for(const s of i)if(!e.hasOwnProperty(s)||!Ao(n[s],e[s],t-1))return!1;return!0}return!1}class Co{constructor(e){g(this,"bufferLayouts");this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?(t=e.attributes)==null?void 0:t.map(i=>i.attribute):[e.name]}mergeBufferLayouts(e,t){const i=[...e];for(const r of t){const s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}getBufferIndex(e){const t=this.bufferLayouts.findIndex(i=>i.name===e);return t===-1&&D.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function C0(n,e){const t=Object.fromEntries(n.attributes.map(r=>[r.name,r.location])),i=e.slice();return i.sort((r,s)=>{const o=r.attributes?r.attributes.map(u=>u.attribute):[r.name],a=s.attributes?s.attributes.map(u=>u.attribute):[s.name],l=Math.min(...o.map(u=>t[u])),c=Math.min(...a.map(u=>t[u]));return l-c}),i}function I0(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function P0(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function E0(n){return I0(n)||P0(n)}function R0(n){return E0(n)||typeof n=="number"||typeof n=="boolean"}function k0(n){const e={bindings:{},uniforms:{}};return Object.keys(n).forEach(t=>{const i=n[t];R0(i)?e.uniforms[t]=i:e.bindings[t]=i}),e}class D0{constructor(e,t){g(this,"options",{disableWarnings:!1});g(this,"modules");g(this,"moduleUniforms");g(this,"moduleBindings");Object.assign(this.options,t);const i=ro(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;D.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,s]of Object.entries(e))this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&D.warn(`Module name: ${r} vs ${s.name}`)()}destroy(){}setProps(e){var t;for(const i of Object.keys(e)){const r=i,s=e[r]||{},o=this.modules[r];if(!o){this.options.disableWarnings||D.warn(`Module ${i} not found`)();continue}const a=this.moduleUniforms[r],l=this.moduleBindings[r],c=((t=o.getUniforms)==null?void 0:t.call(o,s,a))||s,{uniforms:u,bindings:f}=k0(c);this.moduleUniforms[r]={...a,...u},this.moduleBindings[r]={...l,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var t;const e={};for(const[i,r]of Object.entries(this.moduleUniforms))for(const[s,o]of Object.entries(r))e[`${i}.${s}`]={type:(t=this.modules[i].uniformTypes)==null?void 0:t[s],value:String(o)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}let M0="";async function F0(n,e){const t=new Image;return t.crossOrigin="anonymous",t.src=n.startsWith("http")?n:M0+n,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}const N0=["+X","-X","+Y","-Y","+Z","-Z"],O0=["+X","-X","+Y","-Y","+Z","-Z"],Fr=class Fr{constructor(e,t){g(this,"device");g(this,"id");g(this,"props");g(this,"texture");g(this,"sampler");g(this,"view");g(this,"ready");g(this,"isReady",!1);g(this,"destroyed",!1);g(this,"resolveReady",()=>{});g(this,"rejectReady",()=>{});this.device=e;const i=_r("async-texture");this.props={...Fr.defaultProps,id:i,...t},this.id=this.props.id,t={...t},typeof(t==null?void 0:t.data)=="string"&&t.dimension==="2d"&&(t.data=F0(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((r,s)=>{this.resolveReady=()=>{this.isReady=!0,r()},this.rejectReady=s}),this.initAsync(t)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,i=await pu(t).then(void 0,this.rejectReady);if(this.destroyed)return;const r=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(i);if(!r)throw new Error("Texture size could not be determined");const s={...r,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(s.width,s.height);if(s.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,i);break;case"2d":this._setTexture2DData(i);break;case"3d":this._setTexture3DData(this.texture,i);break;case"2d-array":this._setTextureArrayData(this.texture,i);break;case"cube":this._setTextureCubeData(this.texture,i);break;case"cube-array":this._setTextureCubeArrayData(this.texture,i);break}this.props.mipmaps&&this.generateMipmaps(),D.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof cn?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=e==null?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){const i=Object.values(e)[0];return{width:i.width,height:i.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const i=this._normalizeTextureData(e);i.length>1&&this.props.mipmaps!==!1&&D.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let r=0;r<i.length;r++){const s=i[r];this.device.isExternalImage(s)?this.texture.copyExternalImage({image:s,depth:t,mipLevel:r,flipY:!0}):this.texture.copyImageData({data:s.data,mipLevel:r})}}_setTexture3DData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="3d")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="cube")throw new Error(this.id);for(const[r,s]of Object.entries(t)){const o=O0.indexOf(r);this._setTexture2DData(s,o)}}_setTextureArrayData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="2d-array")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,i,r=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&D.warn(`${this.id} has mipmap and multiple LODs.`)();const s=N0.indexOf(i);this._setTexture2DData(t,s)}_normalizeTextureData(e){const t=this.texture;let i;return ArrayBuffer.isView(e)?i=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?i=e:i=[e],i}};g(Fr,"defaultProps",{...Q.defaultProps,data:null,mipmaps:!1});let Gn=Fr;async function pu(n){if(n=await n,Array.isArray(n))return await Promise.all(n.map(pu));if(n&&typeof n=="object"&&n.constructor===Object){const e=n,t=await Promise.all(Object.values(e)),i=Object.keys(e),r={};for(let s=0;s<i.length;s++)r[i[s]]=t[s];return r}return n}const Zt=2,B0=1e4,Nr=class Nr{constructor(e,t){g(this,"device");g(this,"id");g(this,"source");g(this,"vs");g(this,"fs");g(this,"pipelineFactory");g(this,"shaderFactory");g(this,"userData",{});g(this,"parameters");g(this,"topology");g(this,"bufferLayout");g(this,"isInstanced");g(this,"instanceCount",0);g(this,"vertexCount");g(this,"indexBuffer",null);g(this,"bufferAttributes",{});g(this,"constantAttributes",{});g(this,"bindings",{});g(this,"vertexArray");g(this,"transformFeedback",null);g(this,"pipeline");g(this,"shaderInputs");g(this,"_uniformStore");g(this,"_attributeInfos",{});g(this,"_gpuGeometry",null);g(this,"props");g(this,"_pipelineNeedsUpdate","newly created");g(this,"_needsRedraw","initializing");g(this,"_destroyed",!1);g(this,"_lastDrawTimestamp",-1);g(this,"_lastLogTime",0);g(this,"_logOpen",!1);g(this,"_drawCount",0);var l,c,u,f;this.props={...Nr.defaultProps,...t},t=this.props,this.id=t.id||_r("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(((l=this.props.modules)==null?void 0:l.map(h=>[h.name,h]))||[]),r=t.shaderInputs||new D0(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(r);const s=z0(e),o=(((c=this.props.modules)==null?void 0:c.length)>0?this.props.modules:(u=this.shaderInputs)==null?void 0:u.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:h,getUniforms:d}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:s,...this.props,modules:o});this.source=h,this._getModuleUniforms=d,(f=this.props).shaderLayout||(f.shaderLayout=x0(this.source))}else{const{vs:h,fs:d,getUniforms:_}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:o});this.vs=h,this.fs=d,this._getModuleUniforms=_}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||To.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||wo.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return D.info(Zt,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const r=this._getBindings();this.pipeline.setBindings(r,{disableWarnings:this.props.disableWarnings});const{indexBuffer:s}=this.vertexArray,o=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var i;(i=this._gpuGeometry)==null||i.destroy();const t=e&&b0(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const r=new Co(this.bufferLayout);this.bufferLayout=r.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new Co(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Ao(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new ye(this.shaderInputs.modules);for(const[t,i]of Object.entries(this.shaderInputs.modules))if(U0(i)){const r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const i=(t==null?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&D.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=C0(this.pipeline.shaderLayout,this.bufferLayout);const r=new Co(this.bufferLayout);for(const[s,o]of Object.entries(e)){const a=r.getBufferLayout(s);if(!a){i||D.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const l=r.getAttributeNamesForBuffer(a);let c=!1;for(const u of l){const f=this._attributeInfos[u];if(f){const h=this.device.type==="webgpu"?r.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),c=!0}}!c&&!i&&D.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,r]of Object.entries(e)){const s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):((t==null?void 0:t.disableWarnings)??this.props.disableWarnings)||D.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Gn&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,i]of Object.entries(this.bindings))i instanceof Gn?i.isReady&&(e[t]=i.texture):e[t]=i;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof Fi?e=Math.max(e,t.texture.updateTimestamp):t instanceof L||t instanceof Q?e=Math.max(e,t.updateTimestamp):t instanceof Gn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof cn||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(D.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:i,fs:r}),this._attributeInfos=ja(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=D.level>3?0:B0;D.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,D.group(Zt,`>>> DRAWING MODEL ${this.id}`,{collapsed:D.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=w0(this.pipeline.shaderLayout,this.id);D.table(Zt,e)();const t=this.shaderInputs.getDebugTable();D.table(Zt,t)();const i=this._getAttributeDebugTable();D.table(Zt,this._attributeInfos)(),D.table(Zt,i)(),D.groupEnd(Zt)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const i=e.props.framebuffer;i&&A0(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,i]of Object.entries(this._attributeInfos)){const r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){const i=za(t);return(e instanceof L?new i(e.debugData):e).toString()}};g(Nr,"defaultProps",{...Wt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:oo.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let _e=Nr;function U0(n){return!!(n.uniformTypes&&!L0(n.uniformTypes))}function z0(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}function L0(n){for(const e in n)return!1;return!0}class Nt{constructor(e,t,i,r,s){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=t,this.store=i,this.data=r,s&&(this.points=s)}}const V0=`#version 300 es
|
|
96
|
+
`&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new bu(e,t,this._line,this._start,this._current))}}function z(n){return Array.isArray(n)||(n==null?void 0:n.buffer)instanceof ArrayBuffer}const pr=new Float32Array(1),l0=new Uint32Array(pr.buffer),c0=new Uint32Array(pr.buffer),mr=new Int32Array(1),u0=new Float32Array(mr.buffer),f0=new Uint32Array(mr.buffer),gr=new Uint32Array(1),h0=new Float32Array(gr.buffer),d0=new Int32Array(gr.buffer);function Su(n,e,t){if(e===t)return n;if(e==="f32"){if(t==="i32"||t==="x32")return pr[0]=n,l0[0];if(t==="u32")return pr[0]=n,c0[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return mr[0]=n,u0[0];if(t==="u32")return mr[0]=n,f0[0]}else if(e==="u32"){if(t==="f32")return gr[0]=n,h0[0];if(t==="i32"||t==="x32")return gr[0]=n,d0[0]}return console.error(`Unsupported cast from ${e} to ${t}`),n}class p0{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class _r{constructor(e,t){this.align=e,this.size=t}}class _t{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Zy,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(const t of e)t instanceof jn&&this._functions.set(t.name,new p0(t));for(const t of e)if(t instanceof At){const i=this.getTypeInfo(t,null);i instanceof Dt&&this.structs.push(i)}for(const t of e)if(t instanceof mo)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof ho){const i=t,r=this._getAttributeNum(i.attributes,"id",0),s=i.type!=null?this.getTypeInfo(i.type,i.attributes):null;this.overrides.push(new qy(i.name,s,i.attributes,r));continue}if(this._isUniformVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new lr(i.name,o,r,s,i.attributes,Ft.Uniform,i.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new lr(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Storage,i.access);l.access||(l.access="read"),this.storage.push(l);continue}if(this._isTextureVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=this._isStorageTexture(o),l=new lr(i.name,o,r,s,i.attributes,a?Ft.StorageTexture:Ft.Texture,i.access);l.access||(l.access="read"),a?this.storage.push(l):this.textures.push(l);continue}if(this._isSamplerVar(t)){const i=t,r=this._getAttributeNum(i.attributes,"group",0),s=this._getAttributeNum(i.attributes,"binding",0),o=this.getTypeInfo(i.type,i.attributes),a=new lr(i.name,o,r,s,i.attributes,Ft.Sampler,i.access);this.samplers.push(a);continue}}for(const t of e)if(t instanceof jn){const i=this._getAttribute(t,"vertex"),r=this._getAttribute(t,"fragment"),s=this._getAttribute(t,"compute"),o=i||r||s,a=new Ky(t.name,o==null?void 0:o.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(l=>new jy(l.name,this.getTypeInfo(l.type,l.attributes),l.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(i=>{var r,s,o;if(i instanceof vu){if(i.value)if(z(i.value))for(const a of i.value)for(const l of this.overrides)a===l.name&&((r=t.info)===null||r===void 0||r.overrides.push(l));else for(const a of this.overrides)i.value===a.name&&((s=t.info)===null||s===void 0||s.overrides.push(a))}else if(i instanceof Ze)for(const a of this.overrides)i.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const r of e.calls){const s=(i=this._functions.get(r.name))===null||i===void 0?void 0:i.info;s&&t.add(s)}}findResource(e,t,i){if(i){for(const r of this.entry.compute)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.vertex)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}for(const r of this.entry.fragment)if(r.name===i){for(const s of r.resources)if(s.group==e&&s.binding==t)return s}}for(const r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(const r of this.storage)if(r.group==e&&r.binding==t)return r;for(const r of this.textures)if(r.group==e&&r.binding==t)return r;for(const r of this.samplers)if(r.group==e&&r.binding==t)return r;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],r=this,s=[];return e.search(o=>{if(o instanceof cr)s.push({});else if(o instanceof ur)s.pop();else if(o instanceof wt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof gt){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Kn){const a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a)}else if(o instanceof Ze){const a=o;if(s.length>0&&s[s.length-1][a.name])return;const l=r._findResource(a.name);l&&i.push(l)}else if(o instanceof go){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}else if(o instanceof po){const a=o,l=r._functions.get(a.name);l&&(t&&(l.inUse=!0),e.calls.add(l.node),l.resources===null&&(l.resources=r._findResources(l.node,t)),i.push(...l.resources))}}),[...new Map(i.map(o=>[o.name,o])).values()]}getBindGroups(){const e=[];function t(i,r){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),r>=e[i].length&&(e[i].length=r+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof At)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);i!==null&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof At)this._getStructOutputs(i.type,t);else{const r=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(r!==null){const s=this.getTypeInfo(i.type,i.type.attributes),o=this._parseInt(r.value),a=new Kc(i.name,s,r.name,o);t.push(a)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new Kc("",i,t.name,r)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(const i of e)if(i.type instanceof At)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof At)this._getStructInputs(i.type,t);else{const r=this._getInputInfo(i);r!==null&&t.push(r)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){const i=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),s=this._parseInt(t.value),o=new Yy(e.name,r,t.name,s);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Xy(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof hr){const r=e.type?this.getTypeInfo(e.type,e.attributes):null,s=new lo(e.name,r,t);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Qn){const r=e,s=r.format?this.getTypeInfo(r.format,r.attributes):null,o=new Mt(r.name,t);return o.format=s,o.count=r.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof At){const r=e,s=new Dt(r.name,t);s.startLine=r.startLine,s.endLine=r.endLine;for(const o of r.members){const a=this.getTypeInfo(o.type,o.attributes);s.members.push(new jc(o.name,a,o.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof Jn){const r=e,s=r.format instanceof k,o=r.format?s?this.getTypeInfo(r.format,null):new Je(r.format,null):null,a=new qt(r.name,o,t,r.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof T){const r=e,s=r.format?this.getTypeInfo(r.format,null):null,o=new qt(r.name,s,t,r.access);return this._types.set(e,o),this._updateTypeInfo(o),o}const i=new Je(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,r;const s=this._getTypeSize(e);if(e.size=(t=s==null?void 0:s.size)!==null&&t!==void 0?t:0,e instanceof Mt&&e.format){const o=this._getTypeSize(e.format);e.stride=Math.max((i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,(r=o==null?void 0:o.align)!==null&&r!==void 0?r:0),this._updateTypeInfo(e.format)}e instanceof lo&&this._updateTypeInfo(e.format),e instanceof Dt&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,r=0,s=0,o=0;for(let a=0,l=e.members.length;a<l;++a){const c=e.members[a],u=this._getTypeSize(c);if(!u)continue;(t=this._getAlias(c.type.name))!==null&&t!==void 0||c.type;const f=u.align,h=u.size;i=this._roundUp(f,i+r),r=h,s=i,o=Math.max(o,f),c.offset=i,c.size=h,this._updateTypeInfo(c.type)}e.size=this._roundUp(o,s+r),e.align=o}_getTypeSize(e){var t,i;if(e==null)return null;const r=this._getAttributeNum(e.attributes,"size",0),s=this._getAttributeNum(e.attributes,"align",0);if(e instanceof jc&&(e=e.type),e instanceof Je){const o=this._getAlias(e.name);o!==null&&(e=o)}{const o=_t._typeInfo[e.name];if(o!==void 0){const a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new _r(Math.max(s,o.align/a),Math.max(r,o.size/a))}}{const o=_t._typeInfo[e.name.substring(0,e.name.length-1)];if(o){const a=e.name[e.name.length-1]==="h"?2:1;return new _r(Math.max(s,o.align/a),Math.max(r,o.size/a))}}if(e instanceof Mt){let o=e,a=8,l=8;const c=this._getTypeSize(o.format);return c!==null&&(l=c.size,a=c.align),l=o.count*this._getAttributeNum((i=e==null?void 0:e.attributes)!==null&&i!==void 0?i:null,"stride",this._roundUp(a,l)),r&&(l=r),new _r(Math.max(s,a),Math.max(r,l))}if(e instanceof Dt){let o=0,a=0,l=0,c=0,u=0;for(const f of e.members){const h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),l=this._roundUp(h.align,l+c),c=h.size,u=l)}return a=this._roundUp(o,u+c),new _r(Math.max(s,o),Math.max(r,a))}return null}_isUniformVar(e){return e instanceof wt&&e.storage=="uniform"}_isStorageVar(e){return e instanceof wt&&e.storage=="storage"}_isTextureVar(e){return e instanceof wt&&e.type!==null&&_t._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof wt&&e.type!==null&&_t._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){const i=e;if(!i||!i.attributes)return null;const r=i.attributes;for(let s of r)if(s.name==t)return s;return null}_getAttributeNum(e,t,i){if(e===null)return i;for(let r of e)if(r.name==t){let s=r!==null&&r.value!==null?r.value:i;return s instanceof Array&&(s=s[0]),typeof s=="number"?s:typeof s=="string"?parseInt(s):i}return i}_roundUp(e,t){return Math.ceil(t/e)*e}}_t._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},_t._textureTypes=p.any_texture_type.map(n=>n.name),_t._samplerTypes=p.sampler_type.map(n=>n.name);let xo=0;class yo{constructor(e,t,i){this.id=xo++,this.name=e,this.value=t,this.node=i}clone(){return new yo(this.name,this.value,this.node)}}class vo{constructor(e){this.id=xo++,this.name=e.name,this.node=e}clone(){return new vo(this.node)}}class bo{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=xo++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new yo(e,t,i??null))}setVariable(e,t,i){const r=this.getVariable(e);r!==null?r.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return(t=i==null?void 0:i.value)!==null&&t!==void 0?t:null}clone(){return new bo(this)}}class m0{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class g0{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let r=!0;if(i instanceof g)return i.data.forEach(s=>{s||(r=!1)}),new v(r?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=i.data.some(s=>s);return new v(r?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof v))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.evalExpression(i,t);if(r instanceof ve&&r.typeInfo.size===0){const s=r.typeInfo,o=r.buffer.byteLength/s.stride;return new v(o,this.getTypeInfo("u32"))}return new v(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.abs(s)),i.typeInfo);const r=i;return new v(Math.abs(r.value),r.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acos(s)),i.typeInfo);const r=i;return new v(Math.acos(r.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.acosh(s)),i.typeInfo);const r=i;return new v(Math.acosh(r.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asin(s)),i.typeInfo);const r=i;return new v(Math.asin(r.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.asinh(s)),i.typeInfo);const r=i;return new v(Math.asinh(r.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atan(s)),i.typeInfo);const r=i;return new v(Math.atan(r.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.atanh(s)),i.typeInfo);const r=i;return new v(Math.atanh(r.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.atan2(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.atan2(s.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.ceil(s)),i.typeInfo);const r=i;return new v(Math.ceil(r.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((c,u)=>this._clamp(c,r.data[u],s.data[u])),i.typeInfo);const o=i,a=r,l=s;return new v(this._clamp(o.value,a.value,l.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cos(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.cosh(s)),i.typeInfo);const r=i;return new v(Math.cos(r.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.clz32(s)),i.typeInfo);const r=i;return new v(Math.clz32(r.value),i.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countOneBits(s)),i.typeInfo);const r=i;return new v(this._countOneBits(r.value),i.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._countTrailingZeros(s)),i.typeInfo);const r=i;return new v(this._countTrailingZeros(r.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){if(i.data.length!==3||r.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const s=i.data,o=r.data;return new g([s[1]*o[2]-o[1]*s[2],s[2]*o[0]-o[2]*s[0],s[0]*o[1]-o[0]*s[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return i instanceof g?new g(i.data.map(s=>s*r),i.typeInfo):new v(i.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof K){const r=i.data,s=i.typeInfo.getTypeName(),o=s.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h")return new v(r[0]*r[3]-r[1]*r[2],o);if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);if(s==="mat2x4"||s==="mat2x4f"||s==="mat2x4h")console.error(`TODO: Determinant for ${s}`);else if(s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h")console.error(`TODO: Determinant for ${s}`);else{if(s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h")return new v(r[0]*(r[4]*r[8]-r[5]*r[7])-r[1]*(r[3]*r[8]-r[5]*r[6])+r[2]*(r[3]*r[7]-r[4]*r[6]),o);s==="mat3x4"||s==="mat3x4f"||s==="mat3x4h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h"?console.error(`TODO: Determinant for ${s}`):s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h"||console.error(`TODO: Determinant for ${s}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){let a=0;for(let l=0;l<i.data.length;++l)a+=(i.data[l]-r.data[l])*(i.data[l]-r.data[l]);return new v(Math.sqrt(a),this.getTypeInfo("f32"))}const s=i,o=r;return new v(Math.abs(s.value-o.value),i.typeInfo)}_dot(e,t){let i=0;for(let r=0;r<e.length;++r)i+=t[r]*e[r];return i}Dot(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return i instanceof g&&r instanceof g?new v(this._dot(i.data,r.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.exp(s)),i.typeInfo);const r=i;return new v(Math.exp(r.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.pow(2,s)),i.typeInfo);const r=i;return new v(Math.pow(2,r.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(r.typeInfo.name!=="u32"&&r.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=r.value,a=s.value;if(i instanceof g)return new g(i.data.map(c=>c>>o&(1<<a)-1),i.typeInfo);if(i.typeInfo.name!=="i32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;const l=i.value;return new v(l>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g){const o=this._dot(r.data,s.data);return new g(o<0?Array.from(i.data):i.data.map(a=>-a),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstLeadingBit(s)),i.typeInfo);const r=i;return new v(this._firstLeadingBit(r.value),i.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>this._firstTrailingBit(s)),i.typeInfo);const r=i;return new v(this._firstTrailingBit(r.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.floor(s)),i.typeInfo);const r=i;return new v(Math.floor(r.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return i.data.length!==r.data.length||i.data.length!==s.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new g(i.data.map((c,u)=>c*r.data[u]+s.data[u]),i.typeInfo);const o=i,a=r,l=s;return new v(o.value*a.value+l.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>s-Math.floor(s)),i.typeInfo);const r=i;return new v(r.value-Math.floor(r.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const a=s.value,l=(1<<o.value)-1<<a,c=~l;if(i instanceof g&&r instanceof g)return new g(i.data.map((h,d)=>h&c|r.data[d]<<a&l),i.typeInfo);const u=i.value,f=r.value;return new v(u&c|f<<a&l,i.typeInfo)}InverseSqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>1/Math.sqrt(s)),i.typeInfo);const r=i;return new v(1/Math.sqrt(r.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){let s=0;return i.data.forEach(o=>{s+=o*o}),new v(Math.sqrt(s),this.getTypeInfo("f32"))}const r=i;return new v(Math.abs(r.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log(s)),i.typeInfo);const r=i;return new v(Math.log(r.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.log2(s)),i.typeInfo);const r=i;return new v(Math.log2(r.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.max(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.max(s.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.min(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.min(s.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof g)return new g(i.data.map((l,c)=>i.data[c]*(1-s.data[c])+r.data[c]*s.data[c]),i.typeInfo);const o=r,a=s;return new v(i.value*(1-a.value)+o.value*a.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((o,a)=>o%r.data[a]),i.typeInfo);const s=r;return new v(i.value%s.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g){const r=this.Length(e,t).value;return new g(i.data.map(s=>s/r),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g)return new g(i.data.map((a,l)=>Math.pow(a,r.data[l])),i.typeInfo);const s=i,o=r;return new v(Math.pow(s.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r),i.typeInfo):new v(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof g?new g(i.data.map(r=>r*Math.PI/180),i.typeInfo):new v(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof g&&r instanceof g){const s=this._dot(i.data,r.data);return new g(i.data.map((o,a)=>o-2*s*r.data[a]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&r instanceof g&&s instanceof v){const o=this._dot(r.data,i.data);return new g(i.data.map((a,l)=>{const c=1-s.value*s.value*(1-o*o);if(c<0)return 0;const u=Math.sqrt(c);return s.value*a-(s.value*o+u)*r.data[l]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.round(s)),i.typeInfo);const r=i;return new v(Math.round(r.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.min(Math.max(s,0),1)),i.typeInfo);const r=i;return new v(Math.min(Math.max(r.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sign(s)),i.typeInfo);const r=i;return new v(Math.sign(r.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sin(s)),i.typeInfo);const r=i;return new v(Math.sin(r.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sinh(s)),i.typeInfo);const r=i;return new v(Math.sinh(r.value),i.typeInfo)}_smoothstep(e,t,i){const r=Math.min(Math.max((i-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(s instanceof g&&i instanceof g&&r instanceof g)return new g(s.data.map((c,u)=>this._smoothstep(i.data[u],r.data[u],c)),s.typeInfo);const o=i,a=r,l=s;return new v(this._smoothstep(o.value,a.value,l.value),s.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.sqrt(s)),i.typeInfo);const r=i;return new v(Math.sqrt(r.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof g&&i instanceof g)return new g(r.data.map((o,a)=>o<i.data[a]?0:1),r.typeInfo);const s=i;return new v(r.value<s.value?0:1,s.typeInfo)}Tan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tan(s)),i.typeInfo);const r=i;return new v(Math.tan(r.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.tanh(s)),i.typeInfo);const r=i;return new v(Math.tanh(r.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof K))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const r=this._getTransposeType(i.typeInfo);if(i.typeInfo.name==="mat2x2"||i.typeInfo.name==="mat2x2f"||i.typeInfo.name==="mat2x2h"){const s=i.data;return new K([s[0],s[2],s[1],s[3]],r)}if(i.typeInfo.name==="mat2x3"||i.typeInfo.name==="mat2x3f"||i.typeInfo.name==="mat2x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7]],r)}if(i.typeInfo.name==="mat2x4"||i.typeInfo.name==="mat2x4f"||i.typeInfo.name==="mat2x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13]],r)}if(i.typeInfo.name==="mat3x2"||i.typeInfo.name==="mat3x2f"||i.typeInfo.name==="mat3x2h"){const s=i.data;return new K([s[0],s[3],s[1],s[4],s[2],s[5]],r)}if(i.typeInfo.name==="mat3x3"||i.typeInfo.name==="mat3x3f"||i.typeInfo.name==="mat3x3h"){const s=i.data;return new K([s[0],s[3],s[6],s[1],s[4],s[7],s[2],s[5],s[8]],r)}if(i.typeInfo.name==="mat3x4"||i.typeInfo.name==="mat3x4f"||i.typeInfo.name==="mat3x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14]],r)}if(i.typeInfo.name==="mat4x2"||i.typeInfo.name==="mat4x2f"||i.typeInfo.name==="mat4x2h"){const s=i.data;return new K([s[0],s[4],s[1],s[5],s[2],s[6]],r)}if(i.typeInfo.name==="mat4x3"||i.typeInfo.name==="mat4x3f"||i.typeInfo.name==="mat4x3h"){const s=i.data;return new K([s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]],r)}if(i.typeInfo.name==="mat4x4"||i.typeInfo.name==="mat4x4f"||i.typeInfo.name==="mat4x4h"){const s=i.data;return new K([s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]],r)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof g)return new g(i.data.map(s=>Math.trunc(s)),i.typeInfo);const r=i;return new v(Math.trunc(r.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof Ze){const s=i.name,o=t.getVariableValue(s);if(o instanceof Ct){if(r<0||r>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const a=o.getMipLevelSize(r),l=o.dimension;return l==="1d"?new v(a[0],this.getTypeInfo("u32")):l==="3d"?new g(a,this.getTypeInfo("vec3u")):l==="2d"?new g(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${l} not found. Line ${e.line}`),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof Ze){const o=i.name,a=t.getVariableValue(o);if(a instanceof Ct){const l=Math.floor(r.data[0]),c=Math.floor(r.data[1]);if(l<0||l>=a.width||c<0||c>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const u=a.getPixel(l,c,0,s);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new g(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof Ze){const r=i.name,s=t.getVariableValue(r);return s instanceof Ct?new v(s.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof g)||r.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof Ze){const a=i.name,l=t.getVariableValue(a);if(l instanceof Ct){const c=l.getMipLevelSize(0),u=Math.floor(r.data[0]),f=Math.floor(r.data[1]);return u<0||u>=c[0]||f<0||f>=c[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(l.setPixel(u,f,0,s,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t);return t.getVariable(r).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value+=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicSub(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value-=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMax(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.max(l.value,a.value)),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicMin(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=Math.min(l.value,a.value)),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicAnd(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value&a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicOr(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value|a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicXor(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=l.value^a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicExchange(e,t){let i=e.args[0];i instanceof Se&&(i=i.right);const r=this.exec.getVariableName(i,t),s=t.getVariable(r);let o=e.args[1];const a=this.exec.evalExpression(o,t),l=s.value.getSubData(this.exec,i.postfix,t),c=new v(l.value,l.typeInfo);return l instanceof v&&a instanceof v&&(l.value=a.value),s.value instanceof ve&&s.value.setDataValue(this.exec,l,i.postfix,t),c}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const So={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},He={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class Ne extends m0{constructor(e,t){var i;super(),this.ast=e??[],this.reflection=new _t,this.reflection.updateAST(this.ast),this.context=(i=t==null?void 0:t.clone())!==null&&i!==void 0?i:new bo,this.builtins=new g0(this),this.typeInfo={bool:this.getTypeInfo(k.bool),i32:this.getTypeInfo(k.i32),u32:this.getTypeInfo(k.u32),f32:this.getTypeInfo(k.f32),f16:this.getTypeInfo(k.f16),vec2f:this.getTypeInfo(T.vec2f),vec2u:this.getTypeInfo(T.vec2u),vec2i:this.getTypeInfo(T.vec2i),vec2h:this.getTypeInfo(T.vec2h),vec3f:this.getTypeInfo(T.vec3f),vec3u:this.getTypeInfo(T.vec3u),vec3i:this.getTypeInfo(T.vec3i),vec3h:this.getTypeInfo(T.vec3h),vec4f:this.getTypeInfo(T.vec4f),vec4u:this.getTypeInfo(T.vec4u),vec4i:this.getTypeInfo(T.vec4i),vec4h:this.getTypeInfo(T.vec4h),mat2x2f:this.getTypeInfo(T.mat2x2f),mat2x3f:this.getTypeInfo(T.mat2x3f),mat2x4f:this.getTypeInfo(T.mat2x4f),mat3x2f:this.getTypeInfo(T.mat3x2f),mat3x3f:this.getTypeInfo(T.mat3x3f),mat3x4f:this.getTypeInfo(T.mat3x4f),mat4x2f:this.getTypeInfo(T.mat4x2f),mat4x3f:this.getTypeInfo(T.mat4x3f),mat4x4f:this.getTypeInfo(T.mat4x4f)}}getVariableValue(e){var t,i;const r=(i=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&i!==void 0?i:null;if(r===null)return null;if(r instanceof v)return r.value;if(r instanceof g||r instanceof K)return Array.from(r.data);if(r instanceof ve&&r.typeInfo instanceof Mt){if(r.typeInfo.format.name==="u32")return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="i32")return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if(r.typeInfo.format.name==="f32")return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,r){const s=this.context.clone();(r=r??{}).constants&&this._setOverrides(r.constants,s),this._execStatements(this.ast,s);const o=s.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const a=t[0],l=t[1],c=t[2],u=this.getTypeInfo("vec3u");s.setVariable("@num_workgroups",new g(t,u));const f=this.reflection.getFunctionInfo(e);f===null&&console.error(`Function ${e} not found in reflection data`);for(const h in i)for(const d in i[h]){const _=i[h][d];s.variables.forEach(I=>{var P;const A=I.node;if(A!=null&&A.attributes){let O=null,E=null;for(const x of A.attributes)x.name==="binding"?O=x.value:x.name==="group"&&(E=x.value);if(d==O&&h==E){let x=!1;for(const R of f.resources)if(R.name===I.name&&R.group===parseInt(h)&&R.binding===parseInt(d)){x=!0;break}if(x)if(_.texture!==void 0&&_.descriptor!==void 0){const R=new Ct(_.texture,this.getTypeInfo(A.type),_.descriptor,(P=_.texture.view)!==null&&P!==void 0?P:null);I.value=R}else _.uniform!==void 0?I.value=new ve(_.uniform,this.getTypeInfo(A.type)):I.value=new ve(_,this.getTypeInfo(A.type))}}})}for(let h=0;h<c;++h)for(let d=0;d<l;++d)for(let _=0;_<a;++_)s.setVariable("@workgroup_id",new g([_,d,h],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[_,d,h],s)}execStatement(e,t){if(e instanceof au)return this.evalExpression(e.value,t);if(e instanceof cu){if(e.condition){const i=this.evalExpression(e.condition,t);if(!(i instanceof v))throw new Error("Invalid break-if condition");if(!i.value)return null}return Ne._breakObj}if(e instanceof uu)return Ne._continueObj;if(e instanceof Kn)this._let(e,t);else if(e instanceof wt)this._var(e,t);else if(e instanceof fr)this._const(e,t);else if(e instanceof jn)this._function(e,t);else{if(e instanceof ou)return this._if(e,t);if(e instanceof su)return this._switch(e,t);if(e instanceof tu)return this._for(e,t);if(e instanceof eu)return this._while(e,t);if(e instanceof ru)return this._loop(e,t);if(e instanceof fo){const i=t.clone();return i.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,i)}if(e instanceof iu)this._assign(e,t);else if(e instanceof nu)this._increment(e,t);else{if(e instanceof At)return null;if(e instanceof ho){const i=e.name;t.getVariable(i)===null&&t.setVariable(i,new v(0,this.getTypeInfo("u32")))}else if(e instanceof po)this._call(e,t);else{if(e instanceof lu||e instanceof mo)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof ct?this._evalBinaryOp(e,t):e instanceof Ae?this._evalLiteral(e,t):e instanceof Ze?this._evalVariable(e,t):e instanceof go?this._evalCall(e,t):e instanceof gt?this._evalCreate(e,t):e instanceof hu?this._evalConst(e,t):e instanceof du?this._evalBitcast(e,t):e instanceof Se?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof k){const r=this.reflection.getTypeInfo(e);if(r!==null)return r}let i=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return i!==null||(i=this.reflection.getTypeInfoByName(e)),i}_setOverrides(e,t){for(const i in e){const r=e[i],s=this.reflection.getOverrideInfo(i);s!==null?(s.type===null&&(s.type=this.getTypeInfo("u32")),s.type.name==="u32"||s.type.name==="i32"||s.type.name==="f32"||s.type.name==="f16"?t.setVariable(i,new v(r,s.type)):s.type.name==="bool"?t.setVariable(i,new v(r?1:0,s.type)):s.type.name==="vec2"||s.type.name==="vec3"||s.type.name==="vec4"||s.type.name==="vec2f"||s.type.name==="vec3f"||s.type.name==="vec4f"||s.type.name==="vec2i"||s.type.name==="vec3i"||s.type.name==="vec4i"||s.type.name==="vec2u"||s.type.name==="vec3u"||s.type.name==="vec4u"||s.type.name==="vec2h"||s.type.name==="vec3h"||s.type.name==="vec4h"?t.setVariable(i,new g(r,s.type)):console.error(`Invalid constant type for ${i}`)):console.error(`Override ${i} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,i){const r=[1,1,1];for(const u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){const f=i.getVariableValue(u.value[0]);r[0]=f instanceof v?f.value:parseInt(u.value[0])}if(u.value.length>1){const f=i.getVariableValue(u.value[1]);r[1]=f instanceof v?f.value:parseInt(u.value[1])}if(u.value.length>2){const f=i.getVariableValue(u.value[2]);r[2]=f instanceof v?f.value:parseInt(u.value[2])}}const s=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new g(r,s));const a=r[0],l=r[1],c=r[2];for(let u=0,f=0;u<c;++u)for(let h=0;h<l;++h)for(let d=0;d<a;++d,++f){const _=[d,h,u],I=[d+t[0]*r[0],h+t[1]*r[1],u+t[2]*r[2]];i.setVariable("@local_invocation_id",new g(_,s)),i.setVariable("@global_invocation_id",new g(I,s)),i.setVariable("@local_invocation_index",new v(f,o)),this._dispatchExec(e,i)}}_dispatchExec(e,t){for(const i of e.node.args)for(const r of i.attributes)if(r.name==="builtin"){const s=`@${r.value}`,o=t.getVariable(s);o!==void 0&&t.variables.set(i.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof Se;)e=e.right;return e instanceof Ze?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(const i of e){if(i instanceof Array){const s=t.clone(),o=this._execStatements(i,s);if(o)return o;continue}const r=this.execStatement(i,t);if(r)return r}return null}_call(e,t){const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(r){for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.setVariable(o.name,a,o)}this._execStatements(r.node.body,i)}else e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const i=this.getVariableName(e.variable,t),r=t.getVariable(i);r?e.operator==="++"?r.value instanceof v?r.value.value++:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):e.operator==="--"?r.value instanceof v?r.value.value--:console.error(`Variable ${i} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${i} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof Ze){const i=this.getVariableName(e,t),r=t.getVariable(i);return r===null?(console.error(`Variable ${i} not found. Line ${e.line}`),null):r.value.getSubData(this,e.postfix,t)}if(e instanceof Se){if(e.operator==="*"){const i=this._getVariableData(e.right,t);return i instanceof xn?i.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){const i=this._getVariableData(e.right,t);return new xn(i)}}return null}_assign(e,t){let i=null,r="<var>",s=null;if(e.variable instanceof Se){const l=this._getVariableData(e.variable,t),c=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(l instanceof v||l instanceof g||l instanceof K){if(c instanceof v||c instanceof g||c instanceof K&&l.data.length===c.data.length)return void l.data.set(c.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(l instanceof ve&&c instanceof ve&&l.buffer.byteLength-l.offset>=c.buffer.byteLength-c.offset)return void(l.buffer.byteLength%4==0?new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4).set(new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4)):new Uint8Array(l.buffer,l.offset,l.typeInfo.size).set(new Uint8Array(c.buffer,c.offset,c.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return l instanceof v||l instanceof g||l instanceof K?c instanceof v||c instanceof g||c instanceof K?void l.data.set(c.data.map((f,h)=>l.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(l instanceof v||l instanceof g||l instanceof K)&&(c instanceof v||c instanceof g||c instanceof K)?void l.data.set(c.data.map((f,h)=>l.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Se){if(e.variable.operator==="*"){r=this.getVariableName(e.variable.right,t);const l=t.getVariable(r);if(!(l&&l.value instanceof xn))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);i=l.value.reference;let c=e.variable.postfix;if(!c){let u=e.variable.right;for(;u instanceof Se;){if(u.postfix){c=u.postfix;break}u=u.right}}c&&(i=i.getSubData(this,c,t))}}else{s=e.variable.postfix,r=this.getVariableName(e.variable,t);const l=t.getVariable(r);if(l===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);i=l.value}if(i instanceof xn&&(i=i.reference),i===null)return void console.error(`Variable ${r} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),a=e.operator;if(a!=="="){const l=i.getSubData(this,s,t);if(l instanceof g&&o instanceof v){const c=l.data,u=o.value;if(a==="+=")for(let f=0;f<c.length;++f)c[f]+=u;else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u;else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u;else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u;else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u;else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u;else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u;else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u;else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u;else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(l instanceof g&&o instanceof g){const c=l.data,u=o.data;if(c.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let f=0;f<c.length;++f)c[f]+=u[f];else if(a==="-=")for(let f=0;f<c.length;++f)c[f]-=u[f];else if(a==="*=")for(let f=0;f<c.length;++f)c[f]*=u[f];else if(a==="/=")for(let f=0;f<c.length;++f)c[f]/=u[f];else if(a==="%=")for(let f=0;f<c.length;++f)c[f]%=u[f];else if(a==="&=")for(let f=0;f<c.length;++f)c[f]&=u[f];else if(a==="|=")for(let f=0;f<c.length;++f)c[f]|=u[f];else if(a==="^=")for(let f=0;f<c.length;++f)c[f]^=u[f];else if(a==="<<=")for(let f=0;f<c.length;++f)c[f]<<=u[f];else if(a===">>=")for(let f=0;f<c.length;++f)c[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(l instanceof v&&o instanceof v))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?l.value+=o.value:a==="-="?l.value-=o.value:a==="*="?l.value*=o.value:a==="/="?l.value/=o.value:a==="%="?l.value%=o.value:a==="&="?l.value&=o.value:a==="|="?l.value|=o.value:a==="^="?l.value^=o.value:a==="<<="?l.value<<=o.value:a===">>="?l.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}return void(i instanceof ve&&i.setDataValue(this,l,s,t))}if(i instanceof ve)i.setDataValue(this,o,s,t);else if(s){if(!(i instanceof g||i instanceof K))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(s instanceof _n){const l=this.evalExpression(s.index,t).value;if(i instanceof g){if(!(o instanceof v))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[l]=o.value}else{if(!(i instanceof K))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const c=this.evalExpression(s.index,t).value;if(c<0)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const u=i.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(c<2&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(c<2&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(c<2&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(c<3&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(c<3&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(c<3&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(c<4&&o.data.length===2))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*c]=o.data[0],i.data[2*c+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(c<4&&o.data.length===3))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*c]=o.data[0],i.data[3*c+1]=o.data[1],i.data[3*c+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(c<4&&o.data.length===4))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*c]=o.data[0],i.data[4*c+1]=o.data[1],i.data[4*c+2]=o.data[2],i.data[4*c+3]=o.data[3]}}}}}else if(s instanceof jt){const l=s.value;if(!(i instanceof g))return void console.error(`Invalid assignment to ${l}. Variable ${r} is not a vector. Line ${e.line}`);if(o instanceof v){if(l.length>1)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);if(l==="x")i.data[0]=o.value;else if(l==="y"){if(i.data.length<2)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[1]=o.value}else if(l==="z"){if(i.data.length<3)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[2]=o.value}else if(l==="w"){if(i.data.length<4)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof g))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(l.length!==o.data.length)return void console.error(`Invalid assignment to ${l} for variable ${r}. Line ${e.line}`);for(let c=0;c<l.length;++c){const u=l[c];if(u==="x"||u==="r")i.data[0]=o.data[c];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[1]=o.data[c]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[2]=o.data[c]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${r}. Line ${e.line}`);i.data[3]=o.data[c]}}}}}else i instanceof v&&o instanceof v?i.value=o.value:i instanceof g&&o instanceof g||i instanceof K&&o instanceof K?i.data.set(o.data):console.error(`Invalid assignment to ${r}. Line ${e.line}`)}_function(e,t){const i=new vo(e);t.functions.set(e.name,i)}_const(e,t){let i=null;e.value!==null&&(i=this.evalExpression(e.value,t)),t.createVariable(e.name,i,e)}_let(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Se||(i=i.clone())}else{const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||r==="array"){const s=new gt(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_var(e,t){let i=null;if(e.value!==null){if(i=this.evalExpression(e.value,t),i===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof Se||(i=i.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);const r=e.type.name;if(r==="f32"||r==="i32"||r==="u32"||r==="bool"||r==="f16"||r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2b"||r==="vec3b"||r==="vec4b"||r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"||e.type instanceof Qn||e.type instanceof At||e.type instanceof T){const s=new gt(e.type,[]);i=this._evalCreate(s,t)}}t.createVariable(e.name,i,e)}_switch(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;let r=null;for(const s of e.cases)if(s instanceof gu)for(const o of s.selectors){if(o instanceof dr){r=s;continue}const a=this.evalExpression(o,t);if(!(a instanceof v))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===i.value)return this._execStatements(s.body,t)}else s instanceof _u&&(r=s);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();const i=this.evalExpression(e.condition,t);if(!(i instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(e.body,t);for(const r of e.elseif){const s=this.evalExpression(r.condition,t);if(!(s instanceof v))return console.error(`Invalid if condition. Line ${e.line}`),null;if(s.value)return this._execStatements(r.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof v?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Ne._breakObj)break;if(i!==null&&i!==Ne._continueObj)return i;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const i=this._execStatements(e.body,t);if(i===Ne._breakObj)break;if(i===Ne._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===Ne._breakObj)break}else if(i!==null)return i}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const i=this._execStatements(e.body,t);if(i===Ne._breakObj)break;if(i!==Ne._continueObj&&i!==null)return i}return null}_evalBitcast(e,t){const i=this.evalExpression(e.value,t),r=e.type;if(i instanceof v){const s=Su(i.value,i.typeInfo.name,r.name);return new v(s,this.getTypeInfo(r))}if(i instanceof g){const s=i.typeInfo.getTypeName();let o="";if(s.endsWith("f"))o="f32";else if(s.endsWith("i"))o="i32";else if(s.endsWith("u"))o="u32";else if(s.endsWith("b"))o="bool";else{if(!s.endsWith("h"))return console.error(`Unknown vector type ${s}. Line ${e.line}`),null;o="f16"}const a=r.getTypeName();let l="";if(a.endsWith("f"))l="f32";else if(a.endsWith("i"))l="i32";else if(a.endsWith("u"))l="u32";else if(a.endsWith("b"))l="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${l}. Line ${e.line}`),null;l="f16"}const c=function(u,f,h){if(f===h)return u;const d=new Array(u.length);for(let _=0;_<u.length;_++)d[_]=Su(u[_],f,h);return d}(Array.from(i.data),o,l);return new g(c,this.getTypeInfo(r))}return console.error(`TODO: bitcast for ${i.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var i;if(e instanceof gt){if(e.type===null)return _o.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}const r=e instanceof gt?e.type.name:e.name,s=e instanceof gt?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(s===null)return console.error(`Unknown type ${r}. Line ${e.line}`),null;if(s.size===0)return null;const o=new ve(new ArrayBuffer(s.size),s,0);if(s instanceof Dt){if(e.args)for(let a=0;a<e.args.length;++a){const l=s.members[a],c=e.args[a],u=this.evalExpression(c,t);o.setData(this,u,l.type,l.offset,t)}}else if(s instanceof Mt){let a=0;if(e.args)for(let l=0;l<e.args.length;++l){const c=e.args[l],u=this.evalExpression(c,t);s.format===null&&(((i=u.typeInfo)===null||i===void 0?void 0:i.name)==="x32"?s.format=this.getTypeInfo("i32"):s.format=u.typeInfo),o.setData(this,u,s.format,a,t),a+=s.stride}}else console.error(`Unknown type "${r}". Line ${e.line}`);return e instanceof gt?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){const i=this.getTypeInfo(e.type),r=i.name;return r==="x32"||r==="u32"||r==="f32"||r==="f16"||r==="i32"||r==="bool"?new v(e.scalarValue,i):r==="vec2"||r==="vec3"||r==="vec4"||r==="vec2f"||r==="vec3f"||r==="vec4f"||r==="vec2h"||r==="vec3h"||r==="vec4h"||r==="vec2i"||r==="vec3i"||r==="vec4i"||r==="vec2u"||r==="vec3u"||r==="vec4u"?this._callConstructorVec(e,t):r==="mat2x2"||r==="mat2x3"||r==="mat2x4"||r==="mat3x2"||r==="mat3x3"||r==="mat3x4"||r==="mat4x2"||r==="mat4x3"||r==="mat4x4"||r==="mat2x2f"||r==="mat2x3f"||r==="mat2x4f"||r==="mat3x2f"||r==="mat3x3f"||r==="mat3x4f"||r==="mat4x2f"||r==="mat4x3f"||r==="mat4x4f"||r==="mat2x2h"||r==="mat2x3h"||r==="mat2x4h"||r==="mat3x2h"||r==="mat3x3h"||r==="mat3x4h"||r==="mat4x2h"||r==="mat4x3h"||r==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const i=t.getVariableValue(e.name);return i===null?i:i.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let i=1;i<e.length;++i){const r=Ne._priority.get(t.name);Ne._priority.get(e[i].name)<r&&(t=e[i])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const i=this.evalExpression(e.right,t);if(e.operator==="&")return new xn(i);if(e.operator==="*")return i instanceof xn?i.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);const r=i instanceof v?i.value:i instanceof g?Array.from(i.data):null;switch(e.operator){case"+":{if(z(r)){const a=r.map((l,c)=>+l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(+s,o)}case"-":{if(z(r)){const a=r.map((l,c)=>-l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(-s,o)}case"!":{if(z(r)){const a=r.map((l,c)=>l?0:1);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(s?0:1,o)}case"~":{if(z(r)){const a=r.map((l,c)=>~l);return new g(a,i.typeInfo)}const s=r,o=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new v(~s,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),s=i instanceof v?i.value:i instanceof g||i instanceof K?Array.from(i.data):null,o=r instanceof v?r.value:r instanceof g||r instanceof K?Array.from(r.data):null;switch(e.operator){case"+":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d+f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h+u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u+h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a+l,c)}case"-":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d-f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h-u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u-h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a-l,c)}case"*":{if(z(s)&&z(o)){const u=s,f=o;if(i instanceof K&&r instanceof K){const h=function(P,A,O,E){if(He[A.name]===void 0||He[E.name]===void 0)return null;const x=He[A.name][0],R=He[A.name][1],N=He[E.name][0];if(x!==He[E.name][1])return null;const U=new Array(N*R);for(let W=0;W<R;W++)for(let q=0;q<N;q++){let G=0;for(let B=0;B<x;B++)G+=P[B*R+W]*O[q*x+B];U[W*N+q]=G}return U}(u,i.typeInfo,f,r.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;const d=He[r.typeInfo.name][0],_=He[i.typeInfo.name][1],I=this.getTypeInfo(`mat${d}x${_}f`);return new K(h,I)}if(i instanceof K&&r instanceof g){const h=function(d,_,I,P){if(He[_.name]===void 0||So[P.name]===void 0)return null;const A=He[_.name][0],O=He[_.name][1];if(A!==I.length)return null;const E=new Array(O);for(let x=0;x<O;x++){let R=0;for(let N=0;N<A;N++)R+=d[N*O+x]*I[N];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,r.typeInfo)}if(i instanceof g&&r instanceof K){const h=function(d,_,I,P){if(So[_.name]===void 0||He[P.name]===void 0)return null;const A=He[P.name][0],O=He[P.name][1];if(O!==d.length)return null;const E=[];for(let x=0;x<A;x++){let R=0;for(let N=0;N<O;N++)R+=d[N]*I[N*A+x];E[x]=R}return E}(u,i.typeInfo,f,r.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,i.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d*f[_]);return new g(h,i.typeInfo)}}if(z(s)){const u=o,f=s.map((h,d)=>h*u);return i instanceof K?new K(f,i.typeInfo):new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u*h);return r instanceof K?new K(f,r.typeInfo):new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a*l,c)}case"%":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d%f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h%u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u%h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a%l,c)}case"/":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d/f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h/u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u/h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a/l,c)}case"&":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d&f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h&u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u&h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a&l,c)}case"|":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d|f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h|u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u|h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a|l,c)}case"^":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d^f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h^u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u^h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a^l,c)}case"<<":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d<<f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h<<u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u<<h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a<<l,c)}case">>":{if(z(s)&&z(o)){const u=s,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const h=u.map((d,_)=>d>>f[_]);return new g(h,i.typeInfo)}if(z(s)){const u=o,f=s.map((h,d)=>h>>u);return new g(f,i.typeInfo)}if(z(o)){const u=s,f=o.map((h,d)=>u>>h);return new g(f,r.typeInfo)}const a=s,l=o,c=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new v(a>>l,c)}case">":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c>a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a>c?1:0);return new g(l,r.typeInfo)}return new v(s>o?1:0,this.getTypeInfo("bool"));case"<":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c<a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a<c?1:0);return new g(l,r.typeInfo)}return new v(s<o?1:0,this.getTypeInfo("bool"));case"==":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u===l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c==a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a==c?1:0);return new g(l,r.typeInfo)}return new v(s===o?1:0,this.getTypeInfo("bool"));case"!=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u!==l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c!==a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a!==c?1:0);return new g(l,r.typeInfo)}return new v(s!==o?1:0,this.getTypeInfo("bool"));case">=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u>=l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c>=a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a>=c?1:0);return new g(l,r.typeInfo)}return new v(s>=o?1:0,this.getTypeInfo("bool"));case"<=":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u<=l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c<=a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a<=c?1:0);return new g(l,r.typeInfo)}return new v(s<=o?1:0,this.getTypeInfo("bool"));case"&&":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u&&l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c&&a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a&&c?1:0);return new g(l,r.typeInfo)}return new v(s&&o?1:0,this.getTypeInfo("bool"));case"||":if(z(s)&&z(o)){const a=s,l=o;if(a.length!==l.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const c=a.map((u,f)=>u||l[f]?1:0);return new g(c,i.typeInfo)}if(z(s)){const a=o,l=s.map((c,u)=>c||a?1:0);return new g(l,i.typeInfo)}if(z(o)){const a=s,l=o.map((c,u)=>a||c?1:0);return new g(l,r.typeInfo)}return new v(s||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let s=0;s<r.node.args.length;++s){const o=r.node.args[s],a=this.evalExpression(e.args[s],i);i.createVariable(o.name,a,o)}return this._execStatements(r.node.body,i)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const i=t.getFunction(e.name);if(i){const r=t.clone();for(let s=0;s<i.node.args.length;++s){const o=i.node.args[s],a=this.evalExpression(e.args[s],r);r.setVariable(o.name,a,o)}return this._execStatements(i.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new v(0,this.getTypeInfo(e.type));const i=this.evalExpression(e.args[0],t);return i.typeInfo=this.getTypeInfo(e.type),i.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=So[r];if(s===void 0)return console.error(`Invalid vec constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Ae)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);if(l instanceof g){const c=l.data;for(let u=0;u<c.length;++u){let f=c[u];o.push(f)}}else if(l instanceof v){let c=l.value;o.push(c)}}if(e.type instanceof T&&e.type.format===null&&(e.type.format=T.f32),o.length===0){const a=new Array(s).fill(0);return new g(a,i).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<s;)o.push(o[0]);return o.length<s?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new g(o.length>s?o.slice(0,s):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=He[r];if(s===void 0)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof Ae)if(e.isVector){const a=e.vectorValue;for(const l of a)o.push(l)}else o.push(e.scalarValue);else if(e.args)for(const a of e.args){const l=this.evalExpression(a,t);l instanceof g?o.push(...l.data):l instanceof v?o.push(l.value):l instanceof K&&o.push(...l.data)}if(i instanceof qt&&i.format===null&&(i.format=this.getTypeInfo("f32")),o.length===0){const a=new Array(s[2]).fill(0);return new K(a,i).getSubData(this,e.postfix,t)}return o.length!==s[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new K(o,i).getSubData(this,e.postfix,t)}}Ne._breakObj=new et(new Je("BREAK",null),null),Ne._continueObj=new et(new Je("CONTINUE",null),null),Ne._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class _0{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class x0{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new _0,this._exec=new Ne,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const i=this._global_decl_or_directive();if(!i)break;t.push(i)}if(this._deferArrayCountEval.length>0){for(const i of this._deferArrayCountEval){const r=i.arrayType,s=i.countNode;if(s instanceof Ze){const o=s.name,a=this._context.constants.get(o);if(a)try{const l=a.constEvaluate(this._exec);r.count=l}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const i of t)i.search(r=>{r instanceof yu||r instanceof hr?r.type=this._forwardType(r.type):r instanceof Qn?r.format=this._forwardType(r.format):r instanceof wt||r instanceof Kn||r instanceof fr?r.type=this._forwardType(r.type):r instanceof jn?r.returnType=this._forwardType(r.returnType):r instanceof xu&&(r.type=this._forwardType(r.type))});return t}_forwardType(e){if(e instanceof fu){const t=this._getType(e.name);if(t)return t}else e instanceof hr?e.type=this._forwardType(e.type):e instanceof Qn&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){const t=new a0(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof S)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t<i;++t){const r=e[t];if(this._check(r))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const i=t.type;let r=!1;for(const s of e){if(i===s)return!0;s===p.tokens.name&&(r=!0)}if(r){const s=p.tokens.name.rule.exec(t.lexeme);if(s&&s.index==0&&s[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){const i=p.tokens.name.rule.exec(t.lexeme);return i&&i.index==0&&i[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){const t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){const t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){const t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){const t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}const e=this._attribute();if(this._check(p.keywords.var)){const t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){const t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){const t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){const t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){const t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){const t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");const i=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;const a=this._attribute(),l=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");const c=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=c,i.push(this._updateNode(new xu(l,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(p.tokens.arrow)){const a=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=a)}const s=this._compound_statement(),o=this._currentLine;return this._updateNode(new jn(t,i,r,s,e,o),e)}_compound_statement(){const e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){const t=this._statement();t!==null&&e.push(t)}return this._consume(p.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._check(p.tokens.attr)&&this._attribute(),this._check(p.keywords.if))return this._if_statement();if(this._check(p.keywords.switch))return this._switch_statement();if(this._check(p.keywords.loop))return this._loop_statement();if(this._check(p.keywords.for))return this._for_statement();if(this._check(p.keywords.while))return this._while_statement();if(this._check(p.keywords.continuing))return this._continuing_statement();if(this._check(p.keywords.static_assert))return this._static_assert_statement();if(this._check(p.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(p.keywords.return))e=this._return_statement();else if(this._check([p.keywords.var,p.keywords.let,p.keywords.const]))e=this._variable_statement();else if(this._match(p.keywords.discard))e=this._updateNode(new r0);else if(this._match(p.keywords.break)){const t=this._updateNode(new cu);if(this._currentLoop.length>0){const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){const t=this._updateNode(new uu);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const i=this._currentLoop[this._currentLoop.length-1];t.loopId=i.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(p.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(p.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new t0(t),e)}_while_statement(){if(!this._match(p.keywords.while))return null;const e=this._updateNode(new eu(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(p.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new fo(i,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");const e=this._updateNode(new tu(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(p.tokens.semicolon)?null:this._for_init(),this._consume(p.tokens.semicolon,"Expected ';'."),e.condition=this._check(p.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(p.tokens.semicolon,"Expected ';'."),e.increment=this._check(p.tokens.paren_right)?null:this._for_increment(),this._consume(p.tokens.paren_right,"Expected ')'."),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(p.keywords.var)){const e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new wt(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new Kn(t,i,null,null,r),e)}if(this._match(p.keywords.const)){const e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString();let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}this._consume(p.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return i===null&&r instanceof Ae&&(i=r.type),this._updateNode(new fr(t,i,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;const i=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new nu(i.type===p.tokens.plus_plus?gn.increment:gn.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let i=this._match(p.tokens.underscore);if(i||(e=this._unary_expression()),!i&&e==null)return null;const r=this._consume(p.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return this._updateNode(new iu(Zn.parse(r.lexeme),e,s),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume(p.tokens.ident,"Expected function name."),r=this._argument_expression_list();return r===null?(this._current=t,null):this._updateNode(new po(i.lexeme,r),e)}_loop_statement(){if(!this._match(p.keywords.loop))return null;this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new ru([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof fo){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(p.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(p.keywords.switch))return null;const e=this._updateNode(new su(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),e.cases==null||e.cases.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(p.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){const i=this._case_selectors();for(const s of i)if(s instanceof dr){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch case.");const r=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new gu(i,r)))}if(this._match(p.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new _u(i)))}}return e}_case_selectors(){const e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new dr)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new dr)):e.push(this._shift_expression());return e}_case_body(){if(this._match(p.keywords.fallthrough))return this._consume(p.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);const t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();const i=this._compound_statement();let r=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let s=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),s=this._compound_statement()),this._updateNode(new ou(t,i,r,s),e)}_match_elseif(){return this._tokens[this._current].type===p.keywords.else&&this._tokens[this._current+1].type===p.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new s0(t,i))),this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(p.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new au(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new ct(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(p.tokens.and_and);)e=this._updateNode(new ct(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(p.tokens.or);)e=this._updateNode(new ct(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(p.tokens.xor);)e=this._updateNode(new ct(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(p.tokens.and);)e=this._updateNode(new ct(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([p.tokens.equal_equal,p.tokens.not_equal])?this._updateNode(new ct(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([p.tokens.less_than,p.tokens.greater_than,p.tokens.less_than_equal,p.tokens.greater_than_equal]);)e=this._updateNode(new ct(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([p.tokens.shift_left,p.tokens.shift_right]);)e=this._updateNode(new ct(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([p.tokens.plus,p.tokens.minus]);)e=this._updateNode(new ct(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([p.tokens.star,p.tokens.forward_slash,p.tokens.modulo]);)e=this._updateNode(new ct(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([p.tokens.minus,p.tokens.bang,p.tokens.tilde,p.tokens.star,p.tokens.and])?this._updateNode(new Se(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new _n(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match(p.tokens.period)){const e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new jt(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return k.void;case"bool":return k.bool;case"i32":return k.i32;case"u32":return k.u32;case"f32":return k.f32;case"f16":return k.f16;case"vec2f":return T.vec2f;case"vec3f":return T.vec3f;case"vec4f":return T.vec4f;case"vec2i":return T.vec2i;case"vec3i":return T.vec3i;case"vec4i":return T.vec4i;case"vec2u":return T.vec2u;case"vec3u":return T.vec3u;case"vec4u":return T.vec4u;case"vec2h":return T.vec2h;case"vec3h":return T.vec3h;case"vec4h":return T.vec4h;case"mat2x2f":return T.mat2x2f;case"mat2x3f":return T.mat2x3f;case"mat2x4f":return T.mat2x4f;case"mat3x2f":return T.mat3x2f;case"mat3x3f":return T.mat3x3f;case"mat3x4f":return T.mat3x4f;case"mat4x2f":return T.mat4x2f;case"mat4x3f":return T.mat4x3f;case"mat4x4f":return T.mat4x4f;case"mat2x2h":return T.mat2x2h;case"mat2x3h":return T.mat2x3h;case"mat2x4h":return T.mat2x4h;case"mat3x2h":return T.mat3x2h;case"mat3x3h":return T.mat3x3h;case"mat3x4h":return T.mat3x4h;case"mat4x2h":return T.mat4x2h;case"mat4x3h":return T.mat4x3h;case"mat4x4h":return T.mat4x4h;case"mat2x2i":return T.mat2x2i;case"mat2x3i":return T.mat2x3i;case"mat2x4i":return T.mat2x4i;case"mat3x2i":return T.mat3x2i;case"mat3x3i":return T.mat3x3i;case"mat3x4i":return T.mat3x4i;case"mat4x2i":return T.mat4x2i;case"mat4x3i":return T.mat4x3i;case"mat4x4i":return T.mat4x4i;case"mat2x2u":return T.mat2x2u;case"mat2x3u":return T.mat2x3u;case"mat2x4u":return T.mat2x4u;case"mat3x2u":return T.mat3x2u;case"mat3x3u":return T.mat3x3u;case"mat3x4u":return T.mat3x4u;case"mat4x2u":return T.mat4x2u;case"mat4x3u":return T.mat4x3u;case"mat4x4u":return T.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){const i=this._previous().toString();if(this._check(p.tokens.paren_left)){const r=this._argument_expression_list(),s=this._getType(i);return s!==null?this._updateNode(new gt(s,r)):this._updateNode(new go(i,r))}if(this._context.constants.has(i)){const r=this._context.constants.get(i);return this._updateNode(new hu(i,r.value))}return this._updateNode(new Ze(i))}if(this._match(p.tokens.int_literal)){const i=this._previous().toString();let r=i.endsWith("i")||i.endsWith("i")?k.i32:i.endsWith("u")||i.endsWith("U")?k.u32:k.x32;const s=parseInt(i);return this._validateTypeRange(s,r),this._updateNode(new Ae(new v(s,this._exec.getTypeInfo(r)),r))}if(this._match(p.tokens.uint_literal)){const i=parseInt(this._previous().toString());return this._validateTypeRange(i,k.u32),this._updateNode(new Ae(new v(i,this._exec.getTypeInfo(k.u32)),k.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let i=this._previous().toString(),r=i.endsWith("h");r&&(i=i.substring(0,i.length-1));const s=parseFloat(i);this._validateTypeRange(s,r?k.f16:k.f32);const o=r?k.f16:k.f32;return this._updateNode(new Ae(new v(s,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let i=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new Ae(new v(i?1:0,this._exec.getTypeInfo(k.bool)),k.bool))}if(this._check(p.tokens.paren_left))return this._paren_expression();if(this._match(p.keywords.bitcast)){this._consume(p.tokens.less_than,"Expected '<'.");const i=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");const r=this._paren_expression();return this._updateNode(new du(i,r))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new gt(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;const e=[];do{if(this._check(p.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_paren_expression(){this._consume(p.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(p.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(p.keywords.struct))return null;const e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check(p.tokens.brace_right);){const o=this._attribute(),a=this._consume(p.tokens.name,"Expected variable name.").toString();this._consume(p.tokens.colon,"Expected ':' for struct member type.");const l=this._attribute(),c=this._type_decl();c!=null&&(c.attributes=l),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new yu(a,c,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,s=this._updateNode(new At(t,i,e,r),e);return this._context.structs.set(t,s),s}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){const t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof Ae){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof Ae&&(e.type=e.value.type.name==="x32"?k.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(p.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(p.keywords.const))return null;const t=this._consume(p.tokens.name,"Expected variable name"),i=this._currentLine;let r=null;if(this._match(p.tokens.colon)){const l=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=l)}let s=null;this._consume(p.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let l=[k.f32],c=o.constEvaluate(this._exec,l);c instanceof v&&this._validateTypeRange(c.value,l[0]),l[0]instanceof T&&l[0].format===null&&c.typeInfo instanceof qt&&c.typeInfo.format!==null&&(c.typeInfo.format.name==="f16"?l[0].format=k.f16:c.typeInfo.format.name==="f32"?l[0].format=k.f32:c.typeInfo.format.name==="i32"?l[0].format=k.i32:c.typeInfo.format.name==="u32"?l[0].format=k.u32:c.typeInfo.format.name==="bool"?l[0].format=k.bool:console.error(`TODO: impelement template format type ${c.typeInfo.format.name}`)),s=this._updateNode(new Ae(c,l[0])),this._exec.context.setVariable(t.toString(),c)}catch{s=o}if(r!==null&&s instanceof Ae){if(s.type.name!=="x32"&&r.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${r.name}. Line:${this._currentLine}`);s.type=r,s.isScalar&&this._validateTypeRange(s.scalarValue,s.type)}else r===null&&s instanceof Ae&&(r=(e=s==null?void 0:s.type)!==null&&e!==void 0?e:k.f32,r===k.x32&&(r=k.i32));const a=this._updateNode(new fr(t.toString(),r,"","",s),i);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;const e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name");let i=null;if(this._match(p.tokens.colon)){const s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}let r=null;if(this._match(p.tokens.equal)&&(r=this._const_expression()),i!==null&&r instanceof Ae){if(r.type.name!=="x32"&&i.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${i.name}. Line:${this._currentLine}`);r.type=i}else i===null&&r instanceof Ae&&(i=r.type.name==="x32"?k.i32:r.type);return r instanceof Ae&&r.isScalar&&this._validateTypeRange(r.scalarValue,i),this._updateNode(new Kn(t.toString(),i,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));const r=this._consume(p.tokens.name,"Expected variable name");let s=null;if(this._match(p.tokens.colon)){const o=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=o)}return this._updateNode(new wt(r.toString(),s,t,i,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;const e=this._consume(p.tokens.name,"Expected variable name");let t=null;if(this._match(p.tokens.colon)){const i=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=i)}return this._updateNode(new ho(e.toString(),t,null))}_diagnostic(){this._consume(p.tokens.paren_left,"Expected '('");const e=this._consume(p.tokens.ident,"Expected severity control name.");this._consume(p.tokens.comma,"Expected ','");let t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new lu(e.toString(),t))}_enable_directive(){const e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new n0(e.toString()))}_requires_directive(){const e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){const t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new i0(e))}_type_alias(){const e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new mo(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){const i=this._advance().toString();if(this._context.structs.has(i))return this._context.structs.get(i);if(this._context.aliases.has(i))return this._context.aliases.get(i).type;if(!this._getType(i)){const r=this._updateNode(new fu(i));return this._forwardTypeCount++,r}return this._updateNode(new k(i))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let i=this._advance().toString(),r=null,s=null;return this._match(p.tokens.less_than)&&(r=this._type_decl(),s=null,this._match(p.tokens.comma)&&(s=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new T(i,r,s))}if(this._match(p.keywords.ptr)){let i=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");const r=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");const s=this._type_decl();let o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new hr(i,r.toString(),s,o))}const t=this._attribute();if(this._match(p.keywords.array)){let i=null,r=-1;const s=this._previous();let o=null;if(this._match(p.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let l="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{l=o.constEvaluate(this._exec).toString(),o=null}catch{l="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),r=l?parseInt(l):0}const a=this._updateNode(new Qn(s.toString(),t,i,r));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Jn(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Jn(this._previous().toString(),null,null));if(this._match(p.sampled_texture_type)||this._match(p.multisampled_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Jn(e.toString(),t,null))}if(this._match(p.storage_texture_type)){const e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");const i=this._consume(p.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Jn(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){const t=this._consume(p.attribute_name,"Expected attribute name"),i=this._updateNode(new vu(t.toString(),null));if(this._match(p.tokens.paren_left)){if(i.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{const r=this._consume(p.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(r)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(i)}return e.length==0?null:e}}class y0 extends _t{constructor(e){super(),e&&this.update(e)}update(e){const t=new x0().parse(e);this.updateAST(t)}}function v0(n){var s;const e={attributes:[],bindings:[]};let t;try{t=b0(n)}catch(o){return D.error(o.message)(),e}for(const o of t.uniforms){const a=[];for(const l of((s=o.type)==null?void 0:s.members)||[])a.push({name:l.name,type:Tu(l.type)});e.bindings.push({type:"uniform",name:o.name,group:o.group,location:o.binding,members:a})}for(const o of t.textures)e.bindings.push({type:"texture",name:o.name,group:o.group,location:o.binding});for(const o of t.samplers)e.bindings.push({type:"sampler",name:o.name,group:o.group,location:o.binding});const i=t.entry.vertex[0],r=(i==null?void 0:i.inputs.length)||0;for(let o=0;o<r;o++){const a=i.inputs[o];if(a.locationType==="location"){const l=Tu(a.type);e.attributes.push({name:a.name,location:Number(a.location),type:l})}}return e}function Tu(n){return n!=null&&n.format?`${n.name}<${n.format.name}>`:n.name}function b0(n){try{return new y0(n)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(t+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(t+=e.token.line||""),new Error(t,{cause:e})}}const To={};function xr(n="id"){To[n]=To[n]||1;const e=To[n]++;return`${n}-${e}`}class wu{constructor(e){m(this,"id");m(this,"userData",{});m(this,"topology");m(this,"bufferLayout",[]);m(this,"vertexCount");m(this,"indices");m(this,"attributes");if(this.id=e.id||xr("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&L.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function S0(n,e){if(e instanceof wu)return e;const t=T0(n,e),{attributes:i,bufferLayout:r}=w0(n,e);return new wu({topology:e.topology||"triangle-list",bufferLayout:r,vertexCount:e.vertexCount,indices:t,attributes:i})}function T0(n,e){if(!e.indices)return;const t=e.indices.value;return n.createBuffer({usage:L.INDEX,data:t})}function w0(n,e){const t=[],i={};for(const[s,o]of Object.entries(e.attributes)){let a=s;switch(s){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){i[a]=n.createBuffer({data:o.value,id:`${s}-buffer`});const{value:l,size:c,normalized:u}=o;t.push({name:a,format:Xp(l,c,u)})}}const r=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:t,vertexCount:r}}const Mr=class Mr{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_hashCounter",0);m(this,"_hashes",{});m(this,"_renderPipelineCache",{});m(this,"_computePipelineCache",{});this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Mr(e),e._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var o;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const t={...Wt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.log(3,`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:xr("unnamed-cached")}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}createComputePipeline(e){var o;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const t={...Bi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t);let s=(o=i[r])==null?void 0:o.pipeline;return s?(i[r].useCount++,this.debug&&D.log(3,`${this}: ${i[r].pipeline} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={pipeline:s,useCount:1},this.debug&&D.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.debug&&D.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(D.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.debug&&D.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Bi&&(t=this._computePipelineCache),e instanceof Wt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device,i=this._getHash(e.shader.source);return`${t}/C/${i}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r="-",s=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${i}V${r}BL${s}`;case"webgpu":default:const a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${i}V${r}T${e.topology}P${a}BL${s}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};m(Mr,"defaultProps",{...Wt.defaultProps});let wo=Mr;const Fr=class Fr{constructor(e){m(this,"device");m(this,"cachingEnabled");m(this,"destroyPolicy");m(this,"debug");m(this,"_cache",{});this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(e){var t;return(t=e._lumaData).defaultShaderFactory||(t.defaultShaderFactory=new Fr(e)),e._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let i=this._cache[t];if(i)i.useCount++,this.debug&&D.log(3,`${this}: Reusing shader ${i.shader.id} count=${i.useCount}`)();else{const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:r,useCount:1},this.debug&&D.log(3,`${this}: Created new shader ${r.id}`)()}return i.shader}release(e){if(!this.cachingEnabled){e.destroy();return}const t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],i.shader.destroy(),this.debug&&D.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&D.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};m(Fr,"defaultProps",{...Ni.defaultProps});let Ao=Fr;function A0(n,e){var r;const t={},i="Values";if(n.attributes.length===0&&!((r=n.varyings)!=null&&r.length))return{"No attributes or varyings":{[i]:"N/A"}};for(const s of n.attributes)if(s){const o=`${s.location} ${s.name}: ${s.type}`;t[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(const s of n.varyings||[]){const o=`${s.location} ${s.name}`;t[`out ${o}`]={[i]:JSON.stringify(s)}}return t}let Pe=null,Kt=null;function C0(n,{id:e,minimap:t,opaque:i,top:r="0",left:s="0",rgbaScale:o=1}){Pe||(Pe=document.createElement("canvas"),Pe.id=e,Pe.title=e,Pe.style.zIndex="100",Pe.style.position="absolute",Pe.style.top=r,Pe.style.left=s,Pe.style.border="blue 5px solid",Pe.style.transform="scaleY(-1)",document.body.appendChild(Pe),Kt=Pe.getContext("2d")),(Pe.width!==n.width||Pe.height!==n.height)&&(Pe.width=n.width/2,Pe.height=n.height/2,Pe.style.width="400px",Pe.style.height="400px");const a=n.device.readPixelsToArrayWebGL(n),l=Kt==null?void 0:Kt.createImageData(n.width,n.height);if(l){for(let u=0;u<a.length;u+=4)l.data[0+u+0]=a[u+0]*o,l.data[0+u+1]=a[u+1]*o,l.data[0+u+2]=a[u+2]*o,l.data[0+u+3]=i?255:a[u+3]*o;Kt==null||Kt.putImageData(l,0,0)}}function Co(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!Co(n[i],e[i],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof n=="object"&&typeof e=="object"){const i=Object.keys(n),r=Object.keys(e);if(i.length!==r.length)return!1;for(const s of i)if(!e.hasOwnProperty(s)||!Co(n[s],e[s],t-1))return!1;return!0}return!1}class Io{constructor(e){m(this,"bufferLayouts");this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?(t=e.attributes)==null?void 0:t.map(i=>i.attribute):[e.name]}mergeBufferLayouts(e,t){const i=[...e];for(const r of t){const s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}getBufferIndex(e){const t=this.bufferLayouts.findIndex(i=>i.name===e);return t===-1&&D.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function I0(n,e){const t=Object.fromEntries(n.attributes.map(r=>[r.name,r.location])),i=e.slice();return i.sort((r,s)=>{const o=r.attributes?r.attributes.map(u=>u.attribute):[r.name],a=s.attributes?s.attributes.map(u=>u.attribute):[s.name],l=Math.min(...o.map(u=>t[u])),c=Math.min(...a.map(u=>t[u]));return l-c}),i}function P0(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function E0(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function R0(n){return P0(n)||E0(n)}function k0(n){return R0(n)||typeof n=="number"||typeof n=="boolean"}function D0(n){const e={bindings:{},uniforms:{}};return Object.keys(n).forEach(t=>{const i=n[t];k0(i)?e.uniforms[t]=i:e.bindings[t]=i}),e}class M0{constructor(e,t){m(this,"options",{disableWarnings:!1});m(this,"modules");m(this,"moduleUniforms");m(this,"moduleBindings");Object.assign(this.options,t);const i=so(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;D.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,s]of Object.entries(e))this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&D.warn(`Module name: ${r} vs ${s.name}`)()}destroy(){}setProps(e){var t;for(const i of Object.keys(e)){const r=i,s=e[r]||{},o=this.modules[r];if(!o){this.options.disableWarnings||D.warn(`Module ${i} not found`)();continue}const a=this.moduleUniforms[r],l=this.moduleBindings[r],c=((t=o.getUniforms)==null?void 0:t.call(o,s,a))||s,{uniforms:u,bindings:f}=D0(c);this.moduleUniforms[r]={...a,...u},this.moduleBindings[r]={...l,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var t;const e={};for(const[i,r]of Object.entries(this.moduleUniforms))for(const[s,o]of Object.entries(r))e[`${i}.${s}`]={type:(t=this.modules[i].uniformTypes)==null?void 0:t[s],value:String(o)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}let F0="";async function N0(n,e){const t=new Image;return t.crossOrigin="anonymous",t.src=n.startsWith("http")?n:F0+n,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}const O0=["+X","-X","+Y","-Y","+Z","-Z"],B0=["+X","-X","+Y","-Y","+Z","-Z"],Nr=class Nr{constructor(e,t){m(this,"device");m(this,"id");m(this,"props");m(this,"texture");m(this,"sampler");m(this,"view");m(this,"ready");m(this,"isReady",!1);m(this,"destroyed",!1);m(this,"resolveReady",()=>{});m(this,"rejectReady",()=>{});this.device=e;const i=xr("async-texture");this.props={...Nr.defaultProps,id:i,...t},this.id=this.props.id,t={...t},typeof(t==null?void 0:t.data)=="string"&&t.dimension==="2d"&&(t.data=N0(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((r,s)=>{this.resolveReady=()=>{this.isReady=!0,r()},this.rejectReady=s}),this.initAsync(t)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,i=await Au(t).then(void 0,this.rejectReady);if(this.destroyed)return;const r=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(i);if(!r)throw new Error("Texture size could not be determined");const s={...r,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(s.width,s.height);if(s.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,i);break;case"2d":this._setTexture2DData(i);break;case"3d":this._setTexture3DData(this.texture,i);break;case"2d-array":this._setTextureArrayData(this.texture,i);break;case"cube":this._setTextureCubeData(this.texture,i);break;case"cube-array":this._setTextureCubeArrayData(this.texture,i);break}this.props.mipmaps&&this.generateMipmaps(),D.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof cn?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=e==null?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){const i=Object.values(e)[0];return{width:i.width,height:i.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const i=this._normalizeTextureData(e);i.length>1&&this.props.mipmaps!==!1&&D.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let r=0;r<i.length;r++){const s=i[r];this.device.isExternalImage(s)?this.texture.copyExternalImage({image:s,depth:t,mipLevel:r,flipY:!0}):this.texture.copyImageData({data:s.data,mipLevel:r})}}_setTexture3DData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="3d")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="cube")throw new Error(this.id);for(const[r,s]of Object.entries(t)){const o=B0.indexOf(r);this._setTexture2DData(s,o)}}_setTextureArrayData(e,t){var i;if(((i=this.texture)==null?void 0:i.props.dimension)!=="2d-array")throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,i,r=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&D.warn(`${this.id} has mipmap and multiple LODs.`)();const s=O0.indexOf(i);this._setTexture2DData(t,s)}_normalizeTextureData(e){const t=this.texture;let i;return ArrayBuffer.isView(e)?i=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?i=e:i=[e],i}};m(Nr,"defaultProps",{...Q.defaultProps,data:null,mipmaps:!1});let Gn=Nr;async function Au(n){if(n=await n,Array.isArray(n))return await Promise.all(n.map(Au));if(n&&typeof n=="object"&&n.constructor===Object){const e=n,t=await Promise.all(Object.values(e)),i=Object.keys(e),r={};for(let s=0;s<i.length;s++)r[i[s]]=t[s];return r}return n}const Zt=2,U0=1e4,Or=class Or{constructor(e,t){m(this,"device");m(this,"id");m(this,"source");m(this,"vs");m(this,"fs");m(this,"pipelineFactory");m(this,"shaderFactory");m(this,"userData",{});m(this,"parameters");m(this,"topology");m(this,"bufferLayout");m(this,"isInstanced");m(this,"instanceCount",0);m(this,"vertexCount");m(this,"indexBuffer",null);m(this,"bufferAttributes",{});m(this,"constantAttributes",{});m(this,"bindings",{});m(this,"vertexArray");m(this,"transformFeedback",null);m(this,"pipeline");m(this,"shaderInputs");m(this,"_uniformStore");m(this,"_attributeInfos",{});m(this,"_gpuGeometry",null);m(this,"props");m(this,"_pipelineNeedsUpdate","newly created");m(this,"_needsRedraw","initializing");m(this,"_destroyed",!1);m(this,"_lastDrawTimestamp",-1);m(this,"_lastLogTime",0);m(this,"_logOpen",!1);m(this,"_drawCount",0);var l,c,u,f;this.props={...Or.defaultProps,...t},t=this.props,this.id=t.id||xr("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(((l=this.props.modules)==null?void 0:l.map(h=>[h.name,h]))||[]),r=t.shaderInputs||new M0(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(r);const s=L0(e),o=(((c=this.props.modules)==null?void 0:c.length)>0?this.props.modules:(u=this.shaderInputs)==null?void 0:u.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){const{source:h,getUniforms:d}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:s,...this.props,modules:o});this.source=h,this._getModuleUniforms=d,(f=this.props).shaderLayout||(f.shaderLayout=v0(this.source))}else{const{vs:h,fs:d,getUniforms:_}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:o});this.vs=h,this.fs=d,this._getModuleUniforms=_}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||wo.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Ao.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return D.info(Zt,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const r=this._getBindings();this.pipeline.setBindings(r,{disableWarnings:this.props.disableWarnings});const{indexBuffer:s}=this.vertexArray,o=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var i;(i=this._gpuGeometry)==null||i.destroy();const t=e&&S0(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const r=new Io(this.bufferLayout);this.bufferLayout=r.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new Io(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Co(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new xe(this.shaderInputs.modules);for(const[t,i]of Object.entries(this.shaderInputs.modules))if(z0(i)){const r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const i=(t==null?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&D.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=I0(this.pipeline.shaderLayout,this.bufferLayout);const r=new Io(this.bufferLayout);for(const[s,o]of Object.entries(e)){const a=r.getBufferLayout(s);if(!a){i||D.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const l=r.getAttributeNamesForBuffer(a);let c=!1;for(const u of l){const f=this._attributeInfos[u];if(f){const h=this.device.type==="webgpu"?r.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),c=!0}}!c&&!i&&D.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,r]of Object.entries(e)){const s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):((t==null?void 0:t.disableWarnings)??this.props.disableWarnings)||D.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Gn&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,i]of Object.entries(this.bindings))i instanceof Gn?i.isReady&&(e[t]=i.texture):e[t]=i;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof Fi?e=Math.max(e,t.texture.updateTimestamp):t instanceof L||t instanceof Q?e=Math.max(e,t.updateTimestamp):t instanceof Gn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof cn||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(D.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:i,fs:r}),this._attributeInfos=Ka(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=D.level>3?0:U0;D.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,D.group(Zt,`>>> DRAWING MODEL ${this.id}`,{collapsed:D.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=A0(this.pipeline.shaderLayout,this.id);D.table(Zt,e)();const t=this.shaderInputs.getDebugTable();D.table(Zt,t)();const i=this._getAttributeDebugTable();D.table(Zt,this._attributeInfos)(),D.table(Zt,i)(),D.groupEnd(Zt)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const i=e.props.framebuffer;i&&C0(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,i]of Object.entries(this._attributeInfos)){const r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){const i=La(t);return(e instanceof L?new i(e.debugData):e).toString()}};m(Or,"defaultProps",{...Wt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:ao.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let me=Or;function z0(n){return!!(n.uniformTypes&&!V0(n.uniformTypes))}function L0(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}function V0(n){for(const e in n)return!1;return!0}class Nt{constructor(e,t,i,r,s){this._debugRandomNumber=Math.floor(Math.random()*1e3),this.device=e,this.config=t,this.store=i,this.data=r,s&&(this.points=s)}}const H0=`#version 300 es
|
|
97
97
|
precision highp float;
|
|
98
98
|
|
|
99
99
|
in vec4 rgba;
|
|
@@ -101,7 +101,7 @@ out vec4 fragColor;
|
|
|
101
101
|
|
|
102
102
|
void main() {
|
|
103
103
|
fragColor = rgba;
|
|
104
|
-
}`,
|
|
104
|
+
}`,W0=`#version 300 es
|
|
105
105
|
precision highp float;
|
|
106
106
|
|
|
107
107
|
uniform sampler2D positionsTexture;
|
|
@@ -127,7 +127,7 @@ void main() {
|
|
|
127
127
|
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
|
128
128
|
gl_PointSize = 1.0;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
`,$0=`#version 300 es
|
|
131
131
|
precision highp float;
|
|
132
132
|
|
|
133
133
|
uniform sampler2D positionsTexture;
|
|
@@ -163,7 +163,7 @@ void main() {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
fragColor = velocity;
|
|
166
|
-
}`;function yr(n){const e=new Float32Array(n*n*2);for(let t=0;t<n;t++)for(let i=0;i<n;i++){const r=t*n*2+i*2;e[r+0]=i,e[r+1]=t}return e}function
|
|
166
|
+
}`;function yr(n){const e=new Float32Array(n*n*2);for(let t=0;t<n;t++)for(let i=0;i<n;i++){const r=t*n*2+i*2;e[r+0]=i,e[r+1]=t}return e}function ie(n,e){const t=Vt.getInfo(n);return e*(t.bytesPerPixel??0)}const tt=`#version 300 es
|
|
167
167
|
#ifdef GL_ES
|
|
168
168
|
precision highp float;
|
|
169
169
|
#endif
|
|
@@ -176,7 +176,7 @@ void main() {
|
|
|
176
176
|
textureCoords = (vertexCoord + 1.0) / 2.0;
|
|
177
177
|
gl_Position = vec4(vertexCoord, 0, 1);
|
|
178
178
|
}
|
|
179
|
-
`;class
|
|
179
|
+
`;class X0 extends Nt{create(){var r;const{device:e,store:t}=this,{pointsTextureSize:i}=t;if(i){if(this.centermassTexture||(this.centermassTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST})),this.centermassTexture.copyImageData({data:new Float32Array(4).fill(0),bytesPerRow:ie("rgba32float",1),mipLevel:0,x:0,y:0}),this.centermassFbo||(this.centermassFbo=e.createFramebuffer({width:1,height:1,colorAttachments:[this.centermassTexture]})),!this.pointIndices||this.previousPointsTextureSize!==t.pointsTextureSize){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const s=yr(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:s,usage:L.VERTEX|L.COPY_DST}),(r=this.calculateCentermassCommand)==null||r.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=i}}initPrograms(){const{device:e,store:t,points:i}=this;!i||!t.pointsTextureSize||!this.centermassFbo||this.centermassFbo.destroyed||!this.centermassTexture||this.centermassTexture.destroyed||(this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.calculateUniformStore||(this.calculateUniformStore=new xe({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32"}}})),this.forceUniformStore||(this.forceUniformStore=new xe({forceCenterUniforms:{uniformTypes:{centerForce:"f32",alpha:"f32"}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new me(e,{fs:H0,vs:W0,topology:"point-list",attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.runCommand||(this.runCommand=new me(e,{fs:$0,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCenterUniforms:this.forceUniformStore.getManagedUniformBuffer(e,"forceCenterUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,store:t,points:i}=this;if(!i||!this.calculateCentermassCommand||!this.calculateUniformStore||!this.runCommand||!this.forceUniformStore||!this.centermassFbo||!this.centermassTexture||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!i.velocityFbo||i.velocityFbo.destroyed||t.pointsTextureSize!==this.previousPointsTextureSize||!this.pointIndices)return;const r=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:t.pointsTextureSize??0}}),this.calculateCentermassCommand.setBindings({positionsTexture:i.previousPositionTexture}),this.calculateCentermassCommand.draw(r),r.end(),this.forceUniformStore.setUniforms({forceCenterUniforms:{centerForce:this.config.simulationCenter??0,alpha:t.alpha}}),this.runCommand.setBindings({positionsTexture:i.previousPositionTexture,centermassTexture:this.centermassTexture});const s=e.beginRenderPass({framebuffer:i.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(s),s.end()}destroy(){var e,t,i,r;(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(t=this.runCommand)==null||t.destroy(),this.runCommand=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=void 0,(i=this.calculateUniformStore)==null||i.destroy(),this.calculateUniformStore=void 0,(r=this.forceUniformStore)==null||r.destroy(),this.forceUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0,this.previousPointsTextureSize=void 0}}const Y0=`#version 300 es
|
|
180
180
|
precision highp float;
|
|
181
181
|
|
|
182
182
|
uniform sampler2D positionsTexture;
|
|
@@ -215,7 +215,7 @@ void main() {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
fragColor = velocity;
|
|
218
|
-
}`;class
|
|
218
|
+
}`;class q0 extends Nt{initPrograms(){const{device:e,points:t,store:i}=this;!t||!i.pointsTextureSize||(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new xe({forceGravityUniforms:{uniformTypes:{gravity:"f32",spaceSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new me(e,{fs:Y0,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceGravityUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceGravityUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,points:t,store:i}=this;if(!t||!this.runCommand||!this.uniformStore||!t.previousPositionTexture||t.previousPositionTexture.destroyed||!t.velocityFbo||t.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceGravityUniforms:{gravity:this.config.simulationGravity??0,spaceSize:i.adjustedSpaceSize??0,alpha:i.alpha}}),this.runCommand.setBindings({positionsTexture:t.previousPositionTexture});const r=e.beginRenderPass({framebuffer:t.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(r),r.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}function j0(n){return`#version 300 es
|
|
219
219
|
precision highp float;
|
|
220
220
|
|
|
221
221
|
uniform sampler2D positionsTexture;
|
|
@@ -301,7 +301,7 @@ void main() {
|
|
|
301
301
|
|
|
302
302
|
fragColor = vec4(velocity.rg, 0.0, 0.0);
|
|
303
303
|
}
|
|
304
|
-
`}function re(n,e){return!n||n.length!==2?e:[n[0],n[1]]}function Re(n,e){return!n||n.length!==4?e:[n[0],n[1],n[2],n[3]]}var
|
|
304
|
+
`}function re(n,e){return!n||n.length!==2?e:[n[0],n[1]]}function Re(n,e){return!n||n.length!==4?e:[n[0],n[1],n[2],n[3]]}var Po=(n=>(n.OUTGOING="outgoing",n.INCOMING="incoming",n))(Po||{});class Cu extends Nt{constructor(){super(...arguments),this.linkFirstIndicesAndAmount=new Float32Array,this.indices=new Float32Array,this.maxPointDegree=0}create(e){var h;const{device:t,store:{pointsTextureSize:i,linksTextureSize:r},data:s}=this;if(!i||!r)return;this.linkFirstIndicesAndAmount=new Float32Array(i*i*4),this.indices=new Float32Array(r*r*4);const o=new Float32Array(r*r*4),a=new Float32Array(r*r*4),l=e==="incoming"?s.sourceIndexToTargetIndices:s.targetIndexToSourceIndices;this.maxPointDegree=0;let c=0;l==null||l.forEach((d,_)=>{d&&(this.linkFirstIndicesAndAmount[_*4+0]=c%r,this.linkFirstIndicesAndAmount[_*4+1]=Math.floor(c/r),this.linkFirstIndicesAndAmount[_*4+2]=d.length??0,d.forEach(([I,P])=>{var U,W,q;this.indices[c*4+0]=I%i,this.indices[c*4+1]=Math.floor(I/i);const A=((U=s.degree)==null?void 0:U[I])??0,O=((W=s.degree)==null?void 0:W[_])??0,E=A+O,x=E!==0?A/E:.5,R=Math.min(A,O);let N=((q=s.linkStrength)==null?void 0:q[P])??1/Math.max(R,1);N=Math.sqrt(N),o[c*4+0]=x,o[c*4+1]=N,a[c*4]=this.store.getRandomFloat(0,1),c+=1}),this.maxPointDegree=Math.max(this.maxPointDegree,d.length??0))});const u=!this.linkFirstIndicesAndAmountTexture||this.linkFirstIndicesAndAmountTexture.width!==i||this.linkFirstIndicesAndAmountTexture.height!==i,f=!this.indicesTexture||this.indicesTexture.width!==r||this.indicesTexture.height!==r;u&&(this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=t.createTexture({width:i,height:i,format:"rgba32float",usage:Q.SAMPLE|Q.COPY_DST})),this.linkFirstIndicesAndAmountTexture.copyImageData({data:this.linkFirstIndicesAndAmount,bytesPerRow:ie("rgba32float",i),mipLevel:0,x:0,y:0}),f&&(this.indicesTexture&&!this.indicesTexture.destroyed&&this.indicesTexture.destroy(),this.biasAndStrengthTexture&&!this.biasAndStrengthTexture.destroyed&&this.biasAndStrengthTexture.destroy(),this.randomDistanceTexture&&!this.randomDistanceTexture.destroyed&&this.randomDistanceTexture.destroy(),this.indicesTexture=t.createTexture({width:r,height:r,format:"rgba32float",usage:Q.SAMPLE|Q.COPY_DST}),this.biasAndStrengthTexture=t.createTexture({width:r,height:r,format:"rgba32float",usage:Q.SAMPLE|Q.COPY_DST}),this.randomDistanceTexture=t.createTexture({width:r,height:r,format:"rgba32float",usage:Q.SAMPLE|Q.COPY_DST})),this.indicesTexture.copyImageData({data:this.indices,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),this.biasAndStrengthTexture.copyImageData({data:o,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),this.randomDistanceTexture.copyImageData({data:a,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),this.previousMaxPointDegree!==void 0&&this.previousMaxPointDegree!==this.maxPointDegree&&((h=this.runCommand)==null||h.destroy(),this.runCommand=void 0),this.previousMaxPointDegree=this.maxPointDegree,this.previousPointsTextureSize=i,this.previousLinksTextureSize=r}initPrograms(){const{device:e,store:t,points:i}=this;!i||!t.pointsTextureSize||!t.linksTextureSize||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new xe({forceLinkUniforms:{uniformTypes:{linkSpring:"f32",linkDistance:"f32",linkDistRandomVariationRange:"vec2<f32>",pointsTextureSize:"f32",linksTextureSize:"f32",alpha:"f32"}}})),this.runCommand||(this.runCommand=new me(e,{fs:j0(this.maxPointDegree),vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceLinkUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceLinkUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,store:t,points:i}=this;if(!i||!this.runCommand||!this.uniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!this.linkFirstIndicesAndAmountTexture||!this.indicesTexture||!this.biasAndStrengthTexture||!this.randomDistanceTexture||!i.velocityFbo||i.velocityFbo.destroyed||t.pointsTextureSize!==this.previousPointsTextureSize||t.linksTextureSize!==this.previousLinksTextureSize)return;this.uniformStore.setUniforms({forceLinkUniforms:{linkSpring:this.config.simulationLinkSpring??0,linkDistance:this.config.simulationLinkDistance??0,linkDistRandomVariationRange:re(this.config.simulationLinkDistRandomVariationRange,[0,0]),pointsTextureSize:t.pointsTextureSize,linksTextureSize:t.linksTextureSize,alpha:t.alpha}}),this.runCommand.setBindings({positionsTexture:i.previousPositionTexture,linkInfoTexture:this.linkFirstIndicesAndAmountTexture,linkIndicesTexture:this.indicesTexture,linkPropertiesTexture:this.biasAndStrengthTexture,linkRandomDistanceTexture:this.randomDistanceTexture});const r=e.beginRenderPass({framebuffer:i.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(r),r.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,this.linkFirstIndicesAndAmountTexture&&!this.linkFirstIndicesAndAmountTexture.destroyed&&this.linkFirstIndicesAndAmountTexture.destroy(),this.linkFirstIndicesAndAmountTexture=void 0,this.indicesTexture&&!this.indicesTexture.destroyed&&this.indicesTexture.destroy(),this.indicesTexture=void 0,this.biasAndStrengthTexture&&!this.biasAndStrengthTexture.destroyed&&this.biasAndStrengthTexture.destroy(),this.biasAndStrengthTexture=void 0,this.randomDistanceTexture&&!this.randomDistanceTexture.destroyed&&this.randomDistanceTexture.destroy(),this.randomDistanceTexture=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const K0=`#version 300 es
|
|
305
305
|
precision highp float;
|
|
306
306
|
|
|
307
307
|
in vec4 vColor;
|
|
@@ -309,7 +309,7 @@ out vec4 fragColor;
|
|
|
309
309
|
|
|
310
310
|
void main() {
|
|
311
311
|
fragColor = vColor;
|
|
312
|
-
}`,
|
|
312
|
+
}`,Z0=`#version 300 es
|
|
313
313
|
precision highp float;
|
|
314
314
|
|
|
315
315
|
uniform sampler2D positionsTexture;
|
|
@@ -345,7 +345,7 @@ void main() {
|
|
|
345
345
|
|
|
346
346
|
gl_Position = vec4(levelPosition, 0.0, 1.0);
|
|
347
347
|
gl_PointSize = 1.0;
|
|
348
|
-
}`,
|
|
348
|
+
}`,Q0=`#version 300 es
|
|
349
349
|
precision highp float;
|
|
350
350
|
|
|
351
351
|
uniform sampler2D positionsTexture;
|
|
@@ -482,7 +482,7 @@ void main() {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
fragColor = velocity;
|
|
485
|
-
}`,
|
|
485
|
+
}`,J0=`#version 300 es
|
|
486
486
|
precision highp float;
|
|
487
487
|
|
|
488
488
|
uniform sampler2D positionsTexture;
|
|
@@ -542,7 +542,7 @@ void main() {
|
|
|
542
542
|
velocity.xy += velocity.xy * random.rg;
|
|
543
543
|
|
|
544
544
|
fragColor = velocity;
|
|
545
|
-
}`;class
|
|
545
|
+
}`;class G0 extends Nt{constructor(){super(...arguments),this.levels=0,this.levelTargets=new Map}create(){var o;const{device:e,store:t}=this;if(!t.pointsTextureSize)return;this.levels=Math.log2(t.adjustedSpaceSize);for(let a=0;a<this.levels;a+=1){const l=Math.pow(2,a+1),c=this.levelTargets.get(a);if(c&&c.texture.width===l&&c.texture.height===l){c.texture.copyImageData({data:new Float32Array(l*l*4).fill(0),bytesPerRow:ie("rgba32float",l),mipLevel:0,x:0,y:0});continue}c&&(c.fbo.destroyed||c.fbo.destroy(),c.texture.destroyed||c.texture.destroy());const u=e.createTexture({width:l,height:l,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST});u.copyImageData({data:new Float32Array(l*l*4).fill(0),bytesPerRow:ie("rgba32float",l),mipLevel:0,x:0,y:0});const f=e.createFramebuffer({width:l,height:l,colorAttachments:[u]});this.levelTargets.set(a,{texture:u,fbo:f})}for(const[a,l]of Array.from(this.levelTargets.entries()))a>=this.levels&&(l.fbo.destroyed||l.fbo.destroy(),l.texture.destroyed||l.texture.destroy(),this.levelTargets.delete(a));const i=t.pointsTextureSize*t.pointsTextureSize,r=new Float32Array(i*4);for(let a=0;a<i;++a)r[a*4]=t.getRandomFloat(-1,1)*1e-5,r[a*4+1]=t.getRandomFloat(-1,1)*1e-5;if((!this.randomValuesTexture||this.randomValuesTexture.destroyed||this.randomValuesTexture.width!==t.pointsTextureSize||this.randomValuesTexture.height!==t.pointsTextureSize)&&(this.randomValuesTexture&&!this.randomValuesTexture.destroyed&&this.randomValuesTexture.destroy(),this.randomValuesTexture=e.createTexture({width:t.pointsTextureSize,height:t.pointsTextureSize,format:"rgba32float",usage:Q.SAMPLE|Q.COPY_DST})),this.randomValuesTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",t.pointsTextureSize),mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==t.pointsTextureSize){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const a=yr(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:a,usage:L.VERTEX|L.COPY_DST}),(o=this.calculateLevelsCommand)==null||o.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=t.pointsTextureSize,this.previousSpaceSize=t.adjustedSpaceSize}initPrograms(){const{device:e,store:t,data:i,points:r}=this;!i.pointsNumber||!r||!t.pointsTextureSize||(this.calculateLevelsUniformStore||(this.calculateLevelsUniformStore=new xe({calculateLevelsUniforms:{uniformTypes:{pointsTextureSize:"f32",levelTextureSize:"f32",cellSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,levelTextureSize:0,cellSize:0}}})),this.calculateLevelsCommand||(this.calculateLevelsCommand=new me(e,{fs:K0,vs:Z0,topology:"point-list",vertexCount:i.pointsNumber,attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateLevelsUniforms:this.calculateLevelsUniformStore.getManagedUniformBuffer(e,"calculateLevelsUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceUniformStore||(this.forceUniformStore=new xe({forceUniforms:{uniformTypes:{level:"f32",levels:"f32",levelTextureSize:"f32",alpha:"f32",repulsion:"f32",spaceSize:"f32",theta:"f32"},defaultUniforms:{level:0,levels:this.levels,levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:t.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}})),this.forceVertexCoordBuffer||(this.forceVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.forceCommand||(this.forceCommand=new me(e,{fs:Q0,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceUniforms:this.forceUniformStore.getManagedUniformBuffer(e,"forceUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.forceCenterUniformStore||(this.forceCenterUniformStore=new xe({forceCenterUniforms:{uniformTypes:{levelTextureSize:"f32",alpha:"f32",repulsion:"f32"},defaultUniforms:{levelTextureSize:0,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0}}})),this.forceFromItsOwnCentermassCommand||(this.forceFromItsOwnCentermassCommand=new me(e,{fs:J0,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.forceVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceCenterUniforms:this.forceCenterUniformStore.getManagedUniformBuffer(e,"forceCenterUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})))}run(){this.store.pointsTextureSize!==this.previousPointsTextureSize||this.store.adjustedSpaceSize!==this.previousSpaceSize||(this.drawLevels(),this.drawForces())}destroy(){var e,t,i,r,s,o;(e=this.calculateLevelsCommand)==null||e.destroy(),this.calculateLevelsCommand=void 0,(t=this.forceCommand)==null||t.destroy(),this.forceCommand=void 0,(i=this.forceFromItsOwnCentermassCommand)==null||i.destroy(),this.forceFromItsOwnCentermassCommand=void 0;for(const a of this.levelTargets.values())a.fbo&&!a.fbo.destroyed&&a.fbo.destroy();this.randomValuesTexture&&!this.randomValuesTexture.destroyed&&this.randomValuesTexture.destroy(),this.randomValuesTexture=void 0;for(const a of this.levelTargets.values())a.texture&&!a.texture.destroyed&&a.texture.destroy();this.levelTargets.clear(),(r=this.calculateLevelsUniformStore)==null||r.destroy(),this.calculateLevelsUniformStore=void 0,(s=this.forceUniformStore)==null||s.destroy(),this.forceUniformStore=void 0,(o=this.forceCenterUniformStore)==null||o.destroy(),this.forceCenterUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.forceVertexCoordBuffer&&!this.forceVertexCoordBuffer.destroyed&&this.forceVertexCoordBuffer.destroy(),this.forceVertexCoordBuffer=void 0}drawLevels(){const{device:e,store:t,data:i,points:r}=this;if(r&&!(!this.calculateLevelsCommand||!this.calculateLevelsUniformStore)&&!(!r.previousPositionTexture||r.previousPositionTexture.destroyed)&&i.pointsNumber&&this.pointIndices)for(let s=0;s<this.levels;s+=1){const o=this.levelTargets.get(s);if(!o||o.fbo.destroyed||o.texture.destroyed)continue;const a=Math.pow(2,s+1),l=(t.adjustedSpaceSize??0)/a;this.calculateLevelsUniformStore.setUniforms({calculateLevelsUniforms:{pointsTextureSize:t.pointsTextureSize??0,levelTextureSize:a,cellSize:l}}),this.calculateLevelsCommand.setVertexCount(i.pointsNumber),this.calculateLevelsCommand.setBindings({positionsTexture:r.previousPositionTexture});const c=e.beginRenderPass({framebuffer:o.fbo,clearColor:[0,0,0,0]});this.calculateLevelsCommand.draw(c),c.end()}}drawForces(){const{device:e,store:t,points:i}=this;if(!i||!this.forceCommand||!this.forceUniformStore||!this.forceFromItsOwnCentermassCommand||!this.forceCenterUniformStore||!i.previousPositionTexture||i.previousPositionTexture.destroyed||!this.randomValuesTexture||this.randomValuesTexture.destroyed||!i.velocityFbo||i.velocityFbo.destroyed)return;const r=e.beginRenderPass({framebuffer:i.velocityFbo,clearColor:[0,0,0,0]});for(let s=0;s<this.levels;s+=1){const o=this.levelTargets.get(s);if(!o||o.texture.destroyed)continue;const a=Math.pow(2,s+1);this.forceUniformStore.setUniforms({forceUniforms:{level:s,levels:this.levels,levelTextureSize:a,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0,spaceSize:t.adjustedSpaceSize??0,theta:this.config.simulationRepulsionTheta??0}}),this.forceCommand.setBindings({positionsTexture:i.previousPositionTexture,levelFbo:o.texture}),this.forceCommand.draw(r),s===this.levels-1&&(this.forceCenterUniformStore.setUniforms({forceCenterUniforms:{levelTextureSize:a,alpha:t.alpha,repulsion:this.config.simulationRepulsion??0}}),this.forceFromItsOwnCentermassCommand.setBindings({positionsTexture:i.previousPositionTexture,randomValues:this.randomValuesTexture,levelFbo:o.texture}),this.forceFromItsOwnCentermassCommand.draw(r))}r.end()}}const ev=`#version 300 es
|
|
546
546
|
precision highp float;
|
|
547
547
|
|
|
548
548
|
uniform sampler2D positionsTexture;
|
|
@@ -576,7 +576,7 @@ void main() {
|
|
|
576
576
|
velocity.rg -= addV * vec2(cos(angle), sin(angle));
|
|
577
577
|
|
|
578
578
|
fragColor = velocity;
|
|
579
|
-
}`;class
|
|
579
|
+
}`;class tv extends Nt{initPrograms(){const{device:e,points:t}=this;t&&(this.vertexCoordBuffer||(this.vertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.uniformStore||(this.uniformStore=new xe({forceMouseUniforms:{uniformTypes:{repulsion:"f32",mousePos:"vec2<f32>"}}})),this.runCommand||(this.runCommand=new me(e,{fs:ev,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.vertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{forceMouseUniforms:this.uniformStore.getManagedUniformBuffer(e,"forceMouseUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})))}run(){const{device:e,points:t,store:i}=this;if(!t||!this.runCommand||!this.uniformStore||!t.previousPositionTexture||t.previousPositionTexture.destroyed||!t.velocityFbo||t.velocityFbo.destroyed)return;this.uniformStore.setUniforms({forceMouseUniforms:{repulsion:this.config.simulationRepulsionFromMouse??0,mousePos:re(i.mousePosition,[0,0])}}),this.runCommand.setBindings({positionsTexture:t.previousPositionTexture});const r=e.beginRenderPass({framebuffer:t.velocityFbo,clearColor:[0,0,0,0]});this.runCommand.draw(r),r.end()}destroy(){var e,t;(e=this.runCommand)==null||e.destroy(),this.runCommand=void 0,(t=this.uniformStore)==null||t.destroy(),this.uniformStore=void 0,this.vertexCoordBuffer&&!this.vertexCoordBuffer.destroyed&&this.vertexCoordBuffer.destroy(),this.vertexCoordBuffer=void 0}}const nv=`#version 300 es
|
|
580
580
|
#ifdef GL_ES
|
|
581
581
|
precision highp float;
|
|
582
582
|
#endif
|
|
@@ -587,7 +587,7 @@ out vec4 fragColor;
|
|
|
587
587
|
|
|
588
588
|
void main() {
|
|
589
589
|
fragColor = rgba;
|
|
590
|
-
}`,
|
|
590
|
+
}`,iv=`#version 300 es
|
|
591
591
|
#ifdef GL_ES
|
|
592
592
|
precision highp float;
|
|
593
593
|
#endif
|
|
@@ -625,7 +625,7 @@ void main() {
|
|
|
625
625
|
gl_Position = vec4(xy, 0.0, 1.0);
|
|
626
626
|
gl_PointSize = 1.0;
|
|
627
627
|
}
|
|
628
|
-
`,
|
|
628
|
+
`,rv=`#version 300 es
|
|
629
629
|
#ifdef GL_ES
|
|
630
630
|
precision highp float;
|
|
631
631
|
#endif
|
|
@@ -679,7 +679,7 @@ void main() {
|
|
|
679
679
|
}
|
|
680
680
|
|
|
681
681
|
fragColor = velocity;
|
|
682
|
-
}`;class
|
|
682
|
+
}`;class sv extends Nt{create(){var f,h;const{device:e,store:t,data:i}=this,{pointsTextureSize:r}=t;if(i.pointsNumber===void 0||!i.pointClusters&&!i.clusterPositions)return;this.clusterCount=(i.pointClusters??[]).reduce((d,_)=>_===void 0||_<0?d:Math.max(d,_),0)+1,this.clustersTextureSize=Math.ceil(Math.sqrt(this.clusterCount));const s=this.previousPointsTextureSize!==r||this.previousClustersTextureSize!==this.clustersTextureSize||this.previousClusterCount!==this.clusterCount,o=r*r*4,a=this.clustersTextureSize*this.clustersTextureSize*4,l=new Float32Array(o),c=new Float32Array(a).fill(-1),u=new Float32Array(o).fill(1);if(i.clusterPositions)for(let d=0;d<this.clusterCount;++d)c[d*4+0]=i.clusterPositions[d*2+0]??-1,c[d*4+1]=i.clusterPositions[d*2+1]??-1;for(let d=0;d<i.pointsNumber;++d){const _=(f=i.pointClusters)==null?void 0:f[d];_===void 0?(l[d*4+0]=-1,l[d*4+1]=-1):(l[d*4+0]=_%this.clustersTextureSize,l[d*4+1]=Math.floor(_/this.clustersTextureSize)),i.clusterStrength&&(u[d*4+0]=i.clusterStrength[d]??1)}if(!this.clusterTexture||s?(this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.clusterTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0})):this.clusterTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),!this.clusterPositionsTexture||s?(this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.clusterPositionsTexture.copyImageData({data:c,bytesPerRow:ie("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0})):this.clusterPositionsTexture.copyImageData({data:c,bytesPerRow:ie("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),!this.clusterForceCoefficientTexture||s?(this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=e.createTexture({width:r,height:r,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0})):this.clusterForceCoefficientTexture.copyImageData({data:u,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),!this.centermassTexture||this.previousClustersTextureSize!==this.clustersTextureSize?(this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=e.createTexture({width:this.clustersTextureSize,height:this.clustersTextureSize,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:ie("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),this.centermassFbo=e.createFramebuffer({width:this.clustersTextureSize,height:this.clustersTextureSize,colorAttachments:[this.centermassTexture]})):this.centermassTexture.copyImageData({data:new Float32Array(a).fill(0),bytesPerRow:ie("rgba32float",this.clustersTextureSize),mipLevel:0,x:0,y:0}),!this.pointIndices||this.previousPointsTextureSize!==r){this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy();const d=yr(t.pointsTextureSize);this.pointIndices=e.createBuffer({data:d,usage:L.VERTEX|L.COPY_DST}),(h=this.calculateCentermassCommand)==null||h.setAttributes({pointIndices:this.pointIndices})}this.previousPointsTextureSize=r,this.previousClustersTextureSize=this.clustersTextureSize,this.previousClusterCount=this.clusterCount}initPrograms(){const{device:e,store:t,data:i}=this;i.pointsNumber===void 0||!i.pointClusters&&!i.clusterPositions||(this.calculateCentermassUniformStore||(this.calculateCentermassUniformStore=new xe({calculateCentermassUniforms:{uniformTypes:{pointsTextureSize:"f32",clustersTextureSize:"f32"},defaultUniforms:{pointsTextureSize:t.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}})),this.calculateCentermassCommand||(this.calculateCentermassCommand=new me(e,{fs:nv,vs:iv,topology:"point-list",vertexCount:i.pointsNumber??0,attributes:{...this.pointIndices&&{pointIndices:this.pointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{calculateCentermassUniforms:this.calculateCentermassUniformStore.getManagedUniformBuffer(e,"calculateCentermassUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",depthWriteEnabled:!1,depthCompare:"always"}})),this.applyForcesUniformStore||(this.applyForcesUniformStore=new xe({applyForcesUniforms:{uniformTypes:{alpha:"f32",clustersTextureSize:"f32",clusterCoefficient:"f32"},defaultUniforms:{alpha:t.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}})),this.applyForcesVertexCoordBuffer||(this.applyForcesVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.applyForcesCommand||(this.applyForcesCommand=new me(e,{fs:rv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.applyForcesVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{applyForcesUniforms:this.applyForcesUniformStore.getManagedUniformBuffer(e,"applyForcesUniforms")}})))}calculateCentermass(){const{device:e,points:t}=this;if(!t||!this.calculateCentermassCommand||!this.calculateCentermassUniformStore||!this.pointIndices||!this.centermassFbo||this.centermassFbo.destroyed||!this.clusterTexture||this.clusterTexture.destroyed||!t.previousPositionTexture||t.previousPositionTexture.destroyed)return;this.calculateCentermassCommand.setVertexCount(this.data.pointsNumber??0),this.calculateCentermassUniformStore.setUniforms({calculateCentermassUniforms:{pointsTextureSize:this.store.pointsTextureSize,clustersTextureSize:this.clustersTextureSize??0}}),this.calculateCentermassCommand.setBindings({clusterTexture:this.clusterTexture,positionsTexture:t.previousPositionTexture});const i=e.beginRenderPass({framebuffer:this.centermassFbo,clearColor:[0,0,0,0]});this.calculateCentermassCommand.draw(i),i.end()}run(){var t;if(!this.data.pointClusters&&!this.data.clusterPositions||(this.calculateCentermass(),!this.applyForcesCommand||!this.applyForcesUniformStore)||!this.clusterTexture||this.clusterTexture.destroyed||!this.centermassTexture||this.centermassTexture.destroyed||!this.clusterPositionsTexture||this.clusterPositionsTexture.destroyed||!this.clusterForceCoefficientTexture||this.clusterForceCoefficientTexture.destroyed||!((t=this.points)!=null&&t.previousPositionTexture)||this.points.previousPositionTexture.destroyed||!this.points.velocityFbo||this.points.velocityFbo.destroyed)return;this.applyForcesUniformStore.setUniforms({applyForcesUniforms:{alpha:this.store.alpha,clustersTextureSize:this.clustersTextureSize??0,clusterCoefficient:this.config.simulationCluster??0}}),this.applyForcesCommand.setBindings({clusterTexture:this.clusterTexture,centermassTexture:this.centermassTexture,clusterPositionsTexture:this.clusterPositionsTexture,clusterForceCoefficient:this.clusterForceCoefficientTexture,positionsTexture:this.points.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.points.velocityFbo,clearColor:[0,0,0,0]});this.applyForcesCommand.draw(e),e.end()}destroy(){var e,t,i,r;(e=this.calculateCentermassCommand)==null||e.destroy(),this.calculateCentermassCommand=void 0,(t=this.applyForcesCommand)==null||t.destroy(),this.applyForcesCommand=void 0,this.centermassFbo&&!this.centermassFbo.destroyed&&this.centermassFbo.destroy(),this.centermassFbo=void 0,this.clusterTexture&&!this.clusterTexture.destroyed&&this.clusterTexture.destroy(),this.clusterTexture=void 0,this.clusterPositionsTexture&&!this.clusterPositionsTexture.destroyed&&this.clusterPositionsTexture.destroy(),this.clusterPositionsTexture=void 0,this.clusterForceCoefficientTexture&&!this.clusterForceCoefficientTexture.destroyed&&this.clusterForceCoefficientTexture.destroy(),this.clusterForceCoefficientTexture=void 0,this.centermassTexture&&!this.centermassTexture.destroyed&&this.centermassTexture.destroy(),this.centermassTexture=void 0,(i=this.calculateCentermassUniformStore)==null||i.destroy(),this.calculateCentermassUniformStore=void 0,(r=this.applyForcesUniformStore)==null||r.destroy(),this.applyForcesUniformStore=void 0,this.pointIndices&&!this.pointIndices.destroyed&&this.pointIndices.destroy(),this.pointIndices=void 0,this.applyForcesVertexCoordBuffer&&!this.applyForcesVertexCoordBuffer.destroyed&&this.applyForcesVertexCoordBuffer.destroy(),this.applyForcesVertexCoordBuffer=void 0}}var ov=`<div class="gl-box">
|
|
683
683
|
<svg viewBox="0 0 55 60">
|
|
684
684
|
<text x="27" y="56" class="gl-fps">00 FPS</text>
|
|
685
685
|
<text x="28" y="8" class="gl-mem"></text>
|
|
@@ -696,7 +696,7 @@ void main() {
|
|
|
696
696
|
<line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>
|
|
697
697
|
<path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z"/>
|
|
698
698
|
</svg>
|
|
699
|
-
</div>`,
|
|
699
|
+
</div>`,av=`#gl-bench {
|
|
700
700
|
position:absolute;
|
|
701
701
|
left:0;
|
|
702
702
|
top:0;
|
|
@@ -755,7 +755,7 @@ void main() {
|
|
|
755
755
|
#gl-bench .opacity {
|
|
756
756
|
stroke: #448844;
|
|
757
757
|
}
|
|
758
|
-
`;class
|
|
758
|
+
`;class lv{constructor(e,t={}){this.css=av,this.svg=ov,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],a=>{a.style.display=this.trackGPU?"inline":"none"})},Object.assign(this,t),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let i,r=0,s,o=a=>{++r<20?i=requestAnimationFrame(o):(this.detected=Math.ceil(1e3*r/(a-s)/70),cancelAnimationFrame(i)),s||(s=a)};if(requestAnimationFrame(o),e){const a=async(c,u)=>Promise.resolve(setTimeout(()=>{e.getError();const f=this.now()-c;u.forEach((h,d)=>{h&&(this.gpuAccums[d]+=f)})},0)),l=(c,u,f)=>function(){const h=u.now();c.apply(f,arguments),u.trackGPU&&u.finished.push(a(h,u.activeAccums.slice(0)))};["drawArrays","drawElements","drawArraysInstanced","drawBuffers","drawElementsInstanced","drawRangeElements"].forEach(c=>{e[c]&&(e[c]=l(e[c],this,e))}),e.getExtension=((c,u)=>function(){let f=c.apply(e,arguments);return f&&["drawElementsInstancedANGLE","drawBuffersWEBGL"].forEach(h=>{f[h]&&(f[h]=l(f[h],u,f))}),f})(e.getExtension,this)}if(!this.withoutUI){this.dom||(this.dom=document.body);let a=document.createElement("div");a.id="gl-bench",this.dom.appendChild(a),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=a,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((l,c,u)=>{const f=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],h=Object.assign({},f);return f.forEach(d=>h[d]=c.getElementsByClassName(d)),this.nodes=h,(d,_,I,P,A,O,E)=>{h["gl-cpu"][d].style.strokeDasharray=(_*.27).toFixed(0)+" 100",h["gl-gpu"][d].style.strokeDasharray=(I*.27).toFixed(0)+" 100",h["gl-mem"][d].innerHTML=u[d]?u[d]:P?"mem: "+P.toFixed(0)+"mb":"",h["gl-fps"][d].innerHTML=A.toFixed(0)+" FPS",l(u[d],_,I,P,A,O,E)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((l,c)=>{let u={"gl-chart":c.getElementsByClassName("gl-chart")};return(f,h,d)=>{let _="",I=h.length;for(let P=0;P<I;P++){let A=(d+P+1)%I;h[A]!=null&&(_=_+" "+(55*P/(I-1)).toFixed(1)+","+(45-h[A]*22/60/this.detected).toFixed(1))}u["gl-chart"][f].setAttribute("points",_),l(this.names[f],h,d)}})(this.chartLogger,this.dom)}}addUI(e){this.names.indexOf(e)==-1&&(this.names.push(e),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(e){this.frameId++;const t=e||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=t;else{let i=t-this.paramTime;if(i>=1e3){const r=this.frameId-this.paramFrame,s=r/i*1e3;for(let o=0;o<this.names.length;o++){const a=this.cpuAccums[o]/i*100,l=this.gpuAccums[o]/i*100,c=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(o,a,l,c,s,i,r),this.cpuAccums[o]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[o]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=t}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=t,this.circularId=0;else{let i=t-this.chartTime,r=this.chartHz*i/1e3;for(;--r>0&&this.detected;){const o=(this.frameId-this.chartFrame)/i*1e3;this.chart[this.circularId%this.chartLen]=o;for(let a=0;a<this.names.length;a++)this.chartLogger(a,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=t}}}begin(e){this.updateAccums(e)}end(e){this.updateAccums(e)}updateAccums(e){let t=this.names.indexOf(e);t==-1&&(t=this.names.length,this.addUI(e));const i=this.now(),r=i-this.t0;for(let s=0;s<t+1;s++)this.activeAccums[s]&&(this.cpuAccums[s]+=r);this.activeAccums[t]=!this.activeAccums[t],this.t0=i}}const cv=`
|
|
759
759
|
#gl-bench {
|
|
760
760
|
position:absolute;
|
|
761
761
|
right:0;
|
|
@@ -807,7 +807,13 @@ void main() {
|
|
|
807
807
|
#gl-bench .opacity {
|
|
808
808
|
stroke: #8288e4;
|
|
809
809
|
}
|
|
810
|
-
`;class
|
|
810
|
+
`;class Iu{constructor(e){this.destroy();const t=e.getContext("webgl")||e.getContext("experimental-webgl");this.bench=new lv(t,{css:cv})}begin(){var e;(e=this.bench)==null||e.begin("frame")}end(e){var t,i;(t=this.bench)==null||t.end("frame"),(i=this.bench)==null||i.nextFrame(e)}destroy(){this.bench=void 0,we("#gl-bench").remove()}}var Pu=(n=>(n[n.Circle=0]="Circle",n[n.Square=1]="Square",n[n.Triangle=2]="Triangle",n[n.Diamond=3]="Diamond",n[n.Pentagon=4]="Pentagon",n[n.Hexagon=5]="Hexagon",n[n.Star=6]="Star",n[n.Cross=7]="Cross",n[n.None=8]="None",n))(Pu||{});class uv{constructor(e){this._config=e}get pointsNumber(){return this.pointPositions&&this.pointPositions.length/2}get linksNumber(){return this.links&&this.links.length/2}updatePoints(){this.pointPositions=this.inputPointPositions}updatePointColor(){if(this.pointsNumber===void 0){this.pointColors=void 0;return}const e=Tt(this._config.pointDefaultColor);if(this.inputPointColors===void 0||this.inputPointColors.length/4!==this.pointsNumber){this.pointColors=new Float32Array(this.pointsNumber*4);for(let t=0;t<this.pointColors.length/4;t++)this.pointColors[t*4]=e[0],this.pointColors[t*4+1]=e[1],this.pointColors[t*4+2]=e[2],this.pointColors[t*4+3]=e[3]}else{this.pointColors=this.inputPointColors;for(let t=0;t<this.pointColors.length/4;t++)Ke(this.pointColors[t*4])||(this.pointColors[t*4]=e[0]),Ke(this.pointColors[t*4+1])||(this.pointColors[t*4+1]=e[1]),Ke(this.pointColors[t*4+2])||(this.pointColors[t*4+2]=e[2]),Ke(this.pointColors[t*4+3])||(this.pointColors[t*4+3]=e[3])}}updatePointSize(){if(this.pointsNumber===void 0){this.pointSizes=void 0;return}const e=this._config.pointDefaultSize;if(this.inputPointSizes===void 0||this.inputPointSizes.length!==this.pointsNumber)this.pointSizes=new Float32Array(this.pointsNumber).fill(e);else{this.pointSizes=this.inputPointSizes;for(let t=0;t<this.pointSizes.length;t++)Ke(this.pointSizes[t])||(this.pointSizes[t]=e)}}updatePointShape(){if(this.pointsNumber===void 0){this.pointShapes=void 0;return}const e=0;if(this.inputPointShapes===void 0||this.inputPointShapes.length!==this.pointsNumber)this.pointShapes=new Float32Array(this.pointsNumber).fill(e);else{this.pointShapes=new Float32Array(this.inputPointShapes);const t=this.pointShapes;for(let i=0;i<t.length;i++){const r=t[i];(r==null||!Ke(r)||r<0||r>8)&&(t[i]=e)}}}updatePointImageIndices(){if(this.pointsNumber===void 0){this.pointImageIndices=void 0;return}if(this.inputPointImageIndices===void 0||this.inputPointImageIndices.length!==this.pointsNumber)this.pointImageIndices=new Float32Array(this.pointsNumber).fill(-1);else{const e=new Float32Array(this.inputPointImageIndices);for(let t=0;t<e.length;t++){const i=e[t],r=i===void 0?NaN:i;!Number.isFinite(r)||r<0?e[t]=-1:e[t]=Math.trunc(r)}this.pointImageIndices=e}}updatePointImageSizes(){var t;if(this.pointsNumber===void 0){this.pointImageSizes=void 0;return}const e=this._config.pointDefaultSize;if(this.inputPointImageSizes===void 0||this.inputPointImageSizes.length!==this.pointsNumber)this.pointImageSizes=this.pointSizes?new Float32Array(this.pointSizes):new Float32Array(this.pointsNumber).fill(e);else{this.pointImageSizes=new Float32Array(this.inputPointImageSizes);for(let i=0;i<this.pointImageSizes.length;i++)Ke(this.pointImageSizes[i])||(this.pointImageSizes[i]=((t=this.pointSizes)==null?void 0:t[i])??e)}}updateLinks(){this.links=this.inputLinks}updateLinkColor(){if(this.linksNumber===void 0){this.linkColors=void 0;return}const e=Tt(this._config.linkDefaultColor);if(this.inputLinkColors===void 0||this.inputLinkColors.length/4!==this.linksNumber){this.linkColors=new Float32Array(this.linksNumber*4);for(let t=0;t<this.linkColors.length/4;t++)this.linkColors[t*4]=e[0],this.linkColors[t*4+1]=e[1],this.linkColors[t*4+2]=e[2],this.linkColors[t*4+3]=e[3]}else{this.linkColors=this.inputLinkColors;for(let t=0;t<this.linkColors.length/4;t++)Ke(this.linkColors[t*4])||(this.linkColors[t*4]=e[0]),Ke(this.linkColors[t*4+1])||(this.linkColors[t*4+1]=e[1]),Ke(this.linkColors[t*4+2])||(this.linkColors[t*4+2]=e[2]),Ke(this.linkColors[t*4+3])||(this.linkColors[t*4+3]=e[3])}}updateLinkWidth(){if(this.linksNumber===void 0){this.linkWidths=void 0;return}const e=this._config.linkDefaultWidth;if(this.inputLinkWidths===void 0||this.inputLinkWidths.length!==this.linksNumber)this.linkWidths=new Float32Array(this.linksNumber).fill(e);else{this.linkWidths=this.inputLinkWidths;for(let t=0;t<this.linkWidths.length;t++)Ke(this.linkWidths[t])||(this.linkWidths[t]=e)}}updateArrows(){if(this.linksNumber===void 0){this.linkArrows=void 0;return}const e=this._config.linkDefaultArrows;this.linkArrowsBoolean===void 0||this.linkArrowsBoolean.length!==this.linksNumber?this.linkArrows=new Array(this.linksNumber).fill(+e):this.linkArrows=this.linkArrowsBoolean.map(t=>+t)}updateLinkStrength(){this.linksNumber===void 0&&(this.linkStrength=void 0),this.inputLinkStrength===void 0||this.inputLinkStrength.length!==this.linksNumber?this.linkStrength=void 0:this.linkStrength=this.inputLinkStrength}updateClusters(){if(this.pointsNumber===void 0){this.pointClusters=void 0,this.clusterPositions=void 0;return}this.inputPointClusters===void 0||this.inputPointClusters.length!==this.pointsNumber?this.pointClusters=void 0:this.pointClusters=this.inputPointClusters,this.inputClusterPositions===void 0?this.clusterPositions=void 0:this.clusterPositions=this.inputClusterPositions,this.inputClusterStrength===void 0||this.inputClusterStrength.length!==this.pointsNumber?this.clusterStrength=void 0:this.clusterStrength=this.inputClusterStrength}update(){this.updatePoints(),this.updatePointColor(),this.updatePointSize(),this.updatePointShape(),this.updatePointImageIndices(),this.updatePointImageSizes(),this.updateLinks(),this.updateLinkColor(),this.updateLinkWidth(),this.updateArrows(),this.updateLinkStrength(),this.updateClusters(),this._createAdjacencyLists(),this._calculateDegrees()}getAdjacentIndices(e){var t,i,r,s;return[...((i=(t=this.sourceIndexToTargetIndices)==null?void 0:t[e])==null?void 0:i.map(o=>o[0]))||[],...((s=(r=this.targetIndexToSourceIndices)==null?void 0:r[e])==null?void 0:s.map(o=>o[0]))||[]]}_createAdjacencyLists(){var e,t;if(this.linksNumber===void 0||this.links===void 0){this.sourceIndexToTargetIndices=void 0,this.targetIndexToSourceIndices=void 0;return}this.sourceIndexToTargetIndices=new Array(this.pointsNumber).fill(void 0),this.targetIndexToSourceIndices=new Array(this.pointsNumber).fill(void 0);for(let i=0;i<this.linksNumber;i++){const r=this.links[i*2],s=this.links[i*2+1];r!==void 0&&s!==void 0&&(this.sourceIndexToTargetIndices[r]===void 0&&(this.sourceIndexToTargetIndices[r]=[]),(e=this.sourceIndexToTargetIndices[r])==null||e.push([s,i]),this.targetIndexToSourceIndices[s]===void 0&&(this.targetIndexToSourceIndices[s]=[]),(t=this.targetIndexToSourceIndices[s])==null||t.push([r,i]))}}_calculateDegrees(){var e,t,i,r;if(this.pointsNumber===void 0){this.degree=void 0,this.inDegree=void 0,this.outDegree=void 0;return}this.degree=new Array(this.pointsNumber).fill(0),this.inDegree=new Array(this.pointsNumber).fill(0),this.outDegree=new Array(this.pointsNumber).fill(0);for(let s=0;s<this.pointsNumber;s++)this.inDegree[s]=((t=(e=this.targetIndexToSourceIndices)==null?void 0:e[s])==null?void 0:t.length)??0,this.outDegree[s]=((r=(i=this.sourceIndexToTargetIndices)==null?void 0:i[s])==null?void 0:r.length)??0,this.degree[s]=(this.inDegree[s]??0)+(this.outDegree[s]??0)}}const Eu={name:"conicParametricCurve",vs:`
|
|
811
|
+
vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) {
|
|
812
|
+
vec2 divident = (1.0 - t) * (1.0 - t) * A + 2.0 * (1.0 - t) * t * w * ControlPoint + t * t * B;
|
|
813
|
+
float divisor = (1.0 - t) * (1.0 - t) + 2.0 * (1.0 - t) * t * w + t * t;
|
|
814
|
+
return divident / divisor;
|
|
815
|
+
}
|
|
816
|
+
`},fv=`#version 300 es
|
|
811
817
|
#ifdef GL_ES
|
|
812
818
|
precision highp float;
|
|
813
819
|
#endif
|
|
@@ -865,7 +871,7 @@ void main() {
|
|
|
865
871
|
}
|
|
866
872
|
} else fragColor = vec4(color, opacity);
|
|
867
873
|
|
|
868
|
-
}`,
|
|
874
|
+
}`,hv=`#version 300 es
|
|
869
875
|
#ifdef GL_ES
|
|
870
876
|
precision highp float;
|
|
871
877
|
#endif
|
|
@@ -956,12 +962,6 @@ float map(float value, float min1, float max1, float min2, float max2) {
|
|
|
956
962
|
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
|
|
957
963
|
}
|
|
958
964
|
|
|
959
|
-
vec2 conicParametricCurve(vec2 A, vec2 B, vec2 ControlPoint, float t, float w) {
|
|
960
|
-
vec2 divident = (1.0 - t) * (1.0 - t) * A + 2.0 * (1.0 - t) * t * w * ControlPoint + t * t * B;
|
|
961
|
-
float divisor = (1.0 - t) * (1.0 - t) + 2.0 * (1.0 - t) * t * w + t * t;
|
|
962
|
-
return divident / divisor;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
965
|
float calculateLinkWidth(float width) {
|
|
966
966
|
float linkWidth;
|
|
967
967
|
if (scaleLinksOnZoom > 0.0) {
|
|
@@ -1112,7 +1112,100 @@ void main() {
|
|
|
1112
1112
|
#endif
|
|
1113
1113
|
|
|
1114
1114
|
gl_Position = vec4(final.rg, 0, 1);
|
|
1115
|
-
}`,
|
|
1115
|
+
}`,dv=`#version 300 es
|
|
1116
|
+
#ifdef GL_ES
|
|
1117
|
+
precision highp float;
|
|
1118
|
+
#endif
|
|
1119
|
+
|
|
1120
|
+
in vec4 rgba;
|
|
1121
|
+
|
|
1122
|
+
out vec4 fragColor;
|
|
1123
|
+
|
|
1124
|
+
void main() {
|
|
1125
|
+
fragColor = rgba;
|
|
1126
|
+
}
|
|
1127
|
+
`,pv=`#version 300 es
|
|
1128
|
+
#ifdef GL_ES
|
|
1129
|
+
precision highp float;
|
|
1130
|
+
#endif
|
|
1131
|
+
|
|
1132
|
+
in vec2 pointA;
|
|
1133
|
+
in vec2 pointB;
|
|
1134
|
+
in float linkIndices;
|
|
1135
|
+
|
|
1136
|
+
uniform sampler2D positionsTexture;
|
|
1137
|
+
|
|
1138
|
+
#ifdef USE_UNIFORM_BUFFERS
|
|
1139
|
+
layout(std140) uniform fillSampledLinksUniforms {
|
|
1140
|
+
float pointsTextureSize;
|
|
1141
|
+
mat4 transformationMatrix;
|
|
1142
|
+
float spaceSize;
|
|
1143
|
+
vec2 screenSize;
|
|
1144
|
+
float curvedWeight;
|
|
1145
|
+
float curvedLinkControlPointDistance;
|
|
1146
|
+
float curvedLinkSegments;
|
|
1147
|
+
} fillSampledLinks;
|
|
1148
|
+
|
|
1149
|
+
#define pointsTextureSize fillSampledLinks.pointsTextureSize
|
|
1150
|
+
#define transformationMatrix fillSampledLinks.transformationMatrix
|
|
1151
|
+
#define spaceSize fillSampledLinks.spaceSize
|
|
1152
|
+
#define screenSize fillSampledLinks.screenSize
|
|
1153
|
+
#define curvedWeight fillSampledLinks.curvedWeight
|
|
1154
|
+
#define curvedLinkControlPointDistance fillSampledLinks.curvedLinkControlPointDistance
|
|
1155
|
+
#define curvedLinkSegments fillSampledLinks.curvedLinkSegments
|
|
1156
|
+
#else
|
|
1157
|
+
uniform float pointsTextureSize;
|
|
1158
|
+
uniform float spaceSize;
|
|
1159
|
+
uniform vec2 screenSize;
|
|
1160
|
+
uniform float curvedWeight;
|
|
1161
|
+
uniform float curvedLinkControlPointDistance;
|
|
1162
|
+
uniform float curvedLinkSegments;
|
|
1163
|
+
uniform mat3 transformationMatrix;
|
|
1164
|
+
#endif
|
|
1165
|
+
|
|
1166
|
+
out vec4 rgba;
|
|
1167
|
+
|
|
1168
|
+
void main() {
|
|
1169
|
+
vec4 posA = texture(positionsTexture, (pointA + 0.5) / pointsTextureSize);
|
|
1170
|
+
vec4 posB = texture(positionsTexture, (pointB + 0.5) / pointsTextureSize);
|
|
1171
|
+
vec2 a = posA.rg;
|
|
1172
|
+
vec2 b = posB.rg;
|
|
1173
|
+
|
|
1174
|
+
vec2 tangent = b - a;
|
|
1175
|
+
float angle = -atan(tangent.y, tangent.x);
|
|
1176
|
+
|
|
1177
|
+
vec2 mid;
|
|
1178
|
+
if (curvedLinkSegments <= 1.0) {
|
|
1179
|
+
mid = (a + b) * 0.5;
|
|
1180
|
+
} else if (curvedLinkControlPointDistance != 0.0 && curvedWeight != 0.0) {
|
|
1181
|
+
vec2 xBasis = b - a;
|
|
1182
|
+
vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
|
|
1183
|
+
float linkDist = length(xBasis);
|
|
1184
|
+
float h = curvedLinkControlPointDistance;
|
|
1185
|
+
vec2 controlPoint = (a + b) / 2.0 + yBasis * linkDist * h;
|
|
1186
|
+
mid = conicParametricCurve(a, b, controlPoint, 0.5, curvedWeight);
|
|
1187
|
+
} else {
|
|
1188
|
+
mid = (a + b) * 0.5;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
vec2 p = 2.0 * mid / spaceSize - 1.0;
|
|
1192
|
+
p *= spaceSize / screenSize;
|
|
1193
|
+
#ifdef USE_UNIFORM_BUFFERS
|
|
1194
|
+
mat3 transformMat3 = mat3(transformationMatrix);
|
|
1195
|
+
vec3 final = transformMat3 * vec3(p, 1);
|
|
1196
|
+
#else
|
|
1197
|
+
vec3 final = transformationMatrix * vec3(p, 1);
|
|
1198
|
+
#endif
|
|
1199
|
+
|
|
1200
|
+
vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0;
|
|
1201
|
+
rgba = vec4(linkIndices, mid.x, mid.y, angle);
|
|
1202
|
+
float i = (pointScreenPosition.x + 0.5) / screenSize.x;
|
|
1203
|
+
float j = (pointScreenPosition.y + 0.5) / screenSize.y;
|
|
1204
|
+
gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0);
|
|
1205
|
+
|
|
1206
|
+
gl_PointSize = 1.0;
|
|
1207
|
+
}
|
|
1208
|
+
`,mv=`#version 300 es
|
|
1116
1209
|
#ifdef GL_ES
|
|
1117
1210
|
precision highp float;
|
|
1118
1211
|
#endif
|
|
@@ -1152,7 +1245,7 @@ void main() {
|
|
|
1152
1245
|
// No link at this position, output -1 to indicate no hover
|
|
1153
1246
|
fragColor = vec4(-1.0, 0.0, 0.0, 0.0);
|
|
1154
1247
|
}
|
|
1155
|
-
} `,
|
|
1248
|
+
} `,gv=`#version 300 es
|
|
1156
1249
|
#ifdef GL_ES
|
|
1157
1250
|
precision highp float;
|
|
1158
1251
|
#endif
|
|
@@ -1161,7 +1254,7 @@ in vec2 vertexCoord;
|
|
|
1161
1254
|
|
|
1162
1255
|
void main() {
|
|
1163
1256
|
gl_Position = vec4(vertexCoord, 0.0, 1.0);
|
|
1164
|
-
} `,pv=n=>{const e=nc().exponent(2).range([0,1]).domain([-1,1]),t=ly(0,n).map(r=>-.5+r/n);t.push(.5);const i=new Array(t.length*2);return t.forEach((r,s)=>{i[s*2]=[e(r*2),.5],i[s*2+1]=[e(r*2),-.5]}),i};class gv extends Nt{initPrograms(){var s;const{device:e,config:t,store:i}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST,data:new Float32Array(4).fill(0)})),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=e.createFramebuffer({width:1,height:1,colorAttachments:[this.hoveredLineIndexTexture]})),this.curveLineGeometry||this.updateCurveLineGeometry();const r=this.data.linksNumber??0;this.pointABuffer||(this.pointABuffer=e.createBuffer({data:new Float32Array(r*2),usage:L.VERTEX|L.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=e.createBuffer({data:new Float32Array(r*2),usage:L.VERTEX|L.COPY_DST})),this.colorBuffer||(this.colorBuffer=e.createBuffer({data:new Float32Array(r*4),usage:L.VERTEX|L.COPY_DST})),this.widthBuffer||(this.widthBuffer=e.createBuffer({data:new Float32Array(r),usage:L.VERTEX|L.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=e.createBuffer({data:new Float32Array(r),usage:L.VERTEX|L.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=e.createBuffer({data:new Float32Array(r),usage:L.VERTEX|L.COPY_DST})),this.drawLineUniformStore||(this.drawLineUniformStore=new ye({drawLineUniforms:{uniformTypes:{transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",widthScale:"f32",linkArrowsSizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",linkVisibilityDistanceRange:"vec2<f32>",linkVisibilityMinTransparency:"f32",linkOpacity:"f32",greyoutOpacity:"f32",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32",scaleLinksOnZoom:"f32",maxPointSize:"f32",renderMode:"f32",hoveredLinkIndex:"f32",hoveredLinkColor:"vec4<f32>",hoveredLinkWidthIncrease:"f32"},defaultUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),linkVisibilityDistanceRange:re(t.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:Re(i.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}})),this.drawCurveCommand||(this.drawCurveCommand=new _e(e,{vs:fv,fs:uv,topology:"triangle-strip",vertexCount:((s=this.curveLineGeometry)==null?void 0:s.length)??0,attributes:{...this.curveLineBuffer&&{position:this.curveLineBuffer},...this.pointABuffer&&{pointA:this.pointABuffer},...this.pointBBuffer&&{pointB:this.pointBBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.widthBuffer&&{width:this.widthBuffer},...this.arrowBuffer&&{arrow:this.arrowBuffer},...this.linkIndexBuffer&&{linkIndices:this.linkIndexBuffer}},bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"color",format:"float32x4",stepMode:"instance"},{name:"width",format:"float32",stepMode:"instance"},{name:"arrow",format:"float32",stepMode:"instance"},{name:"linkIndices",format:"float32",stepMode:"instance"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineFragmentUniforms")},parameters:{cullMode:"back",blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.quadBuffer||(this.quadBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:L.VERTEX|L.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new ye({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:re(i.screenMousePosition,[0,0]),screenSize:re(i.screenSize,[0,0])}}})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=new _e(e,{vs:dv,fs:hv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.quadBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(e,"hoveredLineIndexUniforms")}}))}draw(e){const{config:t,points:i,store:r}=this;i&&(!i.currentPositionTexture||i.currentPositionTexture.destroyed||!i.greyoutStatusTexture||i.greyoutStatusTexture.destroyed||((!this.pointABuffer||!this.pointBBuffer)&&this.updatePointsBuffer(),this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!(!this.drawCurveCommand||!this.drawLineUniformStore)&&(this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),linkVisibilityDistanceRange:re(t.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,renderMode:0,hoveredLinkIndex:r.hoveredLinkIndex??-1,hoveredLinkColor:Re(r.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({positionsTexture:i.currentPositionTexture,pointGreyoutStatus:i.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e))))}updateLinkIndexFbo(){var a,l;const{device:e,store:t}=this;if(!this.store.isLinkHoveringEnabled)return;const i=t.screenSize??[0,0],r=i[0],s=i[1];if(!r||!s)return;const o=((a=this.previousScreenSize)==null?void 0:a[0])!==r||((l=this.previousScreenSize)==null?void 0:l[1])!==s;(!this.linkIndexTexture||o)&&(this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=e.createTexture({width:r,height:s,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(r*s*4).fill(0),bytesPerRow:ne("rgba32float",r),mipLevel:0,x:0,y:0}),this.linkIndexFbo=e.createFramebuffer({width:r,height:s,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[r,s])}updatePointsBuffer(){var l;const{device:e,data:t,store:i}=this;if(t.linksNumber===void 0||t.links===void 0||!i.pointsTextureSize)return;const r=new Float32Array(t.linksNumber*2),s=new Float32Array(t.linksNumber*2);for(let c=0;c<t.linksNumber;c++){const u=t.links[c*2],f=t.links[c*2+1],h=u%i.pointsTextureSize,d=Math.floor(u/i.pointsTextureSize),_=f%i.pointsTextureSize,I=Math.floor(f/i.pointsTextureSize);r[c*2]=h,r[c*2+1]=d,s[c*2]=_,s[c*2+1]=I}const o=(((l=this.pointABuffer)==null?void 0:l.byteLength)??0)/(Float32Array.BYTES_PER_ELEMENT*2);!this.pointABuffer||o!==t.linksNumber?(this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||o!==t.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=e.createBuffer({data:s,usage:L.VERTEX|L.COPY_DST})):this.pointBBuffer.write(s);const a=new Float32Array(t.linksNumber);for(let c=0;c<t.linksNumber;c++)a[c]=c;!this.linkIndexBuffer||o!==t.linksNumber?(this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=e.createBuffer({data:a,usage:L.VERTEX|L.COPY_DST})):this.linkIndexBuffer.write(a),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer})}updateColor(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkColors??new Float32Array(i*4).fill(0);this.colorBuffer?(this.colorBuffer.byteLength??0)/(Float32Array.BYTES_PER_ELEMENT*4)!==i?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.colorBuffer.write(r):this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({color:this.colorBuffer})}updateWidth(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkWidths??new Float32Array(i).fill(0);this.widthBuffer?(this.widthBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.widthBuffer.write(r):this.widthBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({width:this.widthBuffer})}updateArrow(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkArrows?new Float32Array(t.linkArrows):new Float32Array(i).fill(0);this.arrowBuffer?(this.arrowBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.arrowBuffer.write(r):this.arrowBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({arrow:this.arrowBuffer})}updateCurveLineGeometry(){const{device:e,config:{curvedLinks:t,curvedLinkSegments:i}}=this;this.curveLineGeometry=pv(t?i??V.curvedLinkSegments:1);const r=new Float32Array(this.curveLineGeometry.length*2);for(let s=0;s<this.curveLineGeometry.length;s++)r[s*2]=this.curveLineGeometry[s][0],r[s*2+1]=this.curveLineGeometry[s][1];!this.curveLineBuffer||this.curveLineBuffer.byteLength!==r.byteLength?(this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.curveLineBuffer.write(r),this.drawCurveCommand&&(this.drawCurveCommand.setAttributes({position:this.curveLineBuffer}),this.drawCurveCommand.setVertexCount(this.curveLineGeometry.length))}findHoveredLine(){const{config:e,points:t,store:i}=this;if(!t||!t.currentPositionTexture||t.currentPositionTexture.destroyed||!t.greyoutStatusTexture||t.greyoutStatusTexture.destroyed||!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawCurveCommand||!this.drawLineUniformStore||!this.linkIndexTexture||this.linkIndexTexture.destroyed)return;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:e.linkWidthScale??1,linkArrowsSizeScale:e.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),linkVisibilityDistanceRange:re(e.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:e.linkVisibilityMinTransparency??0,linkOpacity:e.linkOpacity??1,greyoutOpacity:e.linkGreyoutOpacity??1,curvedWeight:e.curvedLinkWeight??0,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance??0,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:1,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:Re(i.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurveCommand.setBindings({positionsTexture:t.currentPositionTexture,pointGreyoutStatus:t.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0);const r=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurveCommand.draw(r),r.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:re(i.screenMousePosition,[0,0]),screenSize:re(i.screenSize,[0,0])}}),this.hoveredLineIndexCommand.setBindings({linkIndexTexture:this.linkIndexTexture});const s=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(s),s.end()}}destroy(){var e,t,i,r;(e=this.drawCurveCommand)==null||e.destroy(),this.drawCurveCommand=void 0,(t=this.hoveredLineIndexCommand)==null||t.destroy(),this.hoveredLineIndexCommand=void 0,this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexFbo=void 0,this.hoveredLineIndexFbo&&!this.hoveredLineIndexFbo.destroyed&&this.hoveredLineIndexFbo.destroy(),this.hoveredLineIndexFbo=void 0,this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=void 0,this.hoveredLineIndexTexture&&!this.hoveredLineIndexTexture.destroyed&&this.hoveredLineIndexTexture.destroy(),this.hoveredLineIndexTexture=void 0,(i=this.drawLineUniformStore)==null||i.destroy(),this.drawLineUniformStore=void 0,(r=this.hoveredLineIndexUniformStore)==null||r.destroy(),this.hoveredLineIndexUniformStore=void 0,this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=void 0,this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=void 0,this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=void 0,this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=void 0,this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=void 0,this.quadBuffer&&!this.quadBuffer.destroyed&&this.quadBuffer.destroy(),this.quadBuffer=void 0}}const mv=`#version 300 es
|
|
1257
|
+
} `,_v=n=>{const e=dc().exponent(2).range([0,1]).domain([-1,1]),t=cx(0,n).map(r=>-.5+r/n);t.push(.5);const i=new Array(t.length*2);return t.forEach((r,s)=>{i[s*2]=[e(r*2),.5],i[s*2+1]=[e(r*2),-.5]}),i};class xv extends Nt{initPrograms(){var o;const{device:e,config:t,store:i,data:r}=this;this.updateLinkIndexFbo(),this.hoveredLineIndexTexture||(this.hoveredLineIndexTexture=e.createTexture({width:1,height:1,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST,data:new Float32Array(4).fill(0)})),this.hoveredLineIndexFbo||(this.hoveredLineIndexFbo=e.createFramebuffer({width:1,height:1,colorAttachments:[this.hoveredLineIndexTexture]})),this.curveLineGeometry||this.updateCurveLineGeometry();const s=this.data.linksNumber??0;this.pointABuffer||(this.pointABuffer=e.createBuffer({data:new Float32Array(s*2),usage:L.VERTEX|L.COPY_DST})),this.pointBBuffer||(this.pointBBuffer=e.createBuffer({data:new Float32Array(s*2),usage:L.VERTEX|L.COPY_DST})),this.colorBuffer||(this.colorBuffer=e.createBuffer({data:new Float32Array(s*4),usage:L.VERTEX|L.COPY_DST})),this.widthBuffer||(this.widthBuffer=e.createBuffer({data:new Float32Array(s),usage:L.VERTEX|L.COPY_DST})),this.arrowBuffer||(this.arrowBuffer=e.createBuffer({data:new Float32Array(s),usage:L.VERTEX|L.COPY_DST})),this.linkIndexBuffer||(this.linkIndexBuffer=e.createBuffer({data:new Float32Array(s),usage:L.VERTEX|L.COPY_DST})),this.drawLineUniformStore||(this.drawLineUniformStore=new xe({drawLineUniforms:{uniformTypes:{transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",widthScale:"f32",linkArrowsSizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",linkVisibilityDistanceRange:"vec2<f32>",linkVisibilityMinTransparency:"f32",linkOpacity:"f32",greyoutOpacity:"f32",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32",scaleLinksOnZoom:"f32",maxPointSize:"f32",renderMode:"f32",hoveredLinkIndex:"f32",hoveredLinkColor:"vec4<f32>",hoveredLinkWidthIncrease:"f32"},defaultUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),linkVisibilityDistanceRange:re(t.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:0,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:Re(i.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0}},drawLineFragmentUniforms:{uniformTypes:{renderMode:"f32"},defaultUniforms:{renderMode:0}}})),this.drawCurveCommand||(this.drawCurveCommand=new me(e,{vs:hv,fs:fv,modules:[Eu],topology:"triangle-strip",vertexCount:((o=this.curveLineGeometry)==null?void 0:o.length)??0,attributes:{...this.curveLineBuffer&&{position:this.curveLineBuffer},...this.pointABuffer&&{pointA:this.pointABuffer},...this.pointBBuffer&&{pointB:this.pointBBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.widthBuffer&&{width:this.widthBuffer},...this.arrowBuffer&&{arrow:this.arrowBuffer},...this.linkIndexBuffer&&{linkIndices:this.linkIndexBuffer}},bufferLayout:[{name:"position",format:"float32x2"},{name:"pointA",format:"float32x2",stepMode:"instance"},{name:"pointB",format:"float32x2",stepMode:"instance"},{name:"color",format:"float32x4",stepMode:"instance"},{name:"width",format:"float32",stepMode:"instance"},{name:"arrow",format:"float32",stepMode:"instance"},{name:"linkIndices",format:"float32",stepMode:"instance"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawLineUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineUniforms"),drawLineFragmentUniforms:this.drawLineUniformStore.getManagedUniformBuffer(e,"drawLineFragmentUniforms")},parameters:{cullMode:"back",blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.quadBuffer||(this.quadBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),usage:L.VERTEX|L.COPY_DST})),this.hoveredLineIndexUniformStore||(this.hoveredLineIndexUniformStore=new xe({hoveredLineIndexUniforms:{uniformTypes:{mousePosition:"vec2<f32>",screenSize:"vec2<f32>"},defaultUniforms:{mousePosition:re(i.screenMousePosition,[0,0]),screenSize:re(i.screenSize,[0,0])}}})),this.hoveredLineIndexCommand||(this.hoveredLineIndexCommand=new me(e,{vs:gv,fs:mv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.quadBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{hoveredLineIndexUniforms:this.hoveredLineIndexUniformStore.getManagedUniformBuffer(e,"hoveredLineIndexUniforms")}})),this.fillSampledLinksUniformStore||(this.fillSampledLinksUniformStore=new xe({fillSampledLinksUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>",curvedWeight:"f32",curvedLinkControlPointDistance:"f32",curvedLinkSegments:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,transformationMatrix:i.transformationMatrix4x4,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1}}})),this.fillSampledLinksFboCommand||(this.fillSampledLinksFboCommand=new me(e,{fs:dv,vs:pv,modules:[Eu],topology:"point-list",vertexCount:r.linksNumber??0,attributes:{...this.pointABuffer&&{pointA:this.pointABuffer},...this.pointBBuffer&&{pointB:this.pointBBuffer},...this.linkIndexBuffer&&{linkIndices:this.linkIndexBuffer}},bufferLayout:[{name:"pointA",format:"float32x2"},{name:"pointB",format:"float32x2"},{name:"linkIndices",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledLinksUniforms:this.fillSampledLinksUniformStore.getManagedUniformBuffer(e,"fillSampledLinksUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.updateSampledLinksGrid()}draw(e){const{config:t,points:i,store:r}=this;i&&(!i.currentPositionTexture||i.currentPositionTexture.destroyed||!i.greyoutStatusTexture||i.greyoutStatusTexture.destroyed||((!this.pointABuffer||!this.pointBBuffer)&&this.updatePointsBuffer(),this.colorBuffer||this.updateColor(),this.widthBuffer||this.updateWidth(),this.arrowBuffer||this.updateArrow(),this.curveLineGeometry||this.updateCurveLineGeometry(),!(!this.drawCurveCommand||!this.drawLineUniformStore)&&(this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize,widthScale:t.linkWidthScale??1,linkArrowsSizeScale:t.linkArrowsSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),linkVisibilityDistanceRange:re(t.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:t.linkVisibilityMinTransparency??0,linkOpacity:t.linkOpacity??1,greyoutOpacity:t.linkGreyoutOpacity??1,curvedWeight:t.curvedLinkWeight??0,curvedLinkControlPointDistance:t.curvedLinkControlPointDistance??0,curvedLinkSegments:t.curvedLinks?t.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:t.scaleLinksOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,renderMode:0,hoveredLinkIndex:r.hoveredLinkIndex??-1,hoveredLinkColor:Re(r.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:t.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:0}}),this.drawCurveCommand.setBindings({positionsTexture:i.currentPositionTexture,pointGreyoutStatus:i.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0),this.drawCurveCommand.draw(e))))}updateLinkIndexFbo(){var a,l;const{device:e,store:t}=this;if(!this.store.isLinkHoveringEnabled)return;const i=t.screenSize??[0,0],r=i[0],s=i[1];if(!r||!s)return;const o=((a=this.previousScreenSize)==null?void 0:a[0])!==r||((l=this.previousScreenSize)==null?void 0:l[1])!==s;(!this.linkIndexTexture||o)&&(this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=e.createTexture({width:r,height:s,format:"rgba32float",usage:Q.SAMPLE|Q.RENDER|Q.COPY_DST}),this.linkIndexTexture.copyImageData({data:new Float32Array(r*s*4).fill(0),bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),this.linkIndexFbo=e.createFramebuffer({width:r,height:s,colorAttachments:[this.linkIndexTexture]}),this.previousScreenSize=[r,s])}updateSampledLinksGrid(){const{store:{screenSize:e},config:{linkSamplingDistance:t},device:i}=this;let r=t??Math.min(...e)/2;r===0&&(r=V.linkSamplingDistance);const s=Math.ceil(e[0]/r),o=Math.ceil(e[1]/r);s===0||o===0||(!this.sampledLinksFbo||this.sampledLinksFbo.width!==s||this.sampledLinksFbo.height!==o)&&(this.sampledLinksFbo&&!this.sampledLinksFbo.destroyed&&this.sampledLinksFbo.destroy(),this.sampledLinksFbo=i.createFramebuffer({width:s,height:o,colorAttachments:["rgba32float"]}))}updatePointsBuffer(){var l;const{device:e,data:t,store:i}=this;if(t.linksNumber===void 0||t.links===void 0||!i.pointsTextureSize)return;const r=new Float32Array(t.linksNumber*2),s=new Float32Array(t.linksNumber*2);for(let c=0;c<t.linksNumber;c++){const u=t.links[c*2],f=t.links[c*2+1],h=u%i.pointsTextureSize,d=Math.floor(u/i.pointsTextureSize),_=f%i.pointsTextureSize,I=Math.floor(f/i.pointsTextureSize);r[c*2]=h,r[c*2+1]=d,s[c*2]=_,s[c*2+1]=I}const o=(((l=this.pointABuffer)==null?void 0:l.byteLength)??0)/(Float32Array.BYTES_PER_ELEMENT*2);!this.pointABuffer||o!==t.linksNumber?(this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.pointABuffer.write(r),!this.pointBBuffer||o!==t.linksNumber?(this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=e.createBuffer({data:s,usage:L.VERTEX|L.COPY_DST})):this.pointBBuffer.write(s);const a=new Float32Array(t.linksNumber);for(let c=0;c<t.linksNumber;c++)a[c]=c;!this.linkIndexBuffer||o!==t.linksNumber?(this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=e.createBuffer({data:a,usage:L.VERTEX|L.COPY_DST})):this.linkIndexBuffer.write(a),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer}),this.fillSampledLinksFboCommand&&this.fillSampledLinksFboCommand.setAttributes({pointA:this.pointABuffer,pointB:this.pointBBuffer,linkIndices:this.linkIndexBuffer}),this.updateSampledLinksGrid()}updateColor(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkColors??new Float32Array(i*4).fill(0);this.colorBuffer?(this.colorBuffer.byteLength??0)/(Float32Array.BYTES_PER_ELEMENT*4)!==i?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.colorBuffer.write(r):this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({color:this.colorBuffer})}updateWidth(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkWidths??new Float32Array(i).fill(0);this.widthBuffer?(this.widthBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.widthBuffer.write(r):this.widthBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({width:this.widthBuffer})}updateArrow(){const{device:e,data:t}=this,i=t.linksNumber??0,r=t.linkArrows?new Float32Array(t.linkArrows):new Float32Array(i).fill(0);this.arrowBuffer?(this.arrowBuffer.byteLength??0)/Float32Array.BYTES_PER_ELEMENT!==i?(this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.arrowBuffer.write(r):this.arrowBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST}),this.drawCurveCommand&&this.drawCurveCommand.setAttributes({arrow:this.arrowBuffer})}updateCurveLineGeometry(){const{device:e,config:{curvedLinks:t,curvedLinkSegments:i}}=this;this.curveLineGeometry=_v(t?i??V.curvedLinkSegments:1);const r=new Float32Array(this.curveLineGeometry.length*2);for(let s=0;s<this.curveLineGeometry.length;s++)r[s*2]=this.curveLineGeometry[s][0],r[s*2+1]=this.curveLineGeometry[s][1];!this.curveLineBuffer||this.curveLineBuffer.byteLength!==r.byteLength?(this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.curveLineBuffer.write(r),this.drawCurveCommand&&(this.drawCurveCommand.setAttributes({position:this.curveLineBuffer}),this.drawCurveCommand.setVertexCount(this.curveLineGeometry.length))}getSampledLinkPositionsMap(){const e=new Map;if(!this.sampledLinksFbo||this.sampledLinksFbo.destroyed)return e;const t=this.points;if(!(t!=null&&t.currentPositionTexture)||t.currentPositionTexture.destroyed)return e;if(this.fillSampledLinksFboCommand&&this.fillSampledLinksUniformStore&&this.sampledLinksFbo){this.fillSampledLinksFboCommand.setVertexCount(this.data.linksNumber??0),this.fillSampledLinksUniformStore.setUniforms({fillSampledLinksUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),curvedWeight:this.config.curvedLinkWeight??0,curvedLinkControlPointDistance:this.config.curvedLinkControlPointDistance??0,curvedLinkSegments:this.config.curvedLinks?this.config.curvedLinkSegments??V.curvedLinkSegments:1}}),this.fillSampledLinksFboCommand.setBindings({positionsTexture:t.currentPositionTexture});const r=this.device.beginRenderPass({framebuffer:this.sampledLinksFbo,clearColor:[-1,-1,-1,-1]});this.fillSampledLinksFboCommand.draw(r),r.end()}const i=Me(this.device,this.sampledLinksFbo);for(let r=0;r<i.length/4;r++){const s=i[r*4],o=i[r*4+1],a=i[r*4+2],l=i[r*4+3];s!==void 0&&s>=0&&o!==void 0&&a!==void 0&&l!==void 0&&e.set(Math.round(s),[o,a,l])}return e}getSampledLinks(){const e=[],t=[],i=[];if(!this.sampledLinksFbo||this.sampledLinksFbo.destroyed)return{indices:e,positions:t,angles:i};const r=this.points;if(!(r!=null&&r.currentPositionTexture)||r.currentPositionTexture.destroyed)return{indices:e,positions:t,angles:i};if(this.fillSampledLinksFboCommand&&this.fillSampledLinksUniformStore&&this.sampledLinksFbo){this.fillSampledLinksFboCommand.setVertexCount(this.data.linksNumber??0),this.fillSampledLinksUniformStore.setUniforms({fillSampledLinksUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),curvedWeight:this.config.curvedLinkWeight??0,curvedLinkControlPointDistance:this.config.curvedLinkControlPointDistance??0,curvedLinkSegments:this.config.curvedLinks?this.config.curvedLinkSegments??V.curvedLinkSegments:1}}),this.fillSampledLinksFboCommand.setBindings({positionsTexture:r.currentPositionTexture});const o=this.device.beginRenderPass({framebuffer:this.sampledLinksFbo,clearColor:[-1,-1,-1,-1]});this.fillSampledLinksFboCommand.draw(o),o.end()}const s=Me(this.device,this.sampledLinksFbo);for(let o=0;o<s.length/4;o++){const a=s[o*4],l=s[o*4+1],c=s[o*4+2],u=s[o*4+3];a!==void 0&&a>=0&&l!==void 0&&c!==void 0&&u!==void 0&&(e.push(Math.round(a)),t.push(l,c),i.push(u))}return{indices:e,positions:t,angles:i}}findHoveredLine(){const{config:e,points:t,store:i}=this;if(!t||!t.currentPositionTexture||t.currentPositionTexture.destroyed||!t.greyoutStatusTexture||t.greyoutStatusTexture.destroyed||!this.data.linksNumber||!this.store.isLinkHoveringEnabled||!this.linkIndexFbo||!this.drawCurveCommand||!this.drawLineUniformStore||!this.linkIndexTexture||this.linkIndexTexture.destroyed)return;this.drawLineUniformStore.setUniforms({drawLineUniforms:{transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize,widthScale:e.linkWidthScale??1,linkArrowsSizeScale:e.linkArrowsSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),linkVisibilityDistanceRange:re(e.linkVisibilityDistanceRange,[0,0]),linkVisibilityMinTransparency:e.linkVisibilityMinTransparency??0,linkOpacity:e.linkOpacity??1,greyoutOpacity:e.linkGreyoutOpacity??1,curvedWeight:e.curvedLinkWeight??0,curvedLinkControlPointDistance:e.curvedLinkControlPointDistance??0,curvedLinkSegments:e.curvedLinks?e.curvedLinkSegments??V.curvedLinkSegments:1,scaleLinksOnZoom:e.scaleLinksOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,renderMode:1,hoveredLinkIndex:i.hoveredLinkIndex??-1,hoveredLinkColor:Re(i.hoveredLinkColor,[-1,-1,-1,-1]),hoveredLinkWidthIncrease:e.hoveredLinkWidthIncrease??0},drawLineFragmentUniforms:{renderMode:1}}),this.drawCurveCommand.setBindings({positionsTexture:t.currentPositionTexture,pointGreyoutStatus:t.greyoutStatusTexture}),this.drawCurveCommand.setInstanceCount(this.data.linksNumber??0);const r=this.device.beginRenderPass({framebuffer:this.linkIndexFbo,clearColor:[0,0,0,0]});if(this.drawCurveCommand.draw(r),r.end(),this.hoveredLineIndexCommand&&this.hoveredLineIndexFbo&&this.hoveredLineIndexUniformStore){this.hoveredLineIndexUniformStore.setUniforms({hoveredLineIndexUniforms:{mousePosition:re(i.screenMousePosition,[0,0]),screenSize:re(i.screenSize,[0,0])}}),this.hoveredLineIndexCommand.setBindings({linkIndexTexture:this.linkIndexTexture});const s=this.device.beginRenderPass({framebuffer:this.hoveredLineIndexFbo});this.hoveredLineIndexCommand.draw(s),s.end()}}destroy(){var e,t,i,r,s,o;(e=this.drawCurveCommand)==null||e.destroy(),this.drawCurveCommand=void 0,(t=this.hoveredLineIndexCommand)==null||t.destroy(),this.hoveredLineIndexCommand=void 0,(i=this.fillSampledLinksFboCommand)==null||i.destroy(),this.fillSampledLinksFboCommand=void 0,this.linkIndexFbo&&!this.linkIndexFbo.destroyed&&this.linkIndexFbo.destroy(),this.linkIndexFbo=void 0,this.sampledLinksFbo&&!this.sampledLinksFbo.destroyed&&this.sampledLinksFbo.destroy(),this.sampledLinksFbo=void 0,this.hoveredLineIndexFbo&&!this.hoveredLineIndexFbo.destroyed&&this.hoveredLineIndexFbo.destroy(),this.hoveredLineIndexFbo=void 0,this.linkIndexTexture&&!this.linkIndexTexture.destroyed&&this.linkIndexTexture.destroy(),this.linkIndexTexture=void 0,this.hoveredLineIndexTexture&&!this.hoveredLineIndexTexture.destroyed&&this.hoveredLineIndexTexture.destroy(),this.hoveredLineIndexTexture=void 0,(r=this.drawLineUniformStore)==null||r.destroy(),this.drawLineUniformStore=void 0,(s=this.hoveredLineIndexUniformStore)==null||s.destroy(),this.hoveredLineIndexUniformStore=void 0,(o=this.fillSampledLinksUniformStore)==null||o.destroy(),this.fillSampledLinksUniformStore=void 0,this.pointABuffer&&!this.pointABuffer.destroyed&&this.pointABuffer.destroy(),this.pointABuffer=void 0,this.pointBBuffer&&!this.pointBBuffer.destroyed&&this.pointBBuffer.destroy(),this.pointBBuffer=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.widthBuffer&&!this.widthBuffer.destroyed&&this.widthBuffer.destroy(),this.widthBuffer=void 0,this.arrowBuffer&&!this.arrowBuffer.destroyed&&this.arrowBuffer.destroy(),this.arrowBuffer=void 0,this.curveLineBuffer&&!this.curveLineBuffer.destroyed&&this.curveLineBuffer.destroy(),this.curveLineBuffer=void 0,this.linkIndexBuffer&&!this.linkIndexBuffer.destroyed&&this.linkIndexBuffer.destroy(),this.linkIndexBuffer=void 0,this.quadBuffer&&!this.quadBuffer.destroyed&&this.quadBuffer.destroy(),this.quadBuffer=void 0}}const yv=`#version 300 es
|
|
1165
1258
|
#ifdef GL_ES
|
|
1166
1259
|
precision highp float;
|
|
1167
1260
|
#endif
|
|
@@ -1420,7 +1513,7 @@ void main() {
|
|
|
1420
1513
|
finalPointAlpha
|
|
1421
1514
|
);
|
|
1422
1515
|
}
|
|
1423
|
-
`,
|
|
1516
|
+
`,vv=`#version 300 es
|
|
1424
1517
|
#ifdef GL_ES
|
|
1425
1518
|
precision highp float;
|
|
1426
1519
|
#endif
|
|
@@ -1622,7 +1715,7 @@ void main() {
|
|
|
1622
1715
|
imageAtlasUV = atlasCoords;
|
|
1623
1716
|
}
|
|
1624
1717
|
#endif
|
|
1625
|
-
} `,
|
|
1718
|
+
} `,bv=`#version 300 es
|
|
1626
1719
|
#ifdef GL_ES
|
|
1627
1720
|
precision highp float;
|
|
1628
1721
|
#endif
|
|
@@ -1710,7 +1803,7 @@ void main() {
|
|
|
1710
1803
|
}
|
|
1711
1804
|
}
|
|
1712
1805
|
|
|
1713
|
-
`,
|
|
1806
|
+
`,Sv=`#version 300 es
|
|
1714
1807
|
#ifdef GL_ES
|
|
1715
1808
|
precision highp float;
|
|
1716
1809
|
#endif
|
|
@@ -1798,7 +1891,7 @@ void main() {
|
|
|
1798
1891
|
if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) {
|
|
1799
1892
|
fragColor.r = 1.0;
|
|
1800
1893
|
}
|
|
1801
|
-
} `,
|
|
1894
|
+
} `,Tv=`#version 300 es
|
|
1802
1895
|
#ifdef GL_ES
|
|
1803
1896
|
precision highp float;
|
|
1804
1897
|
#endif
|
|
@@ -1841,7 +1934,7 @@ void main () {
|
|
|
1841
1934
|
float opacity = smoothstep(r, r * smoothing, 1.0);
|
|
1842
1935
|
float stroke = smoothstep(width, width * smoothing, r);
|
|
1843
1936
|
fragColor = vec4(rgbColor, opacity * stroke * pointOpacity);
|
|
1844
|
-
}`,
|
|
1937
|
+
}`,wv=`#version 300 es
|
|
1845
1938
|
#ifdef GL_ES
|
|
1846
1939
|
precision highp float;
|
|
1847
1940
|
#endif
|
|
@@ -1985,7 +2078,7 @@ void main () {
|
|
|
1985
2078
|
#endif
|
|
1986
2079
|
|
|
1987
2080
|
gl_Position = vec4(final.rg, 0, 1);
|
|
1988
|
-
}`,
|
|
2081
|
+
}`,Av=`#version 300 es
|
|
1989
2082
|
#ifdef GL_ES
|
|
1990
2083
|
precision highp float;
|
|
1991
2084
|
#endif
|
|
@@ -1999,7 +2092,7 @@ void main() {
|
|
|
1999
2092
|
discard;
|
|
2000
2093
|
}
|
|
2001
2094
|
fragColor = rgba;
|
|
2002
|
-
}`,
|
|
2095
|
+
}`,Cv=`#version 300 es
|
|
2003
2096
|
#ifdef GL_ES
|
|
2004
2097
|
precision highp float;
|
|
2005
2098
|
#endif
|
|
@@ -2111,7 +2204,7 @@ void main() {
|
|
|
2111
2204
|
}
|
|
2112
2205
|
|
|
2113
2206
|
gl_PointSize = 1.0;
|
|
2114
|
-
}`,
|
|
2207
|
+
}`,Iv=`#version 300 es
|
|
2115
2208
|
#ifdef GL_ES
|
|
2116
2209
|
precision highp float;
|
|
2117
2210
|
#endif
|
|
@@ -2122,7 +2215,7 @@ out vec4 fragColor;
|
|
|
2122
2215
|
|
|
2123
2216
|
void main() {
|
|
2124
2217
|
fragColor = rgba;
|
|
2125
|
-
}`,
|
|
2218
|
+
}`,Pv=`#version 300 es
|
|
2126
2219
|
#ifdef GL_ES
|
|
2127
2220
|
precision highp float;
|
|
2128
2221
|
#endif
|
|
@@ -2172,7 +2265,7 @@ void main() {
|
|
|
2172
2265
|
gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0);
|
|
2173
2266
|
|
|
2174
2267
|
gl_PointSize = 1.0;
|
|
2175
|
-
}`,
|
|
2268
|
+
}`,Ev=`#version 300 es
|
|
2176
2269
|
#ifdef GL_ES
|
|
2177
2270
|
precision highp float;
|
|
2178
2271
|
#endif
|
|
@@ -2222,7 +2315,7 @@ void main() {
|
|
|
2222
2315
|
pointPosition.g = clamp(pointPosition.g, 0.0, spaceSize);
|
|
2223
2316
|
|
|
2224
2317
|
fragColor = pointPosition;
|
|
2225
|
-
}`,
|
|
2318
|
+
}`,Rv=`#version 300 es
|
|
2226
2319
|
#ifdef GL_ES
|
|
2227
2320
|
precision highp float;
|
|
2228
2321
|
#endif
|
|
@@ -2252,7 +2345,7 @@ void main() {
|
|
|
2252
2345
|
fragColor = vec4(pointPosition.rg, 1.0, 1.0);
|
|
2253
2346
|
}
|
|
2254
2347
|
|
|
2255
|
-
`,
|
|
2348
|
+
`,kv=`#version 300 es
|
|
2256
2349
|
#ifdef GL_ES
|
|
2257
2350
|
precision highp float;
|
|
2258
2351
|
#endif
|
|
@@ -2285,7 +2378,7 @@ void main() {
|
|
|
2285
2378
|
}
|
|
2286
2379
|
|
|
2287
2380
|
fragColor = pointPosition;
|
|
2288
|
-
}`;function Ev(n,e=16384){if(!(n!=null&&n.length))return null;let t=0;for(const c of n){const u=Math.max(c.width,c.height);u>t&&(t=u)}if(t===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const i=t,r=Math.ceil(Math.sqrt(n.length));let s=r*t,o=1;s>e&&(o=e/s,t=Math.max(1,Math.floor(t*o)),s=Math.max(1,Math.floor(s*o)),console.warn(`🖼️ Atlas scaling required: Original size ${(i*r).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${s.toLocaleString()}px (${Math.round(o*100)}% of original quality)`));const a=new Uint8Array(s*s*4).fill(0),l=new Float32Array(r*r*4).fill(-1);for(const[c,u]of n.entries()){const f=u.width,h=u.height;if(f===0||h===0)continue;const d=Math.min(1,t/Math.max(f,h)),_=Math.floor(f*d),I=Math.floor(h*d),P=Math.floor(c/r),O=c%r*t,E=P*t;l[c*4]=O/s,l[c*4+1]=E/s,l[c*4+2]=(O+_)/s,l[c*4+3]=(E+I)/s;for(let y=0;y<I;y++)for(let R=0;R<_;R++){const N=Math.floor(R*(f/_)),W=(Math.floor(y*(h/I))*f+N)*4,q=((E+y)*s+(O+R))*4;a[q]=u.data[W]??0,a[q+1]=u.data[W+1]??0,a[q+2]=u.data[W+2]??0,a[q+3]=u.data[W+3]??255}}return{atlasData:a,atlasSize:s,atlasCoords:l,atlasCoordsSize:r}}class Rv extends Nt{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){const{device:e,store:t,data:i,config:{rescalePositions:r,enableSimulation:s}}=this,{pointsTextureSize:o}=t;if(!o||!i.pointPositions||i.pointsNumber===void 0)return;const a=o*o*4,l=new Float32Array(a),c=o*o*4*4,u=l.byteLength;u!==c&&console.error("Texture data size mismatch:",{pointsTextureSize:o,expectedBytes:c,actualBytes:u,textureDataSize:a,dataLength:l.length});let f=r;r===void 0&&!s&&(f=!0),this.shouldSkipRescale&&(f=!1),f?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let _=0;_<i.pointsNumber;++_)l[_*4+0]=i.pointPositions[_*2+0],l[_*4+1]=i.pointPositions[_*2+1],l[_*4+2]=_;if(!this.currentPositionTexture||this.currentPositionTexture.width!==o||this.currentPositionTexture.height!==o?(this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.currentPositionTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.currentPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.currentPositionTexture]})):this.currentPositionTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),!this.previousPositionTexture||this.previousPositionTexture.width!==o||this.previousPositionTexture.height!==o?(this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.previousPositionTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.previousPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.previousPositionTexture]})):this.previousPositionTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.config.enableSimulation){const _=new Float32Array(o*o*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==o||this.velocityTexture.height!==o?(this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.velocityTexture.copyImageData({data:_,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.velocityFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.velocityTexture]})):this.velocityTexture.copyImageData({data:_,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0})}!this.selectedTexture||this.selectedTexture.width!==o||this.selectedTexture.height!==o?(this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.selectedTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.selectedFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.selectedTexture]})):this.selectedTexture.copyImageData({data:l,bytesPerRow:ne("rgba32float",o),mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=e.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const h=yr(t.pointsTextureSize),d=h.byteLength;!this.drawPointIndices||this.drawPointIndices.byteLength!==d?(this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.drawPointIndices.write(h),this.drawCommand&&this.drawCommand.setAttributes({pointIndices:this.drawPointIndices}),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==d?(this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.hoveredPointIndices.write(h),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==d?(this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.sampledPointIndices.write(h),this.fillSampledPointsFboCommand&&this.fillSampledPointsFboCommand.setAttributes({pointIndices:this.sampledPointIndices}),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){var s,o,a;const{device:e,config:t,store:i,data:r}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.greyoutStatusTexture||this.updateGreyoutStatus(),t.enableSimulation&&(this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new ye({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:t.simulationFriction??0,spaceSize:i.adjustedSpaceSize??0}}})),this.updatePositionCommand||(this.updatePositionCommand=new _e(e,{fs:Cv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.updatePositionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(e,"updatePositionUniforms")}}))),this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new ye({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:re(i.mousePosition,[0,0]),index:((s=i.hoveredPoint)==null?void 0:s.index)??-1}}})),this.dragPointCommand||(this.dragPointCommand=new _e(e,{fs:Pv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(e,"dragPointUniforms")}})),this.drawUniformStore||(this.drawUniformStore=new ye({drawVertexUniforms:{uniformTypes:{ratio:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",greyoutColor:"vec4<f32>",backgroundColor:"vec4<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",isDarkenGreyout:"f32",skipSelected:"f32",skipUnselected:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32"},defaultUniforms:{ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:(()=>{const l=i.transform??[1,0,0,0,1,0,0,0,1];return[l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]})(),pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),greyoutColor:Re(i.greyoutPointColor,[0,0,0,1]),backgroundColor:Re(i.backgroundColor,[0,0,0,1]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,skipSelected:0,skipUnselected:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>"},defaultUniforms:{greyoutOpacity:t.pointGreyoutOpacity??-1,pointOpacity:t.pointOpacity??1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:Re(i.backgroundColor,[0,0,0,1])}}})),this.drawCommand||(this.drawCommand=new _e(e,{fs:mv,vs:_v,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"color",format:"float32x4"},{name:"shape",format:"float32"},{name:"imageIndex",format:"float32"},{name:"imageSize",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawFragmentUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.findPointsOnAreaSelectionVertexCoordBuffer||(this.findPointsOnAreaSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnAreaSelectionUniformStore||(this.findPointsOnAreaSelectionUniformStore=new ye({findPointsOnAreaSelectionUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",selection0:"vec2<f32>",selection1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,selection0:re((o=i.selectedArea)==null?void 0:o[0],[0,0]),selection1:re((a=i.selectedArea)==null?void 0:a[1],[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=new _e(e,{fs:yv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnAreaSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnAreaSelectionUniforms")}})),this.findPointsOnPolygonSelectionVertexCoordBuffer||(this.findPointsOnPolygonSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnPolygonSelectionUniformStore||(this.findPointsOnPolygonSelectionUniformStore=new ye({findPointsOnPolygonSelectionUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),transformationMatrix:i.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionCommand=new _e(e,{fs:xv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnPolygonSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnPolygonSelectionUniforms")}})),this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new ye({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",skipSelected:"f32",skipUnselected:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,mousePosition:re(i.screenMousePosition,[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,skipSelected:0,skipUnselected:0}}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=new _e(e,{fs:Sv,vs:Tv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(e,"findHoveredPointUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.fillSampledPointsUniformStore||(this.fillSampledPointsUniformStore=new ye({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,transformationMatrix:i.transformationMatrix4x4,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0])}}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=new _e(e,{fs:wv,vs:Av,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.sampledPointIndices&&{pointIndices:this.sampledPointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(e,"fillSampledPointsUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.drawHighlightedVertexCoordBuffer||(this.drawHighlightedVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.drawHighlightedUniformStore||(this.drawHighlightedUniformStore=new ye({drawHighlightedUniforms:{uniformTypes:{size:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",scalePointsOnZoom:"f32",pointIndex:"f32",maxPointSize:"f32",color:"vec4<f32>",universalPointOpacity:"f32",greyoutOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>",greyoutColor:"vec4<f32>",width:"f32"},defaultUniforms:{size:1,transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,pointIndex:-1,maxPointSize:i.maxPointSize??100,color:[0,0,0,1],universalPointOpacity:t.pointOpacity??1,greyoutOpacity:t.pointGreyoutOpacity??-1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:Re(i.backgroundColor,[0,0,0,1]),greyoutColor:Re(i.greyoutPointColor,[0,0,0,1]),width:.85}}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=new _e(e,{fs:vv,vs:bv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(e,"drawHighlightedUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.trackPointsVertexCoordBuffer||(this.trackPointsVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.trackPointsUniformStore||(this.trackPointsUniformStore=new ye({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0}}})),this.trackPointsCommand||(this.trackPointsCommand=new _e(e,{fs:Iv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.trackPointsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(e,"trackPointsUniforms")}}))}updateColor(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=i.pointColors,s=r.byteLength;!this.colorBuffer||this.colorBuffer.byteLength!==s?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.colorBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({color:this.colorBuffer})}updateGreyoutStatus(){const{device:e,store:{selectedIndices:t,pointsTextureSize:i}}=this;if(!i)return;const r=new Float32Array(i*i*4).fill(t?1:0);if(t)for(const s of t)r[s*4]=0;!this.greyoutStatusTexture||this.greyoutStatusTexture.width!==i||this.greyoutStatusTexture.height!==i?(this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=e.createTexture({width:i,height:i,format:"rgba32float"}),this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",i),mipLevel:0,x:0,y:0})):this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",i),mipLevel:0,x:0,y:0})}updatePinnedStatus(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=new Float32Array(t*t*4).fill(0);if(i.inputPinnedPoints&&i.pointsNumber!==void 0)for(const s of i.inputPinnedPoints)s>=0&&s<i.pointsNumber&&(r[s*4]=1);!this.pinnedStatusTexture||this.pinnedStatusTexture.width!==t||this.pinnedStatusTexture.height!==t?(this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",t),mipLevel:0,x:0,y:0})):this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",t),mipLevel:0,x:0,y:0})}updateSize(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t||i.pointsNumber===void 0||i.pointSizes===void 0)return;const r=i.pointSizes,s=r.byteLength;!this.sizeBuffer||this.sizeBuffer.byteLength!==s?(this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.sizeBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({size:this.sizeBuffer});const o=new Float32Array(t*t*4);for(let a=0;a<i.pointsNumber;a++)o[a*4]=i.pointSizes[a];!this.sizeTexture||this.sizeTexture.width!==t||this.sizeTexture.height!==t?(this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.sizeTexture.copyImageData({data:o,bytesPerRow:ne("rgba32float",t),mipLevel:0,x:0,y:0})):this.sizeTexture.copyImageData({data:o,bytesPerRow:ne("rgba32float",t),mipLevel:0,x:0,y:0})}updateShape(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointShapes===void 0)return;const i=t.pointShapes,r=i.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==r?(this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.shapeBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({shape:this.shapeBuffer})}updateImageIndices(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageIndices===void 0)return;const i=t.pointImageIndices,r=i.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==r?(this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.imageIndicesBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({imageIndex:this.imageIndicesBuffer})}updateImageSizes(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageSizes===void 0)return;const i=t.pointImageSizes,r=i.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==r?(this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.imageSizesBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({imageSize:this.imageSizesBuffer})}createAtlas(){var c;const{device:e,data:t,store:i}=this;if(!((c=t.inputImageData)!=null&&c.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=e.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=e.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const r=Ev(t.inputImageData,i.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=t.inputImageData.length;const{atlasData:s,atlasSize:o,atlasCoords:a,atlasCoordsSize:l}=r;this.imageAtlasCoordsTextureSize=l,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=e.createTexture({width:o,height:o,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:s,bytesPerRow:ne("rgba8unorm",o),rowsPerImage:o,mipLevel:0,x:0,y:0}),this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=e.createTexture({width:l,height:l,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:a,bytesPerRow:ne("rgba32float",l),rowsPerImage:l,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},device:i}=this;let r=t??Math.min(...e)/2;r===0&&(r=V.pointSamplingDistance);const s=Math.ceil(e[0]/r),o=Math.ceil(e[1]/r);(!this.sampledPointsFbo||this.sampledPointsFbo.width!==s||this.sampledPointsFbo.height!==o)&&(this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=i.createFramebuffer({width:s,height:o,colorAttachments:["rgba32float"]}))}trackPoints(){var t;if(!((t=this.trackedIndices)!=null&&t.length)||!this.trackPointsCommand||!this.trackPointsUniformStore||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.trackedIndicesTexture||this.trackedIndicesTexture.destroyed)return;this.trackPointsUniformStore.setUniforms({trackPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0}}),this.trackPointsCommand.setBindings({positionsTexture:this.currentPositionTexture,trackedIndices:this.trackedIndicesTexture});const e=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(e),e.end()}draw(e){var a,l;const{data:t,config:i,store:r}=this;if(this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!t.pointsNumber||t.pointsNumber===0||!r.screenSize||r.screenSize[0]===0||r.screenSize[1]===0)return;this.drawCommand.setVertexCount(t.pointsNumber);const s={ratio:i.pixelRatio??V.pixelRatio,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),greyoutColor:Re(r.greyoutPointColor,[-1,-1,-1,-1]),backgroundColor:Re(r.backgroundColor,[0,0,0,1]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0},o={greyoutOpacity:i.pointGreyoutOpacity??-1,pointOpacity:i.pointOpacity??1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1])};if(r.selectedIndices&&r.selectedIndices.length>0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:1,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:1},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),i.renderHoveredPointRing&&r.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((a=t.pointSizes)==null?void 0:a[r.hoveredPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.hoveredPoint.index,maxPointSize:r.maxPointSize??100,color:Re(r.hoveredPointRingColor,[0,0,0,1]),universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1]),greyoutColor:Re(r.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}if(r.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((l=t.pointSizes)==null?void 0:l[r.focusedPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.focusedPoint.index,maxPointSize:r.maxPointSize??100,color:Re(r.focusedPointRingColor,[0,0,0,1]),universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1]),greyoutColor:Re(r.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}}updatePosition(){if(!this.updatePositionCommand||!this.updatePositionUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.velocityTexture||this.velocityTexture.destroyed||!this.pinnedStatusTexture||this.pinnedStatusTexture.destroyed)return;this.updatePositionUniformStore.setUniforms({updatePositionUniforms:{friction:this.config.simulationFriction??0,spaceSize:this.store.adjustedSpaceSize??0}}),this.updatePositionCommand.setBindings({positionsTexture:this.previousPositionTexture,velocity:this.velocityTexture,pinnedStatusTexture:this.pinnedStatusTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.updatePositionCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var t;if(!this.dragPointCommand||!this.dragPointUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed)return;this.dragPointUniformStore.setUniforms({dragPointUniforms:{mousePos:re(this.store.mousePosition,[0,0]),index:((t=this.store.hoveredPoint)==null?void 0:t.index)??-1}}),this.dragPointCommand.setBindings({positionsTexture:this.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var t,i;if(!this.findPointsOnAreaSelectionCommand||!this.findPointsOnAreaSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return;this.findPointsOnAreaSelectionUniformStore.setUniforms({findPointsOnAreaSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),sizeScale:this.config.pointSizeScale??1,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio??V.pixelRatio,selection0:re((t=this.store.selectedArea)==null?void 0:t[0],[0,0]),selection1:re((i=this.store.selectedArea)==null?void 0:i[1],[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,maxPointSize:this.store.maxPointSize??100}}),this.findPointsOnAreaSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnAreaSelectionCommand.draw(e),e.end()}findPointsOnPolygonSelection(){if(!this.findPointsOnPolygonSelectionCommand||!this.findPointsOnPolygonSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return;this.findPointsOnPolygonSelectionUniformStore.setUniforms({findPointsOnPolygonSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsOnPolygonSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnPolygonSelectionCommand.draw(e),e.end()}updatePolygonPath(e){const{device:t}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0;return}const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4);for(const[s,o]of e.entries()){const[a,l]=o;r[s*4]=a,r[s*4+1]=l,r[s*4+2]=0,r[s*4+3]=0}!this.polygonPathTexture||this.polygonPathTexture.width!==i||this.polygonPathTexture.height!==i?(this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=t.createTexture({width:i,height:i,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",i),mipLevel:0,x:0,y:0})):this.polygonPathTexture.copyImageData({data:r,bytesPerRow:ne("rgba32float",i),mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed||!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||(this.greyoutStatusTexture||this.updateGreyoutStatus(),!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed))return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}});const e={ratio:this.config.pixelRatio??V.pixelRatio,sizeScale:this.config.pointSizeScale??1,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,mousePosition:re(this.store.screenMousePosition,[0,0]),maxPointSize:this.store.maxPointSize??100},t={positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture},i=this.device.beginRenderPass({framebuffer:this.hoveredFbo,clearColor:[0,0,0,0]});this.store.selectedIndices&&this.store.selectedIndices.length>0?(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:1,skipUnselected:0}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:0,skipUnselected:1}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i)):(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:0,skipUnselected:0}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i)),i.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:t},device:i}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!t)return;const r=Math.ceil(Math.sqrt(e.length)),s=new Float32Array(r*r*4).fill(-1);for(const[o,a]of e.entries())a!==void 0&&(s[o*4]=a%t,s[o*4+1]=Math.floor(a/t),s[o*4+2]=0,s[o*4+3]=0);!this.trackedIndicesTexture||this.trackedIndicesTexture.width!==r||this.trackedIndicesTexture.height!==r?(this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=i.createTexture({width:r,height:r,format:"rgba32float"}),this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:ne("rgba32float",r),mipLevel:0,x:0,y:0})):this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:ne("rgba32float",r),mipLevel:0,x:0,y:0}),(!this.trackedPositionsFbo||this.trackedPositionsFbo.width!==r||this.trackedPositionsFbo.height!==r)&&(this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=i.createFramebuffer({width:r,height:r,colorAttachments:["rgba32float"]})),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:t}}=this;if((!e||!t)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const i=Xe(this.device,this.trackedPositionsFbo),r=new Map;for(let s=0;s<i.length/4;s+=1){const o=i[s*4],a=i[s*4+1],l=this.trackedIndices[s];o!==void 0&&a!==void 0&&l!==void 0&&r.set(l,[o,a])}return(!e||!t)&&(this.trackedPositions=r,this.isPositionsUpToDate=!0),r}getSampledPointPositionsMap(){const e=new Map;if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return e;if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return e;this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(i),i.end()}const t=Xe(this.device,this.sampledPointsFbo);for(let i=0;i<t.length/4;i++){const r=t[i*4],s=!!t[i*4+1],o=t[i*4+2],a=t[i*4+3];s&&r!==void 0&&o!==void 0&&a!==void 0&&e.set(r,[o,a])}return e}getSampledPoints(){const e=[],t=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:t};if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:t};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(r),r.end()}const i=Xe(this.device,this.sampledPointsFbo);for(let r=0;r<i.length/4;r++){const s=i[r*4],o=!!i[r*4+1],a=i[r*4+2],l=i[r*4+3];o&&s!==void 0&&a!==void 0&&l!==void 0&&(e.push(s),t.push(a,l))}return{indices:e,positions:t}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const t=Xe(this.device,this.trackedPositionsFbo);for(let i=0;i<t.length/4;i+=1){const r=t[i*4],s=t[i*4+1],o=this.trackedIndices[i];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}destroy(){var e,t,i,r,s,o,a,l,c,u,f,h,d,_,I,P,A,O;(e=this.drawCommand)==null||e.destroy(),this.drawCommand=void 0,(t=this.drawHighlightedCommand)==null||t.destroy(),this.drawHighlightedCommand=void 0,(i=this.updatePositionCommand)==null||i.destroy(),this.updatePositionCommand=void 0,(r=this.dragPointCommand)==null||r.destroy(),this.dragPointCommand=void 0,(s=this.findPointsOnAreaSelectionCommand)==null||s.destroy(),this.findPointsOnAreaSelectionCommand=void 0,(o=this.findPointsOnPolygonSelectionCommand)==null||o.destroy(),this.findPointsOnPolygonSelectionCommand=void 0,(a=this.findHoveredPointCommand)==null||a.destroy(),this.findHoveredPointCommand=void 0,(l=this.fillSampledPointsFboCommand)==null||l.destroy(),this.fillSampledPointsFboCommand=void 0,(c=this.trackPointsCommand)==null||c.destroy(),this.trackPointsCommand=void 0,this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionFbo=void 0,this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedFbo=void 0,this.hoveredFbo&&!this.hoveredFbo.destroyed&&this.hoveredFbo.destroy(),this.hoveredFbo=void 0,this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=void 0,this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=void 0,this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionTexture=void 0,this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedTexture=void 0,this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=void 0,this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=void 0,this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=void 0,this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=void 0,this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=void 0,(u=this.updatePositionUniformStore)==null||u.destroy(),this.updatePositionUniformStore=void 0,(f=this.dragPointUniformStore)==null||f.destroy(),this.dragPointUniformStore=void 0,(h=this.drawUniformStore)==null||h.destroy(),this.drawUniformStore=void 0,(d=this.findPointsOnAreaSelectionUniformStore)==null||d.destroy(),this.findPointsOnAreaSelectionUniformStore=void 0,(_=this.findPointsOnPolygonSelectionUniformStore)==null||_.destroy(),this.findPointsOnPolygonSelectionUniformStore=void 0,(I=this.findHoveredPointUniformStore)==null||I.destroy(),this.findHoveredPointUniformStore=void 0,(P=this.fillSampledPointsUniformStore)==null||P.destroy(),this.fillSampledPointsUniformStore=void 0,(A=this.drawHighlightedUniformStore)==null||A.destroy(),this.drawHighlightedUniformStore=void 0,(O=this.trackPointsUniformStore)==null||O.destroy(),this.trackPointsUniformStore=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=void 0,this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=void 0,this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=void 0,this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=void 0,this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=void 0,this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=void 0,this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsOnAreaSelectionVertexCoordBuffer&&!this.findPointsOnAreaSelectionVertexCoordBuffer.destroyed&&this.findPointsOnAreaSelectionVertexCoordBuffer.destroy(),this.findPointsOnAreaSelectionVertexCoordBuffer=void 0,this.findPointsOnPolygonSelectionVertexCoordBuffer&&!this.findPointsOnPolygonSelectionVertexCoordBuffer.destroyed&&this.findPointsOnPolygonSelectionVertexCoordBuffer.destroy(),this.findPointsOnPolygonSelectionVertexCoordBuffer=void 0,this.drawHighlightedVertexCoordBuffer&&!this.drawHighlightedVertexCoordBuffer.destroyed&&this.drawHighlightedVertexCoordBuffer.destroy(),this.drawHighlightedVertexCoordBuffer=void 0,this.trackPointsVertexCoordBuffer&&!this.trackPointsVertexCoordBuffer.destroyed&&this.trackPointsVertexCoordBuffer.destroy(),this.trackPointsVertexCoordBuffer=void 0}swapFbo(){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionFbo||this.previousPositionFbo.destroyed)return;const e=this.previousPositionTexture,t=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=t}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,i=t.length/2;let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let A=0;A<t.length;A+=2){const O=t[A],E=t[A+1];r=Math.min(r,O),s=Math.max(s,O),o=Math.min(o,E),a=Math.max(a,E)}const l=s-r,c=a-o,u=Math.max(l,c);if(u>e){this.scaleX=void 0,this.scaleY=void 0;return}const f=e*e*.001,h=i>f?e*Math.max(1.2,Math.sqrt(i)/e):e*.1,d=h/u,_=(e-h)/2,I=(u-l)/2*d+_,P=(u-c)/2*d+_;this.scaleX=A=>(A-r)*d+I,this.scaleY=A=>(A-o)*d+P;for(let A=0;A<i;A++)this.data.pointPositions[A*2]=this.scaleX(t[A*2]),this.data.pointPositions[A*2+1]=this.scaleY(t[A*2+1])}}const kv={passive:!1},ei={capture:!0,passive:!1};function Po(n){n.stopImmediatePropagation()}function xn(n){n.preventDefault(),n.stopImmediatePropagation()}function yu(n){var e=n.document.documentElement,t=we(n).on("dragstart.drag",xn,ei);"onselectstart"in e?t.on("selectstart.drag",xn,ei):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function xu(n,e){var t=n.document.documentElement,i=we(n).on("dragstart.drag",null);e&&(i.on("click.drag",xn,ei),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in t?i.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const xr=n=>()=>n;function Eo(n,{sourceEvent:e,subject:t,target:i,identifier:r,active:s,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Eo.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Dv(n){return!n.ctrlKey&&!n.button}function Mv(){return this.parentNode}function Fv(n,e){return e??{x:n.x,y:n.y}}function Nv(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ov(){var n=Dv,e=Mv,t=Fv,i=Nv,r={},s=ui("start","drag","end"),o=0,a,l,c,u,f=0;function h(y){y.on("mousedown.drag",d).filter(i).on("touchstart.drag",P).on("touchmove.drag",A,kv).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(y,R){if(!(u||!n.call(this,y,R))){var N=E(this,e.call(this,y,R),y,R,"mouse");N&&(we(y.view).on("mousemove.drag",_,ei).on("mouseup.drag",I,ei),yu(y.view),Po(y),c=!1,a=y.clientX,l=y.clientY,N("start",y))}}function _(y){if(xn(y),!c){var R=y.clientX-a,N=y.clientY-l;c=R*R+N*N>f}r.mouse("drag",y)}function I(y){we(y.view).on("mousemove.drag mouseup.drag",null),xu(y.view,c),xn(y),r.mouse("end",y)}function P(y,R){if(n.call(this,y,R)){var N=y.changedTouches,U=e.call(this,y,R),W=N.length,q,G;for(q=0;q<W;++q)(G=E(this,U,y,R,N[q].identifier,N[q]))&&(Po(y),G("start",y,N[q]))}}function A(y){var R=y.changedTouches,N=R.length,U,W;for(U=0;U<N;++U)(W=r[R[U].identifier])&&(xn(y),W("drag",y,R[U]))}function O(y){var R=y.changedTouches,N=R.length,U,W;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),U=0;U<N;++U)(W=r[R[U].identifier])&&(Po(y),W("end",y,R[U]))}function E(y,R,N,U,W,q){var G=s.copy(),B=xt(q||N,R),he,ie,C;if((C=t.call(y,new Eo("beforestart",{sourceEvent:N,target:h,identifier:W,active:o,x:B[0],y:B[1],dx:0,dy:0,dispatch:G}),U))!=null)return he=C.x-B[0]||0,ie=C.y-B[1]||0,function H(M,$,Z){var j=B,ee;switch(M){case"start":r[W]=H,ee=o++;break;case"end":delete r[W],--o;case"drag":B=xt(Z||$,R),ee=o;break}G.call(M,y,new Eo(M,{sourceEvent:$,subject:C,target:h,identifier:W,active:ee,x:B[0]+he,y:B[1]+ie,dx:B[0]-j[0],dy:B[1]-j[1],dispatch:G}),U)}}return h.filter=function(y){return arguments.length?(n=typeof y=="function"?y:xr(!!y),h):n},h.container=function(y){return arguments.length?(e=typeof y=="function"?y:xr(y),h):e},h.subject=function(y){return arguments.length?(t=typeof y=="function"?y:xr(y),h):t},h.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:xr(!!y),h):i},h.on=function(){var y=s.on.apply(s,arguments);return y===s?h:y},h.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,h):Math.sqrt(f)},h}const vr=n=>()=>n;function Bv(n,{sourceEvent:e,target:t,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function It(n,e,t){this.k=n,this.x=e,this.y=t}It.prototype={constructor:It,scale:function(n){return n===1?this:new It(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new It(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ti=new It(1,0,0);It.prototype;function Ro(n){n.stopImmediatePropagation()}function ni(n){n.preventDefault(),n.stopImmediatePropagation()}function Uv(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function zv(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function vu(){return this.__zoom||ti}function Lv(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function Vv(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hv(n,e,t){var i=n.invertX(e[0][0])-t[0][0],r=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],o=n.invertY(e[1][1])-t[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Wv(){var n=Uv,e=zv,t=Hv,i=Lv,r=Vv,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=ld,c=ui("start","zoom","end"),u,f,h,d=500,_=150,I=0,P=10;function A(C){C.property("__zoom",vu).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",G).filter(r).on("touchstart.zoom",B).on("touchmove.zoom",he).on("touchend.zoom touchcancel.zoom",ie).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(C,H,M,$){var Z=C.selection?C.selection():C;Z.property("__zoom",vu),C!==Z?R(C,H,M,$):Z.interrupt().each(function(){N(this,arguments).event($).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},A.scaleBy=function(C,H,M,$){A.scaleTo(C,function(){var Z=this.__zoom.k,j=typeof H=="function"?H.apply(this,arguments):H;return Z*j},M,$)},A.scaleTo=function(C,H,M,$){A.transform(C,function(){var Z=e.apply(this,arguments),j=this.__zoom,ee=M==null?y(Z):typeof M=="function"?M.apply(this,arguments):M,J=j.invert(ee),ge=typeof H=="function"?H.apply(this,arguments):H;return t(E(O(j,ge),ee,J),Z,o)},M,$)},A.translateBy=function(C,H,M,$){A.transform(C,function(){return t(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof M=="function"?M.apply(this,arguments):M),e.apply(this,arguments),o)},null,$)},A.translateTo=function(C,H,M,$,Z){A.transform(C,function(){var j=e.apply(this,arguments),ee=this.__zoom,J=$==null?y(j):typeof $=="function"?$.apply(this,arguments):$;return t(ti.translate(J[0],J[1]).scale(ee.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof M=="function"?-M.apply(this,arguments):-M),j,o)},$,Z)};function O(C,H){return H=Math.max(s[0],Math.min(s[1],H)),H===C.k?C:new It(H,C.x,C.y)}function E(C,H,M){var $=H[0]-M[0]*C.k,Z=H[1]-M[1]*C.k;return $===C.x&&Z===C.y?C:new It(C.k,$,Z)}function y(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function R(C,H,M,$){C.on("start.zoom",function(){N(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event($).end()}).tween("zoom",function(){var Z=this,j=arguments,ee=N(Z,j).event($),J=e.apply(Z,j),ge=M==null?y(J):typeof M=="function"?M.apply(Z,j):M,ue=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),Te=Z.__zoom,se=typeof H=="function"?H.apply(Z,j):H,He=l(Te.invert(ge).concat(ue/Te.k),se.invert(ge).concat(ue/se.k));return function(We){if(We===1)We=se;else{var nt=He(We),Gt=ue/nt[2];We=new It(Gt,ge[0]-nt[0]*Gt,ge[1]-nt[1]*Gt)}ee.zoom(null,We)}})}function N(C,H,M){return!M&&C.__zooming||new U(C,H)}function U(C,H){this.that=C,this.args=H,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,H),this.taps=0}U.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,H){return this.mouse&&C!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var H=we(this.that).datum();c.call(C,this.that,new Bv(C,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:c}),H)}};function W(C,...H){if(!n.apply(this,arguments))return;var M=N(this,H).event(C),$=this.__zoom,Z=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),j=xt(C);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=$.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if($.k===Z)return;M.mouse=[j,$.invert(j)],xi(this),M.start()}ni(C),M.wheel=setTimeout(ee,_),M.zoom("mouse",t(E(O($,Z),M.mouse[0],M.mouse[1]),M.extent,o));function ee(){M.wheel=null,M.end()}}function q(C,...H){if(h||!n.apply(this,arguments))return;var M=C.currentTarget,$=N(this,H,!0).event(C),Z=we(C.view).on("mousemove.zoom",ge,!0).on("mouseup.zoom",ue,!0),j=xt(C,M),ee=C.clientX,J=C.clientY;yu(C.view),Ro(C),$.mouse=[j,this.__zoom.invert(j)],xi(this),$.start();function ge(Te){if(ni(Te),!$.moved){var se=Te.clientX-ee,He=Te.clientY-J;$.moved=se*se+He*He>I}$.event(Te).zoom("mouse",t(E($.that.__zoom,$.mouse[0]=xt(Te,M),$.mouse[1]),$.extent,o))}function ue(Te){Z.on("mousemove.zoom mouseup.zoom",null),xu(Te.view,$.moved),ni(Te),$.event(Te).end()}}function G(C,...H){if(n.apply(this,arguments)){var M=this.__zoom,$=xt(C.changedTouches?C.changedTouches[0]:C,this),Z=M.invert($),j=M.k*(C.shiftKey?.5:2),ee=t(E(O(M,j),$,Z),e.apply(this,H),o);ni(C),a>0?we(this).transition().duration(a).call(R,ee,$,C):we(this).call(A.transform,ee,$,C)}}function B(C,...H){if(n.apply(this,arguments)){var M=C.touches,$=M.length,Z=N(this,H,C.changedTouches.length===$).event(C),j,ee,J,ge;for(Ro(C),ee=0;ee<$;++ee)J=M[ee],ge=xt(J,this),ge=[ge,this.__zoom.invert(ge),J.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==ge[2]&&(Z.touch1=ge,Z.taps=0):(Z.touch0=ge,j=!0,Z.taps=1+!!u);u&&(u=clearTimeout(u)),j&&(Z.taps<2&&(f=ge[0],u=setTimeout(function(){u=null},d)),xi(this),Z.start())}}function he(C,...H){if(this.__zooming){var M=N(this,H).event(C),$=C.changedTouches,Z=$.length,j,ee,J,ge;for(ni(C),j=0;j<Z;++j)ee=$[j],J=xt(ee,this),M.touch0&&M.touch0[2]===ee.identifier?M.touch0[0]=J:M.touch1&&M.touch1[2]===ee.identifier&&(M.touch1[0]=J);if(ee=M.that.__zoom,M.touch1){var ue=M.touch0[0],Te=M.touch0[1],se=M.touch1[0],He=M.touch1[1],We=(We=se[0]-ue[0])*We+(We=se[1]-ue[1])*We,nt=(nt=He[0]-Te[0])*nt+(nt=He[1]-Te[1])*nt;ee=O(ee,Math.sqrt(We/nt)),J=[(ue[0]+se[0])/2,(ue[1]+se[1])/2],ge=[(Te[0]+He[0])/2,(Te[1]+He[1])/2]}else if(M.touch0)J=M.touch0[0],ge=M.touch0[1];else return;M.zoom("touch",t(E(ee,J,ge),M.extent,o))}}function ie(C,...H){if(this.__zooming){var M=N(this,H).event(C),$=C.changedTouches,Z=$.length,j,ee;for(Ro(C),h&&clearTimeout(h),h=setTimeout(function(){h=null},d),j=0;j<Z;++j)ee=$[j],M.touch0&&M.touch0[2]===ee.identifier?delete M.touch0:M.touch1&&M.touch1[2]===ee.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(ee=xt(ee,this),Math.hypot(f[0]-ee[0],f[1]-ee[1])<P)){var J=we(this).on("dblclick.zoom");J&&J.apply(this,arguments)}}}return A.wheelDelta=function(C){return arguments.length?(i=typeof C=="function"?C:vr(+C),A):i},A.filter=function(C){return arguments.length?(n=typeof C=="function"?C:vr(!!C),A):n},A.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:vr(!!C),A):r},A.extent=function(C){return arguments.length?(e=typeof C=="function"?C:vr([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),A):e},A.scaleExtent=function(C){return arguments.length?(s[0]=+C[0],s[1]=+C[1],A):[s[0],s[1]]},A.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],A):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},A.constrain=function(C){return arguments.length?(t=C,A):t},A.duration=function(C){return arguments.length?(a=+C,A):a},A.interpolate=function(C){return arguments.length?(l=C,A):l},A.on=function(){var C=c.on.apply(c,arguments);return C===c?A:C},A.clickDistance=function(C){return arguments.length?(I=(C=+C)*C,A):Math.sqrt(I)},A.tapDistance=function(C){return arguments.length?(P=+C,A):P},A}class $v{constructor(e,t){this.eventTransform=ti,this.behavior=Wv().scaleExtent([.001,1/0]).on("start",i=>{var s,o;this.isRunning=!0;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomStart)==null||o.call(s,i,r)}).on("zoom",i=>{var h,d;this.eventTransform=i.transform;const{eventTransform:{x:r,y:s,k:o},store:{transform:a,screenSize:l}}=this,c=l[0],u=l[1];if(!c||!u)return;ky(a,c,u),rc(a,a,[r,s]),qs(a,a,[o,o]),rc(a,a,[c/2,u/2]),qs(a,a,[c/2,u/2]),qs(a,a,[1,-1]);const f=!!i.sourceEvent;(d=(h=this.config)==null?void 0:h.onZoom)==null||d.call(h,i,f)}).on("end",i=>{var s,o;this.isRunning=!1;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomEnd)==null||o.call(s,i,r)}),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,i=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:r}}=this,s=r[0],o=r[1];let a=1/0,l=-1/0,c=1/0,u=-1/0;for(let R=0;R<e.length;R+=2){const N=e[R],U=e[R+1];N<a&&(a=N),N>l&&(l=N),U<c&&(c=U),U>u&&(u=U)}const f=[this.store.scaleX(a),this.store.scaleX(l)],h=[this.store.scaleY(c),this.store.scaleY(u)];f[0]===f[1]&&(f[0]-=.5,f[1]+=.5),h[0]===h[1]&&(h[0]+=.5,h[1]-=.5);const d=s*(1-i*2)/(f[1]-f[0]),_=o*(1-i*2)/(h[0]-h[1]),I=Sc(t??Math.min(d,_),...this.behavior.scaleExtent()),P=(f[1]+f[0])/2,A=(h[1]+h[0])/2,O=s/2-P*I,E=o/2-A*I;return ti.translate(O,E).scale(I)}getDistanceToPoint(e){const{x:t,y:i,k:r}=this.eventTransform,s=this.getTransform(e,r),o=t-s.x,a=i-s.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:i,y:r,k:s}}=this,o=t[0],a=t[1],l=(o/2-i)/s,c=(a/2-r)/s,u=this.store.scaleX(e[0]),f=this.store.scaleY(e[1]),h=(l+u)/2,d=(c+f)/2,_=1,I=o/2-h*_,P=a/2-d*_;return ti.translate(I,P).scale(_)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:i,k:r},store:{screenSize:s}}=this,o=s[0],a=s[1],l=(e[0]-t)/r,c=(e[1]-i)/r,u=[l,a-c];return u[0]-=(o-this.store.adjustedSpaceSize)/2,u[1]-=(a-this.store.adjustedSpaceSize)/2,u}convertSpaceToScreenPosition(e){const t=this.eventTransform.applyX(this.store.scaleX(e[0])),i=this.eventTransform.applyY(this.store.scaleY(e[1]));return[t,i]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:i},eventTransform:{k:r}}=this;let s=e*2;return t?s*=r:s*=Math.min(5,Math.max(1,r*.01)),Math.min(s,i)/2}}class Xv{constructor(e,t){this.isActive=!1,this.behavior=Ov().subject(i=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:i.x,y:i.y}:void 0).on("start",i=>{var r,s;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(s=(r=this.config)==null?void 0:r.onDragStart)==null||s.call(r,i))}).on("drag",i=>{var r,s;(s=(r=this.config)==null?void 0:r.onDrag)==null||s.call(r,i)}).on("end",i=>{var r,s;this.isActive=!1,this.store.draggingPointIndex=void 0,(s=(r=this.config)==null?void 0:r.onDragEnd)==null||s.call(r,i)}),this.store=e,this.config=t}}class Yv{constructor(e,t,i){if(this.config=new bx,this.graph=new cv(this.config),this.isReady=!1,this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new vx,this.zoomInstance=new $v(this.store,this.config),this.dragInstance=new Xv(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._lastMouseX=0,this._lastMouseY=0,this._lastCheckedMouseX=0,this._lastCheckedMouseY=0,this._shouldForceHoverDetection=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,t&&this.config.init(t),i)this.deviceInitPromise=i,this.shouldDestroyDevice=!1;else{const r=document.createElement("canvas");this.deviceInitPromise=this.createDevice(r),this.shouldDestroyDevice=!0}this.deviceInitPromise.then(r=>{if(this._isDestroyed)return this.shouldDestroyDevice&&r.destroy(),r;this.device=r,this.isReady=!0;const s=this.validateDevice(r);i&&s.setProps({useDevicePixels:this.config.pixelRatio}),this.store.div=e;const o=s.canvas;o.parentNode!==this.store.div&&(o.parentNode&&o.parentNode.removeChild(o),this.store.div.appendChild(o)),this.addAttribution(),o.style.width="100%",o.style.height="100%",this.canvas=o;const a=this.canvas.clientWidth,l=this.canvas.clientHeight;return this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(a,l),this.canvasD3Selection=we(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",c=>{this._isMouseOnCanvas=!0,this._lastMouseX=c.clientX,this._lastMouseY=c.clientY}).on("mousemove.cosmos",c=>{this._isMouseOnCanvas=!0,this._lastMouseX=c.clientX,this._lastMouseY=c.clientY}).on("mouseleave.cosmos",c=>{this._isMouseOnCanvas=!1,this.currentEvent=c,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(c),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(c),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),we(document).on("keydown.cosmos",c=>{c.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",c=>{c.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",c=>{this.currentEvent=c}).on("zoom.detect",c=>{!!c.sourceEvent&&this.updateMousePosition(c.sourceEvent),this.currentEvent=c}).on("end.detect",c=>{this.currentEvent=c,this._shouldForceHoverDetection=!0}),this.dragInstance.behavior.on("start.detect",c=>{this.currentEvent=c,this.updateCanvasCursor()}).on("drag.detect",c=>{this.dragInstance.isActive&&this.updateMousePosition(c),this.currentEvent=c}).on("end.detect",c=>{this.currentEvent=c,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onContextMenu.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1),this.store.maxPointSize=eo(r,this.config.pixelRatio),this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Rv(r,this.config,this.store,this.graph),this.lines=new gv(r,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new Y0(r,this.config,this.store,this.graph,this.points),this.forceCenter=new $0(r,this.config,this.store,this.graph,this.points),this.forceManyBody=new J0(r,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new gu(r,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new gu(r,this.config,this.store,this.graph,this.points),this.forceMouse=new ev(r,this.config,this.store,this.graph,this.points)),this.clusters=new rv(r,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Tt(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ms),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new mu(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),r}).catch(r=>{throw this.device=void 0,this.isReady=!1,console.error("Device initialization failed:",r),r}),this.ready=this.deviceInitPromise.then(()=>{})}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i,r,s,o,a,l,c,u,f;if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const t={...this.config};this.config.init(e),(t.pointDefaultColor!==this.config.pointDefaultColor||t.pointColor!==this.config.pointColor)&&(this.graph.updatePointColor(),(i=this.points)==null||i.updateColor()),(t.pointDefaultSize!==this.config.pointDefaultSize||t.pointSize!==this.config.pointSize)&&(this.graph.updatePointSize(),(r=this.points)==null||r.updateSize()),(t.linkDefaultColor!==this.config.linkDefaultColor||t.linkColor!==this.config.linkColor)&&(this.graph.updateLinkColor(),(s=this.lines)==null||s.updateColor()),(t.linkDefaultWidth!==this.config.linkDefaultWidth||t.linkWidth!==this.config.linkWidth)&&(this.graph.updateLinkWidth(),(o=this.lines)==null||o.updateWidth()),(t.linkDefaultArrows!==this.config.linkDefaultArrows||t.linkArrows!==this.config.linkArrows)&&(this.graph.updateArrows(),(a=this.lines)==null||a.updateArrow()),(t.curvedLinkSegments!==this.config.curvedLinkSegments||t.curvedLinks!==this.config.curvedLinks)&&((l=this.lines)==null||l.updateCurveLineGeometry()),t.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Tt(this.config.backgroundColor??Al)),t.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),t.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),t.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Ms),t.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),t.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),t.pixelRatio!==this.config.pixelRatio&&(c=this.device)!=null&&c.canvasContext&&(this.device.canvasContext.setProps({useDevicePixels:this.config.pixelRatio}),this.store.maxPointSize=eo(this.device,this.config.pixelRatio)),t.spaceSize!==this.config.spaceSize&&(this.store.adjustSpaceSize(this.config.spaceSize,((u=this.device)==null?void 0:u.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),t.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new mu(this.canvas):((f=this.fpsMonitor)==null||f.destroy(),this.fpsMonitor=void 0)),(t.enableZoom!==this.config.enableZoom||t.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(t.onLinkClick!==this.config.onLinkClick||t.onLinkContextMenu!==this.config.onLinkContextMenu||t.onLinkMouseOver!==this.config.onLinkMouseOver||t.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,t))||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=t,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||this.ensureDevice(()=>this.setPointColors(e))||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointSizes(e))||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(t=this.points)==null||t.createAtlas())}setPointImageIndices(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageIndices(e))||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageSizes(e))||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||this.ensureDevice(()=>this.setLinks(e))||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkColors(e))||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkWidths(e))||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkArrows(e))||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkStrength(e))||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusters(e))||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||this.ensureDevice(()=>this.setClusterPositions(e))||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusterStrength(e))||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setPinnedPoints(e))||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,(t=this.points)==null||t.updatePinnedStatus())}render(e){if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:i,fitViewPadding:r,fitViewDuration:s,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),we(this.canvas).style("cursor",null),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit());return}this._isFirstRenderAfterInit&&t&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{a?this.fitViewByPointIndices(a,s,r):o?this.setZoomTransformByPointPositions(new Float32Array(this.flatten(o)),s,void 0,r):this.fitView(s,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,t=700,i=M_,r=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,t,i,r))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:s}}=this,o=Xe(this.device,this.points.currentPositionFbo);if(e===void 0)return;const a=o[e*4+0],l=o[e*4+1];if(a===void 0||l===void 0)return;const c=this.zoomInstance.getDistanceToPoint([a,l]),u=r?i:Math.max(this.getZoomLevel(),i);if(c<Math.min(s[0],s[1]))this.setZoomTransformByPointPositions(new Float32Array([a,l]),t,u);else{const f=this.zoomInstance.getTransform([a,l],u),h=this.zoomInstance.getMiddlePointTransform([a,l]);this.canvasD3Selection.transition().ease(lp).duration(t/2).call(this.zoomInstance.behavior.transform,h).transition().ease(cp).duration(t/2).call(this.zoomInstance.behavior.transform,f)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,t))||this.canvasD3Selection&&(t===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.device||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],t=Xe(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=t[i*4+0],s=t[i*4+1];r!==void 0&&s!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}getClusterPositions(){if(this._isDestroyed||!this.device||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],t=Xe(this.device,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=t[i*4+0],s=t[i*4+1],o=t[i*4+2];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r/o,e[i*2+1]=s/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,t))||this.setZoomTransformByPointPositions(new Float32Array(this.getPointPositions()),e,void 0,t)}fitViewByPointIndices(e,t=250,i=.1){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,t,i)))return;const r=this.getPointPositions(),s=new Float32Array(e.length*2);for(const[o,a]of e.entries())s[o*2]=r[a*2],s[o*2+1]=r[a*2+1];this.setZoomTransformByPointPositions(s,t,void 0,i)}fitViewByPointPositions(e,t=250,i=.1){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,t,i))||this.setZoomTransformByPointPositions(new Float32Array(e),t,void 0,i)}setZoomTransformByPointPositions(e,t=250,i,r=.1){var o;if(this._isDestroyed||this.ensureDevice(()=>this.setZoomTransformByPointPositions(e,t,i,r)))return;this.resizeCanvas();const s=this.zoomInstance.getTransform(e,i,r);(o=this.canvasD3Selection)==null||o.transition().ease(up).duration(t).call(this.zoomInstance.behavior.transform,s)}getPointsInRect(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;const t=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection(),Xe(this.device,this.points.selectedFbo).map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}getPointsInRange(e){return this.getPointsInRect(e)}getPointsInPolygon(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),Xe(this.device,this.points.selectedFbo).map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}selectPointsInRect(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInRect(e))&&!(!this.device||!this.points)){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const i=Xe(this.device,this.points.selectedFbo);this.store.selectedIndices=i.map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInRange(e){return this.selectPointsInRect(e)}selectPointsInPolygon(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInPolygon(e))&&!(!this.device||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=Xe(this.device,this.points.selectedFbo);this.store.selectedIndices=r.map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointByIndex(e,t)))if(t){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.selectPointsByIndices(e))||this.points&&(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(t=>t!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||this.ensureDevice(()=>this.unselectPoints())||this.points&&(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;if(!this._isDestroyed)return(t=this.graph.pointSizes)==null?void 0:t[e]}trackPointPositionsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.trackPointPositionsByIndices(e))||this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var t,i;this._isDestroyed||this.ensureDevice(()=>this.start(e))||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(t=this.config).onSimulationStart)==null||i.call(t))}stop(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(t=(e=this.config).onSimulationEnd)==null||t.call(e))}pause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.pause())||(this.store.isSimulationRunning=!1,(t=(e=this.config).onSimulationPause)==null||t.call(e))}unpause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.unpause())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationUnpause)==null||t.call(e))}restart(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.restart())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationRestart)==null||t.call(e))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,t,i,r,s,o,a,l,c,u,f,h,d;this._isDestroyed||(this._isDestroyed=!0,this.isReady=!1,window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),we(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(t=this.dragInstance)!=null&&t.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),(r=this.points)==null||r.destroy(),(s=this.lines)==null||s.destroy(),(o=this.clusters)==null||o.destroy(),(a=this.forceGravity)==null||a.destroy(),(l=this.forceCenter)==null||l.destroy(),(c=this.forceManyBody)==null||c.destroy(),(u=this.forceLinkIncoming)==null||u.destroy(),(f=this.forceLinkOutgoing)==null||f.destroy(),(h=this.forceMouse)==null||h.destroy(),this.device&&this.shouldDestroyDevice&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit(),this.device.destroy()),this.shouldDestroyDevice&&this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(d=document.getElementById("gl-bench-style"))==null||d.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0)}create(){var e,t,i,r,s;this._isDestroyed||this.ensureDevice(()=>this.create())||this.points&&this.lines&&(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((t=this.forceLinkIncoming)==null||t.create(Io.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(Io.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((s=this.clusters)==null||s.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let i=0;i<e.length/2;i++)t[i]=[e[i*2],e[i*2+1]];return t}ensureDevice(e){return this.isReady?!1:(this.ready.then(()=>{this._isDestroyed||e()}).catch(t=>{console.error("Device initialization failed",t)}),!0)}validateDevice(e){const t=e.canvasContext;if(t===null||t.type==="offscreen-canvas")throw new Error("Device must have an HTMLCanvasElement canvas context. OffscreenCanvas and compute-only devices are not supported.");return t}async createDevice(e){return await jp.createDevice({type:"webgl",adapters:[qg],createCanvasContext:{canvas:e,useDevicePixels:this.config.pixelRatio,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:t}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((t.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var a,l,c,u,f,h,d,_,I,P,A,O,E,y,R,N,U,W,q;const{config:{simulationGravity:t,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:s}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((a=this.forceMouse)==null||a.run(),(l=this.points)==null||l.updatePosition()),(e||s&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(t&&((c=this.forceGravity)==null||c.run(),(u=this.points)==null||u.updatePosition()),i&&((f=this.forceCenter)==null||f.run(),(h=this.points)==null||h.updatePosition()),(d=this.forceManyBody)==null||d.run(),(_=this.points)==null||_.updatePosition(),this.store.linksTextureSize&&((I=this.forceLinkIncoming)==null||I.run(),(P=this.points)==null||P.updatePosition(),(A=this.forceLinkOutgoing)==null||A.run(),(O=this.points)==null||O.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((E=this.clusters)==null||E.run(),(y=this.points)==null||y.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??V.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Qs/this.store.alpha)),(W=(U=this.config).onSimulationTick)==null||W.call(U,this.store.alpha,(R=this.store.hoveredPoint)==null?void 0:R.index,(N=this.store.hoveredPoint)==null?void 0:N.position)),(q=this.points)==null||q.trackPoints()}initPrograms(){var e,t,i,r,s,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(t=this.forceManyBody)==null||t.initPrograms(),(i=this.forceCenter)==null||i.initPrograms(),(r=this.forceLinkIncoming)==null||r.initPrograms(),(s=this.forceLinkOutgoing)==null||s.initPrograms(),(o=this.forceMouse)==null||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:t}}=this;e<Qs&&t&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var t,i,r,s,o,a,l;if(!this._isDestroyed&&this.store.pointsTextureSize){if((t=this.fpsMonitor)==null||t.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),this.device){const c=this.store.backgroundColor??[0,0,0,1],u=this.device.beginRenderPass({clearColor:c,clearDepth:1,clearStencil:0}),{config:{renderLinks:f}}=this;f!==!1&&!!this.store.linksTextureSize&&!!this.graph.linksNumber&&this.graph.linksNumber>0&&((i=this.lines)==null||i.draw(u)),(r=this.points)==null||r.draw(u),this.dragInstance.isActive&&((s=this.points)==null||s.drag(),(o=this.points)==null||o.drag(),(a=this.points)==null||a.trackPoints()),u.end(),this.device.submit()}(l=this.fpsMonitor)==null||l.end(e??performance.now()),this.currentEvent=void 0}}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(t=(e=this.config).onSimulationEnd)==null||t.call(e),this._shouldForceHoverDetection=!0}onClick(e){var t,i,r,s,o,a,l,c,u,f;(s=(r=this.config).onClick)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointClick)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkClick)==null||c.call(l,this.store.hoveredLinkIndex,e):(f=(u=this.config).onBackgroundClick)==null||f.call(u,e)}updateMousePosition(e){if(!e)return;const t=e.offsetX??e.x,i=e.offsetY??e.y;t===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([t,i]),this.store.screenMousePosition=[t,this.store.screenSize[1]-i])}onMouseMove(e){var t,i,r,s;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(s=(r=this.config).onMouseMove)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onContextMenu(e){var t,i,r,s,o,a,l,c,u,f;e.preventDefault(),(s=(r=this.config).onContextMenu)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointContextMenu)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkContextMenu)==null||c.call(l,this.store.hoveredLinkIndex,e):(f=(u=this.config).onBackgroundContextMenu)==null||f.call(u,e)}resizeCanvas(e=!1){var o,a,l;if(this._isDestroyed)return;const t=this.canvas.clientWidth,i=this.canvas.clientHeight,[r,s]=this.store.screenSize;if(e||r!==t||s!==i){const{k:c}=this.zoomInstance.eventTransform,u=this.zoomInstance.convertScreenToSpacePosition([r/2,s/2]);this.store.updateScreenSize(t,i),(o=this.canvasD3Selection)==null||o.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform(u,c)),(a=this.points)==null||a.updateSampledPointsGrid(),this.store.isLinkHoveringEnabled&&((l=this.lines)==null||l.updateLinkIndexFbo())}}updateZoomDragBehaviors(){var e,t,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(t=this.canvasD3Selection)==null||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(this._isDestroyed||!this._isMouseOnCanvas)return;if(this._findHoveredItemExecutionCount<xx){this._findHoveredItemExecutionCount+=1;return}const e=Math.abs(this._lastMouseX-this._lastCheckedMouseX),t=Math.abs(this._lastMouseY-this._lastCheckedMouseY);if(!(!(e>_c||t>_c)&&!this._shouldForceHoverDetection)){if(this._lastCheckedMouseX=this._lastMouseX,this._lastCheckedMouseY=this._lastMouseY,this._shouldForceHoverDetection=!1,this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const r=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,r&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var l,c,u,f,h;if(this._isDestroyed||!this.device||!this.points)return;this.points.findHoveredPoint();let e=!1,t=!1;const i=Xe(this.device,this.points.hoveredFbo,0,0,2,2),r=i[0],s=i[1],o=i[2],a=i[3];s>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==r)&&(e=!0),this.store.hoveredPoint={index:r,position:[o,a]}):(this.store.hoveredPoint&&(t=!0),this.store.hoveredPoint=void 0),e&&this.store.hoveredPoint&&((u=(c=this.config).onPointMouseOver)==null||u.call(c,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent,((l=this.store.selectedIndices)==null?void 0:l.includes(this.store.hoveredPoint.index))??!1)),t&&((h=(f=this.config).onPointMouseOut)==null||h.call(f,this.currentEvent))}findHoveredLine(){var s,o,a,l,c,u;if(this._isDestroyed||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(o=(s=this.config).onLinkMouseOut)==null||o.call(s,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,t=!1;if(!this.device)return;const r=Xe(this.device,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(t=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(a=this.config).onLinkMouseOver)==null||l.call(a,this.store.hoveredLinkIndex)),t&&((u=(c=this.config).onLinkMouseOut)==null||u.call(c,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?we(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?we(this.canvas).style("cursor",e):we(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?we(this.canvas).style("cursor",t):we(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
|
|
2381
|
+
}`;function Dv(n,e=16384){if(!(n!=null&&n.length))return null;let t=0;for(const c of n){const u=Math.max(c.width,c.height);u>t&&(t=u)}if(t===0)return console.warn("Invalid image dimensions: all images have zero width or height"),null;const i=t,r=Math.ceil(Math.sqrt(n.length));let s=r*t,o=1;s>e&&(o=e/s,t=Math.max(1,Math.floor(t*o)),s=Math.max(1,Math.floor(s*o)),console.warn(`🖼️ Atlas scaling required: Original size ${(i*r).toLocaleString()}px exceeds WebGL limit ${e.toLocaleString()}px. Scaling down to ${s.toLocaleString()}px (${Math.round(o*100)}% of original quality)`));const a=new Uint8Array(s*s*4).fill(0),l=new Float32Array(r*r*4).fill(-1);for(const[c,u]of n.entries()){const f=u.width,h=u.height;if(f===0||h===0)continue;const d=Math.min(1,t/Math.max(f,h)),_=Math.floor(f*d),I=Math.floor(h*d),P=Math.floor(c/r),O=c%r*t,E=P*t;l[c*4]=O/s,l[c*4+1]=E/s,l[c*4+2]=(O+_)/s,l[c*4+3]=(E+I)/s;for(let x=0;x<I;x++)for(let R=0;R<_;R++){const N=Math.floor(R*(f/_)),W=(Math.floor(x*(h/I))*f+N)*4,q=((E+x)*s+(O+R))*4;a[q]=u.data[W]??0,a[q+1]=u.data[W+1]??0,a[q+2]=u.data[W+2]??0,a[q+3]=u.data[W+3]??255}}return{atlasData:a,atlasSize:s,atlasCoords:l,atlasCoordsSize:r}}class Mv extends Nt{constructor(){super(...arguments),this.imageCount=0,this.isPositionsUpToDate=!1,this.polygonPathLength=0}updatePositions(){const{device:e,store:t,data:i,config:{rescalePositions:r,enableSimulation:s}}=this,{pointsTextureSize:o}=t;if(!o||!i.pointPositions||i.pointsNumber===void 0)return;const a=o*o*4,l=new Float32Array(a),c=o*o*4*4,u=l.byteLength;u!==c&&console.error("Texture data size mismatch:",{pointsTextureSize:o,expectedBytes:c,actualBytes:u,textureDataSize:a,dataLength:l.length});let f=r;r===void 0&&!s&&(f=!0),this.shouldSkipRescale&&(f=!1),f?this.rescaleInitialNodePositions():this.shouldSkipRescale||(this.scaleX=void 0,this.scaleY=void 0),this.shouldSkipRescale=void 0;for(let _=0;_<i.pointsNumber;++_)l[_*4+0]=i.pointPositions[_*2+0],l[_*4+1]=i.pointPositions[_*2+1],l[_*4+2]=_;if(!this.currentPositionTexture||this.currentPositionTexture.width!==o||this.currentPositionTexture.height!==o?(this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.currentPositionTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.currentPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.currentPositionTexture]})):this.currentPositionTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),!this.previousPositionTexture||this.previousPositionTexture.width!==o||this.previousPositionTexture.height!==o?(this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.previousPositionTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.previousPositionFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.previousPositionTexture]})):this.previousPositionTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.config.enableSimulation){const _=new Float32Array(o*o*4).fill(0);!this.velocityTexture||this.velocityTexture.width!==o||this.velocityTexture.height!==o?(this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.velocityTexture.copyImageData({data:_,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.velocityFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.velocityTexture]})):this.velocityTexture.copyImageData({data:_,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0})}!this.selectedTexture||this.selectedTexture.width!==o||this.selectedTexture.height!==o?(this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedTexture=e.createTexture({width:o,height:o,format:"rgba32float"}),this.selectedTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.selectedFbo=e.createFramebuffer({width:o,height:o,colorAttachments:[this.selectedTexture]})):this.selectedTexture.copyImageData({data:l,bytesPerRow:ie("rgba32float",o),mipLevel:0,x:0,y:0}),this.hoveredFbo||(this.hoveredFbo=e.createFramebuffer({width:2,height:2,colorAttachments:["rgba32float"]}));const h=yr(t.pointsTextureSize),d=h.byteLength;!this.drawPointIndices||this.drawPointIndices.byteLength!==d?(this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.drawPointIndices.write(h),this.drawCommand&&this.drawCommand.setAttributes({pointIndices:this.drawPointIndices}),!this.hoveredPointIndices||this.hoveredPointIndices.byteLength!==d?(this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.hoveredPointIndices.write(h),!this.sampledPointIndices||this.sampledPointIndices.byteLength!==d?(this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=e.createBuffer({data:h,usage:L.VERTEX|L.COPY_DST})):this.sampledPointIndices.write(h),this.fillSampledPointsFboCommand&&this.fillSampledPointsFboCommand.setAttributes({pointIndices:this.sampledPointIndices}),this.updateGreyoutStatus(),this.updatePinnedStatus(),this.updateSampledPointsGrid(),this.trackPointsByIndices()}initPrograms(){var s,o,a;const{device:e,config:t,store:i,data:r}=this;(!this.imageAtlasCoordsTexture||!this.imageAtlasTexture)&&this.createAtlas(),this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),this.greyoutStatusTexture||this.updateGreyoutStatus(),t.enableSimulation&&(this.updatePositionVertexCoordBuffer||(this.updatePositionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.updatePositionUniformStore||(this.updatePositionUniformStore=new xe({updatePositionUniforms:{uniformTypes:{friction:"f32",spaceSize:"f32"},defaultUniforms:{friction:t.simulationFriction??0,spaceSize:i.adjustedSpaceSize??0}}})),this.updatePositionCommand||(this.updatePositionCommand=new me(e,{fs:Ev,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.updatePositionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{updatePositionUniforms:this.updatePositionUniformStore.getManagedUniformBuffer(e,"updatePositionUniforms")}}))),this.dragPointVertexCoordBuffer||(this.dragPointVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.dragPointUniformStore||(this.dragPointUniformStore=new xe({dragPointUniforms:{uniformTypes:{mousePos:"vec2<f32>",index:"f32"},defaultUniforms:{mousePos:re(i.mousePosition,[0,0]),index:((s=i.hoveredPoint)==null?void 0:s.index)??-1}}})),this.dragPointCommand||(this.dragPointCommand=new me(e,{fs:kv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.dragPointVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{dragPointUniforms:this.dragPointUniformStore.getManagedUniformBuffer(e,"dragPointUniforms")}})),this.drawUniformStore||(this.drawUniformStore=new xe({drawVertexUniforms:{uniformTypes:{ratio:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",greyoutColor:"vec4<f32>",backgroundColor:"vec4<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",isDarkenGreyout:"f32",skipSelected:"f32",skipUnselected:"f32",hasImages:"f32",imageCount:"f32",imageAtlasCoordsTextureSize:"f32"},defaultUniforms:{ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:(()=>{const l=i.transform??[1,0,0,0,1,0,0,0,1];return[l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]})(),pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),greyoutColor:Re(i.greyoutPointColor,[0,0,0,1]),backgroundColor:Re(i.backgroundColor,[0,0,0,1]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,skipSelected:0,skipUnselected:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0}},drawFragmentUniforms:{uniformTypes:{greyoutOpacity:"f32",pointOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>"},defaultUniforms:{greyoutOpacity:t.pointGreyoutOpacity??-1,pointOpacity:t.pointOpacity??1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:Re(i.backgroundColor,[0,0,0,1])}}})),this.drawCommand||(this.drawCommand=new me(e,{fs:yv,vs:vv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.drawPointIndices&&{pointIndices:this.drawPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer},...this.colorBuffer&&{color:this.colorBuffer},...this.shapeBuffer&&{shape:this.shapeBuffer},...this.imageIndicesBuffer&&{imageIndex:this.imageIndicesBuffer},...this.imageSizesBuffer&&{imageSize:this.imageSizesBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"},{name:"color",format:"float32x4"},{name:"shape",format:"float32"},{name:"imageIndex",format:"float32"},{name:"imageSize",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawVertexUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawVertexUniforms"),drawFragmentUniforms:this.drawUniformStore.getManagedUniformBuffer(e,"drawFragmentUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.findPointsOnAreaSelectionVertexCoordBuffer||(this.findPointsOnAreaSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnAreaSelectionUniformStore||(this.findPointsOnAreaSelectionUniformStore=new xe({findPointsOnAreaSelectionUniforms:{uniformTypes:{sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",selection0:"vec2<f32>",selection1:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32"},defaultUniforms:{sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,selection0:re((o=i.selectedArea)==null?void 0:o[0],[0,0]),selection1:re((a=i.selectedArea)==null?void 0:a[1],[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100}}})),this.findPointsOnAreaSelectionCommand||(this.findPointsOnAreaSelectionCommand=new me(e,{fs:bv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnAreaSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnAreaSelectionUniforms:this.findPointsOnAreaSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnAreaSelectionUniforms")}})),this.findPointsOnPolygonSelectionVertexCoordBuffer||(this.findPointsOnPolygonSelectionVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.findPointsOnPolygonSelectionUniformStore||(this.findPointsOnPolygonSelectionUniformStore=new xe({findPointsOnPolygonSelectionUniforms:{uniformTypes:{spaceSize:"f32",screenSize:"vec2<f32>",transformationMatrix:"mat4x4<f32>",polygonPathLength:"f32"},defaultUniforms:{spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),transformationMatrix:i.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}})),this.findPointsOnPolygonSelectionCommand||(this.findPointsOnPolygonSelectionCommand=new me(e,{fs:Sv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.findPointsOnPolygonSelectionVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findPointsOnPolygonSelectionUniforms:this.findPointsOnPolygonSelectionUniformStore.getManagedUniformBuffer(e,"findPointsOnPolygonSelectionUniforms")}})),this.findHoveredPointUniformStore||(this.findHoveredPointUniformStore=new xe({findHoveredPointUniforms:{uniformTypes:{pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",ratio:"f32",transformationMatrix:"mat4x4<f32>",mousePosition:"vec2<f32>",scalePointsOnZoom:"f32",maxPointSize:"f32",skipSelected:"f32",skipUnselected:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),ratio:t.pixelRatio??V.pixelRatio,transformationMatrix:i.transformationMatrix4x4,mousePosition:re(i.screenMousePosition,[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,maxPointSize:i.maxPointSize??100,skipSelected:0,skipUnselected:0}}})),this.findHoveredPointCommand||(this.findHoveredPointCommand=new me(e,{fs:Av,vs:Cv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}},bufferLayout:[{name:"pointIndices",format:"float32x2"},{name:"size",format:"float32"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{findHoveredPointUniforms:this.findHoveredPointUniformStore.getManagedUniformBuffer(e,"findHoveredPointUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always",blend:!1}})),this.fillSampledPointsUniformStore||(this.fillSampledPointsUniformStore=new xe({fillSampledPointsUniforms:{uniformTypes:{pointsTextureSize:"f32",transformationMatrix:"mat4x4<f32>",spaceSize:"f32",screenSize:"vec2<f32>"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0,transformationMatrix:i.transformationMatrix4x4,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0])}}})),this.fillSampledPointsFboCommand||(this.fillSampledPointsFboCommand=new me(e,{fs:Iv,vs:Pv,topology:"point-list",vertexCount:r.pointsNumber??0,attributes:{...this.sampledPointIndices&&{pointIndices:this.sampledPointIndices}},bufferLayout:[{name:"pointIndices",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{fillSampledPointsUniforms:this.fillSampledPointsUniformStore.getManagedUniformBuffer(e,"fillSampledPointsUniforms")},parameters:{depthWriteEnabled:!1,depthCompare:"always"}})),this.drawHighlightedVertexCoordBuffer||(this.drawHighlightedVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.drawHighlightedUniformStore||(this.drawHighlightedUniformStore=new xe({drawHighlightedUniforms:{uniformTypes:{size:"f32",transformationMatrix:"mat4x4<f32>",pointsTextureSize:"f32",sizeScale:"f32",spaceSize:"f32",screenSize:"vec2<f32>",scalePointsOnZoom:"f32",pointIndex:"f32",maxPointSize:"f32",color:"vec4<f32>",universalPointOpacity:"f32",greyoutOpacity:"f32",isDarkenGreyout:"f32",backgroundColor:"vec4<f32>",greyoutColor:"vec4<f32>",width:"f32"},defaultUniforms:{size:1,transformationMatrix:i.transformationMatrix4x4,pointsTextureSize:i.pointsTextureSize??0,sizeScale:t.pointSizeScale??1,spaceSize:i.adjustedSpaceSize??0,screenSize:re(i.screenSize,[0,0]),scalePointsOnZoom:t.scalePointsOnZoom??!0?1:0,pointIndex:-1,maxPointSize:i.maxPointSize??100,color:[0,0,0,1],universalPointOpacity:t.pointOpacity??1,greyoutOpacity:t.pointGreyoutOpacity??-1,isDarkenGreyout:i.isDarkenGreyout??!1?1:0,backgroundColor:Re(i.backgroundColor,[0,0,0,1]),greyoutColor:Re(i.greyoutPointColor,[0,0,0,1]),width:.85}}})),this.drawHighlightedCommand||(this.drawHighlightedCommand=new me(e,{fs:Tv,vs:wv,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.drawHighlightedVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{drawHighlightedUniforms:this.drawHighlightedUniformStore.getManagedUniformBuffer(e,"drawHighlightedUniforms")},parameters:{blend:!0,blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",depthWriteEnabled:!1,depthCompare:"always"}})),this.trackPointsVertexCoordBuffer||(this.trackPointsVertexCoordBuffer=e.createBuffer({data:new Float32Array([-1,-1,1,-1,-1,1,1,1])})),this.trackPointsUniformStore||(this.trackPointsUniformStore=new xe({trackPointsUniforms:{uniformTypes:{pointsTextureSize:"f32"},defaultUniforms:{pointsTextureSize:i.pointsTextureSize??0}}})),this.trackPointsCommand||(this.trackPointsCommand=new me(e,{fs:Rv,vs:tt,topology:"triangle-strip",vertexCount:4,attributes:{vertexCoord:this.trackPointsVertexCoordBuffer},bufferLayout:[{name:"vertexCoord",format:"float32x2"}],defines:{USE_UNIFORM_BUFFERS:!0},bindings:{trackPointsUniforms:this.trackPointsUniformStore.getManagedUniformBuffer(e,"trackPointsUniforms")}}))}updateColor(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=i.pointColors,s=r.byteLength;!this.colorBuffer||this.colorBuffer.byteLength!==s?(this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.colorBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({color:this.colorBuffer})}updateGreyoutStatus(){const{device:e,store:{selectedIndices:t,pointsTextureSize:i}}=this;if(!i)return;const r=new Float32Array(i*i*4).fill(t?1:0);if(t)for(const s of t)r[s*4]=0;!this.greyoutStatusTexture||this.greyoutStatusTexture.width!==i||this.greyoutStatusTexture.height!==i?(this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=e.createTexture({width:i,height:i,format:"rgba32float"}),this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",i),mipLevel:0,x:0,y:0})):this.greyoutStatusTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",i),mipLevel:0,x:0,y:0})}updatePinnedStatus(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t)return;const r=new Float32Array(t*t*4).fill(0);if(i.inputPinnedPoints&&i.pointsNumber!==void 0)for(const s of i.inputPinnedPoints)s>=0&&s<i.pointsNumber&&(r[s*4]=1);!this.pinnedStatusTexture||this.pinnedStatusTexture.width!==t||this.pinnedStatusTexture.height!==t?(this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",t),mipLevel:0,x:0,y:0})):this.pinnedStatusTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",t),mipLevel:0,x:0,y:0})}updateSize(){const{device:e,store:{pointsTextureSize:t},data:i}=this;if(!t||i.pointsNumber===void 0||i.pointSizes===void 0)return;const r=i.pointSizes,s=r.byteLength;!this.sizeBuffer||this.sizeBuffer.byteLength!==s?(this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=e.createBuffer({data:r,usage:L.VERTEX|L.COPY_DST})):this.sizeBuffer.write(r),this.drawCommand&&this.drawCommand.setAttributes({size:this.sizeBuffer});const o=new Float32Array(t*t*4);for(let a=0;a<i.pointsNumber;a++)o[a*4]=i.pointSizes[a];!this.sizeTexture||this.sizeTexture.width!==t||this.sizeTexture.height!==t?(this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=e.createTexture({width:t,height:t,format:"rgba32float"}),this.sizeTexture.copyImageData({data:o,bytesPerRow:ie("rgba32float",t),mipLevel:0,x:0,y:0})):this.sizeTexture.copyImageData({data:o,bytesPerRow:ie("rgba32float",t),mipLevel:0,x:0,y:0})}updateShape(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointShapes===void 0)return;const i=t.pointShapes,r=i.byteLength;!this.shapeBuffer||this.shapeBuffer.byteLength!==r?(this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.shapeBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({shape:this.shapeBuffer})}updateImageIndices(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageIndices===void 0)return;const i=t.pointImageIndices,r=i.byteLength;!this.imageIndicesBuffer||this.imageIndicesBuffer.byteLength!==r?(this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.imageIndicesBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({imageIndex:this.imageIndicesBuffer})}updateImageSizes(){const{device:e,data:t}=this;if(t.pointsNumber===void 0||t.pointImageSizes===void 0)return;const i=t.pointImageSizes,r=i.byteLength;!this.imageSizesBuffer||this.imageSizesBuffer.byteLength!==r?(this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=e.createBuffer({data:i,usage:L.VERTEX|L.COPY_DST})):this.imageSizesBuffer.write(i),this.drawCommand&&this.drawCommand.setAttributes({imageSize:this.imageSizesBuffer})}createAtlas(){var c;const{device:e,data:t,store:i}=this;if(!((c=t.inputImageData)!=null&&c.length)){this.imageCount=0,this.imageAtlasCoordsTextureSize=0,this.imageAtlasCoordsTexture||(this.imageAtlasCoordsTexture=e.createTexture({data:new Float32Array(4).fill(0),width:1,height:1,format:"rgba32float"})),this.imageAtlasTexture||(this.imageAtlasTexture=e.createTexture({data:new Uint8Array(4).fill(0),width:1,height:1,format:"rgba8unorm"}));return}const r=Dv(t.inputImageData,i.webglMaxTextureSize);if(!r){console.warn("Failed to create atlas from image data");return}this.imageCount=t.inputImageData.length;const{atlasData:s,atlasSize:o,atlasCoords:a,atlasCoordsSize:l}=r;this.imageAtlasCoordsTextureSize=l,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=e.createTexture({width:o,height:o,format:"rgba8unorm"}),this.imageAtlasTexture.copyImageData({data:s,bytesPerRow:ie("rgba8unorm",o),rowsPerImage:o,mipLevel:0,x:0,y:0}),this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=e.createTexture({width:l,height:l,format:"rgba32float"}),this.imageAtlasCoordsTexture.copyImageData({data:a,bytesPerRow:ie("rgba32float",l),rowsPerImage:l,mipLevel:0,x:0,y:0})}updateSampledPointsGrid(){const{store:{screenSize:e},config:{pointSamplingDistance:t},device:i}=this;let r=t??Math.min(...e)/2;r===0&&(r=V.pointSamplingDistance);const s=Math.ceil(e[0]/r),o=Math.ceil(e[1]/r);s===0||o===0||(!this.sampledPointsFbo||this.sampledPointsFbo.width!==s||this.sampledPointsFbo.height!==o)&&(this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=i.createFramebuffer({width:s,height:o,colorAttachments:["rgba32float"]}))}trackPoints(){var t;if(!((t=this.trackedIndices)!=null&&t.length)||!this.trackPointsCommand||!this.trackPointsUniformStore||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.trackedIndicesTexture||this.trackedIndicesTexture.destroyed)return;this.trackPointsUniformStore.setUniforms({trackPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0}}),this.trackPointsCommand.setBindings({positionsTexture:this.currentPositionTexture,trackedIndices:this.trackedIndicesTexture});const e=this.device.beginRenderPass({framebuffer:this.trackedPositionsFbo});this.trackPointsCommand.draw(e),e.end()}draw(e){var a,l;const{data:t,config:i,store:r}=this;if(this.colorBuffer||this.updateColor(),this.sizeBuffer||this.updateSize(),this.shapeBuffer||this.updateShape(),this.imageIndicesBuffer||this.updateImageIndices(),this.imageSizesBuffer||this.updateImageSizes(),!this.drawCommand||!this.drawUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed||(!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)&&(this.createAtlas(),!this.imageAtlasTexture||!this.imageAtlasCoordsTexture)||this.imageAtlasTexture.destroyed||this.imageAtlasCoordsTexture.destroyed||!t.pointsNumber||t.pointsNumber===0||!r.screenSize||r.screenSize[0]===0||r.screenSize[1]===0)return;this.drawCommand.setVertexCount(t.pointsNumber);const s={ratio:i.pixelRatio??V.pixelRatio,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),greyoutColor:Re(r.greyoutPointColor,[-1,-1,-1,-1]),backgroundColor:Re(r.backgroundColor,[0,0,0,1]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,maxPointSize:r.maxPointSize??100,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,hasImages:this.imageCount>0?1:0,imageCount:this.imageCount,imageAtlasCoordsTextureSize:this.imageAtlasCoordsTextureSize??0},o={greyoutOpacity:i.pointGreyoutOpacity??-1,pointOpacity:i.pointOpacity??1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1])};if(r.selectedIndices&&r.selectedIndices.length>0?(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:1,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e),this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:1},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)):(this.drawUniformStore.setUniforms({drawVertexUniforms:{...s,skipSelected:0,skipUnselected:0},drawFragmentUniforms:o}),this.drawCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture,imageAtlasTexture:this.imageAtlasTexture,imageAtlasCoords:this.imageAtlasCoordsTexture}),this.drawCommand.draw(e)),i.renderHoveredPointRing&&r.hoveredPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((a=t.pointSizes)==null?void 0:a[r.hoveredPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.hoveredPoint.index,maxPointSize:r.maxPointSize??100,color:Re(r.hoveredPointRingColor,[0,0,0,1]),universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1]),greyoutColor:Re(r.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}if(r.focusedPoint&&this.drawHighlightedCommand&&this.drawHighlightedUniformStore){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed)return;const c=((l=t.pointSizes)==null?void 0:l[r.focusedPoint.index])??1;this.drawHighlightedUniformStore.setUniforms({drawHighlightedUniforms:{size:c,transformationMatrix:r.transformationMatrix4x4,pointsTextureSize:r.pointsTextureSize??0,sizeScale:i.pointSizeScale??1,spaceSize:r.adjustedSpaceSize??0,screenSize:re(r.screenSize,[0,0]),scalePointsOnZoom:i.scalePointsOnZoom??!0?1:0,pointIndex:r.focusedPoint.index,maxPointSize:r.maxPointSize??100,color:Re(r.focusedPointRingColor,[0,0,0,1]),universalPointOpacity:i.pointOpacity??1,greyoutOpacity:i.pointGreyoutOpacity??-1,isDarkenGreyout:r.isDarkenGreyout??!1?1:0,backgroundColor:Re(r.backgroundColor,[0,0,0,1]),greyoutColor:Re(r.greyoutPointColor,[0,0,0,1]),width:.85}}),this.drawHighlightedCommand.setBindings({positionsTexture:this.currentPositionTexture,pointGreyoutStatusTexture:this.greyoutStatusTexture}),this.drawHighlightedCommand.draw(e)}}updatePosition(){if(!this.updatePositionCommand||!this.updatePositionUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.velocityTexture||this.velocityTexture.destroyed||!this.pinnedStatusTexture||this.pinnedStatusTexture.destroyed)return;this.updatePositionUniformStore.setUniforms({updatePositionUniforms:{friction:this.config.simulationFriction??0,spaceSize:this.store.adjustedSpaceSize??0}}),this.updatePositionCommand.setBindings({positionsTexture:this.previousPositionTexture,velocity:this.velocityTexture,pinnedStatusTexture:this.pinnedStatusTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.updatePositionCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}drag(){var t;if(!this.dragPointCommand||!this.dragPointUniformStore||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed)return;this.dragPointUniformStore.setUniforms({dragPointUniforms:{mousePos:re(this.store.mousePosition,[0,0]),index:((t=this.store.hoveredPoint)==null?void 0:t.index)??-1}}),this.dragPointCommand.setBindings({positionsTexture:this.previousPositionTexture});const e=this.device.beginRenderPass({framebuffer:this.currentPositionFbo});this.dragPointCommand.draw(e),e.end(),this.swapFbo(),this.isPositionsUpToDate=!1}findPointsOnAreaSelection(){var t,i;if(!this.findPointsOnAreaSelectionCommand||!this.findPointsOnAreaSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.sizeTexture||this.sizeTexture.destroyed)return;this.findPointsOnAreaSelectionUniformStore.setUniforms({findPointsOnAreaSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),sizeScale:this.config.pointSizeScale??1,transformationMatrix:this.store.transformationMatrix4x4,ratio:this.config.pixelRatio??V.pixelRatio,selection0:re((t=this.store.selectedArea)==null?void 0:t[0],[0,0]),selection1:re((i=this.store.selectedArea)==null?void 0:i[1],[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,maxPointSize:this.store.maxPointSize??100}}),this.findPointsOnAreaSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,pointSize:this.sizeTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnAreaSelectionCommand.draw(e),e.end()}findPointsOnPolygonSelection(){if(!this.findPointsOnPolygonSelectionCommand||!this.findPointsOnPolygonSelectionUniformStore||!this.selectedFbo||this.selectedFbo.destroyed||!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.polygonPathTexture||this.polygonPathTexture.destroyed)return;this.findPointsOnPolygonSelectionUniformStore.setUniforms({findPointsOnPolygonSelectionUniforms:{spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),transformationMatrix:this.store.transformationMatrix4x4,polygonPathLength:this.polygonPathLength}}),this.findPointsOnPolygonSelectionCommand.setBindings({positionsTexture:this.currentPositionTexture,polygonPathTexture:this.polygonPathTexture});const e=this.device.beginRenderPass({framebuffer:this.selectedFbo});this.findPointsOnPolygonSelectionCommand.draw(e),e.end()}updatePolygonPath(e){const{device:t}=this;if(this.polygonPathLength=e.length,e.length===0){this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0;return}const i=Math.ceil(Math.sqrt(e.length)),r=new Float32Array(i*i*4);for(const[s,o]of e.entries()){const[a,l]=o;r[s*4]=a,r[s*4+1]=l,r[s*4+2]=0,r[s*4+3]=0}!this.polygonPathTexture||this.polygonPathTexture.width!==i||this.polygonPathTexture.height!==i?(this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=t.createTexture({width:i,height:i,format:"rgba32float"}),this.polygonPathTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",i),mipLevel:0,x:0,y:0})):this.polygonPathTexture.copyImageData({data:r,bytesPerRow:ie("rgba32float",i),mipLevel:0,x:0,y:0})}findHoveredPoint(){if(!this.hoveredFbo||this.hoveredFbo.destroyed||!this.findHoveredPointCommand||!this.findHoveredPointUniformStore||!this.currentPositionTexture||this.currentPositionTexture.destroyed||(this.greyoutStatusTexture||this.updateGreyoutStatus(),!this.greyoutStatusTexture||this.greyoutStatusTexture.destroyed))return;this.findHoveredPointCommand.setVertexCount(this.data.pointsNumber??0),this.findHoveredPointCommand.setAttributes({...this.hoveredPointIndices&&{pointIndices:this.hoveredPointIndices},...this.sizeBuffer&&{size:this.sizeBuffer}});const e={ratio:this.config.pixelRatio??V.pixelRatio,sizeScale:this.config.pointSizeScale??1,pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0]),scalePointsOnZoom:this.config.scalePointsOnZoom??!0?1:0,mousePosition:re(this.store.screenMousePosition,[0,0]),maxPointSize:this.store.maxPointSize??100},t={positionsTexture:this.currentPositionTexture,pointGreyoutStatus:this.greyoutStatusTexture},i=this.device.beginRenderPass({framebuffer:this.hoveredFbo,clearColor:[0,0,0,0]});this.store.selectedIndices&&this.store.selectedIndices.length>0?(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:1,skipUnselected:0}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i),this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:0,skipUnselected:1}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i)):(this.findHoveredPointUniformStore.setUniforms({findHoveredPointUniforms:{...e,skipSelected:0,skipUnselected:0}}),this.findHoveredPointCommand.setBindings(t),this.findHoveredPointCommand.draw(i)),i.end()}trackPointsByIndices(e){const{store:{pointsTextureSize:t},device:i}=this;if(this.trackedIndices=e,this.trackedPositions=void 0,this.isPositionsUpToDate=!1,!(e!=null&&e.length)||!t)return;const r=Math.ceil(Math.sqrt(e.length)),s=new Float32Array(r*r*4).fill(-1);for(const[o,a]of e.entries())a!==void 0&&(s[o*4]=a%t,s[o*4+1]=Math.floor(a/t),s[o*4+2]=0,s[o*4+3]=0);!this.trackedIndicesTexture||this.trackedIndicesTexture.width!==r||this.trackedIndicesTexture.height!==r?(this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=i.createTexture({width:r,height:r,format:"rgba32float"}),this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0})):this.trackedIndicesTexture.copyImageData({data:s,bytesPerRow:ie("rgba32float",r),mipLevel:0,x:0,y:0}),(!this.trackedPositionsFbo||this.trackedPositionsFbo.width!==r||this.trackedPositionsFbo.height!==r)&&(this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=i.createFramebuffer({width:r,height:r,colorAttachments:["rgba32float"]})),this.trackPoints()}getTrackedPositionsMap(){if(!this.trackedIndices)return new Map;const{config:{enableSimulation:e},store:{isSimulationRunning:t}}=this;if((!e||!t)&&this.isPositionsUpToDate&&this.trackedPositions)return this.trackedPositions;if(!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return new Map;const i=Me(this.device,this.trackedPositionsFbo),r=new Map;for(let s=0;s<i.length/4;s+=1){const o=i[s*4],a=i[s*4+1],l=this.trackedIndices[s];o!==void 0&&a!==void 0&&l!==void 0&&r.set(l,[o,a])}return(!e||!t)&&(this.trackedPositions=r,this.isPositionsUpToDate=!0),r}getSampledPointPositionsMap(){const e=new Map;if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return e;if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return e;this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const i=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(i),i.end()}const t=Me(this.device,this.sampledPointsFbo);for(let i=0;i<t.length/4;i++){const r=t[i*4],s=!!t[i*4+1],o=t[i*4+2],a=t[i*4+3];s&&r!==void 0&&o!==void 0&&a!==void 0&&e.set(r,[o,a])}return e}getSampledPoints(){const e=[],t=[];if(!this.sampledPointsFbo||this.sampledPointsFbo.destroyed)return{indices:e,positions:t};if(this.fillSampledPointsFboCommand&&this.fillSampledPointsUniformStore&&this.sampledPointsFbo){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed)return{indices:e,positions:t};this.fillSampledPointsFboCommand.setVertexCount(this.data.pointsNumber??0),this.fillSampledPointsUniformStore.setUniforms({fillSampledPointsUniforms:{pointsTextureSize:this.store.pointsTextureSize??0,transformationMatrix:this.store.transformationMatrix4x4,spaceSize:this.store.adjustedSpaceSize??0,screenSize:re(this.store.screenSize,[0,0])}}),this.fillSampledPointsFboCommand.setBindings({positionsTexture:this.currentPositionTexture});const r=this.device.beginRenderPass({framebuffer:this.sampledPointsFbo,clearColor:[0,0,0,0]});this.fillSampledPointsFboCommand.draw(r),r.end()}const i=Me(this.device,this.sampledPointsFbo);for(let r=0;r<i.length/4;r++){const s=i[r*4],o=!!i[r*4+1],a=i[r*4+2],l=i[r*4+3];o&&s!==void 0&&a!==void 0&&l!==void 0&&(e.push(s),t.push(a,l))}return{indices:e,positions:t}}getTrackedPositionsArray(){const e=[];if(!this.trackedIndices||!this.trackedPositionsFbo||this.trackedPositionsFbo.destroyed)return e;e.length=this.trackedIndices.length*2;const t=Me(this.device,this.trackedPositionsFbo);for(let i=0;i<t.length/4;i+=1){const r=t[i*4],s=t[i*4+1],o=this.trackedIndices[i];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}destroy(){var e,t,i,r,s,o,a,l,c,u,f,h,d,_,I,P,A,O;(e=this.drawCommand)==null||e.destroy(),this.drawCommand=void 0,(t=this.drawHighlightedCommand)==null||t.destroy(),this.drawHighlightedCommand=void 0,(i=this.updatePositionCommand)==null||i.destroy(),this.updatePositionCommand=void 0,(r=this.dragPointCommand)==null||r.destroy(),this.dragPointCommand=void 0,(s=this.findPointsOnAreaSelectionCommand)==null||s.destroy(),this.findPointsOnAreaSelectionCommand=void 0,(o=this.findPointsOnPolygonSelectionCommand)==null||o.destroy(),this.findPointsOnPolygonSelectionCommand=void 0,(a=this.findHoveredPointCommand)==null||a.destroy(),this.findHoveredPointCommand=void 0,(l=this.fillSampledPointsFboCommand)==null||l.destroy(),this.fillSampledPointsFboCommand=void 0,(c=this.trackPointsCommand)==null||c.destroy(),this.trackPointsCommand=void 0,this.currentPositionFbo&&!this.currentPositionFbo.destroyed&&this.currentPositionFbo.destroy(),this.currentPositionFbo=void 0,this.previousPositionFbo&&!this.previousPositionFbo.destroyed&&this.previousPositionFbo.destroy(),this.previousPositionFbo=void 0,this.velocityFbo&&!this.velocityFbo.destroyed&&this.velocityFbo.destroy(),this.velocityFbo=void 0,this.selectedFbo&&!this.selectedFbo.destroyed&&this.selectedFbo.destroy(),this.selectedFbo=void 0,this.hoveredFbo&&!this.hoveredFbo.destroyed&&this.hoveredFbo.destroy(),this.hoveredFbo=void 0,this.trackedPositionsFbo&&!this.trackedPositionsFbo.destroyed&&this.trackedPositionsFbo.destroy(),this.trackedPositionsFbo=void 0,this.sampledPointsFbo&&!this.sampledPointsFbo.destroyed&&this.sampledPointsFbo.destroy(),this.sampledPointsFbo=void 0,this.currentPositionTexture&&!this.currentPositionTexture.destroyed&&this.currentPositionTexture.destroy(),this.currentPositionTexture=void 0,this.previousPositionTexture&&!this.previousPositionTexture.destroyed&&this.previousPositionTexture.destroy(),this.previousPositionTexture=void 0,this.velocityTexture&&!this.velocityTexture.destroyed&&this.velocityTexture.destroy(),this.velocityTexture=void 0,this.selectedTexture&&!this.selectedTexture.destroyed&&this.selectedTexture.destroy(),this.selectedTexture=void 0,this.greyoutStatusTexture&&!this.greyoutStatusTexture.destroyed&&this.greyoutStatusTexture.destroy(),this.greyoutStatusTexture=void 0,this.sizeTexture&&!this.sizeTexture.destroyed&&this.sizeTexture.destroy(),this.sizeTexture=void 0,this.trackedIndicesTexture&&!this.trackedIndicesTexture.destroyed&&this.trackedIndicesTexture.destroy(),this.trackedIndicesTexture=void 0,this.polygonPathTexture&&!this.polygonPathTexture.destroyed&&this.polygonPathTexture.destroy(),this.polygonPathTexture=void 0,this.imageAtlasTexture&&!this.imageAtlasTexture.destroyed&&this.imageAtlasTexture.destroy(),this.imageAtlasTexture=void 0,this.imageAtlasCoordsTexture&&!this.imageAtlasCoordsTexture.destroyed&&this.imageAtlasCoordsTexture.destroy(),this.imageAtlasCoordsTexture=void 0,this.pinnedStatusTexture&&!this.pinnedStatusTexture.destroyed&&this.pinnedStatusTexture.destroy(),this.pinnedStatusTexture=void 0,(u=this.updatePositionUniformStore)==null||u.destroy(),this.updatePositionUniformStore=void 0,(f=this.dragPointUniformStore)==null||f.destroy(),this.dragPointUniformStore=void 0,(h=this.drawUniformStore)==null||h.destroy(),this.drawUniformStore=void 0,(d=this.findPointsOnAreaSelectionUniformStore)==null||d.destroy(),this.findPointsOnAreaSelectionUniformStore=void 0,(_=this.findPointsOnPolygonSelectionUniformStore)==null||_.destroy(),this.findPointsOnPolygonSelectionUniformStore=void 0,(I=this.findHoveredPointUniformStore)==null||I.destroy(),this.findHoveredPointUniformStore=void 0,(P=this.fillSampledPointsUniformStore)==null||P.destroy(),this.fillSampledPointsUniformStore=void 0,(A=this.drawHighlightedUniformStore)==null||A.destroy(),this.drawHighlightedUniformStore=void 0,(O=this.trackPointsUniformStore)==null||O.destroy(),this.trackPointsUniformStore=void 0,this.colorBuffer&&!this.colorBuffer.destroyed&&this.colorBuffer.destroy(),this.colorBuffer=void 0,this.sizeBuffer&&!this.sizeBuffer.destroyed&&this.sizeBuffer.destroy(),this.sizeBuffer=void 0,this.shapeBuffer&&!this.shapeBuffer.destroyed&&this.shapeBuffer.destroy(),this.shapeBuffer=void 0,this.imageIndicesBuffer&&!this.imageIndicesBuffer.destroyed&&this.imageIndicesBuffer.destroy(),this.imageIndicesBuffer=void 0,this.imageSizesBuffer&&!this.imageSizesBuffer.destroyed&&this.imageSizesBuffer.destroy(),this.imageSizesBuffer=void 0,this.drawPointIndices&&!this.drawPointIndices.destroyed&&this.drawPointIndices.destroy(),this.drawPointIndices=void 0,this.hoveredPointIndices&&!this.hoveredPointIndices.destroyed&&this.hoveredPointIndices.destroy(),this.hoveredPointIndices=void 0,this.sampledPointIndices&&!this.sampledPointIndices.destroyed&&this.sampledPointIndices.destroy(),this.sampledPointIndices=void 0,this.updatePositionVertexCoordBuffer&&!this.updatePositionVertexCoordBuffer.destroyed&&this.updatePositionVertexCoordBuffer.destroy(),this.updatePositionVertexCoordBuffer=void 0,this.dragPointVertexCoordBuffer&&!this.dragPointVertexCoordBuffer.destroyed&&this.dragPointVertexCoordBuffer.destroy(),this.dragPointVertexCoordBuffer=void 0,this.findPointsOnAreaSelectionVertexCoordBuffer&&!this.findPointsOnAreaSelectionVertexCoordBuffer.destroyed&&this.findPointsOnAreaSelectionVertexCoordBuffer.destroy(),this.findPointsOnAreaSelectionVertexCoordBuffer=void 0,this.findPointsOnPolygonSelectionVertexCoordBuffer&&!this.findPointsOnPolygonSelectionVertexCoordBuffer.destroyed&&this.findPointsOnPolygonSelectionVertexCoordBuffer.destroy(),this.findPointsOnPolygonSelectionVertexCoordBuffer=void 0,this.drawHighlightedVertexCoordBuffer&&!this.drawHighlightedVertexCoordBuffer.destroyed&&this.drawHighlightedVertexCoordBuffer.destroy(),this.drawHighlightedVertexCoordBuffer=void 0,this.trackPointsVertexCoordBuffer&&!this.trackPointsVertexCoordBuffer.destroyed&&this.trackPointsVertexCoordBuffer.destroy(),this.trackPointsVertexCoordBuffer=void 0}swapFbo(){if(!this.currentPositionTexture||this.currentPositionTexture.destroyed||!this.previousPositionTexture||this.previousPositionTexture.destroyed||!this.currentPositionFbo||this.currentPositionFbo.destroyed||!this.previousPositionFbo||this.previousPositionFbo.destroyed)return;const e=this.previousPositionTexture,t=this.previousPositionFbo;this.previousPositionTexture=this.currentPositionTexture,this.previousPositionFbo=this.currentPositionFbo,this.currentPositionTexture=e,this.currentPositionFbo=t}rescaleInitialNodePositions(){const{config:{spaceSize:e}}=this;if(!this.data.pointPositions||!e)return;const t=this.data.pointPositions,i=t.length/2;let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let A=0;A<t.length;A+=2){const O=t[A],E=t[A+1];r=Math.min(r,O),s=Math.max(s,O),o=Math.min(o,E),a=Math.max(a,E)}const l=s-r,c=a-o,u=Math.max(l,c);if(u>e){this.scaleX=void 0,this.scaleY=void 0;return}const f=e*e*.001,h=i>f?e*Math.max(1.2,Math.sqrt(i)/e):e*.1,d=h/u,_=(e-h)/2,I=(u-l)/2*d+_,P=(u-c)/2*d+_;this.scaleX=A=>(A-r)*d+I,this.scaleY=A=>(A-o)*d+P;for(let A=0;A<i;A++)this.data.pointPositions[A*2]=this.scaleX(t[A*2]),this.data.pointPositions[A*2+1]=this.scaleY(t[A*2+1])}}const Fv={passive:!1},ei={capture:!0,passive:!1};function Eo(n){n.stopImmediatePropagation()}function yn(n){n.preventDefault(),n.stopImmediatePropagation()}function Ru(n){var e=n.document.documentElement,t=we(n).on("dragstart.drag",yn,ei);"onselectstart"in e?t.on("selectstart.drag",yn,ei):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function ku(n,e){var t=n.document.documentElement,i=we(n).on("dragstart.drag",null);e&&(i.on("click.drag",yn,ei),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in t?i.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}const vr=n=>()=>n;function Ro(n,{sourceEvent:e,subject:t,target:i,identifier:r,active:s,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Ro.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Nv(n){return!n.ctrlKey&&!n.button}function Ov(){return this.parentNode}function Bv(n,e){return e??{x:n.x,y:n.y}}function Uv(){return navigator.maxTouchPoints||"ontouchstart"in this}function zv(){var n=Nv,e=Ov,t=Bv,i=Uv,r={},s=ui("start","drag","end"),o=0,a,l,c,u,f=0;function h(x){x.on("mousedown.drag",d).filter(i).on("touchstart.drag",P).on("touchmove.drag",A,Fv).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(x,R){if(!(u||!n.call(this,x,R))){var N=E(this,e.call(this,x,R),x,R,"mouse");N&&(we(x.view).on("mousemove.drag",_,ei).on("mouseup.drag",I,ei),Ru(x.view),Eo(x),c=!1,a=x.clientX,l=x.clientY,N("start",x))}}function _(x){if(yn(x),!c){var R=x.clientX-a,N=x.clientY-l;c=R*R+N*N>f}r.mouse("drag",x)}function I(x){we(x.view).on("mousemove.drag mouseup.drag",null),ku(x.view,c),yn(x),r.mouse("end",x)}function P(x,R){if(n.call(this,x,R)){var N=x.changedTouches,U=e.call(this,x,R),W=N.length,q,G;for(q=0;q<W;++q)(G=E(this,U,x,R,N[q].identifier,N[q]))&&(Eo(x),G("start",x,N[q]))}}function A(x){var R=x.changedTouches,N=R.length,U,W;for(U=0;U<N;++U)(W=r[R[U].identifier])&&(yn(x),W("drag",x,R[U]))}function O(x){var R=x.changedTouches,N=R.length,U,W;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),U=0;U<N;++U)(W=r[R[U].identifier])&&(Eo(x),W("end",x,R[U]))}function E(x,R,N,U,W,q){var G=s.copy(),B=yt(q||N,R),de,se,C;if((C=t.call(x,new Ro("beforestart",{sourceEvent:N,target:h,identifier:W,active:o,x:B[0],y:B[1],dx:0,dy:0,dispatch:G}),U))!=null)return de=C.x-B[0]||0,se=C.y-B[1]||0,function H(M,$,Z){var j=B,ee;switch(M){case"start":r[W]=H,ee=o++;break;case"end":delete r[W],--o;case"drag":B=yt(Z||$,R),ee=o;break}G.call(M,x,new Ro(M,{sourceEvent:$,subject:C,target:h,identifier:W,active:ee,x:B[0]+de,y:B[1]+se,dx:B[0]-j[0],dy:B[1]-j[1],dispatch:G}),U)}}return h.filter=function(x){return arguments.length?(n=typeof x=="function"?x:vr(!!x),h):n},h.container=function(x){return arguments.length?(e=typeof x=="function"?x:vr(x),h):e},h.subject=function(x){return arguments.length?(t=typeof x=="function"?x:vr(x),h):t},h.touchable=function(x){return arguments.length?(i=typeof x=="function"?x:vr(!!x),h):i},h.on=function(){var x=s.on.apply(s,arguments);return x===s?h:x},h.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,h):Math.sqrt(f)},h}const br=n=>()=>n;function Lv(n,{sourceEvent:e,target:t,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function It(n,e,t){this.k=n,this.x=e,this.y=t}It.prototype={constructor:It,scale:function(n){return n===1?this:new It(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new It(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ti=new It(1,0,0);It.prototype;function ko(n){n.stopImmediatePropagation()}function ni(n){n.preventDefault(),n.stopImmediatePropagation()}function Vv(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function Hv(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function Du(){return this.__zoom||ti}function Wv(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function $v(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xv(n,e,t){var i=n.invertX(e[0][0])-t[0][0],r=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],o=n.invertY(e[1][1])-t[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Yv(){var n=Vv,e=Hv,t=Xv,i=Wv,r=$v,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=vd,c=ui("start","zoom","end"),u,f,h,d=500,_=150,I=0,P=10;function A(C){C.property("__zoom",Du).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",G).filter(r).on("touchstart.zoom",B).on("touchmove.zoom",de).on("touchend.zoom touchcancel.zoom",se).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(C,H,M,$){var Z=C.selection?C.selection():C;Z.property("__zoom",Du),C!==Z?R(C,H,M,$):Z.interrupt().each(function(){N(this,arguments).event($).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},A.scaleBy=function(C,H,M,$){A.scaleTo(C,function(){var Z=this.__zoom.k,j=typeof H=="function"?H.apply(this,arguments):H;return Z*j},M,$)},A.scaleTo=function(C,H,M,$){A.transform(C,function(){var Z=e.apply(this,arguments),j=this.__zoom,ee=M==null?x(Z):typeof M=="function"?M.apply(this,arguments):M,J=j.invert(ee),ge=typeof H=="function"?H.apply(this,arguments):H;return t(E(O(j,ge),ee,J),Z,o)},M,$)},A.translateBy=function(C,H,M,$){A.transform(C,function(){return t(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof M=="function"?M.apply(this,arguments):M),e.apply(this,arguments),o)},null,$)},A.translateTo=function(C,H,M,$,Z){A.transform(C,function(){var j=e.apply(this,arguments),ee=this.__zoom,J=$==null?x(j):typeof $=="function"?$.apply(this,arguments):$;return t(ti.translate(J[0],J[1]).scale(ee.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof M=="function"?-M.apply(this,arguments):-M),j,o)},$,Z)};function O(C,H){return H=Math.max(s[0],Math.min(s[1],H)),H===C.k?C:new It(H,C.x,C.y)}function E(C,H,M){var $=H[0]-M[0]*C.k,Z=H[1]-M[1]*C.k;return $===C.x&&Z===C.y?C:new It(C.k,$,Z)}function x(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function R(C,H,M,$){C.on("start.zoom",function(){N(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event($).end()}).tween("zoom",function(){var Z=this,j=arguments,ee=N(Z,j).event($),J=e.apply(Z,j),ge=M==null?x(J):typeof M=="function"?M.apply(Z,j):M,fe=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),Te=Z.__zoom,oe=typeof H=="function"?H.apply(Z,j):H,We=l(Te.invert(ge).concat(fe/Te.k),oe.invert(ge).concat(fe/oe.k));return function($e){if($e===1)$e=oe;else{var nt=We($e),Gt=fe/nt[2];$e=new It(Gt,ge[0]-nt[0]*Gt,ge[1]-nt[1]*Gt)}ee.zoom(null,$e)}})}function N(C,H,M){return!M&&C.__zooming||new U(C,H)}function U(C,H){this.that=C,this.args=H,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,H),this.taps=0}U.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,H){return this.mouse&&C!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var H=we(this.that).datum();c.call(C,this.that,new Lv(C,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:c}),H)}};function W(C,...H){if(!n.apply(this,arguments))return;var M=N(this,H).event(C),$=this.__zoom,Z=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,i.apply(this,arguments)))),j=yt(C);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=$.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if($.k===Z)return;M.mouse=[j,$.invert(j)],yi(this),M.start()}ni(C),M.wheel=setTimeout(ee,_),M.zoom("mouse",t(E(O($,Z),M.mouse[0],M.mouse[1]),M.extent,o));function ee(){M.wheel=null,M.end()}}function q(C,...H){if(h||!n.apply(this,arguments))return;var M=C.currentTarget,$=N(this,H,!0).event(C),Z=we(C.view).on("mousemove.zoom",ge,!0).on("mouseup.zoom",fe,!0),j=yt(C,M),ee=C.clientX,J=C.clientY;Ru(C.view),ko(C),$.mouse=[j,this.__zoom.invert(j)],yi(this),$.start();function ge(Te){if(ni(Te),!$.moved){var oe=Te.clientX-ee,We=Te.clientY-J;$.moved=oe*oe+We*We>I}$.event(Te).zoom("mouse",t(E($.that.__zoom,$.mouse[0]=yt(Te,M),$.mouse[1]),$.extent,o))}function fe(Te){Z.on("mousemove.zoom mouseup.zoom",null),ku(Te.view,$.moved),ni(Te),$.event(Te).end()}}function G(C,...H){if(n.apply(this,arguments)){var M=this.__zoom,$=yt(C.changedTouches?C.changedTouches[0]:C,this),Z=M.invert($),j=M.k*(C.shiftKey?.5:2),ee=t(E(O(M,j),$,Z),e.apply(this,H),o);ni(C),a>0?we(this).transition().duration(a).call(R,ee,$,C):we(this).call(A.transform,ee,$,C)}}function B(C,...H){if(n.apply(this,arguments)){var M=C.touches,$=M.length,Z=N(this,H,C.changedTouches.length===$).event(C),j,ee,J,ge;for(ko(C),ee=0;ee<$;++ee)J=M[ee],ge=yt(J,this),ge=[ge,this.__zoom.invert(ge),J.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==ge[2]&&(Z.touch1=ge,Z.taps=0):(Z.touch0=ge,j=!0,Z.taps=1+!!u);u&&(u=clearTimeout(u)),j&&(Z.taps<2&&(f=ge[0],u=setTimeout(function(){u=null},d)),yi(this),Z.start())}}function de(C,...H){if(this.__zooming){var M=N(this,H).event(C),$=C.changedTouches,Z=$.length,j,ee,J,ge;for(ni(C),j=0;j<Z;++j)ee=$[j],J=yt(ee,this),M.touch0&&M.touch0[2]===ee.identifier?M.touch0[0]=J:M.touch1&&M.touch1[2]===ee.identifier&&(M.touch1[0]=J);if(ee=M.that.__zoom,M.touch1){var fe=M.touch0[0],Te=M.touch0[1],oe=M.touch1[0],We=M.touch1[1],$e=($e=oe[0]-fe[0])*$e+($e=oe[1]-fe[1])*$e,nt=(nt=We[0]-Te[0])*nt+(nt=We[1]-Te[1])*nt;ee=O(ee,Math.sqrt($e/nt)),J=[(fe[0]+oe[0])/2,(fe[1]+oe[1])/2],ge=[(Te[0]+We[0])/2,(Te[1]+We[1])/2]}else if(M.touch0)J=M.touch0[0],ge=M.touch0[1];else return;M.zoom("touch",t(E(ee,J,ge),M.extent,o))}}function se(C,...H){if(this.__zooming){var M=N(this,H).event(C),$=C.changedTouches,Z=$.length,j,ee;for(ko(C),h&&clearTimeout(h),h=setTimeout(function(){h=null},d),j=0;j<Z;++j)ee=$[j],M.touch0&&M.touch0[2]===ee.identifier?delete M.touch0:M.touch1&&M.touch1[2]===ee.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(ee=yt(ee,this),Math.hypot(f[0]-ee[0],f[1]-ee[1])<P)){var J=we(this).on("dblclick.zoom");J&&J.apply(this,arguments)}}}return A.wheelDelta=function(C){return arguments.length?(i=typeof C=="function"?C:br(+C),A):i},A.filter=function(C){return arguments.length?(n=typeof C=="function"?C:br(!!C),A):n},A.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:br(!!C),A):r},A.extent=function(C){return arguments.length?(e=typeof C=="function"?C:br([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),A):e},A.scaleExtent=function(C){return arguments.length?(s[0]=+C[0],s[1]=+C[1],A):[s[0],s[1]]},A.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],A):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},A.constrain=function(C){return arguments.length?(t=C,A):t},A.duration=function(C){return arguments.length?(a=+C,A):a},A.interpolate=function(C){return arguments.length?(l=C,A):l},A.on=function(){var C=c.on.apply(c,arguments);return C===c?A:C},A.clickDistance=function(C){return arguments.length?(I=(C=+C)*C,A):Math.sqrt(I)},A.tapDistance=function(C){return arguments.length?(P=+C,A):P},A}class qv{constructor(e,t){this.eventTransform=ti,this.behavior=Yv().scaleExtent([.001,1/0]).on("start",i=>{var s,o;this.isRunning=!0;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomStart)==null||o.call(s,i,r)}).on("zoom",i=>{var h,d;this.eventTransform=i.transform;const{eventTransform:{x:r,y:s,k:o},store:{transform:a,screenSize:l}}=this,c=l[0],u=l[1];if(!c||!u)return;Dx(a,c,u),mc(a,a,[r,s]),js(a,a,[o,o]),mc(a,a,[c/2,u/2]),js(a,a,[c/2,u/2]),js(a,a,[1,-1]);const f=!!i.sourceEvent;(d=(h=this.config)==null?void 0:h.onZoom)==null||d.call(h,i,f)}).on("end",i=>{var s,o;this.isRunning=!1;const r=!!i.sourceEvent;(o=(s=this.config)==null?void 0:s.onZoomEnd)==null||o.call(s,i,r)}),this.isRunning=!1,this.store=e,this.config=t}getTransform(e,t,i=.1){if(e.length===0)return this.eventTransform;const{store:{screenSize:r}}=this,s=r[0],o=r[1];let a=1/0,l=-1/0,c=1/0,u=-1/0;for(let R=0;R<e.length;R+=2){const N=e[R],U=e[R+1];N<a&&(a=N),N>l&&(l=N),U<c&&(c=U),U>u&&(u=U)}const f=[this.store.scaleX(a),this.store.scaleX(l)],h=[this.store.scaleY(c),this.store.scaleY(u)];f[0]===f[1]&&(f[0]-=.5,f[1]+=.5),h[0]===h[1]&&(h[0]+=.5,h[1]-=.5);const d=s*(1-i*2)/(f[1]-f[0]),_=o*(1-i*2)/(h[0]-h[1]),I=Mc(t??Math.min(d,_),...this.behavior.scaleExtent()),P=(f[1]+f[0])/2,A=(h[1]+h[0])/2,O=s/2-P*I,E=o/2-A*I;return ti.translate(O,E).scale(I)}getDistanceToPoint(e){const{x:t,y:i,k:r}=this.eventTransform,s=this.getTransform(e,r),o=t-s.x,a=i-s.y;return Math.sqrt(o*o+a*a)}getMiddlePointTransform(e){const{store:{screenSize:t},eventTransform:{x:i,y:r,k:s}}=this,o=t[0],a=t[1],l=(o/2-i)/s,c=(a/2-r)/s,u=this.store.scaleX(e[0]),f=this.store.scaleY(e[1]),h=(l+u)/2,d=(c+f)/2,_=1,I=o/2-h*_,P=a/2-d*_;return ti.translate(I,P).scale(_)}convertScreenToSpacePosition(e){const{eventTransform:{x:t,y:i,k:r},store:{screenSize:s}}=this,o=s[0],a=s[1],l=(e[0]-t)/r,c=(e[1]-i)/r,u=[l,a-c];return u[0]-=(o-this.store.adjustedSpaceSize)/2,u[1]-=(a-this.store.adjustedSpaceSize)/2,u}convertSpaceToScreenPosition(e){const t=this.eventTransform.applyX(this.store.scaleX(e[0])),i=this.eventTransform.applyY(this.store.scaleY(e[1]));return[t,i]}convertSpaceToScreenRadius(e){const{config:{scalePointsOnZoom:t},store:{maxPointSize:i},eventTransform:{k:r}}=this;let s=e*2;return t?s*=r:s*=Math.min(5,Math.max(1,r*.01)),Math.min(s,i)/2}}class jv{constructor(e,t){this.isActive=!1,this.behavior=zv().subject(i=>this.store.hoveredPoint&&!this.store.isSpaceKeyPressed?{x:i.x,y:i.y}:void 0).on("start",i=>{var r,s;this.store.hoveredPoint&&(this.store.draggingPointIndex=this.store.hoveredPoint.index,this.isActive=!0,(s=(r=this.config)==null?void 0:r.onDragStart)==null||s.call(r,i))}).on("drag",i=>{var r,s;(s=(r=this.config)==null?void 0:r.onDrag)==null||s.call(r,i)}).on("end",i=>{var r,s;this.isActive=!1,this.store.draggingPointIndex=void 0,(s=(r=this.config)==null?void 0:r.onDragEnd)==null||s.call(r,i)}),this.store=e,this.config=t}}class Kv{constructor(e,t,i){if(this.config=new Sy,this.graph=new uv(this.config),this.isReady=!1,this.requestAnimationFrameId=0,this.isRightClickMouse=!1,this.store=new by,this.zoomInstance=new qv(this.store,this.config),this.dragInstance=new jv(this.store,this.config),this._findHoveredItemExecutionCount=0,this._isMouseOnCanvas=!1,this._lastMouseX=0,this._lastMouseY=0,this._lastCheckedMouseX=0,this._lastCheckedMouseY=0,this._shouldForceHoverDetection=!1,this._isFirstRenderAfterInit=!0,this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this._isDestroyed=!1,t&&this.config.init(t),i)this.deviceInitPromise=i,this.shouldDestroyDevice=!1;else{const s=document.createElement("canvas");this.deviceInitPromise=this.createDevice(s),this.shouldDestroyDevice=!0}const r=this.deviceInitPromise.then(s=>{if(this._isDestroyed)return this.shouldDestroyDevice&&s.destroy(),s;this.device=s,this.isReady=!0;const o=this.validateDevice(s);i&&o.setProps({useDevicePixels:this.config.pixelRatio}),this.store.div=e;const a=o.canvas;a.parentNode!==this.store.div&&(a.parentNode&&a.parentNode.removeChild(a),this.store.div.appendChild(a)),this.addAttribution(),a.style.width="100%",a.style.height="100%",this.canvas=a;const l=this.canvas.clientWidth,c=this.canvas.clientHeight;return this.store.adjustSpaceSize(this.config.spaceSize,this.device.limits.maxTextureDimension2D),this.store.setWebGLMaxTextureSize(this.device.limits.maxTextureDimension2D),this.store.updateScreenSize(l,c),this.canvasD3Selection=we(this.canvas),this.canvasD3Selection.on("mouseenter.cosmos",u=>{this._isMouseOnCanvas=!0,this._lastMouseX=u.clientX,this._lastMouseY=u.clientY}).on("mousemove.cosmos",u=>{this._isMouseOnCanvas=!0,this._lastMouseX=u.clientX,this._lastMouseY=u.clientY}).on("mouseleave.cosmos",u=>{this._isMouseOnCanvas=!1,this.currentEvent=u,this.store.hoveredPoint!==void 0&&this.config.onPointMouseOut&&this.config.onPointMouseOut(u),this.store.hoveredLinkIndex!==void 0&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(u),this.isRightClickMouse=!1,this.store.hoveredPoint=void 0,this.store.hoveredLinkIndex=void 0,this.updateCanvasCursor()}),we(document).on("keydown.cosmos",u=>{u.code==="Space"&&(this.store.isSpaceKeyPressed=!0)}).on("keyup.cosmos",u=>{u.code==="Space"&&(this.store.isSpaceKeyPressed=!1)}),this.zoomInstance.behavior.on("start.detect",u=>{this.currentEvent=u}).on("zoom.detect",u=>{!!u.sourceEvent&&this.updateMousePosition(u.sourceEvent),this.currentEvent=u}).on("end.detect",u=>{this.currentEvent=u,this._shouldForceHoverDetection=!0}),this.dragInstance.behavior.on("start.detect",u=>{this.currentEvent=u,this.updateCanvasCursor()}).on("drag.detect",u=>{this.dragInstance.isActive&&this.updateMousePosition(u),this.currentEvent=u}).on("end.detect",u=>{this.currentEvent=u,this.updateCanvasCursor()}),this.canvasD3Selection.call(this.dragInstance.behavior).call(this.zoomInstance.behavior).on("click",this.onClick.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("contextmenu",this.onContextMenu.bind(this)),(!this.config.enableZoom||!this.config.enableDrag)&&this.updateZoomDragBehaviors(),this.setZoomLevel(this.config.initialZoomLevel??1),this.store.maxPointSize=to(s,this.config.pixelRatio),this.store.isSimulationRunning=this.config.enableSimulation,this.points=new Mv(s,this.config,this.store,this.graph),this.lines=new xv(s,this.config,this.store,this.graph,this.points),this.config.enableSimulation&&(this.forceGravity=new q0(s,this.config,this.store,this.graph,this.points),this.forceCenter=new X0(s,this.config,this.store,this.graph,this.points),this.forceManyBody=new G0(s,this.config,this.store,this.graph,this.points),this.forceLinkIncoming=new Cu(s,this.config,this.store,this.graph,this.points),this.forceLinkOutgoing=new Cu(s,this.config,this.store,this.graph,this.points),this.forceMouse=new tv(s,this.config,this.store,this.graph,this.points)),this.clusters=new sv(s,this.config,this.store,this.graph,this.points),this.store.backgroundColor=Tt(this.config.backgroundColor),this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),this.config.focusedPointIndex!==void 0&&this.store.setFocusedPoint(this.config.focusedPointIndex),this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Hi),this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),this.store.updateLinkHoveringEnabled(this.config),this.config.showFPSMonitor&&(this.fpsMonitor=new Iu(this.canvas)),this.config.randomSeed!==void 0&&this.store.addRandomSeed(this.config.randomSeed),s}).catch(s=>{throw this.device=void 0,this.isReady=!1,console.error("Device initialization failed:",s),s});this.ready=r.then(()=>{})}get progress(){return this._isDestroyed?0:this.store.simulationProgress}get isSimulationRunning(){return this._isDestroyed?!1:this.store.isSimulationRunning}get maxPointSize(){return this._isDestroyed?0:this.store.maxPointSize}setConfig(e){var i,r,s,o,a,l,c,u,f;if(this._isDestroyed||this.ensureDevice(()=>this.setConfig(e)))return;const t={...this.config};this.config.init(e),t.pointDefaultColor!==this.config.pointDefaultColor&&(this.graph.updatePointColor(),(i=this.points)==null||i.updateColor()),t.pointDefaultSize!==this.config.pointDefaultSize&&(this.graph.updatePointSize(),(r=this.points)==null||r.updateSize()),t.linkDefaultColor!==this.config.linkDefaultColor&&(this.graph.updateLinkColor(),(s=this.lines)==null||s.updateColor()),t.linkDefaultWidth!==this.config.linkDefaultWidth&&(this.graph.updateLinkWidth(),(o=this.lines)==null||o.updateWidth()),t.linkDefaultArrows!==this.config.linkDefaultArrows&&(this.graph.updateArrows(),(a=this.lines)==null||a.updateArrow()),(t.curvedLinkSegments!==this.config.curvedLinkSegments||t.curvedLinks!==this.config.curvedLinks)&&((l=this.lines)==null||l.updateCurveLineGeometry()),t.backgroundColor!==this.config.backgroundColor&&(this.store.backgroundColor=Tt(this.config.backgroundColor??Fs)),t.hoveredPointRingColor!==this.config.hoveredPointRingColor&&this.store.setHoveredPointRingColor(this.config.hoveredPointRingColor??V.hoveredPointRingColor),t.focusedPointRingColor!==this.config.focusedPointRingColor&&this.store.setFocusedPointRingColor(this.config.focusedPointRingColor??V.focusedPointRingColor),t.pointGreyoutColor!==this.config.pointGreyoutColor&&this.store.setGreyoutPointColor(this.config.pointGreyoutColor??Hi),t.hoveredLinkColor!==this.config.hoveredLinkColor&&this.store.setHoveredLinkColor(this.config.hoveredLinkColor??V.hoveredLinkColor),t.focusedPointIndex!==this.config.focusedPointIndex&&this.store.setFocusedPoint(this.config.focusedPointIndex),t.pixelRatio!==this.config.pixelRatio&&(c=this.device)!=null&&c.canvasContext&&(this.device.canvasContext.setProps({useDevicePixels:this.config.pixelRatio}),this.store.maxPointSize=to(this.device,this.config.pixelRatio)),t.spaceSize!==this.config.spaceSize&&(this.store.adjustSpaceSize(this.config.spaceSize,((u=this.device)==null?void 0:u.limits.maxTextureDimension2D)??4096),this.resizeCanvas(!0),this.update(this.store.isSimulationRunning?this.store.alpha:0)),t.showFPSMonitor!==this.config.showFPSMonitor&&(this.config.showFPSMonitor?this.fpsMonitor=new Iu(this.canvas):((f=this.fpsMonitor)==null||f.destroy(),this.fpsMonitor=void 0)),(t.enableZoom!==this.config.enableZoom||t.enableDrag!==this.config.enableDrag)&&this.updateZoomDragBehaviors(),(t.onLinkClick!==this.config.onLinkClick||t.onLinkContextMenu!==this.config.onLinkContextMenu||t.onLinkMouseOver!==this.config.onLinkMouseOver||t.onLinkMouseOut!==this.config.onLinkMouseOut)&&this.store.updateLinkHoveringEnabled(this.config)}setPointPositions(e,t){this._isDestroyed||this.ensureDevice(()=>this.setPointPositions(e,t))||(this.graph.inputPointPositions=e,this.points.shouldSkipRescale=t,this.isPointPositionsUpdateNeeded=!0,this.isLinksUpdateNeeded=!0,this.isPointColorUpdateNeeded=!0,this.isPointSizeUpdateNeeded=!0,this.isPointShapeUpdateNeeded=!0,this.isPointImageIndicesUpdateNeeded=!0,this.isPointImageSizesUpdateNeeded=!0,this.isPointClusterUpdateNeeded=!0,this.isForceManyBodyUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0,this.isForceCenterUpdateNeeded=!0)}setPointColors(e){this._isDestroyed||this.ensureDevice(()=>this.setPointColors(e))||(this.graph.inputPointColors=e,this.isPointColorUpdateNeeded=!0)}getPointColors(){return this._isDestroyed?new Float32Array:this.graph.pointColors??new Float32Array}setPointSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointSizes(e))||(this.graph.inputPointSizes=e,this.isPointSizeUpdateNeeded=!0)}setPointShapes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointShapes(e))||(this.graph.inputPointShapes=e,this.isPointShapeUpdateNeeded=!0)}setImageData(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setImageData(e))||(this.graph.inputImageData=e,(t=this.points)==null||t.createAtlas())}setPointImageIndices(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageIndices(e))||(this.graph.inputPointImageIndices=e,this.isPointImageIndicesUpdateNeeded=!0)}setPointImageSizes(e){this._isDestroyed||this.ensureDevice(()=>this.setPointImageSizes(e))||(this.graph.inputPointImageSizes=e,this.isPointImageSizesUpdateNeeded=!0)}getPointSizes(){return this._isDestroyed?new Float32Array:this.graph.pointSizes??new Float32Array}setLinks(e){this._isDestroyed||this.ensureDevice(()=>this.setLinks(e))||(this.graph.inputLinks=e,this.isLinksUpdateNeeded=!0,this.isLinkColorUpdateNeeded=!0,this.isLinkWidthUpdateNeeded=!0,this.isLinkArrowUpdateNeeded=!0,this.isForceLinkUpdateNeeded=!0)}setLinkColors(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkColors(e))||(this.graph.inputLinkColors=e,this.isLinkColorUpdateNeeded=!0)}getLinkColors(){return this._isDestroyed?new Float32Array:this.graph.linkColors??new Float32Array}setLinkWidths(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkWidths(e))||(this.graph.inputLinkWidths=e,this.isLinkWidthUpdateNeeded=!0)}getLinkWidths(){return this._isDestroyed?new Float32Array:this.graph.linkWidths??new Float32Array}setLinkArrows(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkArrows(e))||(this.graph.linkArrowsBoolean=e,this.isLinkArrowUpdateNeeded=!0)}setLinkStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setLinkStrength(e))||(this.graph.inputLinkStrength=e,this.isForceLinkUpdateNeeded=!0)}setPointClusters(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusters(e))||(this.graph.inputPointClusters=e,this.isPointClusterUpdateNeeded=!0)}setClusterPositions(e){this._isDestroyed||this.ensureDevice(()=>this.setClusterPositions(e))||(this.graph.inputClusterPositions=e,this.isPointClusterUpdateNeeded=!0)}setPointClusterStrength(e){this._isDestroyed||this.ensureDevice(()=>this.setPointClusterStrength(e))||(this.graph.inputClusterStrength=e,this.isPointClusterUpdateNeeded=!0)}setPinnedPoints(e){var t;this._isDestroyed||this.ensureDevice(()=>this.setPinnedPoints(e))||(this.graph.inputPinnedPoints=e&&e.length>0?e:void 0,(t=this.points)==null||t.updatePinnedStatus())}render(e){if(this._isDestroyed||this.ensureDevice(()=>this.render(e)))return;this.graph.update();const{fitViewOnInit:t,fitViewDelay:i,fitViewPadding:r,fitViewDuration:s,fitViewByPointsInRect:o,fitViewByPointIndices:a,initialZoomLevel:l}=this.config;if(!this.graph.pointsNumber&&!this.graph.linksNumber){this.stopFrames(),we(this.canvas).style("cursor",null),this.device&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit());return}this._isFirstRenderAfterInit&&t&&l===void 0&&(this._fitViewOnInitTimeoutID=window.setTimeout(()=>{a?this.fitViewByPointIndices(a,s,r):o?this.setZoomTransformByPointPositions(new Float32Array(this.flatten(o)),s,void 0,r):this.fitView(s,r)},i)),this.update(e),this.startFrames(),this._isFirstRenderAfterInit=!1}zoomToPointByIndex(e,t=700,i=Ol,r=!0){if(this._isDestroyed||this.ensureDevice(()=>this.zoomToPointByIndex(e,t,i,r))||!this.device||!this.points||!this.canvasD3Selection)return;const{store:{screenSize:s}}=this,o=Me(this.device,this.points.currentPositionFbo);if(e===void 0)return;const a=o[e*4+0],l=o[e*4+1];if(a===void 0||l===void 0)return;const c=this.zoomInstance.getDistanceToPoint([a,l]),u=r?i:Math.max(this.getZoomLevel(),i);if(c<Math.min(s[0],s[1]))this.setZoomTransformByPointPositions(new Float32Array([a,l]),t,u);else{const f=this.zoomInstance.getTransform([a,l],u),h=this.zoomInstance.getMiddlePointTransform([a,l]);this.canvasD3Selection.transition().ease(vp).duration(t/2).call(this.zoomInstance.behavior.transform,h).transition().ease(bp).duration(t/2).call(this.zoomInstance.behavior.transform,f)}}zoom(e,t=0){this._isDestroyed||this.setZoomLevel(e,t)}setZoomLevel(e,t=0){this._isDestroyed||this.ensureDevice(()=>this.setZoomLevel(e,t))||this.canvasD3Selection&&(t===0?this.canvasD3Selection.call(this.zoomInstance.behavior.scaleTo,e):this.canvasD3Selection.transition().duration(t).call(this.zoomInstance.behavior.scaleTo,e))}getZoomLevel(){return this._isDestroyed?0:this.zoomInstance.eventTransform.k}getPointPositions(){if(this._isDestroyed||!this.device||!this.points)return[];if(this.graph.pointsNumber===void 0)return[];const e=[],t=Me(this.device,this.points.currentPositionFbo);e.length=this.graph.pointsNumber*2;for(let i=0;i<this.graph.pointsNumber;i+=1){const r=t[i*4+0],s=t[i*4+1];r!==void 0&&s!==void 0&&(e[i*2]=r,e[i*2+1]=s)}return e}getClusterPositions(){if(this._isDestroyed||!this.device||!this.clusters)return[];if(this.graph.pointClusters===void 0||this.clusters.clusterCount===void 0)return[];this.clusters.calculateCentermass();const e=[],t=Me(this.device,this.clusters.centermassFbo);e.length=this.clusters.clusterCount*2;for(let i=0;i<e.length/2;i+=1){const r=t[i*4+0],s=t[i*4+1],o=t[i*4+2];r!==void 0&&s!==void 0&&o!==void 0&&(e[i*2]=r/o,e[i*2+1]=s/o)}return e}fitView(e=250,t=.1){this._isDestroyed||this.ensureDevice(()=>this.fitView(e,t))||this.setZoomTransformByPointPositions(new Float32Array(this.getPointPositions()),e,void 0,t)}fitViewByPointIndices(e,t=250,i=.1){if(this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointIndices(e,t,i)))return;const r=this.getPointPositions(),s=new Float32Array(e.length*2);for(const[o,a]of e.entries())s[o*2]=r[a*2],s[o*2+1]=r[a*2+1];this.setZoomTransformByPointPositions(s,t,void 0,i)}fitViewByPointPositions(e,t=250,i=.1){this._isDestroyed||this.ensureDevice(()=>this.fitViewByPointPositions(e,t,i))||this.setZoomTransformByPointPositions(new Float32Array(e),t,void 0,i)}setZoomTransformByPointPositions(e,t=250,i,r=.1){var o;if(this._isDestroyed||this.ensureDevice(()=>this.setZoomTransformByPointPositions(e,t,i,r)))return;this.resizeCanvas();const s=this.zoomInstance.getTransform(e,i,r);(o=this.canvasD3Selection)==null||o.transition().ease(Sp).duration(t).call(this.zoomInstance.behavior.transform,s)}getPointsInRect(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;const t=this.store.screenSize[1];return this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection(),Me(this.device,this.points.selectedFbo).map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}getPointsInPolygon(e){if(this._isDestroyed||!this.device||!this.points)return new Float32Array;if(e.length<3)return new Float32Array;const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);return this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection(),Me(this.device,this.points.selectedFbo).map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}selectPointsInRect(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInRect(e))&&!(!this.device||!this.points)){if(e){const t=this.store.screenSize[1];this.store.selectedArea=[[e[0][0],t-e[1][1]],[e[1][0],t-e[0][1]]],this.points.findPointsOnAreaSelection();const i=Me(this.device,this.points.selectedFbo);this.store.selectedIndices=i.map((r,s)=>s%4===0&&r!==0?s/4:-1).filter(r=>r!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointsInPolygon(e){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointsInPolygon(e))&&!(!this.device||!this.points)){if(e){if(e.length<3){console.warn("Polygon path requires at least 3 points to form a polygon.");return}const t=this.store.screenSize[1],i=e.map(([s,o])=>[s,t-o]);this.points.updatePolygonPath(i),this.points.findPointsOnPolygonSelection();const r=Me(this.device,this.points.selectedFbo);this.store.selectedIndices=r.map((s,o)=>o%4===0&&s!==0?o/4:-1).filter(s=>s!==-1)}else this.store.selectedIndices=null;this.points.updateGreyoutStatus()}}selectPointByIndex(e,t=!1){if(!this._isDestroyed&&!this.ensureDevice(()=>this.selectPointByIndex(e,t)))if(t){const i=this.graph.getAdjacentIndices(e)??[];this.selectPointsByIndices([e,...i])}else this.selectPointsByIndices([e])}selectPointsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.selectPointsByIndices(e))||this.points&&(e?e.length===0?this.store.selectedIndices=new Float32Array:this.store.selectedIndices=new Float32Array(e.filter(t=>t!==void 0)):this.store.selectedIndices=null,this.points.updateGreyoutStatus())}unselectPoints(){this._isDestroyed||this.ensureDevice(()=>this.unselectPoints())||this.points&&(this.store.selectedIndices=null,this.points.updateGreyoutStatus())}getSelectedIndices(){if(this._isDestroyed)return null;const{selectedIndices:e}=this.store;return e?Array.from(e):null}getAdjacentIndices(e){if(!this._isDestroyed)return this.graph.getAdjacentIndices(e)}spaceToScreenPosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertSpaceToScreenPosition(e)}screenToSpacePosition(e){return this._isDestroyed?[0,0]:this.zoomInstance.convertScreenToSpacePosition(e)}spaceToScreenRadius(e){return this._isDestroyed?0:this.zoomInstance.convertSpaceToScreenRadius(e)}getPointRadiusByIndex(e){var t;if(!this._isDestroyed)return(t=this.graph.pointSizes)==null?void 0:t[e]}trackPointPositionsByIndices(e){this._isDestroyed||this.ensureDevice(()=>this.trackPointPositionsByIndices(e))||this.points&&this.points.trackPointsByIndices(e)}getTrackedPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getTrackedPositionsMap()}getTrackedPointPositionsArray(){return this._isDestroyed||!this.points?[]:this.points.getTrackedPositionsArray()}getSampledPointPositionsMap(){return this._isDestroyed||!this.points?new Map:this.points.getSampledPointPositionsMap()}getSampledPoints(){return this._isDestroyed||!this.points?{indices:[],positions:[]}:this.points.getSampledPoints()}getSampledLinkPositionsMap(){return this._isDestroyed||!this.lines?new Map:this.lines.getSampledLinkPositionsMap()}getSampledLinks(){return this._isDestroyed||!this.lines?{indices:[],positions:[],angles:[]}:this.lines.getSampledLinks()}getScaleX(){if(!(this._isDestroyed||!this.points))return this.points.scaleX}getScaleY(){if(!(this._isDestroyed||!this.points))return this.points.scaleY}start(e=1){var t,i;this._isDestroyed||this.ensureDevice(()=>this.start(e))||this.graph.pointsNumber&&(this.store.isSimulationRunning=!0,this.store.simulationProgress=0,this.store.alpha=e,(i=(t=this.config).onSimulationStart)==null||i.call(t))}stop(){var e,t;this._isDestroyed||(this.store.isSimulationRunning=!1,this.store.simulationProgress=0,this.store.alpha=0,(t=(e=this.config).onSimulationEnd)==null||t.call(e))}pause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.pause())||(this.store.isSimulationRunning=!1,(t=(e=this.config).onSimulationPause)==null||t.call(e))}unpause(){var e,t;this._isDestroyed||this.ensureDevice(()=>this.unpause())||(this.store.isSimulationRunning=!0,(t=(e=this.config).onSimulationUnpause)==null||t.call(e))}step(){this._isDestroyed||this.ensureDevice(()=>this.step())||this.config.enableSimulation&&this.store.pointsTextureSize&&this.runSimulationStep(!0)}destroy(){var e,t,i,r,s,o,a,l,c,u,f,h,d;this._isDestroyed||(this._isDestroyed=!0,this.isReady=!1,window.clearTimeout(this._fitViewOnInitTimeoutID),this.stopFrames(),this.canvasD3Selection&&this.canvasD3Selection.on("mouseenter.cosmos",null).on("mousemove.cosmos",null).on("mouseleave.cosmos",null).on("click",null).on("mousemove",null).on("contextmenu",null).on(".drag",null).on(".zoom",null),we(document).on("keydown.cosmos",null).on("keyup.cosmos",null),(e=this.zoomInstance)!=null&&e.behavior&&this.zoomInstance.behavior.on("start.detect",null).on("zoom.detect",null).on("end.detect",null),(t=this.dragInstance)!=null&&t.behavior&&this.dragInstance.behavior.on("start.detect",null).on("drag.detect",null).on("end.detect",null),(i=this.fpsMonitor)==null||i.destroy(),(r=this.points)==null||r.destroy(),(s=this.lines)==null||s.destroy(),(o=this.clusters)==null||o.destroy(),(a=this.forceGravity)==null||a.destroy(),(l=this.forceCenter)==null||l.destroy(),(c=this.forceManyBody)==null||c.destroy(),(u=this.forceLinkIncoming)==null||u.destroy(),(f=this.forceLinkOutgoing)==null||f.destroy(),(h=this.forceMouse)==null||h.destroy(),this.device&&this.shouldDestroyDevice&&(this.device.beginRenderPass({clearColor:this.store.backgroundColor,clearDepth:1,clearStencil:0}).end(),this.device.submit(),this.device.destroy()),this.shouldDestroyDevice&&this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.attributionDivElement&&this.attributionDivElement.parentNode&&this.attributionDivElement.parentNode.removeChild(this.attributionDivElement),(d=document.getElementById("gl-bench-style"))==null||d.remove(),this.canvasD3Selection=void 0,this.attributionDivElement=void 0)}create(){var e,t,i,r,s;this._isDestroyed||this.ensureDevice(()=>this.create())||this.points&&this.lines&&(this.isPointPositionsUpdateNeeded&&this.points.updatePositions(),this.isPointColorUpdateNeeded&&this.points.updateColor(),this.isPointSizeUpdateNeeded&&this.points.updateSize(),this.isPointShapeUpdateNeeded&&this.points.updateShape(),this.isPointImageIndicesUpdateNeeded&&this.points.updateImageIndices(),this.isPointImageSizesUpdateNeeded&&this.points.updateImageSizes(),this.isLinksUpdateNeeded&&this.lines.updatePointsBuffer(),this.isLinkColorUpdateNeeded&&this.lines.updateColor(),this.isLinkWidthUpdateNeeded&&this.lines.updateWidth(),this.isLinkArrowUpdateNeeded&&this.lines.updateArrow(),this.isForceManyBodyUpdateNeeded&&((e=this.forceManyBody)==null||e.create()),this.isForceLinkUpdateNeeded&&((t=this.forceLinkIncoming)==null||t.create(Po.INCOMING),(i=this.forceLinkOutgoing)==null||i.create(Po.OUTGOING)),this.isForceCenterUpdateNeeded&&((r=this.forceCenter)==null||r.create()),this.isPointClusterUpdateNeeded&&((s=this.clusters)==null||s.create()),this.isPointPositionsUpdateNeeded=!1,this.isPointColorUpdateNeeded=!1,this.isPointSizeUpdateNeeded=!1,this.isPointShapeUpdateNeeded=!1,this.isPointImageIndicesUpdateNeeded=!1,this.isPointImageSizesUpdateNeeded=!1,this.isLinksUpdateNeeded=!1,this.isLinkColorUpdateNeeded=!1,this.isLinkWidthUpdateNeeded=!1,this.isLinkArrowUpdateNeeded=!1,this.isPointClusterUpdateNeeded=!1,this.isForceManyBodyUpdateNeeded=!1,this.isForceLinkUpdateNeeded=!1,this.isForceCenterUpdateNeeded=!1)}flatten(e){return e.flat()}pair(e){const t=new Array(e.length/2);for(let i=0;i<e.length/2;i++)t[i]=[e[i*2],e[i*2+1]];return t}ensureDevice(e){return this.isReady?!1:(this.ready.then(()=>{this._isDestroyed||e()}).catch(t=>{console.error("Device initialization failed",t)}),!0)}validateDevice(e){const t=e.canvasContext;if(t===null||t.type==="offscreen-canvas")throw new Error("Device must have an HTMLCanvasElement canvas context. OffscreenCanvas and compute-only devices are not supported.");return t}async createDevice(e){return await om.createDevice({type:"webgl",adapters:[sg],createCanvasContext:{canvas:e,useDevicePixels:this.config.pixelRatio,autoResize:!0,width:void 0,height:void 0}})}update(e=this.store.alpha){const{graph:t}=this;this.store.pointsTextureSize=Math.ceil(Math.sqrt(t.pointsNumber??0)),this.store.linksTextureSize=Math.ceil(Math.sqrt((t.linksNumber??0)*2)),this.create(),this.initPrograms(),this.store.hoveredPoint=void 0,this.store.alpha=e}runSimulationStep(e=!1){var a,l,c,u,f,h,d,_,I,P,A,O,E,x,R,N,U,W,q;const{config:{simulationGravity:t,simulationCenter:i,enableSimulation:r},store:{isSimulationRunning:s}}=this;if(!r)return;this.isRightClickMouse&&this.config.enableRightClickRepulsion&&((a=this.forceMouse)==null||a.run(),(l=this.points)==null||l.updatePosition()),(e||s&&!(this.zoomInstance.isRunning&&!this.config.enableSimulationDuringZoom))&&(t&&((c=this.forceGravity)==null||c.run(),(u=this.points)==null||u.updatePosition()),i&&((f=this.forceCenter)==null||f.run(),(h=this.points)==null||h.updatePosition()),(d=this.forceManyBody)==null||d.run(),(_=this.points)==null||_.updatePosition(),this.store.linksTextureSize&&((I=this.forceLinkIncoming)==null||I.run(),(P=this.points)==null||P.updatePosition(),(A=this.forceLinkOutgoing)==null||A.run(),(O=this.points)==null||O.updatePosition()),(this.graph.pointClusters||this.graph.clusterPositions)&&((E=this.clusters)==null||E.run(),(x=this.points)==null||x.updatePosition()),this.store.alpha+=this.store.addAlpha(this.config.simulationDecay??V.simulation.decay),this.isRightClickMouse&&this.config.enableRightClickRepulsion&&(this.store.alpha=Math.max(this.store.alpha,.1)),this.store.simulationProgress=Math.sqrt(Math.min(1,Js/this.store.alpha)),(W=(U=this.config).onSimulationTick)==null||W.call(U,this.store.alpha,(R=this.store.hoveredPoint)==null?void 0:R.index,(N=this.store.hoveredPoint)==null?void 0:N.position)),(q=this.points)==null||q.trackPoints()}initPrograms(){var e,t,i,r,s,o;this._isDestroyed||!this.points||!this.lines||!this.clusters||(this.points.initPrograms(),this.lines.initPrograms(),(e=this.forceGravity)==null||e.initPrograms(),(t=this.forceManyBody)==null||t.initPrograms(),(i=this.forceCenter)==null||i.initPrograms(),(r=this.forceLinkIncoming)==null||r.initPrograms(),(s=this.forceLinkOutgoing)==null||s.initPrograms(),(o=this.forceMouse)==null||o.initPrograms(),this.clusters.initPrograms())}frame(){if(this._isDestroyed)return;const{store:{alpha:e,isSimulationRunning:t}}=this;e<Js&&t&&this.end(),this.requestAnimationFrameId=window.requestAnimationFrame(i=>{this.renderFrame(i),this._isDestroyed||this.frame()})}renderFrame(e){var t,i,r,s,o,a,l;if(!this._isDestroyed&&this.store.pointsTextureSize){if((t=this.fpsMonitor)==null||t.begin(),this.resizeCanvas(),this.dragInstance.isActive||this.findHoveredItem(),this.runSimulationStep(!1),this.device){const c=this.store.backgroundColor??[0,0,0,1],u=this.device.beginRenderPass({clearColor:c,clearDepth:1,clearStencil:0}),{config:{renderLinks:f}}=this;f!==!1&&!!this.store.linksTextureSize&&!!this.graph.linksNumber&&this.graph.linksNumber>0&&((i=this.lines)==null||i.draw(u)),(r=this.points)==null||r.draw(u),this.dragInstance.isActive&&((s=this.points)==null||s.drag(),(o=this.points)==null||o.drag(),(a=this.points)==null||a.trackPoints()),u.end(),this.device.submit()}(l=this.fpsMonitor)==null||l.end(e??performance.now()),this.currentEvent=void 0}}stopFrames(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=0)}startFrames(){this._isDestroyed||(this.stopFrames(),this.frame())}end(){var e,t;this.store.isSimulationRunning=!1,this.store.simulationProgress=1,(t=(e=this.config).onSimulationEnd)==null||t.call(e),this._shouldForceHoverDetection=!0}onClick(e){var t,i,r,s,o,a,l,c,u,f;(s=(r=this.config).onClick)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointClick)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkClick)==null||c.call(l,this.store.hoveredLinkIndex,e):(f=(u=this.config).onBackgroundClick)==null||f.call(u,e)}updateMousePosition(e){if(!e)return;const t=e.offsetX??e.x,i=e.offsetY??e.y;t===void 0||i===void 0||(this.store.mousePosition=this.zoomInstance.convertScreenToSpacePosition([t,i]),this.store.screenMousePosition=[t,this.store.screenSize[1]-i])}onMouseMove(e){var t,i,r,s;this.currentEvent=e,this.updateMousePosition(e),this.isRightClickMouse=e.which===3,(s=(r=this.config).onMouseMove)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,this.currentEvent)}onContextMenu(e){var t,i,r,s,o,a,l,c,u,f;e.preventDefault(),(s=(r=this.config).onContextMenu)==null||s.call(r,(t=this.store.hoveredPoint)==null?void 0:t.index,(i=this.store.hoveredPoint)==null?void 0:i.position,e),this.store.hoveredPoint?(a=(o=this.config).onPointContextMenu)==null||a.call(o,this.store.hoveredPoint.index,this.store.hoveredPoint.position,e):this.store.hoveredLinkIndex!==void 0?(c=(l=this.config).onLinkContextMenu)==null||c.call(l,this.store.hoveredLinkIndex,e):(f=(u=this.config).onBackgroundContextMenu)==null||f.call(u,e)}resizeCanvas(e=!1){var o,a,l,c;if(this._isDestroyed)return;const t=this.canvas.clientWidth,i=this.canvas.clientHeight,[r,s]=this.store.screenSize;if(e||r!==t||s!==i){const{k:u}=this.zoomInstance.eventTransform,f=this.zoomInstance.convertScreenToSpacePosition([r/2,s/2]);this.store.updateScreenSize(t,i),(o=this.canvasD3Selection)==null||o.call(this.zoomInstance.behavior.transform,this.zoomInstance.getTransform(f,u)),(a=this.points)==null||a.updateSampledPointsGrid(),(l=this.lines)==null||l.updateSampledLinksGrid(),this.store.isLinkHoveringEnabled&&((c=this.lines)==null||c.updateLinkIndexFbo())}}updateZoomDragBehaviors(){var e,t,i,r;this.config.enableDrag?(e=this.canvasD3Selection)==null||e.call(this.dragInstance.behavior):(t=this.canvasD3Selection)==null||t.call(this.dragInstance.behavior).on(".drag",null),this.config.enableZoom?(i=this.canvasD3Selection)==null||i.call(this.zoomInstance.behavior):(r=this.canvasD3Selection)==null||r.call(this.zoomInstance.behavior).on("wheel.zoom",null)}findHoveredItem(){if(this._isDestroyed||!this._isMouseOnCanvas)return;if(this._findHoveredItemExecutionCount<vy){this._findHoveredItemExecutionCount+=1;return}const e=Math.abs(this._lastMouseX-this._lastCheckedMouseX),t=Math.abs(this._lastMouseY-this._lastCheckedMouseY);if(!(!(e>Pc||t>Pc)&&!this._shouldForceHoverDetection)){if(this._lastCheckedMouseX=this._lastMouseX,this._lastCheckedMouseY=this._lastMouseY,this._shouldForceHoverDetection=!1,this._findHoveredItemExecutionCount=0,this.findHoveredPoint(),this.graph.linksNumber&&this.store.isLinkHoveringEnabled)this.findHoveredLine();else if(this.store.hoveredLinkIndex!==void 0){const r=this.store.hoveredLinkIndex!==void 0;this.store.hoveredLinkIndex=void 0,r&&this.config.onLinkMouseOut&&this.config.onLinkMouseOut(this.currentEvent)}this.updateCanvasCursor()}}findHoveredPoint(){var l,c,u,f,h;if(this._isDestroyed||!this.device||!this.points)return;this.points.findHoveredPoint();let e=!1,t=!1;const i=Me(this.device,this.points.hoveredFbo,0,0,2,2),r=i[0],s=i[1],o=i[2],a=i[3];s>0?((this.store.hoveredPoint===void 0||this.store.hoveredPoint.index!==r)&&(e=!0),this.store.hoveredPoint={index:r,position:[o,a]}):(this.store.hoveredPoint&&(t=!0),this.store.hoveredPoint=void 0),e&&this.store.hoveredPoint&&((u=(c=this.config).onPointMouseOver)==null||u.call(c,this.store.hoveredPoint.index,this.store.hoveredPoint.position,this.currentEvent,((l=this.store.selectedIndices)==null?void 0:l.includes(this.store.hoveredPoint.index))??!1)),t&&((h=(f=this.config).onPointMouseOut)==null||h.call(f,this.currentEvent))}findHoveredLine(){var s,o,a,l,c,u;if(this._isDestroyed||!this.lines)return;if(this.store.hoveredPoint){this.store.hoveredLinkIndex!==void 0&&(this.store.hoveredLinkIndex=void 0,(o=(s=this.config).onLinkMouseOut)==null||o.call(s,this.currentEvent));return}this.lines.findHoveredLine();let e=!1,t=!1;if(!this.device)return;const r=Me(this.device,this.lines.hoveredLineIndexFbo)[0];r>=0?(this.store.hoveredLinkIndex!==r&&(e=!0),this.store.hoveredLinkIndex=r):(this.store.hoveredLinkIndex!==void 0&&(t=!0),this.store.hoveredLinkIndex=void 0),e&&this.store.hoveredLinkIndex!==void 0&&((l=(a=this.config).onLinkMouseOver)==null||l.call(a,this.store.hoveredLinkIndex)),t&&((u=(c=this.config).onLinkMouseOut)==null||u.call(c,this.currentEvent))}updateCanvasCursor(){const{hoveredPointCursor:e,hoveredLinkCursor:t}=this.config;this.dragInstance.isActive?we(this.canvas).style("cursor","grabbing"):this.store.hoveredPoint?!this.config.enableDrag||this.store.isSpaceKeyPressed?we(this.canvas).style("cursor",e):we(this.canvas).style("cursor","grab"):this.store.isLinkHoveringEnabled&&this.store.hoveredLinkIndex!==void 0?we(this.canvas).style("cursor",t):we(this.canvas).style("cursor",null)}addAttribution(){var e;this.config.attribution&&(this.attributionDivElement=document.createElement("div"),this.attributionDivElement.style.cssText=`
|
|
2289
2382
|
user-select: none;
|
|
2290
2383
|
position: absolute;
|
|
2291
2384
|
bottom: 0;
|
|
@@ -2294,5 +2387,5 @@ void main() {
|
|
|
2294
2387
|
margin: 0 0.6rem 0.6rem 0;
|
|
2295
2388
|
font-size: 0.7rem;
|
|
2296
2389
|
font-family: inherit;
|
|
2297
|
-
`,this.attributionDivElement.innerHTML=
|
|
2390
|
+
`,this.attributionDivElement.innerHTML=Fc(this.config.attribution,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br","img"],ALLOWED_ATTR:["href","target","class","id","style","src","alt","title"]}),(e=this.store.div)==null||e.appendChild(this.attributionDivElement))}}te.Graph=Kv,te.PointShape=Pu,te.clamp=Mc,te.defaultBackgroundColor=Fs,te.defaultConfigValues=V,te.defaultGreyoutLinkOpacity=kl,te.defaultGreyoutPointColor=Hi,te.defaultGreyoutPointOpacity=Il,te.defaultLinkColor=Rl,te.defaultLinkOpacity=Dl,te.defaultLinkWidth=Ml,te.defaultPointColor=Cl,te.defaultPointOpacity=Pl,te.defaultPointSize=El,te.defaultScaleToZoom=Ol,te.focusedPointRingOpacity=Nl,te.getMaxPointSize=to,te.getRgbaColor=Tt,te.hoveredPointRingOpacity=Fl,te.isAClassInstance=kc,te.isArray=Gs,te.isFunction=Ec,te.isNumber=Ke,te.isObject=Rc,te.isPlainObject=eo,te.readPixels=Me,te.rgbToBrightness=Dc,te.sanitizeHtml=Fc,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
|
|
2298
2391
|
//# sourceMappingURL=index.min.js.map
|