diff --git a/maplibre/srcjs/ipywidget.js b/maplibre/srcjs/ipywidget.js index e24489ab..e8ec6c0e 100644 --- a/maplibre/srcjs/ipywidget.js +++ b/maplibre/srcjs/ipywidget.js @@ -1,15 +1,21 @@ -var Sy=Object.create;var Cu=Object.defineProperty;var Ay=Object.getOwnPropertyDescriptor;var wy=Object.getOwnPropertyNames;var Py=Object.getPrototypeOf,Cy=Object.prototype.hasOwnProperty;var Ru=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ui=(t,e)=>{for(var r in e)Cu(t,r,{get:e[r],enumerable:!0})},Ry=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wy(e))!Cy.call(t,s)&&s!==r&&Cu(t,s,{get:()=>e[s],enumerable:!(i=Ay(e,s))||i.enumerable});return t};var Ya=(t,e,r)=>(r=t!=null?Sy(Py(t)):{},Ry(e||!t||!t.__esModule?Cu(r,"default",{value:t,enumerable:!0}):r,t));var Z0=Ru((xW,Pl)=>{(function(t,e,r,i){"use strict";var s=["","webkit","Moz","MS","ms","o"],n=e.createElement("div"),o="function",a=Math.round,c=Math.abs,l=Date.now;function u(m,x,E){return setTimeout(v(m,E),x)}function f(m,x,E){return Array.isArray(m)?(h(m,E[x],E),!0):!1}function h(m,x,E){var C;if(m)if(m.forEach)m.forEach(x,E);else if(m.length!==i)for(C=0;C\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",re=t.console&&(t.console.warn||t.console.log);return re&&re.call(t.console,C,H),m.apply(this,arguments)}}var p;typeof Object.assign!="function"?p=function(x){if(x===i||x===null)throw new TypeError("Cannot convert undefined or null to object");for(var E=Object(x),C=1;C-1}function D(m){return m.trim().split(/\s+/g)}function L(m,x,E){if(m.indexOf&&!E)return m.indexOf(x);for(var C=0;CHe[x]}):C=C.sort()),C}function $(m,x){for(var E,C,k=x[0].toUpperCase()+x.slice(1),H=0;H1&&!E.firstMultiple?E.firstMultiple=K(x):k===1&&(E.firstMultiple=!1);var H=E.firstInput,re=E.firstMultiple,Re=re?re.center:H.center,Ne=x.center=G(C);x.timeStamp=l(),x.deltaTime=x.timeStamp-H.timeStamp,x.angle=ut(Re,Ne),x.distance=We(Re,Ne),Ba(E,x),x.offsetDirection=we(x.deltaX,x.deltaY);var He=Ee(x.deltaTime,x.deltaX,x.deltaY);x.overallVelocityX=He.x,x.overallVelocityY=He.y,x.overallVelocity=c(He.x)>c(He.y)?He.x:He.y,x.scale=re?Or(re.pointers,C):1,x.rotation=re?ci(re.pointers,C):0,x.maxPointers=E.prevInput?x.pointers.length>E.prevInput.maxPointers?x.pointers.length:E.prevInput.maxPointers:x.pointers.length,V(E,x);var jt=m.element;F(x.srcEvent.target,jt)&&(jt=x.srcEvent.target),x.target=jt}function Ba(m,x){var E=x.center,C=m.offsetDelta||{},k=m.prevDelta||{},H=m.prevInput||{};(x.eventType===xe||H.eventType===J)&&(k=m.prevDelta={x:H.deltaX||0,y:H.deltaY||0},C=m.offsetDelta={x:E.x,y:E.y}),x.deltaX=k.x+(E.x-C.x),x.deltaY=k.y+(E.y-C.y)}function V(m,x){var E=m.lastInterval||x,C=x.timeStamp-E.timeStamp,k,H,re,Re;if(x.eventType!=Te&&(C>at||E.velocity===i)){var Ne=x.deltaX-E.deltaX,He=x.deltaY-E.deltaY,jt=Ee(C,Ne,He);H=jt.x,re=jt.y,k=c(jt.x)>c(jt.y)?jt.x:jt.y,Re=we(Ne,He),m.lastInterval=x}else k=E.velocity,H=E.velocityX,re=E.velocityY,Re=E.direction;x.velocity=k,x.velocityX=H,x.velocityY=re,x.direction=Re}function K(m){for(var x=[],E=0;E=c(x)?m<0?ct:Ir:x<0?ai:Wt}function We(m,x,E){E||(E=pn);var C=x[E[0]]-m[E[0]],k=x[E[1]]-m[E[1]];return Math.sqrt(C*C+k*k)}function ut(m,x,E){E||(E=pn);var C=x[E[0]]-m[E[0]],k=x[E[1]]-m[E[1]];return Math.atan2(k,C)*180/Math.PI}function ci(m,x){return ut(x[1],x[0],ts)+ut(m[1],m[0],ts)}function Or(m,x){return We(x[0],x[1],ts)/We(m[0],m[1],ts)}var Ua={mousedown:xe,mousemove:me,mouseup:J},ny="mousedown",oy="mousemove mouseup";function za(){this.evEl=ny,this.evWin=oy,this.pressed=!1,Ke.apply(this,arguments)}y(za,Ke,{handler:function(x){var E=Ua[x.type];E&xe&&x.button===0&&(this.pressed=!0),E&me&&x.which!==1&&(E=J),this.pressed&&(E&J&&(this.pressed=!1),this.callback(this.manager,E,{pointers:[x],changedPointers:[x],pointerType:j,srcEvent:x}))}});var ay={pointerdown:xe,pointermove:me,pointerup:J,pointercancel:Te,pointerout:Te},cy={2:he,3:_u,4:j,5:B},Ip="pointerdown",Op="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(Ip="MSPointerDown",Op="MSPointerMove MSPointerUp MSPointerCancel");function yu(){this.evEl=Ip,this.evWin=Op,Ke.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}y(yu,Ke,{handler:function(x){var E=this.store,C=!1,k=x.type.toLowerCase().replace("ms",""),H=ay[k],re=cy[x.pointerType]||x.pointerType,Re=re==he,Ne=L(E,x.pointerId,"pointerId");H&xe&&(x.button===0||Re)?Ne<0&&(E.push(x),Ne=E.length-1):H&(J|Te)&&(C=!0),!(Ne<0)&&(E[Ne]=x,this.callback(this.manager,H,{pointers:E,changedPointers:[x],pointerType:re,srcEvent:x}),C&&E.splice(Ne,1))}});var ly={touchstart:xe,touchmove:me,touchend:J,touchcancel:Te},uy="touchstart",fy="touchstart touchmove touchend touchcancel";function Np(){this.evTarget=uy,this.evWin=fy,this.started=!1,Ke.apply(this,arguments)}y(Np,Ke,{handler:function(x){var E=ly[x.type];if(E===xe&&(this.started=!0),!!this.started){var C=hy.call(this,x,E);E&(J|Te)&&C[0].length-C[1].length===0&&(this.started=!1),this.callback(this.manager,E,{pointers:C[0],changedPointers:C[1],pointerType:he,srcEvent:x})}}});function hy(m,x){var E=Y(m.touches),C=Y(m.changedTouches);return x&(J|Te)&&(E=X(E.concat(C),"identifier",!0)),[E,C]}var dy={touchstart:xe,touchmove:me,touchend:J,touchcancel:Te},py="touchstart touchmove touchend touchcancel";function Va(){this.evTarget=py,this.targetIds={},Ke.apply(this,arguments)}y(Va,Ke,{handler:function(x){var E=dy[x.type],C=gy.call(this,x,E);C&&this.callback(this.manager,E,{pointers:C[0],changedPointers:C[1],pointerType:he,srcEvent:x})}});function gy(m,x){var E=Y(m.touches),C=this.targetIds;if(x&(xe|me)&&E.length===1)return C[E[0].identifier]=!0,[E,E];var k,H,re=Y(m.changedTouches),Re=[],Ne=this.target;if(H=E.filter(function(He){return F(He.target,Ne)}),x===xe)for(k=0;k-1&&C.splice(H,1)};setTimeout(k,my)}}function xy(m){for(var x=m.srcEvent.clientX,E=m.srcEvent.clientY,C=0;C-1&&this.requireFail.splice(x,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(m){return!!this.simultaneous[m.id]},emit:function(m){var x=this,E=this.state;function C(k){x.manager.emit(k,m)}E=Nr&&C(x.options.event+zp(E))},tryEmit:function(m){if(this.canEmit())return this.emit(m);this.state=Ht},canEmit:function(){for(var m=0;mx.threshold&&k&x.direction},attrTest:function(m){return Ct.prototype.attrTest.call(this,m)&&(this.state&ft||!(this.state&ft)&&this.directionTest(m))},emit:function(m){this.pX=m.deltaX,this.pY=m.deltaY;var x=Vp(m.direction);x&&(m.additionalEvent=this.options.event+x),this._super.emit.call(this,m)}});function Eu(){Ct.apply(this,arguments)}y(Eu,Ct,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[li]},attrTest:function(m){return this._super.attrTest.call(this,m)&&(Math.abs(m.scale-1)>this.options.threshold||this.state&ft)},emit:function(m){if(m.scale!==1){var x=m.scale<1?"in":"out";m.additionalEvent=this.options.event+x}this._super.emit.call(this,m)}});function Su(){ur.apply(this,arguments),this._timer=null,this._input=null}y(Su,ur,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Up]},process:function(m){var x=this.options,E=m.pointers.length===x.pointers,C=m.distancex.time;if(this._input=m,!C||!E||m.eventType&(J|Te)&&!k)this.reset();else if(m.eventType&xe)this.reset(),this._timer=u(function(){this.state=lr,this.tryEmit()},x.time,this);else if(m.eventType&J)return lr;return Ht},reset:function(){clearTimeout(this._timer)},emit:function(m){this.state===lr&&(m&&m.eventType&J?this.manager.emit(this.options.event+"up",m):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function Au(){Ct.apply(this,arguments)}y(Au,Ct,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[li]},attrTest:function(m){return this._super.attrTest.call(this,m)&&(Math.abs(m.rotation)>this.options.threshold||this.state&ft)}});function wu(){Ct.apply(this,arguments)}y(wu,Ct,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:lt|cr,pointers:1},getTouchAction:function(){return Xa.prototype.getTouchAction.call(this)},attrTest:function(m){var x=this.options.direction,E;return x&(lt|cr)?E=m.overallVelocity:x<?E=m.overallVelocityX:x&cr&&(E=m.overallVelocityY),this._super.attrTest.call(this,m)&&x&m.offsetDirection&&m.distance>this.options.threshold&&m.maxPointers==this.options.pointers&&c(E)>this.options.velocity&&m.eventType&J},emit:function(m){var x=Vp(m.offsetDirection);x&&this.manager.emit(this.options.event+x,m),this.manager.emit(this.options.event,m)}});function $a(){ur.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}y($a,ur,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[vu]},process:function(m){var x=this.options,E=m.pointers.length===x.pointers,C=m.distance{(function(t){"use strict";var e="Compound",r="Identifier",i="MemberExpression",s="Literal",n="ThisExpression",o="CallExpression",a="UnaryExpression",c="BinaryExpression",l="LogicalExpression",u="ConditionalExpression",f="ArrayExpression",h=46,d=44,p=39,g=34,_=40,y=41,v=91,T=93,S=63,R=59,M=58,F=function(j,B){var at=new Error(j+" at character "+B);throw at.index=B,at.description=j,at},N=!0,D={"-":N,"!":N,"~":N,"+":N},L={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Y=function(j){var B=0,at;for(var xe in j)(at=xe.length)>B&&j.hasOwnProperty(xe)&&(B=at);return B},X=Y(D),$=Y(L),Z={true:!0,false:!1,null:null},ge="this",rt=function(j){return L[j]||0},ot=function(j,B,at){var xe=j==="||"||j==="&&"?l:c;return{type:xe,operator:j,left:B,right:at}},Pt=function(j){return j>=48&&j<=57},Vt=function(j){return j===36||j===95||j>=65&&j<=90||j>=97&&j<=122||j>=128&&!L[String.fromCharCode(j)]},hn=function(j){return j===36||j===95||j>=65&&j<=90||j>=97&&j<=122||j>=48&&j<=57||j>=128&&!L[String.fromCharCode(j)]},he=function(j){for(var B=0,at=j.charAt,xe=j.charCodeAt,me=function(V){return at.call(j,V)},J=function(V){return xe.call(j,V)},Te=j.length,Ve=function(){for(var V=J(B);V===32||V===9||V===10||V===13;)V=J(++B)},ct=function(){var V=ai(),K,G;if(Ve(),J(B)===S){if(B++,K=ct(),K||F("Expected expression",B),Ve(),J(B)===M)return B++,G=ct(),G||F("Expected expression",B),{type:u,test:V,consequent:K,alternate:G};F("Expected :",B)}else return V},Ir=function(){Ve();for(var V,K=j.substr(B,$),G=K.length;G>0;){if(L.hasOwnProperty(K)&&(!Vt(J(B))||B+K.length2&&Ee<=we[we.length-2].prec;)ci=we.pop(),G=we.pop().value,ut=we.pop(),K=ot(G,ut,ci),we.push(K);K=Wt(),K||F("Expected expression after "+Ua,B),we.push(We,K)}for(Or=we.length-1,K=we[Or];Or>1;)K=ot(we[Or-1].value,we[Or-2],K),Or-=2;return K},Wt=function(){var V,K,G;if(Ve(),V=J(B),Pt(V)||V===h)return lt();if(V===p||V===g)return cr();if(V===v)return xu();for(K=j.substr(B,X),G=K.length;G>0;){if(D.hasOwnProperty(K)&&(!Vt(J(B))||B+K.length=G.length&&F("Unexpected token "+String.fromCharCode(V),B);break}else if(K===d){if(B++,We++,We!==G.length){if(V===y)F("Unexpected token ,",B);else if(V===T)for(var ut=G.length;ut"u"){var _u=t.jsep;t.jsep=he,he.noConflict=function(){return t.jsep===he&&(t.jsep=_u),he}}else typeof Ul<"u"&&Ul.exports?ra=Ul.exports=he:ra.parse=he})(ra)});var j2=Ru((wK,ap)=>{"use strict";ap.exports=Gl;ap.exports.default=Gl;function Gl(t,e,r){r=r||2;var i=e&&e.length,s=i?e[0]*r:t.length,n=V2(t,0,s,r,!0),o=[];if(!n||n.next===n.prev)return o;var a,c,l,u,f,h,d;if(i&&(n=JP(t,e,n,r)),t.length>80*r){a=l=t[0],c=u=t[1];for(var p=r;pl&&(l=f),h>u&&(u=h);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return ma(n,o,r,a,c,d,0),o}function V2(t,e,r,i,s){var n,o;if(s===op(t,e,r,i)>0)for(n=e;n=e;n-=i)o=z2(n,t[n],t[n+1],o);return o&&Zl(o,o.next)&&(xa(o),o=o.next),o}function qi(t,e){if(!t)return t;e||(e=t);var r=t,i;do if(i=!1,!r.steiner&&(Zl(r,r.next)||_e(r.prev,r,r.next)===0)){if(xa(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function ma(t,e,r,i,s,n,o){if(t){!o&&n&&iC(t,i,s,n);for(var a=t,c,l;t.prev!==t.next;){if(c=t.prev,l=t.next,n?qP(t,i,s,n):KP(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),xa(t),t=l.next,a=l.next;continue}if(t=l,t===a){o?o===1?(t=GP(qi(t),e,r),ma(t,e,r,i,s,n,2)):o===2&&ZP(t,e,r,i,s,n):ma(qi(t),e,r,i,s,n,1);break}}}}function KP(t){var e=t.prev,r=t,i=t.next;if(_e(e,r,i)>=0)return!1;for(var s=e.x,n=r.x,o=i.x,a=e.y,c=r.y,l=i.y,u=sn?s>o?s:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&Hs(s,a,n,c,o,l,p.x,p.y)&&_e(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function qP(t,e,r,i){var s=t.prev,n=t,o=t.next;if(_e(s,n,o)>=0)return!1;for(var a=s.x,c=n.x,l=o.x,u=s.y,f=n.y,h=o.y,d=ac?a>l?a:l:c>l?c:l,_=u>f?u>h?u:h:f>h?f:h,y=sp(d,p,e,r,i),v=sp(g,_,e,r,i),T=t.prevZ,S=t.nextZ;T&&T.z>=y&&S&&S.z<=v;){if(T.x>=d&&T.x<=g&&T.y>=p&&T.y<=_&&T!==s&&T!==o&&Hs(a,u,c,f,l,h,T.x,T.y)&&_e(T.prev,T,T.next)>=0||(T=T.prevZ,S.x>=d&&S.x<=g&&S.y>=p&&S.y<=_&&S!==s&&S!==o&&Hs(a,u,c,f,l,h,S.x,S.y)&&_e(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;T&&T.z>=y;){if(T.x>=d&&T.x<=g&&T.y>=p&&T.y<=_&&T!==s&&T!==o&&Hs(a,u,c,f,l,h,T.x,T.y)&&_e(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;S&&S.z<=v;){if(S.x>=d&&S.x<=g&&S.y>=p&&S.y<=_&&S!==s&&S!==o&&Hs(a,u,c,f,l,h,S.x,S.y)&&_e(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function GP(t,e,r){var i=t;do{var s=i.prev,n=i.next.next;!Zl(s,n)&&W2(s,i,i.next,n)&&_a(s,n)&&_a(n,s)&&(e.push(s.i/r|0),e.push(i.i/r|0),e.push(n.i/r|0),xa(i),xa(i.next),i=t=n),i=i.next}while(i!==t);return qi(i)}function ZP(t,e,r,i,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&oC(o,a)){var c=H2(o,a);o=qi(o,o.next),c=qi(c,c.next),ma(o,e,r,i,s,n,0),ma(c,e,r,i,s,n,0);return}a=a.next}o=o.next}while(o!==t)}function JP(t,e,r,i){var s=[],n,o,a,c,l;for(n=0,o=e.length;n=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>n&&(n=a,o=r.x=r.x&&r.x>=l&&i!==r.x&&Hs(so.x||r.x===o.x&&rC(o,r)))&&(o=r,f=h)),r=r.next;while(r!==c);return o}function rC(t,e){return _e(t.prev,t,e.prev)<0&&_e(e.next,t,t.next)<0}function iC(t,e,r,i){var s=t;do s.z===0&&(s.z=sp(s.x,s.y,e,r,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,sC(s)}function sC(t){var e,r,i,s,n,o,a,c,l=1;do{for(r=t,t=null,n=null,o=0;r;){for(o++,i=r,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||r.z<=i.z)?(s=r,r=r.nextZ,a--):(s=i,i=i.nextZ,c--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=i}n.nextZ=null,l*=2}while(o>1);return t}function sp(t,e,r,i,s){return t=(t-r)*s|0,e=(e-i)*s|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function nC(t){var e=t,r=t;do(e.x=(t-o)*(n-a)&&(t-o)*(i-a)>=(r-o)*(e-a)&&(r-o)*(n-a)>=(s-o)*(i-a)}function oC(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!aC(t,e)&&(_a(t,e)&&_a(e,t)&&cC(t,e)&&(_e(t.prev,t,e.prev)||_e(t,e.prev,e))||Zl(t,e)&&_e(t.prev,t,t.next)>0&&_e(e.prev,e,e.next)>0)}function _e(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Zl(t,e){return t.x===e.x&&t.y===e.y}function W2(t,e,r,i){var s=ql(_e(t,e,r)),n=ql(_e(t,e,i)),o=ql(_e(r,i,t)),a=ql(_e(r,i,e));return!!(s!==n&&o!==a||s===0&&Kl(t,r,e)||n===0&&Kl(t,i,e)||o===0&&Kl(r,t,i)||a===0&&Kl(r,e,i))}function Kl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function ql(t){return t>0?1:t<0?-1:0}function aC(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&W2(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function _a(t,e){return _e(t.prev,t,t.next)<0?_e(t,e,t.next)>=0&&_e(t,t.prev,e)>=0:_e(t,e,t.prev)<0||_e(t,t.next,e)<0}function cC(t,e){var r=t,i=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&s<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function H2(t,e){var r=new np(t.i,t.x,t.y),i=new np(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function z2(t,e,r,i){var s=new np(t,e,r);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function xa(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function np(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Gl.deviation=function(t,e,r,i){var s=e&&e.length,n=s?e[0]*r:t.length,o=Math.abs(op(t,0,n,r));if(s)for(var a=0,c=e.length;a0&&(i+=t[s-1].length,r.holes.push(i))}return r}});import fn from"https://esm.sh/maplibre-gl@3.6.2";import{Protocol as c6}from"https://esm.sh/pmtiles@3.0.6";var yn=class{constructor(e){this._options=e||{}}onAdd(e){return this._map=e,this._container=document.createElement("div"),this._container.className="maplibregl-ctrl maplibregl-ctrl-group",this._container.style.cssText=this._options.cssText||"padding: 10px;",this._container.innerHTML=this._options.content||"We out here.",this._container}onRemove(){this._container.parentNode.removeChild(this._container),this._map=void 0}};var My={default:"layer-switcher-ctrl",simple:"layer-switcher-ctrl-simple"};function Iy(t,e){let r=document.createElement("div");r.id="layer-switcher-menu";for(let i of t){let s=document.createElement("a");s.id=i,s.href="#",s.textContent=i;let n=e.getLayoutProperty(i,"visibility");(typeof n>"u"||n==="visible")&&(s.className="active"),s.onclick=function(o){let a=this.textContent,c=e.getLayoutProperty(a,"visibility");if(console.log(a,c),typeof c>"u"||c==="visible"){e.setLayoutProperty(a,"visibility","none"),this.className="";return}e.setLayoutProperty(a,"visibility","visible"),this.className="active"},r.appendChild(s)}return r}var bn=class{constructor(e){this._options=e}onAdd(e){this._map=e,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl"),this._container.classList.add(My[this._options.theme||"default"]),this._container.style.cssText=this._options.cssText||"";let r=this._options.layerIds;return this._container.appendChild(Iy(r,e)),this._container}onRemove(){this._container.parentNode.removeChild(this._container),this._map=void 0}getDefaultPosition(){return"top-left"}};function Fr(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var Xt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Oy=Xt.self||Xt.window||Xt.global||{},Ny=Xt.window||Xt.self||Xt.global||{},Fy=Xt.global||Xt.self||Xt.window||{},Dy=Xt.document||{};var fi=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var jp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Ly=jp&&parseFloat(jp[1])||0;var Ka=globalThis,ky=globalThis.document||{},qa=globalThis.process||{},By=globalThis.console,Xp=globalThis.navigator||{};function Ga(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function ke(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ga()}function Mu(t){return!t&&!ke()?"Node":Ga(t)?"Electron":(t||Xp.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Iu="4.0.7";function zy(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Za=class{constructor(e,r,i="sessionStorage"){this.storage=zy(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function $p(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Yp(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Ja;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ja||(Ja={}));var Vy=10;function Kp(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ja[t]||Ja.WHITE)}function qp(t,e,r){return!ke&&typeof t=="string"&&(e&&(t=`\x1B[${Kp(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Kp(r)+Vy}m${t}\x1B[49m`)),t}function Gp(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),s=t;for(let n of i){let o=s[n];typeof o=="function"&&(e.find(a=>n===a)||(s[n]=o.bind(t)))}}function vn(t,e){if(!t)throw new Error(e||"Assertion failed")}function hi(){let t;if(ke()&&Ka.performance)t=Ka?.performance?.now?.();else if("hrtime"in qa){let e=qa?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ss={debug:ke()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Wy={enabled:!0,level:0};function ns(){}var Zp={},Jp={once:!0},qe=class{constructor({id:e}={id:""}){this.VERSION=Iu,this._startTs=hi(),this._deltaTs=hi(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Za(`__probe-${this.id}__`,Wy),this.timeStamp(`${this.id} started`),Gp(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((hi()-this._startTs).toPrecision(10))}getDelta(){return Number((hi()-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,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,ss.warn,arguments,Jp)}error(e){return this._getLogFunction(0,e,ss.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,ss.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,ss.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,ss.debug||ss.info,arguments,Jp)}table(e,r,i){return r?this._getLogFunction(e,r,console.table||ns,i&&[i],{tag:jy(r)}):ns}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||ns)}group(e,r,i={collapsed:!1}){let s=Qp({logLevel:e,message:r,opts:i}),{collapsed:n}=i;return s.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||ns)}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=eg(e)}_getLogFunction(e,r,i,s,n){if(this._shouldLog(e)){n=Qp({logLevel:e,message:r,args:s,opts:n}),i=i||n.method,vn(i),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=hi();let o=n.tag||n.message;if(n.once&&o)if(!Zp[o])Zp[o]=hi();else return ns;return r=Hy(this.id,n.message,n),i.bind(console,r,...n.args)}return ns}};qe.VERSION=Iu;function eg(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return vn(Number.isFinite(e)&&e>=0),e}function Qp(t){let{logLevel:e,message:r}=t;t.logLevel=eg(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return vn(s==="string"||s==="object"),Object.assign(t,{args:i},t.opts)}function Hy(t,e,r){if(typeof e=="string"){let i=r.time?Yp($p(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=qp(e,r.color,r.background)}return e}function jy(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var Q6=new qe({id:"@probe.gl/log"});function Ou(t,e){return tg(t||{},e)}function tg(t,e,r=0){if(r>3)return e;let i={...t};for(let[s,n]of Object.entries(e))n&&typeof n=="object"&&!Array.isArray(n)?i[s]=tg(i[s]||{},e[s],r+1):i[s]=e[s];return i}var rg="latest";function Xy(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.1"),globalThis._loadersgl_.version}var Nu=Xy();function je(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var $t={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},oM=$t.self||$t.window||$t.global||{},aM=$t.window||$t.self||$t.global||{},cM=$t.global||$t.self||$t.window||{},lM=$t.document||{};var ht=typeof process!="object"||String(process)!=="[object process]"||process.browser;var sg=typeof window<"u"&&typeof window.orientation<"u",ig=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),uM=ig&&parseFloat(ig[1])||0;var Tn=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){je(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){je(this.isRunning),this.isRunning=!1,this._reject(e)}};var os=class{terminate(){}};var Fu=new Map;function ng(t){je(t.source&&!t.url||!t.source&&t.url);let e=Fu.get(t.source||t.url);return e||(t.url&&(e=$y(t.url),Fu.set(t.url,e)),t.source&&(e=og(t.source),Fu.set(t.source,e))),je(e),e}function $y(t){if(!t.startsWith("http"))return t;let e=Yy(t);return og(e)}function og(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function Yy(t){return`try { +var CF=Object.create;var Nm=Object.defineProperty;var MF=Object.getOwnPropertyDescriptor;var PF=Object.getOwnPropertyNames;var IF=Object.getPrototypeOf,RF=Object.prototype.hasOwnProperty;var MT=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Sr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),dr=(t,e)=>{for(var r in e)Nm(t,r,{get:e[r],enumerable:!0})},BF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of PF(e))!RF.call(t,n)&&n!==r&&Nm(t,n,{get:()=>e[n],enumerable:!(i=MF(e,n))||i.enumerable});return t};var Ys=(t,e,r)=>(r=t!=null?CF(IF(t)):{},BF(e||!t||!t.__esModule?Nm(r,"default",{value:t,enumerable:!0}):r,t));var gC=Sr((I1e,Bd)=>{(function(t,e,r,i){"use strict";var n=["","webkit","Moz","MS","ms","o"],s=e.createElement("div"),o="function",a=Math.round,A=Math.abs,h=Date.now;function g(I,D,W){return setTimeout(R(I,W),D)}function _(I,D,W){return Array.isArray(I)?(x(I,W[D],W),!0):!1}function x(I,D,W){var se;if(I)if(I.forEach)I.forEach(D,W);else if(I.length!==i)for(se=0;se\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",ct=t.console&&(t.console.warn||t.console.log);return ct&&ct.call(t.console,se,Be),I.apply(this,arguments)}}var v;typeof Object.assign!="function"?v=function(D){if(D===i||D===null)throw new TypeError("Cannot convert undefined or null to object");for(var W=Object(D),se=1;se-1}function H(I){return I.trim().split(/\s+/g)}function L(I,D,W){if(I.indexOf&&!W)return I.indexOf(D);for(var se=0;seUr[D]}):se=se.sort()),se}function he(I,D){for(var W,se,ge=D[0].toUpperCase()+D.slice(1),Be=0;Be1&&!W.firstMultiple?W.firstMultiple=Pe(D):ge===1&&(W.firstMultiple=!1);var Be=W.firstInput,ct=W.firstMultiple,hr=ct?ct.center:Be.center,xr=D.center=Ue(se);D.timeStamp=h(),D.deltaTime=D.timeStamp-Be.timeStamp,D.angle=ci(hr,xr),D.distance=fr(hr,xr),Ac(W,D),D.offsetDirection=Vt(D.deltaX,D.deltaY);var Ur=Qt(D.deltaTime,D.deltaX,D.deltaY);D.overallVelocityX=Ur.x,D.overallVelocityY=Ur.y,D.overallVelocity=A(Ur.x)>A(Ur.y)?Ur.x:Ur.y,D.scale=ct?en(ct.pointers,se):1,D.rotation=ct?os(ct.pointers,se):0,D.maxPointers=W.prevInput?D.pointers.length>W.prevInput.maxPointers?D.pointers.length:W.prevInput.maxPointers:D.pointers.length,Ce(W,D);var rn=I.element;re(D.srcEvent.target,rn)&&(rn=D.srcEvent.target),D.target=rn}function Ac(I,D){var W=D.center,se=I.offsetDelta||{},ge=I.prevDelta||{},Be=I.prevInput||{};(D.eventType===Nt||Be.eventType===Ge)&&(ge=I.prevDelta={x:Be.deltaX||0,y:Be.deltaY||0},se=I.offsetDelta={x:W.x,y:W.y}),D.deltaX=ge.x+(W.x-se.x),D.deltaY=ge.y+(W.y-se.y)}function Ce(I,D){var W=I.lastInterval||D,se=D.timeStamp-W.timeStamp,ge,Be,ct,hr;if(D.eventType!=Jt&&(se>Br||W.velocity===i)){var xr=D.deltaX-W.deltaX,Ur=D.deltaY-W.deltaY,rn=Qt(se,xr,Ur);Be=rn.x,ct=rn.y,ge=A(rn.x)>A(rn.y)?rn.x:rn.y,hr=Vt(xr,Ur),I.lastInterval=D}else ge=W.velocity,Be=W.velocityX,ct=W.velocityY,hr=W.direction;D.velocity=ge,D.velocityX=Be,D.velocityY=ct,D.direction=hr}function Pe(I){for(var D=[],W=0;W=A(D)?I<0?oi:Sn:D<0?ss:Ri}function fr(I,D,W){W||(W=Lo);var se=D[W[0]]-I[W[0]],ge=D[W[1]]-I[W[1]];return Math.sqrt(se*se+ge*ge)}function ci(I,D,W){W||(W=Lo);var se=D[W[0]]-I[W[0]],ge=D[W[1]]-I[W[1]];return Math.atan2(ge,se)*180/Math.PI}function os(I,D){return ci(D[1],D[0],zs)+ci(I[1],I[0],zs)}function en(I,D){return fr(D[0],D[1],zs)/fr(I[0],I[1],zs)}var No={mousedown:Nt,mousemove:kt,mouseup:Ge},Jg="mousedown",Zg="mousemove mouseup";function Do(){this.evEl=Jg,this.evWin=Zg,this.pressed=!1,Dr.apply(this,arguments)}M(Do,Dr,{handler:function(D){var W=No[D.type];W&Nt&&D.button===0&&(this.pressed=!0),W&kt&&D.which!==1&&(W=Ge),this.pressed&&(W&Ge&&(this.pressed=!1),this.callback(this.manager,W,{pointers:[D],changedPointers:[D],pointerType:Re,srcEvent:D}))}});var $g={pointerdown:Nt,pointermove:kt,pointerup:Ge,pointercancel:Jt,pointerout:Jt},em={2:De,3:rr,4:Re,5:de},Mh="pointerdown",tA="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(Mh="MSPointerDown",tA="MSPointerMove MSPointerUp MSPointerCancel");function rA(){this.evEl=Mh,this.evWin=tA,Dr.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}M(rA,Dr,{handler:function(D){var W=this.store,se=!1,ge=D.type.toLowerCase().replace("ms",""),Be=$g[ge],ct=em[D.pointerType]||D.pointerType,hr=ct==De,xr=L(W,D.pointerId,"pointerId");Be&Nt&&(D.button===0||hr)?xr<0&&(W.push(D),xr=W.length-1):Be&(Ge|Jt)&&(se=!0),!(xr<0)&&(W[xr]=D,this.callback(this.manager,Be,{pointers:W,changedPointers:[D],pointerType:ct,srcEvent:D}),se&&W.splice(xr,1))}});var tm={touchstart:Nt,touchmove:kt,touchend:Ge,touchcancel:Jt},rm="touchstart",iA="touchstart touchmove touchend touchcancel";function Ph(){this.evTarget=rm,this.evWin=iA,this.started=!1,Dr.apply(this,arguments)}M(Ph,Dr,{handler:function(D){var W=tm[D.type];if(W===Nt&&(this.started=!0),!!this.started){var se=im.call(this,D,W);W&(Ge|Jt)&&se[0].length-se[1].length===0&&(this.started=!1),this.callback(this.manager,W,{pointers:se[0],changedPointers:se[1],pointerType:De,srcEvent:D})}}});function im(I,D){var W=ae(I.touches),se=ae(I.changedTouches);return D&(Ge|Jt)&&(W=fe(W.concat(se),"identifier",!0)),[W,se]}var _e={touchstart:Nt,touchmove:kt,touchend:Ge,touchcancel:Jt},Cb="touchstart touchmove touchend touchcancel";function nA(){this.evTarget=Cb,this.targetIds={},Dr.apply(this,arguments)}M(nA,Dr,{handler:function(D){var W=_e[D.type],se=Mb.call(this,D,W);se&&this.callback(this.manager,W,{pointers:se[0],changedPointers:se[1],pointerType:De,srcEvent:D})}});function Mb(I,D){var W=ae(I.touches),se=this.targetIds;if(D&(Nt|kt)&&W.length===1)return se[W[0].identifier]=!0,[W,W];var ge,Be,ct=ae(I.changedTouches),hr=[],xr=this.target;if(Be=W.filter(function(Ur){return re(Ur.target,xr)}),D===Nt)for(ge=0;ge-1&&se.splice(Be,1)};setTimeout(ge,Pb)}}function Rb(I){for(var D=I.srcEvent.clientX,W=I.srcEvent.clientY,se=0;se-1&&this.requireFail.splice(D,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(I){return!!this.simultaneous[I.id]},emit:function(I){var D=this,W=this.state;function se(ge){D.manager.emit(ge,I)}W=as&&se(D.options.event+Am(W))},tryEmit:function(I){if(this.canEmit())return this.emit(I);this.state=tn},canEmit:function(){for(var I=0;ID.threshold&&ge&D.direction},attrTest:function(I){return bi.prototype.attrTest.call(this,I)&&(this.state&xi||!(this.state&xi)&&this.directionTest(I))},emit:function(I){this.pX=I.deltaX,this.pY=I.deltaY;var D=um(I.direction);D&&(I.additionalEvent=this.options.event+D),this._super.emit.call(this,I)}});function Oh(){bi.apply(this,arguments)}M(Oh,bi,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Hs]},attrTest:function(I){return this._super.attrTest.call(this,I)&&(Math.abs(I.scale-1)>this.options.threshold||this.state&xi)},emit:function(I){if(I.scale!==1){var D=I.scale<1?"in":"out";I.additionalEvent=this.options.event+D}this._super.emit.call(this,I)}});function Fh(){Mn.apply(this,arguments),this._timer=null,this._input=null}M(Fh,Mn,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[lm]},process:function(I){var D=this.options,W=I.pointers.length===D.pointers,se=I.distanceD.time;if(this._input=I,!se||!W||I.eventType&(Ge|Jt)&&!ge)this.reset();else if(I.eventType&Nt)this.reset(),this._timer=g(function(){this.state=Cn,this.tryEmit()},D.time,this);else if(I.eventType&Ge)return Cn;return tn},reset:function(){clearTimeout(this._timer)},emit:function(I){this.state===Cn&&(I&&I.eventType&Ge?this.manager.emit(this.options.event+"up",I):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}});function Lh(){bi.apply(this,arguments)}M(Lh,bi,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Hs]},attrTest:function(I){return this._super.attrTest.call(this,I)&&(Math.abs(I.rotation)>this.options.threshold||this.state&xi)}});function Nh(){bi.apply(this,arguments)}M(Nh,bi,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:ai|Ji,pointers:1},getTouchAction:function(){return cA.prototype.getTouchAction.call(this)},attrTest:function(I){var D=this.options.direction,W;return D&(ai|Ji)?W=I.overallVelocity:D&ai?W=I.overallVelocityX:D&Ji&&(W=I.overallVelocityY),this._super.attrTest.call(this,I)&&D&I.offsetDirection&&I.distance>this.options.threshold&&I.maxPointers==this.options.pointers&&A(W)>this.options.velocity&&I.eventType&Ge},emit:function(I){var D=um(I.offsetDirection);D&&this.manager.emit(this.options.event+D,I),this.manager.emit(this.options.event,I)}});function lA(){Mn.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}M(lA,Mn,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Rh]},process:function(I){var D=this.options,W=I.pointers.length===D.pointers,se=I.distance{(function(t){"use strict";var e="Compound",r="Identifier",i="MemberExpression",n="Literal",s="ThisExpression",o="CallExpression",a="UnaryExpression",A="BinaryExpression",h="LogicalExpression",g="ConditionalExpression",_="ArrayExpression",x=46,T=44,v=39,S=34,C=40,M=41,R=91,B=93,k=63,Q=59,$=58,re=function(Re,de){var Br=new Error(Re+" at character "+de);throw Br.index=de,Br.description=Re,Br},Y=!0,H={"-":Y,"!":Y,"~":Y,"+":Y},L={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},ae=function(Re){var de=0,Br;for(var Nt in Re)(Br=Nt.length)>de&&Re.hasOwnProperty(Nt)&&(de=Br);return de},fe=ae(H),he=ae(L),ye={true:!0,false:!1,null:null},Ne="this",nt=function(Re){return L[Re]||0},it=function(Re,de,Br){var Nt=Re==="||"||Re==="&&"?h:A;return{type:Nt,operator:Re,left:de,right:Br}},et=function(Re){return Re>=48&&Re<=57},st=function(Re){return Re===36||Re===95||Re>=65&&Re<=90||Re>=97&&Re<=122||Re>=128&&!L[String.fromCharCode(Re)]},At=function(Re){return Re===36||Re===95||Re>=65&&Re<=90||Re>=97&&Re<=122||Re>=48&&Re<=57||Re>=128&&!L[String.fromCharCode(Re)]},De=function(Re){for(var de=0,Br=Re.charAt,Nt=Re.charCodeAt,kt=function(Ce){return Br.call(Re,Ce)},Ge=function(Ce){return Nt.call(Re,Ce)},Jt=Re.length,yr=function(){for(var Ce=Ge(de);Ce===32||Ce===9||Ce===10||Ce===13;)Ce=Ge(++de)},oi=function(){var Ce=ss(),Pe,Ue;if(yr(),Ge(de)===k){if(de++,Pe=oi(),Pe||re("Expected expression",de),yr(),Ge(de)===$)return de++,Ue=oi(),Ue||re("Expected expression",de),{type:g,test:Ce,consequent:Pe,alternate:Ue};re("Expected :",de)}else return Ce},Sn=function(){yr();for(var Ce,Pe=Re.substr(de,he),Ue=Pe.length;Ue>0;){if(L.hasOwnProperty(Pe)&&(!st(Ge(de))||de+Pe.length2&&Qt<=Vt[Vt.length-2].prec;)os=Vt.pop(),Ue=Vt.pop().value,ci=Vt.pop(),Pe=it(Ue,ci,os),Vt.push(Pe);Pe=Ri(),Pe||re("Expected expression after "+No,de),Vt.push(fr,Pe)}for(en=Vt.length-1,Pe=Vt[en];en>1;)Pe=it(Vt[en-1].value,Vt[en-2],Pe),en-=2;return Pe},Ri=function(){var Ce,Pe,Ue;if(yr(),Ce=Ge(de),et(Ce)||Ce===x)return ai();if(Ce===v||Ce===S)return Ji();if(Ce===R)return Zi();for(Pe=Re.substr(de,fe),Ue=Pe.length;Ue>0;){if(H.hasOwnProperty(Pe)&&(!st(Ge(de))||de+Pe.length=Ue.length&&re("Unexpected token "+String.fromCharCode(Ce),de);break}else if(Pe===T){if(de++,fr++,fr!==Ue.length){if(Ce===M)re("Unexpected token ,",de);else if(Ce===B)for(var ci=Ue.length;ci"u"){var rr=t.jsep;t.jsep=De,De.noConflict=function(){return t.jsep===De&&(t.jsep=rr),De}}else typeof Xd<"u"&&Xd.exports?Af=Xd.exports=De:Af.parse=De})(Af)});var dM=Sr((Ybe,Fy)=>{"use strict";Fy.exports=sp;Fy.exports.default=sp;function sp(t,e,r){r=r||2;var i=e&&e.length,n=i?e[0]*r:t.length,s=uM(t,0,n,r,!0),o=[];if(!s||s.next===s.prev)return o;var a,A,h,g,_,x,T;if(i&&(s=jG(t,e,s,r)),t.length>80*r){a=h=t[0],A=g=t[1];for(var v=r;vh&&(h=_),x>g&&(g=x);T=Math.max(h-a,g-A),T=T!==0?32767/T:0}return wf(s,o,r,a,A,T,0),o}function uM(t,e,r,i,n){var s,o;if(n===Oy(t,e,r,i)>0)for(s=e;s=e;s-=i)o=AM(s,t[s],t[s+1],o);return o&&op(o,o.next)&&(Mf(o),o=o.next),o}function Ua(t,e){if(!t)return t;e||(e=t);var r=t,i;do if(i=!1,!r.steiner&&(op(r,r.next)||Kt(r.prev,r,r.next)===0)){if(Mf(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function wf(t,e,r,i,n,s,o){if(t){!o&&s&&KG(t,i,n,s);for(var a=t,A,h;t.prev!==t.next;){if(A=t.prev,h=t.next,s?HG(t,i,n,s):zG(t)){e.push(A.i/r|0),e.push(t.i/r|0),e.push(h.i/r|0),Mf(t),t=h.next,a=h.next;continue}if(t=h,t===a){o?o===1?(t=GG(Ua(t),e,r),wf(t,e,r,i,n,s,2)):o===2&&WG(t,e,r,i,n,s):wf(Ua(t),e,r,i,n,s,1);break}}}}function zG(t){var e=t.prev,r=t,i=t.next;if(Kt(e,r,i)>=0)return!1;for(var n=e.x,s=r.x,o=i.x,a=e.y,A=r.y,h=i.y,g=ns?n>o?n:o:s>o?s:o,T=a>A?a>h?a:h:A>h?A:h,v=i.next;v!==e;){if(v.x>=g&&v.x<=x&&v.y>=_&&v.y<=T&&cl(n,a,s,A,o,h,v.x,v.y)&&Kt(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function HG(t,e,r,i){var n=t.prev,s=t,o=t.next;if(Kt(n,s,o)>=0)return!1;for(var a=n.x,A=s.x,h=o.x,g=n.y,_=s.y,x=o.y,T=aA?a>h?a:h:A>h?A:h,C=g>_?g>x?g:x:_>x?_:x,M=Ry(T,v,e,r,i),R=Ry(S,C,e,r,i),B=t.prevZ,k=t.nextZ;B&&B.z>=M&&k&&k.z<=R;){if(B.x>=T&&B.x<=S&&B.y>=v&&B.y<=C&&B!==n&&B!==o&&cl(a,g,A,_,h,x,B.x,B.y)&&Kt(B.prev,B,B.next)>=0||(B=B.prevZ,k.x>=T&&k.x<=S&&k.y>=v&&k.y<=C&&k!==n&&k!==o&&cl(a,g,A,_,h,x,k.x,k.y)&&Kt(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;B&&B.z>=M;){if(B.x>=T&&B.x<=S&&B.y>=v&&B.y<=C&&B!==n&&B!==o&&cl(a,g,A,_,h,x,B.x,B.y)&&Kt(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;k&&k.z<=R;){if(k.x>=T&&k.x<=S&&k.y>=v&&k.y<=C&&k!==n&&k!==o&&cl(a,g,A,_,h,x,k.x,k.y)&&Kt(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function GG(t,e,r){var i=t;do{var n=i.prev,s=i.next.next;!op(n,s)&&fM(n,i,i.next,s)&&Cf(n,s)&&Cf(s,n)&&(e.push(n.i/r|0),e.push(i.i/r|0),e.push(s.i/r|0),Mf(i),Mf(i.next),i=t=s),i=i.next}while(i!==t);return Ua(i)}function WG(t,e,r,i,n,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&$G(o,a)){var A=hM(o,a);o=Ua(o,o.next),A=Ua(A,A.next),wf(o,e,r,i,n,s,0),wf(A,e,r,i,n,s,0);return}a=a.next}o=o.next}while(o!==t)}function jG(t,e,r,i){var n=[],s,o,a,A,h;for(s=0,o=e.length;s=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>s&&(s=a,o=r.x=r.x&&r.x>=h&&i!==r.x&&cl(no.x||r.x===o.x&&qG(o,r)))&&(o=r,_=x)),r=r.next;while(r!==A);return o}function qG(t,e){return Kt(t.prev,t,e.prev)<0&&Kt(e.next,t,t.next)<0}function KG(t,e,r,i){var n=t;do n.z===0&&(n.z=Ry(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,JG(n)}function JG(t){var e,r,i,n,s,o,a,A,h=1;do{for(r=t,t=null,s=null,o=0;r;){for(o++,i=r,a=0,e=0;e0||A>0&&i;)a!==0&&(A===0||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,A--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=i}s.nextZ=null,h*=2}while(o>1);return t}function Ry(t,e,r,i,n){return t=(t-r)*n|0,e=(e-i)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function ZG(t){var e=t,r=t;do(e.x=(t-o)*(s-a)&&(t-o)*(i-a)>=(r-o)*(e-a)&&(r-o)*(s-a)>=(n-o)*(i-a)}function $G(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!eW(t,e)&&(Cf(t,e)&&Cf(e,t)&&tW(t,e)&&(Kt(t.prev,t,e.prev)||Kt(t,e.prev,e))||op(t,e)&&Kt(t.prev,t,t.next)>0&&Kt(e.prev,e,e.next)>0)}function Kt(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function op(t,e){return t.x===e.x&&t.y===e.y}function fM(t,e,r,i){var n=np(Kt(t,e,r)),s=np(Kt(t,e,i)),o=np(Kt(r,i,t)),a=np(Kt(r,i,e));return!!(n!==s&&o!==a||n===0&&ip(t,r,e)||s===0&&ip(t,i,e)||o===0&&ip(r,t,i)||a===0&&ip(r,e,i))}function ip(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function np(t){return t>0?1:t<0?-1:0}function eW(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&fM(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Cf(t,e){return Kt(t.prev,t,t.next)<0?Kt(t,e,t.next)>=0&&Kt(t,t.prev,e)>=0:Kt(t,e,t.prev)<0||Kt(t,t.next,e)<0}function tW(t,e){var r=t,i=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function hM(t,e){var r=new By(t.i,t.x,t.y),i=new By(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function AM(t,e,r,i){var n=new By(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Mf(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function By(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}sp.deviation=function(t,e,r,i){var n=e&&e.length,s=n?e[0]*r:t.length,o=Math.abs(Oy(t,0,s,r));if(n)for(var a=0,A=e.length;a0&&(i+=t[n-1].length,r.holes.push(i))}return r}});var wp=Sr(Ps=>{"use strict";var E5=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",kj=E5+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",v5="["+E5+"]["+kj+"]*",Vj=new RegExp("^"+v5+"$"),zj=function(t,e){let r=[],i=e.exec(t);for(;i;){let n=[];n.startIndex=e.lastIndex-i[0].length;let s=i.length;for(let o=0;o"u")};Ps.isExist=function(t){return typeof t<"u"};Ps.isEmptyObject=function(t){return Object.keys(t).length===0};Ps.merge=function(t,e,r){if(e){let i=Object.keys(e),n=i.length;for(let s=0;s{"use strict";var Jy=wp(),Gj={allowBooleanAttributes:!1,unpairedTags:[]};P5.validate=function(t,e){e=Object.assign({},Gj,e);let r=[],i=!1,n=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s"&&t[s]!==" "&&t[s]!==" "&&t[s]!==` +`&&t[s]!=="\r";s++)A+=t[s];if(A=A.trim(),A[A.length-1]==="/"&&(A=A.substring(0,A.length-1),s--),!Jj(A)){let _;return A.trim().length===0?_="Invalid space after '<'.":_="Tag '"+A+"' is an invalid name.",sr("InvalidTag",_,ri(t,s))}let h=Xj(t,s);if(h===!1)return sr("InvalidAttr","Attributes for '"+A+"' have open quote.",ri(t,s));let g=h.value;if(s=h.index,g[g.length-1]==="/"){let _=s-g.length;g=g.substring(0,g.length-1);let x=M5(g,e);if(x===!0)i=!0;else return sr(x.err.code,x.err.msg,ri(t,_+x.err.line))}else if(a)if(h.tagClosed){if(g.trim().length>0)return sr("InvalidTag","Closing tag '"+A+"' can't have attributes or invalid starting.",ri(t,o));if(r.length===0)return sr("InvalidTag","Closing tag '"+A+"' has not been opened.",ri(t,o));{let _=r.pop();if(A!==_.tagName){let x=ri(t,_.tagStartPos);return sr("InvalidTag","Expected closing tag '"+_.tagName+"' (opened in line "+x.line+", col "+x.col+") instead of closing tag '"+A+"'.",ri(t,o))}r.length==0&&(n=!0)}}else return sr("InvalidTag","Closing tag '"+A+"' doesn't have proper closing.",ri(t,s));else{let _=M5(g,e);if(_!==!0)return sr(_.err.code,_.err.msg,ri(t,s-g.length+_.err.line));if(n===!0)return sr("InvalidXml","Multiple possible root nodes found.",ri(t,s));e.unpairedTags.indexOf(A)!==-1||r.push({tagName:A,tagStartPos:o}),i=!0}for(s++;s0)return sr("InvalidXml","Invalid '"+JSON.stringify(r.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return sr("InvalidXml","Start tag expected.",1);return!0};function S5(t){return t===" "||t===" "||t===` +`||t==="\r"}function w5(t,e){let r=e;for(;e5&&i==="xml")return sr("InvalidXml","XML declaration allowed only at the start of the document.",ri(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function C5(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e"){e+=2;break}}return e}var Wj='"',jj="'";function Xj(t,e){let r="",i="",n=!1;for(;e"&&i===""){n=!0;break}r+=t[e]}return i!==""?!1:{value:r,index:e,tagClosed:n}}var Yj=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function M5(t,e){let r=Jy.getAllMatches(t,Yj),i={};for(let n=0;n{var I5={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}},Zj=function(t){return Object.assign({},I5,t)};$y.buildOptions=Zj;$y.defaultOptions=I5});var O5=Sr((xwe,B5)=>{"use strict";var e3=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}};B5.exports=e3});var L5=Sr((bwe,F5)=>{var $j=wp();function eX(t,e){let r={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let i=1,n=!1,s=!1,o="";for(;e"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,i--):i--,i===0)break}else t[e]==="["?n=!0:o+=t[e];if(i!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:e}}function tX(t,e){let r="";for(;e{var cX=/^[-+]?0x[a-fA-F0-9]+$/,lX=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var AX={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function uX(t,e={}){if(e=Object.assign({},AX,e),!t||typeof t!="string")return t;let r=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(e.hex&&cX.test(r))return Number.parseInt(r,16);{let i=lX.exec(r);if(i){let n=i[1],s=i[2],o=fX(i[3]),a=i[4]||i[6];if(!e.leadingZeros&&s.length>0&&n&&r[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!n&&r[1]!==".")return t;{let A=Number(r),h=""+A;return h.search(/[eE]/)!==-1||a?e.eNotation?A:t:r.indexOf(".")!==-1?h==="0"&&o===""||h===o||n&&h==="-"+o?A:t:s?o===h||n+o===h?A:t:r===h||r===n+h?A:t}}else return t}}function fX(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}N5.exports=uX});var V5=Sr((Ewe,k5)=>{"use strict";var U5=wp(),jf=O5(),hX=L5(),dX=D5(),t3=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(r,i)=>String.fromCharCode(Number.parseInt(i,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,i)=>String.fromCharCode(Number.parseInt(i,16))}},this.addExternalEntities=pX,this.parseXml=xX,this.parseTextData=gX,this.resolveNameSpace=mX,this.buildAttributesMap=yX,this.isItStopNode=vX,this.replaceEntitiesValue=TX,this.readStopNodeData=wX,this.saveTextToParentTag=EX,this.addChild=bX}};function pX(t){let e=Object.keys(t);for(let r=0;r0)){o||(t=this.replaceEntitiesValue(t));let a=this.options.tagValueProcessor(e,t,r,n,s);return a==null?t:typeof a!=typeof t||a!==t?a:this.options.trimValues?i3(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?i3(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function mX(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var _X=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function yX(t,e,r){if(!this.options.ignoreAttributes&&typeof t=="string"){let i=U5.getAllMatches(t,_X),n=i.length,s={};for(let o=0;o",s,"Closing Tag is not closed."),A=t.substring(s+2,a).trim();if(this.options.removeNSPrefix){let _=A.indexOf(":");_!==-1&&(A=A.substr(_+1))}this.options.transformTagName&&(A=this.options.transformTagName(A)),r&&(i=this.saveTextToParentTag(i,r,n));let h=n.substring(n.lastIndexOf(".")+1);if(A&&this.options.unpairedTags.indexOf(A)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: `);let g=0;h&&this.options.unpairedTags.indexOf(h)!==-1?(g=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):g=n.lastIndexOf("."),n=n.substring(0,g),r=this.tagsNodeStack.pop(),i="",s=a}else if(t[s+1]==="?"){let a=r3(t,s,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){let A=new jf(a.tagName);A.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(A[":@"]=this.buildAttributesMap(a.tagExp,n,a.tagName)),this.addChild(r,A,n)}s=a.closeIndex+1}else if(t.substr(s+1,3)==="!--"){let a=Wa(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){let A=t.substring(s+4,a-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[{[this.options.textNodeName]:A}])}s=a}else if(t.substr(s+1,2)==="!D"){let a=hX(t,s);this.docTypeEntities=a.entities,s=a.i}else if(t.substr(s+1,2)==="!["){let a=Wa(t,"]]>",s,"CDATA is not closed.")-2,A=t.substring(s+9,a);i=this.saveTextToParentTag(i,r,n);let h=this.parseTextData(A,r.tagname,n,!0,!1,!0,!0);h==null&&(h=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:A}]):r.add(this.options.textNodeName,h),s=a+2}else{let a=r3(t,s,this.options.removeNSPrefix),A=a.tagName,h=a.rawTagName,g=a.tagExp,_=a.attrExpPresent,x=a.closeIndex;this.options.transformTagName&&(A=this.options.transformTagName(A)),r&&i&&r.tagname!=="!xml"&&(i=this.saveTextToParentTag(i,r,n,!1));let T=r;if(T&&this.options.unpairedTags.indexOf(T.tagname)!==-1&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),A!==e.tagname&&(n+=n?"."+A:A),this.isItStopNode(this.options.stopNodes,n,A)){let v="";if(g.length>0&&g.lastIndexOf("/")===g.length-1)A[A.length-1]==="/"?(A=A.substr(0,A.length-1),n=n.substr(0,n.length-1),g=A):g=g.substr(0,g.length-1),s=a.closeIndex;else if(this.options.unpairedTags.indexOf(A)!==-1)s=a.closeIndex;else{let C=this.readStopNodeData(t,h,x+1);if(!C)throw new Error(`Unexpected end of ${h}`);s=C.i,v=C.tagContent}let S=new jf(A);A!==g&&_&&(S[":@"]=this.buildAttributesMap(g,n,A)),v&&(v=this.parseTextData(v,A,n,!0,_,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),S.add(this.options.textNodeName,v),this.addChild(r,S,n)}else{if(g.length>0&&g.lastIndexOf("/")===g.length-1){A[A.length-1]==="/"?(A=A.substr(0,A.length-1),n=n.substr(0,n.length-1),g=A):g=g.substr(0,g.length-1),this.options.transformTagName&&(A=this.options.transformTagName(A));let v=new jf(A);A!==g&&_&&(v[":@"]=this.buildAttributesMap(g,n,A)),this.addChild(r,v,n),n=n.substr(0,n.lastIndexOf("."))}else{let v=new jf(A);this.tagsNodeStack.push(r),A!==g&&_&&(v[":@"]=this.buildAttributesMap(g,n,A)),this.addChild(r,v,n),r=v}i="",s=x}}else i+=t[s];return e.child};function bX(t,e,r){let i=this.options.updateTag(e.tagname,r,e[":@"]);i===!1||(typeof i=="string"&&(e.tagname=i),t.addChild(e))}var TX=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){let r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){let r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){let r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function EX(t,e,r,i){return t&&(i===void 0&&(i=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,i),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function vX(t,e,r){let i="*."+r;for(let n in t){let s=t[n];if(i===s||e===s)return!0}return!1}function SX(t,e,r=">"){let i,n="";for(let s=e;s",r,`${e} is not closed`);if(t.substring(r+2,s).trim()===e&&(n--,n===0))return{tagContent:t.substring(i,r),i:s};r=s}else if(t[r+1]==="?")r=Wa(t,"?>",r+1,"StopNode is not closed.");else if(t.substr(r+1,3)==="!--")r=Wa(t,"-->",r+3,"StopNode is not closed.");else if(t.substr(r+1,2)==="![")r=Wa(t,"]]>",r,"StopNode is not closed.")-2;else{let s=r3(t,r,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&n++,r=s.closeIndex)}}function i3(t,e,r){if(e&&typeof t=="string"){let i=t.trim();return i==="true"?!0:i==="false"?!1:dX(t,r)}else return U5.isExist(t)?t:""}k5.exports=t3});var G5=Sr(H5=>{"use strict";function CX(t,e){return z5(t,e)}function z5(t,e,r){let i,n={};for(let s=0;s0&&(n[e.textNodeName]=i):i!==void 0&&(n[e.textNodeName]=i),n}function MX(t){let e=Object.keys(t);for(let r=0;r{var{buildOptions:RX}=R5(),BX=V5(),{prettify:OX}=G5(),FX=Zy(),n3=class{constructor(e){this.externalEntities={},this.options=RX(e)}parse(e,r){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=FX.validate(e,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let i=new BX(this.options);i.addExternalEntities(this.externalEntities);let n=i.parseXml(e);return this.options.preserveOrder||n===void 0?n:OX(n,this.options)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for ' '");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}};W5.exports=n3});var K5=Sr((wwe,q5)=>{var LX=` +`;function NX(t,e){let r="";return e.format&&e.indentBy.length>0&&(r=LX),Y5(t,e,"",r)}function Y5(t,e,r,i){let n="",s=!1;for(let o=0;o`,s=!1;continue}else if(A===e.commentPropName){n+=i+``,s=!0;continue}else if(A[0]==="?"){let v=X5(a[":@"],e),S=A==="?xml"?"":i,C=a[A][0][e.textNodeName];C=C.length!==0?" "+C:"",n+=S+`<${A}${C}${v}?>`,s=!0;continue}let g=i;g!==""&&(g+=e.indentBy);let _=X5(a[":@"],e),x=i+`<${A}${_}`,T=Y5(a[A],e,h,g);e.unpairedTags.indexOf(A)!==-1?e.suppressUnpairedNode?n+=x+">":n+=x+"/>":(!T||T.length===0)&&e.suppressEmptyNode?n+=x+"/>":T&&T.endsWith(">")?n+=x+`>${T}${i}`:(n+=x+">",T&&i!==""&&(T.includes("/>")||T.includes("`),s=!0}return n}function DX(t){let e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r{"use strict";var kX=K5(),VX={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function Co(t){this.options=Object.assign({},VX,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=GX),this.processTextOrObjNode=zX,this.options.format?(this.indentate=HX,this.tagEndChar=`> +`,this.newLine=` +`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Co.prototype.build=function(t){return this.options.preserveOrder?kX(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)};Co.prototype.j2x=function(t,e){let r="",i="";for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n))if(typeof t[n]>"u")this.isAttribute(n)&&(i+="");else if(t[n]===null)this.isAttribute(n)?i+="":n[0]==="?"?i+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if(t[n]instanceof Date)i+=this.buildTextValNode(t[n],n,"",e);else if(typeof t[n]!="object"){let s=this.isAttribute(n);if(s)r+=this.buildAttrPairStr(s,""+t[n]);else if(n===this.options.textNodeName){let o=this.options.tagValueProcessor(n,""+t[n]);i+=this.replaceEntitiesValue(o)}else i+=this.buildTextValNode(t[n],n,"",e)}else if(Array.isArray(t[n])){let s=t[n].length,o="";for(let a=0;a"u"||(A===null?n[0]==="?"?i+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+n+"/"+this.tagEndChar:typeof A=="object"?this.options.oneListGroup?o+=this.j2x(A,e+1).val:o+=this.processTextOrObjNode(A,n,e):o+=this.buildTextValNode(A,n,"",e))}this.options.oneListGroup&&(o=this.buildObjectNode(o,n,"",e)),i+=o}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){let s=Object.keys(t[n]),o=s.length;for(let a=0;a"+t+n:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(i)+``+this.newLine:this.indentate(i)+"<"+e+r+s+this.tagEndChar+t+this.indentate(i)+n}};Co.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(i)+``+this.newLine;if(e[0]==="?")return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),n===""?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"0&&this.options.processEntities)for(let e=0;e{"use strict";var WX=Zy(),jX=j5(),XX=Z5();$5.exports={XMLParser:jX,XMLValidator:WX,XMLBuilder:XX}});var d3=Sr((uI,Kf)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof MT=="function"&&typeof Kf=="object"&&Kf&&Kf.exports?Kf.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(uI,function(){"use strict";function t(H,L,ae){this.low=H|0,this.high=L|0,this.unsigned=!!ae}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(H){return(H&&H.__isLong__)===!0}t.isLong=e;var r={},i={};function n(H,L){var ae,fe,he;return L?(H>>>=0,(he=0<=H&&H<256)&&(fe=i[H],fe)?fe:(ae=o(H,(H|0)<0?-1:0,!0),he&&(i[H]=ae),ae)):(H|=0,(he=-128<=H&&H<128)&&(fe=r[H],fe)?fe:(ae=o(H,H<0?-1:0,!1),he&&(r[H]=ae),ae))}t.fromInt=n;function s(H,L){if(isNaN(H)||!isFinite(H))return L?M:C;if(L){if(H<0)return M;if(H>=T)return $}else{if(H<=-v)return re;if(H+1>=v)return Q}return H<0?s(-H,L).neg():o(H%x|0,H/x|0,L)}t.fromNumber=s;function o(H,L,ae){return new t(H,L,ae)}t.fromBits=o;var a=Math.pow;function A(H,L,ae){if(H.length===0)throw Error("empty string");if(H==="NaN"||H==="Infinity"||H==="+Infinity"||H==="-Infinity")return C;if(typeof L=="number"?(ae=L,L=!1):L=!!L,ae=ae||10,ae<2||360)throw Error("interior hyphen");if(fe===0)return A(H.substring(1),L,ae).neg();for(var he=s(a(ae,8)),ye=C,Ne=0;Ne>>0:this.low},Y.toNumber=function(){return this.unsigned?(this.high>>>0)*x+(this.low>>>0):this.high*x+(this.low>>>0)},Y.toString=function(L){if(L=L||10,L<2||36>>0,st=et.toString(L);if(Ne=it,Ne.isZero())return st+nt;for(;st.length<6;)st="0"+st;nt=""+st+nt}},Y.getHighBits=function(){return this.high},Y.getHighBitsUnsigned=function(){return this.high>>>0},Y.getLowBits=function(){return this.low},Y.getLowBitsUnsigned=function(){return this.low>>>0},Y.getNumBitsAbs=function(){if(this.isNegative())return this.eq(re)?64:this.neg().getNumBitsAbs();for(var L=this.high!=0?this.high:this.low,ae=31;ae>0&&!(L&1<=0},Y.isOdd=function(){return(this.low&1)===1},Y.isEven=function(){return(this.low&1)===0},Y.equals=function(L){return e(L)||(L=h(L)),this.unsigned!==L.unsigned&&this.high>>>31===1&&L.high>>>31===1?!1:this.high===L.high&&this.low===L.low},Y.eq=Y.equals,Y.notEquals=function(L){return!this.eq(L)},Y.neq=Y.notEquals,Y.lessThan=function(L){return this.comp(L)<0},Y.lt=Y.lessThan,Y.lessThanOrEqual=function(L){return this.comp(L)<=0},Y.lte=Y.lessThanOrEqual,Y.greaterThan=function(L){return this.comp(L)>0},Y.gt=Y.greaterThan,Y.greaterThanOrEqual=function(L){return this.comp(L)>=0},Y.gte=Y.greaterThanOrEqual,Y.compare=function(L){if(e(L)||(L=h(L)),this.eq(L))return 0;var ae=this.isNegative(),fe=L.isNegative();return ae&&!fe?-1:!ae&&fe?1:this.unsigned?L.high>>>0>this.high>>>0||L.high===this.high&&L.low>>>0>this.low>>>0?-1:1:this.sub(L).isNegative()?-1:1},Y.comp=Y.compare,Y.negate=function(){return!this.unsigned&&this.eq(re)?re:this.not().add(R)},Y.neg=Y.negate,Y.add=function(L){e(L)||(L=h(L));var ae=this.high>>>16,fe=this.high&65535,he=this.low>>>16,ye=this.low&65535,Ne=L.high>>>16,nt=L.high&65535,it=L.low>>>16,et=L.low&65535,st=0,At=0,De=0,rr=0;return rr+=ye+et,De+=rr>>>16,rr&=65535,De+=he+it,At+=De>>>16,De&=65535,At+=fe+nt,st+=At>>>16,At&=65535,st+=ae+Ne,st&=65535,o(De<<16|rr,st<<16|At,this.unsigned)},Y.subtract=function(L){return e(L)||(L=h(L)),this.add(L.neg())},Y.sub=Y.subtract,Y.multiply=function(L){if(this.isZero()||(e(L)||(L=h(L)),L.isZero()))return C;if(this.eq(re))return L.isOdd()?re:C;if(L.eq(re))return this.isOdd()?re:C;if(this.isNegative())return L.isNegative()?this.neg().mul(L.neg()):this.neg().mul(L).neg();if(L.isNegative())return this.mul(L.neg()).neg();if(this.lt(S)&&L.lt(S))return s(this.toNumber()*L.toNumber(),this.unsigned);var ae=this.high>>>16,fe=this.high&65535,he=this.low>>>16,ye=this.low&65535,Ne=L.high>>>16,nt=L.high&65535,it=L.low>>>16,et=L.low&65535,st=0,At=0,De=0,rr=0;return rr+=ye*et,De+=rr>>>16,rr&=65535,De+=he*et,At+=De>>>16,De&=65535,De+=ye*it,At+=De>>>16,De&=65535,At+=fe*et,st+=At>>>16,At&=65535,At+=he*it,st+=At>>>16,At&=65535,At+=ye*nt,st+=At>>>16,At&=65535,st+=ae*et+fe*it+he*nt+ye*Ne,st&=65535,o(De<<16|rr,st<<16|At,this.unsigned)},Y.mul=Y.multiply,Y.divide=function(L){if(e(L)||(L=h(L)),L.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?M:C;var ae,fe,he;if(this.unsigned){if(L.unsigned||(L=L.toUnsigned()),L.gt(this))return M;if(L.gt(this.shru(1)))return B;he=M}else{if(this.eq(re)){if(L.eq(R)||L.eq(k))return re;if(L.eq(re))return R;var ye=this.shr(1);return ae=ye.div(L).shl(1),ae.eq(C)?L.isNegative()?R:k:(fe=this.sub(L.mul(ae)),he=ae.add(fe.div(L)),he)}else if(L.eq(re))return this.unsigned?M:C;if(this.isNegative())return L.isNegative()?this.neg().div(L.neg()):this.neg().div(L).neg();if(L.isNegative())return this.div(L.neg()).neg();he=C}for(fe=this;fe.gte(L);){ae=Math.max(1,Math.floor(fe.toNumber()/L.toNumber()));for(var Ne=Math.ceil(Math.log(ae)/Math.LN2),nt=Ne<=48?1:a(2,Ne-48),it=s(ae),et=it.mul(L);et.isNegative()||et.gt(fe);)ae-=nt,it=s(ae,this.unsigned),et=it.mul(L);it.isZero()&&(it=R),he=he.add(it),fe=fe.sub(et)}return he},Y.div=Y.divide,Y.modulo=function(L){return e(L)||(L=h(L)),this.sub(this.div(L).mul(L))},Y.mod=Y.modulo,Y.not=function(){return o(~this.low,~this.high,this.unsigned)},Y.and=function(L){return e(L)||(L=h(L)),o(this.low&L.low,this.high&L.high,this.unsigned)},Y.or=function(L){return e(L)||(L=h(L)),o(this.low|L.low,this.high|L.high,this.unsigned)},Y.xor=function(L){return e(L)||(L=h(L)),o(this.low^L.low,this.high^L.high,this.unsigned)},Y.shiftLeft=function(L){return e(L)&&(L=L.toInt()),(L&=63)===0?this:L<32?o(this.low<>>32-L,this.unsigned):o(0,this.low<>>L|this.high<<32-L,this.high>>L,this.unsigned):o(this.high>>L-32,this.high>=0?0:-1,this.unsigned)},Y.shr=Y.shiftRight,Y.shiftRightUnsigned=function(L){if(e(L)&&(L=L.toInt()),L&=63,L===0)return this;var ae=this.high;if(L<32){var fe=this.low;return o(fe>>>L|ae<<32-L,ae>>>L,this.unsigned)}else return L===32?o(ae,0,this.unsigned):o(ae>>>L-32,0,this.unsigned)},Y.shru=Y.shiftRightUnsigned,Y.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},Y.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},Y.toBytes=function(H){return H?this.toBytesLE():this.toBytesBE()},Y.toBytesLE=function(){var H=this.high,L=this.low;return[L&255,L>>>8&255,L>>>16&255,L>>>24&255,H&255,H>>>8&255,H>>>16&255,H>>>24&255]},Y.toBytesBE=function(){var H=this.high,L=this.low;return[H>>>24&255,H>>>16&255,H>>>8&255,H&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255]},t})});var t8=Sr(cb=>{cb.read=function(t,e,r,i,n){var s,o,a=n*8-i-1,A=(1<>1,g=-7,_=r?n-1:0,x=r?-1:1,T=t[e+_];for(_+=x,s=T&(1<<-g)-1,T>>=-g,g+=a;g>0;s=s*256+t[e+_],_+=x,g-=8);for(o=s&(1<<-g)-1,s>>=-g,g+=i;g>0;o=o*256+t[e+_],_+=x,g-=8);if(s===0)s=1-h;else{if(s===A)return o?NaN:(T?-1:1)*(1/0);o=o+Math.pow(2,i),s=s-h}return(T?-1:1)*o*Math.pow(2,s-i)};cb.write=function(t,e,r,i,n,s){var o,a,A,h=s*8-n-1,g=(1<>1,x=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:s-1,v=i?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=g):(o=Math.floor(Math.log(e)/Math.LN2),e*(A=Math.pow(2,-o))<1&&(o--,A*=2),o+_>=1?e+=x/A:e+=x*Math.pow(2,1-_),e*A>=2&&(o++,A/=2),o+_>=g?(a=0,o=g):o+_>=1?(a=(e*A-1)*Math.pow(2,n),o=o+_):(a=e*Math.pow(2,_-1)*Math.pow(2,n),o=0));n>=8;t[r+T]=a&255,T+=v,a/=256,n-=8);for(o=o<0;t[r+T]=o&255,T+=v,o/=256,h-=8);t[r+T-v]|=S*128}});var a8=Sr((rLe,o8)=>{"use strict";o8.exports=Ct;var Vg=t8();function Ct(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ct.Varint=0;Ct.Fixed64=1;Ct.Bytes=2;Ct.Fixed32=5;var lb=65536*65536,r8=1/lb,eee=12,s8=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");Ct.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=i&7,t(n,e,this),this.pos===s&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=zg(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=n8(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=zg(this.buf,this.pos)+zg(this.buf,this.pos+4)*lb;return this.pos+=8,t},readSFixed64:function(){var t=zg(this.buf,this.pos)+n8(this.buf,this.pos+4)*lb;return this.pos+=8,t},readFloat:function(){var t=Vg.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Vg.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,tee(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=eee&&s8?pee(this.buf,e,t):dee(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Ct.Bytes)return t.push(this.readVarint(e));var r=Vs(this);for(t=t||[];this.pos127;);else if(e===Ct.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ct.Fixed32)this.pos+=4;else if(e===Ct.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0){ree(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=gee(this.buf,t,this.pos);var r=this.pos-e;r>=128&&i8(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Vg.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Vg.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&i8(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Ct.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,see,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,oee,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,lee,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,aee,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,cee,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Aee,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,uee,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,fee,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,hee,e)},writeBytesField:function(t,e){this.writeTag(t,Ct.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ct.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ct.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ct.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ct.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ct.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ct.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ct.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ct.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ct.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function tee(t,e,r){var i=r.buf,n,s;if(s=i[r.pos++],n=(s&112)>>4,s<128||(s=i[r.pos++],n|=(s&127)<<3,s<128)||(s=i[r.pos++],n|=(s&127)<<10,s<128)||(s=i[r.pos++],n|=(s&127)<<17,s<128)||(s=i[r.pos++],n|=(s&127)<<24,s<128)||(s=i[r.pos++],n|=(s&1)<<31,s<128))return Kl(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function Vs(t){return t.type===Ct.Bytes?t.readVarint()+t.pos:t.pos+1}function Kl(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function ree(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),iee(r,i,e),nee(i,e)}function iee(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function nee(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function i8(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function see(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function n8(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function dee(t,e,r){for(var i="",n=e;n239?4:s>223?3:s>191?2:1;if(n+a>r)break;var A,h,g;a===1?s<128&&(o=s):a===2?(A=t[n+1],(A&192)===128&&(o=(s&31)<<6|A&63,o<=127&&(o=null))):a===3?(A=t[n+1],h=t[n+2],(A&192)===128&&(h&192)===128&&(o=(s&15)<<12|(A&63)<<6|h&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(A=t[n+1],h=t[n+2],g=t[n+3],(A&192)===128&&(h&192)===128&&(g&192)===128&&(o=(s&15)<<18|(A&63)<<12|(h&63)<<6|g&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),n+=a}return i}function pee(t,e,r){return s8.decode(t.subarray(e,r))}function gee(t,e,r){for(var i=0,n,s;i55295&&n<57344)if(s)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=n;continue}else n=s-55296<<10|n-56320|65536,s=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=n;continue}else s&&(t[r++]=239,t[r++]=191,t[r++]=189,s=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});import eA from"https://esm.sh/maplibre-gl@3.6.2";import{Protocol as fte}from"https://esm.sh/pmtiles@3.0.6";var mA=class{constructor(e){this._options=e||{}}onAdd(e){return this._map=e,this._container=document.createElement("div"),this._container.className="maplibregl-ctrl maplibregl-ctrl-group",this._container.style.cssText=this._options.cssText||"padding: 10px;",this._container.innerHTML=this._options.content||"We out here.",this._container}onRemove(){this._container.parentNode.removeChild(this._container),this._map=void 0}};var OF={default:"layer-switcher-ctrl",simple:"layer-switcher-ctrl-simple"};function FF(t,e){let r=document.createElement("a");r.id=e,r.href="#",r.textContent=e;let i=t.getLayoutProperty(e,"visibility");return(typeof i>"u"||i==="visible")&&(r.className="active"),r.onclick=function(n){let s=this.textContent,o=t.getLayoutProperty(s,"visibility");if(console.log(s,o),typeof o>"u"||o==="visible"){t.setLayoutProperty(s,"visibility","none"),this.className="";return}t.setLayoutProperty(s,"visibility","visible"),this.className="active"},r}function LF(t,e){let r=document.createElement("div");r.id="layer-switcher-menu";for(let i of e){let n=FF(t,i);r.appendChild(n)}return r}var _A=class{constructor(e){this._options=e}onAdd(e){this._map=e,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl"),this._container.classList.add(OF[this._options.theme||"default"]),this._container.style.cssText=this._options.cssText||"";let r=this._options.layerIds;return this._container.appendChild(LF(e,r)),this._container}onRemove(){this._container.parentNode.removeChild(this._container),this._map=void 0}getDefaultPosition(){return"top-left"}};async function Ti(t,e,r,i){return i._parse(t,e,r,i)}function at(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var On={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},NF=On.self||On.window||On.global||{},DF=On.window||On.self||On.global||{},UF=On.global||On.self||On.window||{},kF=On.document||{};var As=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var PT=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),VF=PT&&parseFloat(PT[1])||0;var Yh=globalThis,zF=globalThis.document||{},Qh=globalThis.process||{},HF=globalThis.console,IT=globalThis.navigator||{};function qh(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function Hr(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||qh()}function Dm(t){return!t&&!Hr()?"Node":qh(t)?"Electron":(t||IT.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Um="4.0.7";function WF(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Kh=class{constructor(e,r,i="sessionStorage"){this.storage=WF(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function RT(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function BT(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Jh;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Jh||(Jh={}));var jF=10;function OT(t){return typeof t!="string"?t:(t=t.toUpperCase(),Jh[t]||Jh.WHITE)}function FT(t,e,r){return!Hr&&typeof t=="string"&&(e&&(t=`\x1B[${OT(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${OT(r)+jF}m${t}\x1B[49m`)),t}function LT(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),n=t;for(let s of i){let o=n[s];typeof o=="function"&&(e.find(a=>s===a)||(n[s]=o.bind(t)))}}function yA(t,e){if(!t)throw new Error(e||"Assertion failed")}function Yo(){let t;if(Hr()&&Yh.performance)t=Yh?.performance?.now?.();else if("hrtime"in Qh){let e=Qh?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var yc={debug:Hr()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},XF={enabled:!0,level:0};function xc(){}var NT={},DT={once:!0},ui=class{constructor({id:e}={id:""}){this.VERSION=Um,this._startTs=Yo(),this._deltaTs=Yo(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Kh(`__probe-${this.id}__`,XF),this.timeStamp(`${this.id} started`),LT(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((Yo()-this._startTs).toPrecision(10))}getDelta(){return Number((Yo()-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,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,yc.warn,arguments,DT)}error(e){return this._getLogFunction(0,e,yc.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,yc.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,yc.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,yc.debug||yc.info,arguments,DT)}table(e,r,i){return r?this._getLogFunction(e,r,console.table||xc,i&&[i],{tag:QF(r)}):xc}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||xc)}group(e,r,i={collapsed:!1}){let n=UT({logLevel:e,message:r,opts:i}),{collapsed:s}=i;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||xc)}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=kT(e)}_getLogFunction(e,r,i,n,s){if(this._shouldLog(e)){s=UT({logLevel:e,message:r,args:n,opts:s}),i=i||s.method,yA(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=Yo();let o=s.tag||s.message;if(s.once&&o)if(!NT[o])NT[o]=Yo();else return xc;return r=YF(this.id,s.message,s),i.bind(console,r,...s.args)}return xc}};ui.VERSION=Um;function kT(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return yA(Number.isFinite(e)&&e>=0),e}function UT(t){let{logLevel:e,message:r}=t;t.logLevel=kT(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let n=typeof t.message;return yA(n==="string"||n==="object"),Object.assign(t,{args:i},t.opts)}function YF(t,e,r){if(typeof e=="string"){let i=r.time?BT(RT(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=FT(e,r.color,r.background)}return e}function QF(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var km=new ui({id:"@probe.gl/log"});function xA(t,e){return VT(t||{},e)}function VT(t,e,r=0){if(r>3)return e;let i={...t};for(let[n,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[n]=VT(i[n]||{},e[n],r+1):i[n]=e[n];return i}function Vm(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function zm(t){return globalThis.loaders?.modules?.[t]||null}var zT="latest";function qF(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.1"),globalThis._loadersgl_.version}var bA=qF();function Or(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var Fn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},jre=Fn.self||Fn.window||Fn.global||{},Xre=Fn.window||Fn.self||Fn.global||{},Yre=Fn.global||Fn.self||Fn.window||{},Qre=Fn.document||{};var wr=typeof process!="object"||String(process)!=="[object process]"||process.browser,TA=typeof importScripts=="function",GT=typeof window<"u"&&typeof window.orientation<"u",HT=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),qre=HT&&parseFloat(HT[1])||0;var EA=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,n)=>{this._resolve=i,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){Or(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Or(this.isRunning),this.isRunning=!1,this._reject(e)}};var bc=class{terminate(){}};var Hm=new Map;function WT(t){Or(t.source&&!t.url||!t.source&&t.url);let e=Hm.get(t.source||t.url);return e||(t.url&&(e=KF(t.url),Hm.set(t.url,e)),t.source&&(e=jT(t.source),Hm.set(t.source,e))),Or(e),e}function KF(t){if(!t.startsWith("http"))return t;let e=JF(t);return jT(e)}function jT(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function JF(t){return`try { importScripts('${t}'); } catch (error) { console.error(error); throw error; -}`}function Du(t,e=!0,r){let i=r||new Set;if(t){if(ag(t))i.add(t);else if(ag(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let s in t)Du(t[s],e,i)}}return r===void 0?Array.from(i):[]}function ag(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Lu=()=>{},Dr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&ht||typeof os<"u"&&!ht}constructor(e){let{name:r,source:i,url:s}=e;je(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=Lu,this.onError=n=>console.log(n),this.worker=ht?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Lu,this.onError=Lu,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,r){r=r||Du(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=ng({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new os(i,{eval:!1})}else if(this.source)e=new os(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var En=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Dr.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(s,n,o)=>s.done(o),i=(s,n)=>s.error(n)){let s=new Promise(n=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new Tn(r.name,e);e.onMessage=s=>r.onMessage(i,s.type,s.payload),e.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!ht||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},di=class t{props;workerPools=new Map;static _workerFarm;static isSupported(){return Dr.isSupported()}static getWorkerFarm(e={}){return t._workerFarm=t._workerFarm||new t({}),t._workerFarm.setProps(e),t._workerFarm}constructor(e){this.props={...Ky},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:s}=e,n=this.workerPools.get(r);return n||(n=new En({name:r,source:i,url:s}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function ku(t,e={}){let r=e[t.id]||{},i=ht?`${t.id}-worker.js`:`${t.id}-worker-node.js`,s=r.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),e._workerType==="test"&&(ht?s=`modules/${t.module}/dist/${i}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let n=t.version;n==="latest"&&(n=rg);let o=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${o}/dist/${i}`}return je(s),s}function Bu(t,e=Nu){je(t,"no worker provided");let r=t.version;return!(!e||!r)}function Uu(t,e){return!di.isSupported()||!ht&&!e?._nodeWorkers?!1:t.worker&&e?.worker}async function zu(t,e,r,i,s){let n=t.id,o=ku(t,r),c=di.getWorkerFarm(r).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",qy.bind(null,s));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function qy(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:s,input:n,options:o}=i;try{let a=await t(n,o);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Vu(t,e,r){if(r=r||t.byteLength,t.byteLengthn instanceof ArrayBuffer?new Uint8Array(n):n),r=e.reduce((n,o)=>n+o.byteLength,0),i=new Uint8Array(r),s=0;for(let n of e)i.set(n,s),s+=n.byteLength;return i.buffer}async function Hu(t){let e=[];for await(let r of t)e.push(r);return Wu(...e)}function Sn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var pi=class{constructor(e,r){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=r,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=Sn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Sn()-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)}};var dt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,s=this.stats[r];return s||(e instanceof pi?s=e:s=new pi(r,i),this.stats[r]=s),s}};var Gy="",lg={};function ju(t){for(let e in lg)if(t.startsWith(e)){let r=lg[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${Gy}${t}`),t}function ug(t){return t&&typeof t=="object"&&t.isBuffer}function Qa(t){if(ug(t))return t;if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}var gi={};ui(gi,{dirname:()=>Jy,filename:()=>Zy,join:()=>Qy,resolve:()=>eb});function fg(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function Zy(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):""}function Jy(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function Qy(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function eb(...t){let e=[];for(let n=0;n=-1&&!i;n--){let o;n>=0?o=e[n]:(s===void 0&&(s=fg()),o=s),o.length!==0&&(r=`${o}/${r}`,i=o.charCodeAt(0)===An)}return r=tb(r,!i),i?`/${r}`:r.length>0?r:"."}var An=47,Xu=46;function tb(t,e){let r="",i=-1,s=0,n,o=!1;for(let a=0;a<=t.length;++a){if(a2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==An;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,s=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,o=!1;continue}}e&&(r.length>0?r+="/..":r="..",o=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,o=!1}i=a,s=0}else n===Xu&&s!==-1?++s:s=-1}return r}var rb=t=>typeof t=="boolean",wn=t=>typeof t=="function",mi=t=>t!==null&&typeof t=="object",$u=t=>mi(t)&&t.constructor==={}.constructor;var hg=t=>!!t&&typeof t[Symbol.iterator]=="function",dg=t=>t&&typeof t[Symbol.asyncIterator]=="function";var pt=t=>typeof Response<"u"&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json;var gt=t=>typeof Blob<"u"&&t instanceof Blob,pg=t=>t&&typeof t=="object"&&t.isBuffer;var ib=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||mi(t)&&wn(t.tee)&&wn(t.cancel)&&wn(t.getReader);var sb=t=>mi(t)&&wn(t.read)&&wn(t.pipe)&&rb(t.readable),ec=t=>ib(t)||sb(t);var tc=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var nb=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ob=/^([-\w.]+\/[-\w.+]+)/;function Yu(t,e){return t.toLowerCase()===e.toLowerCase()}function gg(t){let e=ob.exec(t);return e?e[1]:t}function Ku(t){let e=nb.exec(t);return e?e[1]:""}var mg=/\?.*/;function _g(t){let e=t.match(mg);return e&&e[0]}function as(t){return t.replace(mg,"")}function xg(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function _i(t){return pt(t)?t.url:gt(t)?t.name||"":typeof t=="string"?t:""}function Pn(t){if(pt(t)){let e=t,r=e.headers.get("content-type")||"",i=as(e.url);return gg(r)||Ku(i)}return gt(t)?t.type||"":typeof t=="string"?Ku(t):""}function yg(t){return pt(t)?t.headers["content-length"]||-1:gt(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function rc(t){if(pt(t))return t;let e={},r=yg(t);r>=0&&(e["content-length"]=String(r));let i=_i(t),s=Pn(t);s&&(e["content-type"]=s);let n=await cb(t);n&&(e["x-first-bytes"]=n),typeof t=="string"&&(t=new TextEncoder().encode(t));let o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function bg(t){if(!t.ok)throw await ab(t)}async function ab(t){let e=xg(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let s=t.headers.get("Content-Type");i.reason=s?.includes("application/json")?await t.json():t.text()}catch{}return new tc(r,i)}async function cb(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let s=new FileReader;s.onload=n=>i(n?.target?.result),s.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${lb(r)}`}return null}function lb(t){let e="",r=new Uint8Array(t);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},sc=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Zu={fetch:null,mimeType:void 0,nothrow:!1,log:new sc,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:fi,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},vg={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Ju(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Qu(){let t=Ju();return t.globalOptions=t.globalOptions||{...Zu},t.globalOptions}function Sg(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],db(t,r),gb(e,t,i)}function db(t,e){Tg(t,null,Zu,vg,e);for(let r of e){let i=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Tg(i,r.id,s,n,e)}}function Tg(t,e,r,i,s){let n=e||"Top level",o=e?`${e}.`:"";for(let a in t){let c=!e&&mi(t[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in r)&&!l&&!u){if(a in i)Gu.warn(`${n} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c){let f=pb(a,s);Gu.warn(`${n} loader option '${o}${a}' not recognized. ${f}`)()}}}}function pb(t,e){let r=t.toLowerCase(),i="";for(let s of e)for(let n in s.options){if(t===n)return`Did you mean '${s.id}.${n}'?`;let o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(i=i||`Did you mean '${s.id}.${n}'?`)}return i}function gb(t,e,r){let s={...t.options||{}};return mb(s,r),s.log===null&&(s.log=new ic),Eg(s,Qu()),Eg(s,e),s}function Eg(t,e){for(let r in e)if(r in e){let i=e[r];$u(i)&&$u(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function mb(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}function Cn(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function Rn(t){Fr(t,"null loader"),Fr(Cn(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var Ag=()=>{let t=Ju();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function ef(t){let e=Ag();t=Array.isArray(t)?t:[t];for(let r of t){let i=Rn(r);e.find(s=>i===s)||e.unshift(i)}}function wg(){return Ag()}var Pg=new qe({id:"loaders.gl"});var _b=/\.([^.]+)$/;async function Mg(t,e=[],r,i){if(!Ig(t))return null;let s=Cg(t,e,{...r,nothrow:!0},i);if(s)return s;if(gt(t)&&(t=await t.slice(0,10).arrayBuffer(),s=Cg(t,e,r,i)),!s&&!r?.nothrow)throw new Error(Og(t));return s}function Cg(t,e=[],r,i){if(!Ig(t))return null;if(e&&!Array.isArray(e))return Rn(e);let s=[];e&&(s=s.concat(e)),r?.ignoreRegisteredLoaders||s.push(...wg()),yb(s);let n=xb(t,s,r,i);if(!n&&!r?.nothrow)throw new Error(Og(t));return n}function xb(t,e,r,i){let s=_i(t),n=Pn(t),o=as(s)||i?.url,a=null,c="";return r?.mimeType&&(a=tf(e,r?.mimeType),c=`match forced by supplied MIME type ${r?.mimeType}`),a=a||bb(e,o),c=c||(a?`matched url ${o}`:""),a=a||tf(e,n),c=c||(a?`matched MIME type ${n}`:""),a=a||Tb(e,t),c=c||(a?`matched initial data ${Ng(t)}`:""),r?.fallbackMimeType&&(a=a||tf(e,r?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&Pg.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Ig(t){return!(t instanceof Response&&t.status===204)}function Og(t){let e=_i(t),r=Pn(t),i="No valid loader found (";i+=e?`${gi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let s=t?Ng(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function yb(t){for(let e of t)Rn(e)}function bb(t,e){let r=e&&_b.exec(e),i=r&&r[1];return i?vb(t,i):null}function vb(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function tf(t,e){for(let r of t)if(r.mimeTypes?.some(i=>Yu(e,i))||Yu(e,`application/x.${r.id}`))return r;return null}function Tb(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(Eb(e,r))return r}else if(ArrayBuffer.isView(e)){if(Rg(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&Rg(e,0,r))return r;return null}function Eb(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function Rg(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>Sb(t,e,r,s))}function Sb(t,e,r,i){if(i instanceof ArrayBuffer)return Vu(i,t,i.byteLength);switch(typeof i){case"function":return i(t);case"string":let s=rf(t,e,i.length);return i===s;default:return!1}}function Ng(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?rf(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?rf(t,0,e):""}function rf(t,e,r){if(t.byteLengthqu(s,i.fetch):e?.fetch?e?.fetch:qu}function zg(t,e,r){if(r)return r;let i={fetch:nc(e,t),...t};if(i.url){let s=as(i.url);i.baseUrl=s,i.queryString=_g(i.url),i.filename=gi.filename(s),i.baseUrl=gi.dirname(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function Vg(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function Mn(t,e,r,i){e&&!Array.isArray(e)&&!Cn(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let s=_i(t),o=Vg(e,i),a=await Mg(t,o,r);return a?(r=Sg(r,a,o,s),i=zg({url:s,_parse:Mn,loaders:o},r,i||null),await Cb(a,t,r,i)):null}async function Cb(t,e,r,i){if(Bu(t),r=Ou(t.options,r),pt(e)){let n=e,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=n,h=Object.fromEntries(n.headers.entries());i.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}e=await Ug(e,t,r);let s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,r,i);if(Uu(t,r))return await zu(t,e,r,i,Mn);if(s.parseText&&typeof e=="string")return await s.parseText(e,r,i);if(s.parse)return await s.parse(e,r,i);throw je(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function Lr(t,e,r,i){let s,n;!Array.isArray(e)&&!Cn(e)?(s=[],n=e,i=void 0):(s=e,n=r);let o=nc(n),a=t;return typeof t=="string"&&(a=await o(t)),gt(t)&&(a=await o(t)),Array.isArray(s)?await Mn(a,s,n):await Mn(a,s,n)}var Wg="4.2.1";var Rb=globalThis.loaders?.parseImageNode,nf=typeof Image<"u",of=typeof ImageBitmap<"u",Mb=!!Rb,af=fi?!0:Mb;function Hg(t){switch(t){case"auto":return of||nf||af;case"imagebitmap":return of;case"image":return nf;case"data":return af;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function jg(){if(of)return"imagebitmap";if(nf)return"image";if(af)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Ib(t){let e=Ob(t);if(!e)throw new Error("Not an image");return e}function Xg(t){switch(Ib(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Ob(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var Nb=/^data:image\/svg\+xml/,Fb=/\.svg((\?|#).*)?$/;function oc(t){return t&&(Nb.test(t)||Fb.test(t))}function $g(t,e){if(oc(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return cf(t,e)}function cf(t,e){if(oc(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function ac(t,e,r){let i=$g(t,r),s=self.URL||self.webkitURL,n=typeof i!="string"&&s.createObjectURL(i);try{return await Db(n||i,e)}finally{n&&s.revokeObjectURL(n)}}async function Db(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=n=>{let o=n instanceof Error?n.message:"error";s(new Error(o))}}catch(n){s(n)}})}var Lb={},Yg=!0;async function Kg(t,e,r){let i;oc(r)?i=await ac(t,e,r):i=cf(t,r);let s=e&&e.imagebitmap;return await kb(i,s)}async function kb(t,e=null){if((Bb(e)||!Yg)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Yg=!1}return await createImageBitmap(t)}function Bb(t){for(let e in t||Lb)return!1;return!0}function qg(t){return!Wb(t,"ftyp",4)||!(t[8]&96)?null:Ub(t)}function Ub(t){switch(zb(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function zb(t,e,r){return String.fromCharCode(...t.slice(e,r))}function Vb(t){return[...t].map(e=>e.charCodeAt(0))}function Wb(t,e,r=0){let i=Vb(e);for(let s=0;s=24&&e.getUint32(0,Yt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Yt),height:e.getUint32(20,Yt)}:null}function Xb(t){let e=On(t);return e.byteLength>=10&&e.getUint32(0,Yt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,In),height:e.getUint16(8,In)}:null}function $b(t){let e=On(t);return e.byteLength>=14&&e.getUint16(0,Yt)===16973&&e.getUint32(2,In)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,In),height:e.getUint32(22,In)}:null}function Yb(t){let e=On(t);if(!(e.byteLength>=3&&e.getUint16(0,Yt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:s}=Kb(),n=2;for(;n+9!!cc(new DataView(t))],options:Jb};var Qb=new qe({id:"deck"}),U=Qb;var uf={};function Jg(t){uf=t}function ye(t,e,r,i){U.level>0&&uf[t]&&uf[t].call(null,e,r,i)}function ev(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var Qg={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:ev,parseTextSync:JSON.parse};function tv(){let t="9.0.16",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(U.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:U,_registerLoggers:Jg},ef([Qg,[lf,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var em=tv();function Kt(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var ff={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function rm(t){let e={};for(let[r,i]of Object.entries(t))e[r]=rv(i);return e}function im(t,e,r){let i={};for(let[s,n]of Object.entries(e))t&&s in t&&!n.private?(n.validate&&Kt(n.validate(t[s],n),`${r}: invalid ${s}`),i[s]=t[s]):i[s]=n.value;return i}function rv(t){let e=tm(t);if(e!=="object")return{value:t,...ff[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...ff[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=tm(t.value),{...t,...ff[e],type:e}):{type:"object",value:null};throw new Error("props")}function tm(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var sm=`#ifdef MODULE_LOGDEPTH +}`}function Gm(t,e=!0,r){let i=r||new Set;if(t){if(XT(t))i.add(t);else if(XT(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let n in t)Gm(t[n],e,i)}}return r===void 0?Array.from(i):[]}function XT(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Wm=()=>{},Qs=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&wr||typeof bc<"u"&&!wr}constructor(e){let{name:r,source:i,url:n}=e;Or(i||n),this.name=r,this.source=i,this.url=n,this.onMessage=Wm,this.onError=s=>console.log(s),this.worker=wr?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Wm,this.onError=Wm,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,r){r=r||Gm(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=WT({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new bc(i,{eval:!1})}else if(this.source)e=new bc(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var vA=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Qs.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(n,s,o)=>n.done(o),i=(n,s)=>n.error(s)){let n=new Promise(s=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:s}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new EA(r.name,e);e.onMessage=n=>r.onMessage(i,n.type,n.payload),e.onError=n=>r.onError(i,n),r.onStart(i);try{await i.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!wr||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},Qo=class t{props;workerPools=new Map;static _workerFarm;static isSupported(){return Qs.isSupported()}static getWorkerFarm(e={}){return t._workerFarm=t._workerFarm||new t({}),t._workerFarm.setProps(e),t._workerFarm}constructor(e){this.props={...ZF},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:n}=e,s=this.workerPools.get(r);return s||(s=new vA({name:r,source:i,url:n}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function jm(t,e={}){let r=e[t.id]||{},i=wr?`${t.id}-worker.js`:`${t.id}-worker-node.js`,n=r.workerUrl;if(!n&&t.id==="compression"&&(n=e.workerUrl),e._workerType==="test"&&(wr?n=`modules/${t.module}/dist/${i}`:n=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!n){let s=t.version;s==="latest"&&(s=zT);let o=s?`@${s}`:"";n=`https://unpkg.com/@loaders.gl/${t.module}${o}/dist/${i}`}return Or(n),n}function Xm(t,e=bA){Or(t,"no worker provided");let r=t.version;return!(!e||!r)}var Ym={};async function Ln(t,e=null,r={},i=null){return e&&(t=YT(t,e,r,i)),Ym[t]=Ym[t]||$F(t),await Ym[t]}function YT(t,e,r={},i=null){if(!r.useLocalLibraries&&t.startsWith("http"))return t;i=i||t;let n=r.modules||{};return n[i]?n[i]:wr?r.CDN?(Or(r.CDN.startsWith("http")),`${r.CDN}/${e}@${bA}/dist/libs/${i}`):TA?`../src/libs/${i}`:`modules/${e}/src/libs/${i}`:`modules/${e}/dist/libs/${i}`}async function $F(t){if(t.endsWith("wasm"))return await tL(t);if(!wr)try{let{requireFromFile:r}=globalThis.loaders||{};return await r?.(t)}catch(r){return console.error(r),null}if(TA)return importScripts(t);let e=await rL(t);return eL(e,t)}function eL(t,e){if(!wr){let{requireFromString:i}=globalThis.loaders||{};return i?.(t,e)}if(TA)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function tL(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};return wr||!e||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await e(t)}async function rL(t){let{readFileAsText:e}=globalThis.loaders||{};return wr||!e||t.startsWith("http")?await(await fetch(t)).text():await e(t)}function Qm(t,e){return!Qo.isSupported()||!wr&&!e?._nodeWorkers?!1:t.worker&&e?.worker}async function qm(t,e,r,i,n){let s=t.id,o=jm(t,r),A=Qo.getWorkerFarm(r).getWorkerPool({name:s,url:o});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let h=await A.startJob("process-on-worker",iL.bind(null,n));return h.postMessage("process",{input:e,options:r,context:i}),await(await h.result).result}async function iL(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:n,input:s,options:o}=i;try{let a=await t(s,o);e.postMessage("done",{id:n,result:a})}catch(a){let A=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:n,error:A})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function qT(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?QT(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?QT(t,0,e):""}function QT(t,e,r){if(t.byteLength<=e+r)return"";let i=new DataView(t),n="";for(let s=0;ss instanceof ArrayBuffer?new Uint8Array(s):s),r=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(r),n=0;for(let s of e)i.set(s,n),n+=s.byteLength;return i.buffer}function SA(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let i=e.reduce((o,a)=>o+a.length,0),n=new r(i),s=0;for(let o of e)n.set(o,s),s+=o.length;return n}function qo(t,e,r){let i=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(i).buffer}function qs(t,e){return at(t>=0),at(e>0),t+(e-1)&~(e-1)}function $m(t,e,r){let i;if(t instanceof ArrayBuffer)i=new Uint8Array(t);else{let n=t.byteOffset,s=t.byteLength;i=new Uint8Array(t.buffer||t.arrayBuffer,n,s)}return e.set(i,r),r+qs(i.byteLength,4)}async function e1(t){let e=[];for await(let r of t)e.push(r);return Zm(...e)}function wA(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Ko=class{constructor(e,r){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=r,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=wA(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(wA()-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)}};var Gr=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,n=this.stats[r];return n||(e instanceof Ko?n=e:n=new Ko(r,i),this.stats[r]=n),n}};var nL="Queued Requests",sL="Active Requests",oL="Cancelled Requests",aL="Queued Requests Ever",cL="Active Requests Ever",lL={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Ks=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...lL,...e},this.stats=new Gr({id:this.props.id}),this.stats.get(nL),this.stats.get(sL),this.stats.get(oL),this.stats.get(aL),this.stats.get(cL)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let i={handle:e,priority:0,getPriority:r},n=new Promise(s=>(i.resolve=s,i));return this.requestQueue.push(i),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){let{handle:r,resolve:i}=e,n=!1,s=()=>{n||(n=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:s}):Promise.resolve({done:s})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;rr.priority-i.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var AL="",JT={};function t1(t){for(let e in JT)if(t.startsWith(e)){let r=JT[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${AL}${t}`),t}function ZT(t){return t&&typeof t=="object"&&t.isBuffer}function Zh(t){if(ZT(t))return t;if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}var Ei={};dr(Ei,{dirname:()=>fL,filename:()=>uL,join:()=>hL,resolve:()=>dL});function $T(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function uL(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):""}function fL(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function hL(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function dL(...t){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(n===void 0&&(n=$T()),o=n),o.length!==0&&(r=`${o}/${r}`,i=o.charCodeAt(0)===CA)}return r=pL(r,!i),i?`/${r}`:r.length>0?r:"."}var CA=47,r1=46;function pL(t,e){let r="",i=-1,n=0,s,o=!1;for(let a=0;a<=t.length;++a){if(a2){let A=r.length-1,h=A;for(;h>=0&&r.charCodeAt(h)!==CA;--h);if(h!==A){r=h===-1?"":r.slice(0,h),i=a,n=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,n=0,o=!1;continue}}e&&(r.length>0?r+="/..":r="..",o=!0)}else{let A=t.slice(i+1,a);r.length>0?r+=`/${A}`:r=A,o=!1}i=a,n=0}else s===r1&&n!==-1?++n:n=-1}return r}var $h=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(e){this.props={...e},this.loadOptions={...e.loadOptions},this.fetch=gL(this.loadOptions)}setProps(e){this.props=Object.assign(this.props,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}};function gL(t){let e=t?.fetch;if(e&&typeof e=="function")return(i,n)=>e(i,n);let r=t?.fetch;return r&&typeof r!="function"?i=>fetch(i,r):i=>fetch(i)}var Nn=class extends $h{static type="template";static testURL=e=>!1};var mL=t=>typeof t=="boolean",MA=t=>typeof t=="function",Jo=t=>t!==null&&typeof t=="object",i1=t=>Jo(t)&&t.constructor==={}.constructor;var eE=t=>!!t&&typeof t[Symbol.iterator]=="function",tE=t=>t&&typeof t[Symbol.asyncIterator]=="function";var Li=t=>typeof Response<"u"&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json;var Ni=t=>typeof Blob<"u"&&t instanceof Blob,rE=t=>t&&typeof t=="object"&&t.isBuffer;var _L=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||Jo(t)&&MA(t.tee)&&MA(t.cancel)&&MA(t.getReader);var yL=t=>Jo(t)&&MA(t.read)&&MA(t.pipe)&&mL(t.readable),e0=t=>_L(t)||yL(t);var t0=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var xL=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,bL=/^([-\w.]+\/[-\w.+]+)/;function n1(t,e){return t.toLowerCase()===e.toLowerCase()}function iE(t){let e=bL.exec(t);return e?e[1]:t}function s1(t){let e=xL.exec(t);return e?e[1]:""}var nE=/\?.*/;function sE(t){let e=t.match(nE);return e&&e[0]}function Tc(t){return t.replace(nE,"")}function oE(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Zo(t){return Li(t)?t.url:Ni(t)?t.name||"":typeof t=="string"?t:""}function PA(t){if(Li(t)){let e=t,r=e.headers.get("content-type")||"",i=Tc(e.url);return iE(r)||s1(i)}return Ni(t)?t.type||"":typeof t=="string"?s1(t):""}function aE(t){return Li(t)?t.headers["content-length"]||-1:Ni(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function r0(t){if(Li(t))return t;let e={},r=aE(t);r>=0&&(e["content-length"]=String(r));let i=Zo(t),n=PA(t);n&&(e["content-type"]=n);let s=await EL(t);s&&(e["x-first-bytes"]=s),typeof t=="string"&&(t=new TextEncoder().encode(t));let o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function cE(t){if(!t.ok)throw await TL(t)}async function TL(t){let e=oE(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let n=t.headers.get("Content-Type");i.reason=n?.includes("application/json")?await t.json():t.text()}catch{}return new t0(r,i)}async function EL(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let n=new FileReader;n.onload=s=>i(s?.target?.result),n.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${vL(r)}`}return null}function vL(t){let e="",r=new Uint8Array(t);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},n0=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var c1={fetch:null,mimeType:void 0,nothrow:!1,log:new n0,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:As,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},lE={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function l1(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function A1(){let t=l1();return t.globalOptions=t.globalOptions||{...c1},t.globalOptions}function fE(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],ML(t,r),IL(e,t,i)}function ML(t,e){AE(t,null,c1,lE,e);for(let r of e){let i=t&&t[r.id]||{},n=r.options&&r.options[r.id]||{},s=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};AE(i,r.id,n,s,e)}}function AE(t,e,r,i,n){let s=e||"Top level",o=e?`${e}.`:"";for(let a in t){let A=!e&&Jo(t[a]),h=a==="baseUri"&&!e,g=a==="workerUrl"&&e;if(!(a in r)&&!h&&!g){if(a in i)a1.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!A){let _=PL(a,n);a1.warn(`${s} loader option '${o}${a}' not recognized. ${_}`)()}}}}function PL(t,e){let r=t.toLowerCase(),i="";for(let n of e)for(let s in n.options){if(t===s)return`Did you mean '${n.id}.${s}'?`;let o=s.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(i=i||`Did you mean '${n.id}.${s}'?`)}return i}function IL(t,e,r){let n={...t.options||{}};return RL(n,r),n.log===null&&(n.log=new i0),uE(n,A1()),uE(n,e),n}function uE(t,e){for(let r in e)if(r in e){let i=e[r];i1(i)&&i1(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function RL(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}function IA(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function RA(t){at(t,"null loader"),at(IA(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var hE=()=>{let t=l1();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function u1(t){let e=hE();t=Array.isArray(t)?t:[t];for(let r of t){let i=RA(r);e.find(n=>i===n)||e.unshift(i)}}function dE(){return hE()}var pE=new ui({id:"loaders.gl"});var BL=/\.([^.]+)$/;async function _E(t,e=[],r,i){if(!yE(t))return null;let n=gE(t,e,{...r,nothrow:!0},i);if(n)return n;if(Ni(t)&&(t=await t.slice(0,10).arrayBuffer(),n=gE(t,e,r,i)),!n&&!r?.nothrow)throw new Error(xE(t));return n}function gE(t,e=[],r,i){if(!yE(t))return null;if(e&&!Array.isArray(e))return RA(e);let n=[];e&&(n=n.concat(e)),r?.ignoreRegisteredLoaders||n.push(...dE()),FL(n);let s=OL(t,n,r,i);if(!s&&!r?.nothrow)throw new Error(xE(t));return s}function OL(t,e,r,i){let n=Zo(t),s=PA(t),o=Tc(n)||i?.url,a=null,A="";return r?.mimeType&&(a=f1(e,r?.mimeType),A=`match forced by supplied MIME type ${r?.mimeType}`),a=a||LL(e,o),A=A||(a?`matched url ${o}`:""),a=a||f1(e,s),A=A||(a?`matched MIME type ${s}`:""),a=a||DL(e,t),A=A||(a?`matched initial data ${bE(t)}`:""),r?.fallbackMimeType&&(a=a||f1(e,r?.fallbackMimeType),A=A||(a?`matched fallback MIME type ${s}`:"")),A&&pE.log(1,`selectLoader selected ${a?.name}: ${A}.`),a}function yE(t){return!(t instanceof Response&&t.status===204)}function xE(t){let e=Zo(t),r=PA(t),i="No valid loader found (";i+=e?`${Ei.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let n=t?bE(t):"";return i+=n?` first bytes: "${n}"`:"first bytes: not available",i+=")",i}function FL(t){for(let e of t)RA(e)}function LL(t,e){let r=e&&BL.exec(e),i=r&&r[1];return i?NL(t,i):null}function NL(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function f1(t,e){for(let r of t)if(r.mimeTypes?.some(i=>n1(e,i))||n1(e,`application/x.${r.id}`))return r;return null}function DL(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(UL(e,r))return r}else if(ArrayBuffer.isView(e)){if(mE(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&mE(e,0,r))return r;return null}function UL(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function mE(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>kL(t,e,r,n))}function kL(t,e,r,i){if(i instanceof ArrayBuffer)return Jm(i,t,i.byteLength);switch(typeof i){case"function":return i(t);case"string":let n=h1(t,e,i.length);return i===n;default:return!1}}function bE(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?h1(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?h1(t,0,e):""}function h1(t,e,r){if(t.byteLengtho1(n,i.fetch):e?.fetch?e?.fetch:o1}function ME(t,e,r){if(r)return r;let i={fetch:s0(e,t),...t};if(i.url){let n=Tc(i.url);i.baseUrl=n,i.queryString=sE(i.url),i.filename=Ei.filename(n),i.baseUrl=Ei.dirname(n)}return Array.isArray(i.loaders)||(i.loaders=null),i}function PE(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function BA(t,e,r,i){e&&!Array.isArray(e)&&!IA(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let n=Zo(t),o=PE(e,i),a=await _E(t,o,r);return a?(r=fE(r,a,o,n),i=ME({url:n,_parse:BA,loaders:o},r,i||null),await WL(a,t,r,i)):null}async function WL(t,e,r,i){if(Xm(t),r=xA(t.options,r),Li(e)){let s=e,{ok:o,redirected:a,status:A,statusText:h,type:g,url:_}=s,x=Object.fromEntries(s.headers.entries());i.response={headers:x,ok:o,redirected:a,status:A,statusText:h,type:g,url:_}}e=await CE(e,t,r);let n=t;if(n.parseTextSync&&typeof e=="string")return n.parseTextSync(e,r,i);if(Qm(t,r))return await qm(t,e,r,i,BA);if(n.parseText&&typeof e=="string")return await n.parseText(e,r,i);if(n.parse)return await n.parse(e,r,i);throw Or(!n.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}function IE(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function us(t){let e=1/0,r=1/0,i=1/0,n=-1/0,s=-1/0,o=-1/0,a=t.POSITION?t.POSITION.value:[],A=a&&a.length;for(let h=0;hn?g:n,s=_>s?_:s,o=x>o?x:o}return[[e,r,i],[n,s,o]]}function p1(t,e,r){let i=IE(e.value),n=r||RE(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:i}]},nullable:!1,metadata:n}}function RE(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}async function Cr(t,e,r,i){let n,s;!Array.isArray(e)&&!IA(e)?(n=[],s=e,i=void 0):(n=e,s=r);let o=s0(s),a=t;return typeof t=="string"&&(a=await o(t)),Ni(t)&&(a=await o(t)),Array.isArray(n)?await BA(a,n,s):await BA(a,n,s)}var BE="4.2.1";var jL=globalThis.loaders?.parseImageNode,g1=typeof Image<"u",m1=typeof ImageBitmap<"u",XL=!!jL,_1=As?!0:XL;function OE(t){switch(t){case"auto":return m1||g1||_1;case"imagebitmap":return m1;case"image":return g1;case"data":return _1;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function FE(){if(m1)return"imagebitmap";if(g1)return"image";if(_1)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function LE(t){let e=YL(t);if(!e)throw new Error("Not an image");return e}function OA(t){switch(LE(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function YL(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var QL=/^data:image\/svg\+xml/,qL=/\.svg((\?|#).*)?$/;function o0(t){return t&&(QL.test(t)||qL.test(t))}function NE(t,e){if(o0(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return y1(t,e)}function y1(t,e){if(o0(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function a0(t,e,r){let i=NE(t,r),n=self.URL||self.webkitURL,s=typeof i!="string"&&n.createObjectURL(i);try{return await KL(s||i,e)}finally{s&&n.revokeObjectURL(s)}}async function KL(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,n)=>{try{r.onload=()=>i(r),r.onerror=s=>{let o=s instanceof Error?s.message:"error";n(new Error(o))}}catch(s){n(s)}})}var JL={},DE=!0;async function UE(t,e,r){let i;o0(r)?i=await a0(t,e,r):i=y1(t,r);let n=e&&e.imagebitmap;return await ZL(i,n)}async function ZL(t,e=null){if(($L(e)||!DE)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),DE=!1}return await createImageBitmap(t)}function $L(t){for(let e in t||JL)return!1;return!0}function kE(t){return!iN(t,"ftyp",4)||!(t[8]&96)?null:eN(t)}function eN(t){switch(tN(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function tN(t,e,r){return String.fromCharCode(...t.slice(e,r))}function rN(t){return[...t].map(e=>e.charCodeAt(0))}function iN(t,e,r=0){let i=rN(e);for(let n=0;n=24&&e.getUint32(0,Dn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Dn),height:e.getUint32(20,Dn)}:null}function oN(t){let e=LA(t);return e.byteLength>=10&&e.getUint32(0,Dn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,FA),height:e.getUint16(8,FA)}:null}function aN(t){let e=LA(t);return e.byteLength>=14&&e.getUint16(0,Dn)===16973&&e.getUint32(2,FA)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,FA),height:e.getUint32(22,FA)}:null}function cN(t){let e=LA(t);if(!(e.byteLength>=3&&e.getUint16(0,Dn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:n}=lN(),s=2;for(;s+9!!$o(new DataView(t))],options:hN};var x1={};function b1(t){if(x1[t]===void 0){let e=As?pN(t):dN(t);x1[t]=e}return x1[t]}function dN(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e;return!!globalThis.loaders?.parseImageNode&&r.includes(t)}function pN(t){switch(t){case"image/avif":case"image/webp":return gN(t);default:return!0}}function gN(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var mN=new ui({id:"deck"}),me=mN;var T1={};function HE(t){T1=t}function Zt(t,e,r,i){me.level>0&&T1[t]&&T1[t].call(null,e,r,i)}function _N(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var GE={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:_N,parseTextSync:JSON.parse};function yN(){let t="9.0.16",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(me.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:me,_registerLoggers:HE},u1([GE,[Un,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var WE=yN();function kn(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var E1={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function XE(t){let e={};for(let[r,i]of Object.entries(t))e[r]=xN(i);return e}function YE(t,e,r){let i={};for(let[n,s]of Object.entries(e))t&&n in t&&!s.private?(s.validate&&kn(s.validate(t[n],s),`${r}: invalid ${n}`),i[n]=t[n]):i[n]=s.value;return i}function xN(t){let e=jE(t);if(e!=="object")return{value:t,...E1[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...E1[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=jE(t.value),{...t,...E1[e],type:e}):{type:"object",value:null};throw new Error("props")}function jE(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var QE=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif -`,nm=`#ifdef MODULE_MATERIAL +`,qE=`#ifdef MODULE_MATERIAL gl_FragColor = material_filterColor(gl_FragColor); #endif #ifdef MODULE_LIGHTING @@ -25,14 +31,14 @@ gl_FragColor = picking_filterPickingColor(gl_FragColor); #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif -`;var iv={vertex:sm,fragment:nm},om=/void\s+main\s*\([^)]*\)\s*\{\n?/,am=/}\n?[^{}]*$/,hf=[],Nn="__LUMA_INJECT_DECLARATIONS__";function cm(t){let e={vertex:{},fragment:{}};for(let r in t){let i=t[r],s=sv(r);typeof i=="string"&&(i={order:0,injection:i}),e[s][r]=i}return e}function sv(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function Fn(t,e,r,i=!1){let s=e==="vertex";for(let n in r){let o=r[n];o.sort((c,l)=>c.order-l.order),hf.length=o.length;for(let c=0,l=o.length;cA.order-h.order),v1.length=o.length;for(let A=0,h=o.length;Ac+a));break;case"vs:#main-end":s&&(t=t.replace(am,c=>a+c));break;case"fs:#decl":s||(t=t.replace(Nn,a));break;case"fs:#main-start":s||(t=t.replace(om,c=>c+a));break;case"fs:#main-end":s||(t=t.replace(am,c=>a+c));break;default:t=t.replace(n,c=>c+a)}}return t=t.replace(Nn,""),i&&(t=t.replace(/\}\s*$/,n=>n+iv[e])),t}var nv=1,cs=class t{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof t)return r;Kt(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${nv++}`);let i=new t(r);return i.dependencies=t.instantiateModules(r.dependencies||[]),i})}constructor(e){let{name:r,vs:i,fs:s,dependencies:n=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:c,deprecations:l=[],defines:u={},inject:f={}}=e;Kt(typeof r=="string"),this.name=r,this.vs=i,this.fs=s,this.getModuleUniforms=c,this.dependencies=t.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=u,this.injections=cm(f),this.uniformTypes=o,a&&(this.uniforms=rm(a))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:Kt(!1)}let i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} --------------- +`;switch(s){case"vs:#decl":n&&(t=t.replace(NA,a));break;case"vs:#main-start":n&&(t=t.replace(KE,A=>A+a));break;case"vs:#main-end":n&&(t=t.replace(JE,A=>a+A));break;case"fs:#decl":n||(t=t.replace(NA,a));break;case"fs:#main-start":n||(t=t.replace(KE,A=>A+a));break;case"fs:#main-end":n||(t=t.replace(JE,A=>a+A));break;default:t=t.replace(s,A=>A+a)}}return t=t.replace(NA,""),i&&(t=t.replace(/\}\s*$/,s=>s+bN[e])),t}var EN=1,Ec=class t{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof t)return r;kn(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${EN++}`);let i=new t(r);return i.dependencies=t.instantiateModules(r.dependencies||[]),i})}constructor(e){let{name:r,vs:i,fs:n,dependencies:s=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:A,deprecations:h=[],defines:g={},inject:_={}}=e;kn(typeof r=="string"),this.name=r,this.vs=i,this.fs=n,this.getModuleUniforms=A,this.dependencies=t.instantiateModules(s),this.deprecations=this._parseDeprecationDefinitions(h),this.defines=g,this.injections=ZE(_),this.uniformTypes=o,a&&(this.uniforms=XE(a))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:kn(!1)}let i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} --------------- #define MODULE_${i} ${r} -`}getUniforms(e,r){return this.getModuleUniforms?this.getModuleUniforms(e,r):im(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,r){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(e={}){let r={},i=this.uniforms;for(let s in i){let n=i[s];s in e&&!n.private?(n.validate&&Kt(n.validate(e[s],n),`${this.name}: invalid ${s}`),r[s]=e[s]):r[s]=n.value}return r}};function df(t){if(t.source&&t.platformInfo.type==="webgpu")return{...t,vs:void 0,fs:void 0};if(!t.vs)throw new Error("no vertex shader");let e=lm(t.platformInfo,t.vs),r;return t.fs&&(r=lm(t.platformInfo,t.fs)),{...t,vs:e,fs:r}}function lm(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function xi(t){let e=cs.instantiateModules(t);return ov(e)}function ov(t){let e={},r={};return um({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((i,s)=>r[s]-r[i]).map(i=>e[i])}function um(t){let{modules:e,level:r,moduleMap:i,moduleDepth:s}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of e)i[n.name]=n,(s[n.name]===void 0||s[n.name]{i.regex?.test(e)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(e={}){let r={},i=this.uniforms;for(let n in i){let s=i[n];n in e&&!s.private?(s.validate&&kn(s.validate(e[n],s),`${this.name}: invalid ${n}`),r[n]=e[n]):r[n]=s.value}return r}};function S1(t){if(t.source&&t.platformInfo.type==="webgpu")return{...t,vs:void 0,fs:void 0};if(!t.vs)throw new Error("no vertex shader");let e=$E(t.platformInfo,t.vs),r;return t.fs&&(r=$E(t.platformInfo,t.fs)),{...t,vs:e,fs:r}}function $E(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function ea(t){let e=Ec.instantiateModules(t);return vN(e)}function vN(t){let e={},r={};return ev({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((i,n)=>r[n]-r[i]).map(i=>e[i])}function ev(t){let{modules:e,level:r,moduleMap:i,moduleDepth:n}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(n[s.name]===void 0||n[s.name]o.order-a.order);for(let o of n)r+=` ${o.injection} -`}s.footer&&(r+=` ${s.footer}`),r+=`} -`}return r}function mf(t){let e={vertex:{},fragment:{}};for(let r of t){let i,s;typeof r!="string"?(i=r,s=i.hook):(i={},s=r),s=s.trim();let[n,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(i,{signature:o});switch(n){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(n)}}return e}function gm(t,e){return{name:lv(t,e),language:"glsl",version:uv(t)}}function lv(t,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return i?i[1]:e}function uv(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var _m=` - -${Nn} -`,fv=`precision highp float; -`;function xm(t){let e=xi(t.modules||[]);return{source:_f(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:xf(e)}}function ym(t){let e=xi(t.modules||[]);return{vs:_f(t.platformInfo,{...t,source:t.vs,stage:"vertex",modules:e}),fs:_f(t.platformInfo,{...t,source:t.fs,stage:"fragment",modules:e}),getUniforms:xf(e)}}function bm(t){let{vs:e,fs:r}=t,i=xi(t.modules||[]);return{vs:mm(t.platformInfo,{...t,source:e,stage:"vertex",modules:i}),fs:mm(t.platformInfo,{...t,source:r,stage:"fragment",modules:i}),getUniforms:xf(i)}}function _f(t,e){let{source:r,stage:i,modules:s,hookFunctions:n=[],inject:o={},log:a}=e;Kt(typeof r=="string","shader source must be a string");let c=r,l="",u=mf(n),f={},h={},d={};for(let g in o){let _=typeof o[g]=="string"?{injection:o[g],order:0}:o[g],y=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(y){let v=y[2],T=y[3];v?T==="decl"?h[g]=[_]:d[g]=[_]:f[g]=[_]}else d[g]=[_]}let p=t.type!=="webgpu"?s:[];for(let g of p){a&&g.checkDeprecations(c,a);let _=g.getModuleSource(i,"wgsl");l+=_;let y=g.injections[i];for(let v in y){let T=/^(v|f)s:#([\w-]+)$/.exec(v);if(T){let R=T[2]==="decl"?h:d;R[v]=R[v]||[],R[v].push(y[v])}else f[v]=f[v]||[],f[v].push(y[v])}}return l+=_m,l=Fn(l,i,h),l+=gf(u[i],f),l+=c,l=Fn(l,i,d),l}function mm(t,e){let{id:r,source:i,stage:s,language:n="glsl",modules:o,defines:a={},hookFunctions:c=[],inject:l={},prologue:u=!0,log:f}=e;Kt(typeof i=="string","shader source must be a string");let h=n==="glsl"?gm(i).version:-1,d=t.shaderLanguageVersion,p=h===100?"#version 100":"#version 300 es",_=i.split(` +`}}function iv(t,e){if(Number(t.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=rv(t,SN),t;case"fragment":return t=rv(t,wN),t;default:throw new Error(e)}}var nv=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],SN=[...nv,[w1("attribute"),"in $1"],[w1("varying"),"out $1"]],wN=[...nv,[w1("varying"),"in $1"]];function rv(t,e){for(let[r,i]of e)t=t.replace(r,i);return t}function w1(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function C1(t,e){let r="";for(let i in t){let n=t[i];if(r+=`void ${n.signature} { +`,n.header&&(r+=` ${n.header}`),e[i]){let s=e[i];s.sort((o,a)=>o.order-a.order);for(let o of s)r+=` ${o.injection} +`}n.footer&&(r+=` ${n.footer}`),r+=`} +`}return r}function M1(t){let e={vertex:{},fragment:{}};for(let r of t){let i,n;typeof r!="string"?(i=r,n=i.hook):(i={},n=r),n=n.trim();let[s,o]=n.split(":"),a=n.replace(/\(.+/,""),A=Object.assign(i,{signature:o});switch(s){case"vs":e.vertex[a]=A;break;case"fs":e.fragment[a]=A;break;default:throw new Error(s)}}return e}function sv(t,e){return{name:CN(t,e),language:"glsl",version:MN(t)}}function CN(t,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return i?i[1]:e}function MN(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var av=` + +${NA} +`,PN=`precision highp float; +`;function cv(t){let e=ea(t.modules||[]);return{source:P1(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:I1(e)}}function lv(t){let e=ea(t.modules||[]);return{vs:P1(t.platformInfo,{...t,source:t.vs,stage:"vertex",modules:e}),fs:P1(t.platformInfo,{...t,source:t.fs,stage:"fragment",modules:e}),getUniforms:I1(e)}}function Av(t){let{vs:e,fs:r}=t,i=ea(t.modules||[]);return{vs:ov(t.platformInfo,{...t,source:e,stage:"vertex",modules:i}),fs:ov(t.platformInfo,{...t,source:r,stage:"fragment",modules:i}),getUniforms:I1(i)}}function P1(t,e){let{source:r,stage:i,modules:n,hookFunctions:s=[],inject:o={},log:a}=e;kn(typeof r=="string","shader source must be a string");let A=r,h="",g=M1(s),_={},x={},T={};for(let S in o){let C=typeof o[S]=="string"?{injection:o[S],order:0}:o[S],M=/^(v|f)s:(#)?([\w-]+)$/.exec(S);if(M){let R=M[2],B=M[3];R?B==="decl"?x[S]=[C]:T[S]=[C]:_[S]=[C]}else T[S]=[C]}let v=t.type!=="webgpu"?n:[];for(let S of v){a&&S.checkDeprecations(A,a);let C=S.getModuleSource(i,"wgsl");h+=C;let M=S.injections[i];for(let R in M){let B=/^(v|f)s:#([\w-]+)$/.exec(R);if(B){let Q=B[2]==="decl"?x:T;Q[R]=Q[R]||[],Q[R].push(M[R])}else _[R]=_[R]||[],_[R].push(M[R])}}return h+=av,h=DA(h,i,x),h+=C1(g[i],_),h+=A,h=DA(h,i,T),h}function ov(t,e){let{id:r,source:i,stage:n,language:s="glsl",modules:o,defines:a={},hookFunctions:A=[],inject:h={},prologue:g=!0,log:_}=e;kn(typeof i=="string","shader source must be a string");let x=s==="glsl"?sv(i).version:-1,T=t.shaderLanguageVersion,v=x===100?"#version 100":"#version 300 es",C=i.split(` `).slice(1).join(` -`),y={};o.forEach(F=>{Object.assign(y,F.getDefines())}),Object.assign(y,a);let v="";switch(n){case"wgsl":break;case"glsl":v=u?`${p} +`),M={};o.forEach(re=>{Object.assign(M,re.getDefines())}),Object.assign(M,a);let R="";switch(s){case"wgsl":break;case"glsl":R=g?`${v} // ----- PROLOGUE ------------------------- -${hv({id:r,source:i,stage:s})} -${`#define SHADER_TYPE_${s.toUpperCase()}`} -${fm(t)} -${s==="fragment"?fv:""} +${IN({id:r,source:i,stage:n})} +${`#define SHADER_TYPE_${n.toUpperCase()}`} +${tv(t)} +${n==="fragment"?PN:""} // ----- APPLICATION DEFINES ------------------------- -${dv(y)} +${RN(M)} -`:`${p} -`;break}let T=mf(c),S={},R={},M={};for(let F in l){let N=typeof l[F]=="string"?{injection:l[F],order:0}:l[F],D=/^(v|f)s:(#)?([\w-]+)$/.exec(F);if(D){let L=D[2],Y=D[3];L?Y==="decl"?R[F]=[N]:M[F]=[N]:S[F]=[N]}else M[F]=[N]}for(let F of o){f&&F.checkDeprecations(_,f);let N=F.getModuleSource(s);v+=N;let D=F.injections[s];for(let L in D){let Y=/^(v|f)s:#([\w-]+)$/.exec(L);if(Y){let $=Y[2]==="decl"?R:M;$[L]=$[L]||[],$[L].push(D[L])}else S[L]=S[L]||[],S[L].push(D[L])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=_m,v=Fn(v,s,R),v+=gf(T[s],S),v+=_,v=Fn(v,s,M),n==="glsl"&&h!==d&&(v=dm(v,s)),v.trim()}function xf(t){return function(r){let i={};for(let s of t){let n=s.getUniforms(r,i);Object.assign(i,n)}return i}}function hv(t){let{id:e,source:r,stage:i}=t;return e&&r.indexOf("SHADER_NAME")===-1?` +`:`${v} +`;break}let B=M1(A),k={},Q={},$={};for(let re in h){let Y=typeof h[re]=="string"?{injection:h[re],order:0}:h[re],H=/^(v|f)s:(#)?([\w-]+)$/.exec(re);if(H){let L=H[2],ae=H[3];L?ae==="decl"?Q[re]=[Y]:$[re]=[Y]:k[re]=[Y]}else $[re]=[Y]}for(let re of o){_&&re.checkDeprecations(C,_);let Y=re.getModuleSource(n);R+=Y;let H=re.injections[n];for(let L in H){let ae=/^(v|f)s:#([\w-]+)$/.exec(L);if(ae){let he=ae[2]==="decl"?Q:$;he[L]=he[L]||[],he[L].push(H[L])}else k[L]=k[L]||[],k[L].push(H[L])}}return R+="// ----- MAIN SHADER SOURCE -------------------------",R+=av,R=DA(R,n,Q),R+=C1(B[n],k),R+=C,R=DA(R,n,$),s==="glsl"&&x!==T&&(R=iv(R,n)),R.trim()}function I1(t){return function(r){let i={};for(let n of t){let s=n.getUniforms(r,i);Object.assign(i,s)}return i}}function IN(t){let{id:e,source:r,stage:i}=t;return e&&r.indexOf("SHADER_NAME")===-1?` #define SHADER_NAME ${e}_${i} -`:""}function dv(t={}){let e="";for(let r in t){let i=t[r];(i||Number.isFinite(i))&&(e+=`#define ${r.toUpperCase()} ${t[r]} -`)}return e}var yi=class t{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return t.defaultShaderAssembler=t.defaultShaderAssembler||new t,t.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let r=this._getModuleList(e.modules),i=this._hookFunctions,s=df(e);return{...xm({platformInfo:e.platformInfo,...s,modules:r,hookFunctions:i}),modules:r}}assembleShaderPair(e){let r=df(e),i=this._getModuleList(e.modules),s=this._hookFunctions,{platformInfo:n}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?ym({platformInfo:n,...r,modules:i,hookFunctions:s}):bm({platformInfo:n,...r,modules:i,hookFunctions:s}),modules:i}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),i={},s=0;for(let n=0,o=this._defaultModules.length;nr.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let r=this._getModuleList(e.modules),i=this._hookFunctions,n=S1(e);return{...cv({platformInfo:e.platformInfo,...n,modules:r,hookFunctions:i}),modules:r}}assembleShaderPair(e){let r=S1(e),i=this._getModuleList(e.modules),n=this._hookFunctions,{platformInfo:s}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?lv({platformInfo:s,...r,modules:i,hookFunctions:n}):Av({platformInfo:s,...r,modules:i,hookFunctions:n}),modules:i}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),i={},n=0;for(let s=0,o=this._defaultModules.length;st.startsWith(e))}function uc(t){let e=Ev.exec(t);if(e){let[,r,i,s,n,o]=e;if(r){let a=`${s}${i}`,c=lc(a);return{format:r,components:r.length,srgb:n==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...c}}}return Av(t)}var Sv={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function Av(t){let e=Sv[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var Ln=class{},kn=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},hr=class t{static defaultProps={id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:!!O.get("debug"),spector:!!(O.get("spector")||O.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>O.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=Tm;constructor(e){this.props={...t.defaultProps,...e},this.id=this.props.id||Fe(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=ls;_lumaData={};isTextureFormatCompressed(e){return Sm(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&ie.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":O.warn("indices buffer content must be of integer type")()),r}};function ee(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var Bn=new Map,dr=class t{static defaultProps={...hr.defaultProps,type:"best-available",devices:void 0};static stats=ls;static log=O;static registerDevices(e){for(let r of e)ee(r.type&&r.isSupported&&r.create),Bn.set(r.type,r)}static getAvailableDevices(){return Array.from(Bn).map(e=>e.type)}static getSupportedDevices(){return Array.from(Bn).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(hr.defaultProps,e)}static async attachDevice(e){let r=Am(e.devices)||Bn;if(e.handle instanceof WebGL2RenderingContext){let i=r.get("webgl");if(i)return await i.attach(e.handle)}if(e.handle===null){let i=r.get("unknown");if(i)return await i.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){e={...t.defaultProps,...e},e.gl&&(e.type="webgl");let r=Am(e.devices)||Bn;switch(e.type){case"webgpu":let i=r.get("webgpu");if(i)return await i.create(e);break;case"webgl":let s=r.get("webgl");if(s)return await s.create(e);break;case"unknown":let n=r.get("unknown");if(n)return await n.create(e);break;case"best-available":if(i=r.get("webgpu"),i?.isSupported?.())return await i.create(e);if(s=r.get("webgl"),s?.isSupported?.())return await s.create(e);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){let r=HTMLCanvasElement.prototype;if(!e&&r.originalGetContext){r.getContext=r.originalGetContext,r.originalGetContext=void 0;return}r.originalGetContext=r.getContext,r.getContext=function(i,s){return i==="webgl"||i==="experimental-webgl"?this.originalGetContext("webgl2",s):this.originalGetContext(i,s)}}};function Am(t){if(!t||t?.length===0)return null;let e=new Map;for(let r of t)e.set(r.type,r);return e}var wv=ke()&&typeof document<"u",fc=()=>wv&&document.readyState==="complete",Pv={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},bi=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return fc()}static pageLoaded=Cv();constructor(e){if(this.props={...Pv,...e},e=this.props,!ke()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Mv(e.canvas):this.canvas=e.canvas;else{let r=Iv(e),i=Rv(e?.container||null);i.insertBefore(r,i.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let i of r)i.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[s,n]=this.getDrawingBufferSize();return Ov(e,i,s,n,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let i="width"in r?r.width:this.htmlCanvas.clientWidth,s="height"in r?r.height:this.htmlCanvas.clientHeight;(!i||!s)&&(O.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,s=this.htmlCanvas.height||1);let n=this._canvasSizeInfo;if(n.clientWidth!==i||n.clientHeight!==s||n.devicePixelRatio!==e){let o=e,a=Math.floor(i*o),c=Math.floor(s*o);this.htmlCanvas.width=a,this.htmlCanvas.height=c;let[l,u]=this.getDrawingBufferSize();(l!==a||u!==c)&&(o=Math.min(l/i,u/s),this.htmlCanvas.width=Math.floor(i*o),this.htmlCanvas.height=Math.floor(s*o),O.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=s,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};function Cv(){return fc()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function Rv(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!fc())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function Mv(t){let e=document.getElementById(t);if(!e&&!fc())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function Iv(t){let{width:e,height:r}=t,i=document.createElement("canvas");return i.id="lumagl-auto-created-canvas",i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",i}function Ov(t,e,r,i,s){let n=t,o=wm(n[0],e,r),a=Pm(n[1],e,i,s),c=wm(n[0]+1,e,r),l=c===r-1?c:c-1;c=Pm(n[1]+1,e,i,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function wm(t,e,r){return Math.min(Math.round(t*e),r-1)}function Pm(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var Se=class t extends Q{static defaultProps={...Q.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,i=t.defaultProps){super(e,r,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}};var vi=class t extends Q{static defaultProps={...Q.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,t.defaultProps)}};function Rm(t,e,r){let i="",s=e.split(/\r?\n/),n=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(i+=Mm(s[a-1],a,r);n.length>o&&n[o].lineNum===a;){let c=n[o++];i+=Cm(c,s,c.lineNum,{...r,inlineSource:!1})}return i;case"issues":case"no":for(let a of t)i+=Cm(a,s,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function Cm(t,e,r,i){if(i?.inlineSource){let s=Nv(e,r),n=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ + ${i} = ${s}; +}`}function FN(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function uv(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var le=new ui({id:"luma.gl"});var R1=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Gr({id:e})),this.stats.get(e)}},vc=new R1;function LN(){let t="9.0.14",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${t}`);return globalThis.luma||(Hr()&&le.log(1,`${t} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:le,stats:vc}),t}var fv=LN();function NN(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function Js(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:NN(t)}var B1={};function pr(t="id"){B1[t]=B1[t]||1;let e=B1[t]++;return`${t}-${e}`}function Zs(t){let e=!0;for(let r in t){e=!1;break}return e}var Ke=class{static defaultProps={id:"undefined",handle:void 0,userData:void 0};id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,r,i){if(!e)throw new Error("no device");this._device=e,this.props=DN(r,i);let n=this.props.id!=="undefined"?this.props.id:pr(this[Symbol.toStringTag]);this.props.id=n,this.id=n,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}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(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e,r=this[Symbol.toStringTag]){let i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};function DN(t,e){let r={...e};for(let i in t)t[i]!==void 0&&(r[i]=t[i]);return r}var gt=class t extends Ke{static defaultProps={...Ke.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1};static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let i={...r};(r.usage||0)&t.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array&&(i.indexType="uint16")),super(e,i,t.defaultProps),this.usage=r.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}readSyncWebGL(e,r){throw new Error("not implemented")}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,r,i){let n=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:i,t.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):r===0&&i===e.byteLength?this.debugData=n.slice(0,s):this.debugData=n.slice(r,r+s)}};function c0(t){let e=hv[t],r=UN(e),i=t.includes("norm"),n=!i&&!t.startsWith("float"),s=t.startsWith("s");return{dataType:hv[t],byteLength:r,integer:n,signed:s,normalized:i}}function UN(t){return kN[t]}var hv={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},kN={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var VN=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],zN=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function dv(t){return VN.some(e=>t.startsWith(e))}function l0(t){let e=zN.exec(t);if(e){let[,r,i,n,s,o]=e;if(r){let a=`${n}${i}`,A=c0(a);return{format:r,components:r.length,srgb:s==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...A}}}return GN(t)}var HN={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function GN(t){let e=HN[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var kA=class{},VA=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},fs=class t{static defaultProps={id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:!!le.get("debug"),spector:!!(le.get("spector")||le.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>le.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=fv;constructor(e){this.props={...t.defaultProps,...e},this.id=this.props.id||pr(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=vc;_lumaData={};isTextureFormatCompressed(e){return dv(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)>.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":le.warn("indices buffer content must be of integer type")()),r}};function He(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var zA=new Map,hs=class t{static defaultProps={...fs.defaultProps,type:"best-available",devices:void 0};static stats=vc;static log=le;static registerDevices(e){for(let r of e)He(r.type&&r.isSupported&&r.create),zA.set(r.type,r)}static getAvailableDevices(){return Array.from(zA).map(e=>e.type)}static getSupportedDevices(){return Array.from(zA).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(fs.defaultProps,e)}static async attachDevice(e){let r=pv(e.devices)||zA;if(e.handle instanceof WebGL2RenderingContext){let i=r.get("webgl");if(i)return await i.attach(e.handle)}if(e.handle===null){let i=r.get("unknown");if(i)return await i.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){e={...t.defaultProps,...e},e.gl&&(e.type="webgl");let r=pv(e.devices)||zA;switch(e.type){case"webgpu":let i=r.get("webgpu");if(i)return await i.create(e);break;case"webgl":let n=r.get("webgl");if(n)return await n.create(e);break;case"unknown":let s=r.get("unknown");if(s)return await s.create(e);break;case"best-available":if(i=r.get("webgpu"),i?.isSupported?.())return await i.create(e);if(n=r.get("webgl"),n?.isSupported?.())return await n.create(e);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){let r=HTMLCanvasElement.prototype;if(!e&&r.originalGetContext){r.getContext=r.originalGetContext,r.originalGetContext=void 0;return}r.originalGetContext=r.getContext,r.getContext=function(i,n){return i==="webgl"||i==="experimental-webgl"?this.originalGetContext("webgl2",n):this.originalGetContext(i,n)}}};function pv(t){if(!t||t?.length===0)return null;let e=new Map;for(let r of t)e.set(r.type,r);return e}var WN=Hr()&&typeof document<"u",A0=()=>WN&&document.readyState==="complete",jN={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},ra=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return A0()}static pageLoaded=XN();constructor(e){if(this.props={...jN,...e},e=this.props,!Hr()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=QN(e.canvas):this.canvas=e.canvas;else{let r=qN(e),i=YN(e?.container||null);i.insertBefore(r,i.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let i of r)i.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[n,s]=this.getDrawingBufferSize();return KN(e,i,n,s,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let i="width"in r?r.width:this.htmlCanvas.clientWidth,n="height"in r?r.height:this.htmlCanvas.clientHeight;(!i||!n)&&(le.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==i||s.clientHeight!==n||s.devicePixelRatio!==e){let o=e,a=Math.floor(i*o),A=Math.floor(n*o);this.htmlCanvas.width=a,this.htmlCanvas.height=A;let[h,g]=this.getDrawingBufferSize();(h!==a||g!==A)&&(o=Math.min(h/i,g/n),this.htmlCanvas.width=Math.floor(i*o),this.htmlCanvas.height=Math.floor(n*o),le.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};function XN(){return A0()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function YN(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!A0())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function QN(t){let e=document.getElementById(t);if(!e&&!A0())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function qN(t){let{width:e,height:r}=t,i=document.createElement("canvas");return i.id="lumagl-auto-created-canvas",i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",i}function KN(t,e,r,i,n){let s=t,o=gv(s[0],e,r),a=mv(s[1],e,i,n),A=gv(s[0]+1,e,r),h=A===r-1?A:A-1;A=mv(s[1]+1,e,i,n);let g;return n?(A=A===0?A:A+1,g=a,a=A):g=A===i-1?A:A-1,{x:o,y:a,width:Math.max(h-o+1,1),height:Math.max(g-a+1,1)}}function gv(t,e,r){return Math.min(Math.round(t*e),r-1)}function mv(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var $t=class t extends Ke{static defaultProps={...Ke.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,i=t.defaultProps){super(e,r,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}};var ia=class t extends Ke{static defaultProps={...Ke.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,t.defaultProps)}};function yv(t,e,r){let i="",n=e.split(/\r?\n/),s=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=n.length;a++)for(i+=xv(n[a-1],a,r);s.length>o&&s[o].lineNum===a;){let A=s[o++];i+=_v(A,n,A.lineNum,{...r,inlineSource:!1})}return i;case"issues":case"no":for(let a of t)i+=_v(a,n,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function _v(t,e,r,i){if(i?.inlineSource){let n=JN(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ `:"";return` -${s}${n}${t.type.toUpperCase()}: ${t.message} +${n}${s}${t.type.toUpperCase()}: ${t.message} -`}return i?.html?`
${t.type.toUpperCase()}: ${t.message}
`:`${t.type.toUpperCase()}: ${t.message}`}function Nv(t,e,r){let i="";for(let s=e-2;s<=e;s++){let n=t[s-1];n!==void 0&&(i+=Mm(n,e,r))}return i}function Mm(t,e,r){let i=r?.html?Dv(t):t;return`${Fv(String(e),4)}: ${i}${r?.html?"
":` -`}`}function Fv(t,e){let r="";for(let i=t.length;i",">").replaceAll('"',""").replaceAll("'","'")}function vf(t,e){return{name:Lv(t,e),language:"glsl",version:kv(t)}}function Lv(t,e="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return i?i[1]:e}function kv(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}return e}var Ti=class t extends Q{static defaultProps={...Q.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:Bv(r),...r},t.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=vf(this.source).name,i=`${this.stage} ${r}`,s=Rm(e,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource();n&&(s+=`

Translated Source



${n}
`);let o=document.createElement("Button");o.innerHTML=` +`}return i?.html?`
${t.type.toUpperCase()}: ${t.message}
`:`${t.type.toUpperCase()}: ${t.message}`}function JN(t,e,r){let i="";for(let n=e-2;n<=e;n++){let s=t[n-1];s!==void 0&&(i+=xv(s,e,r))}return i}function xv(t,e,r){let i=r?.html?$N(t):t;return`${ZN(String(e),4)}: ${i}${r?.html?"
":` +`}`}function ZN(t,e){let r="";for(let i=t.length;i",">").replaceAll('"',""").replaceAll("'","'")}function O1(t,e){return{name:eD(t,e),language:"glsl",version:tD(t)}}function eD(t,e="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return i?i[1]:e}function tD(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}return e}var na=class t extends Ke{static defaultProps={...Ke.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:rD(r),...r},t.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=O1(this.source).name,i=`${this.stage} ${r}`,n=yv(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(n+=`

Translated Source



${s}
`);let o=document.createElement("Button");o.innerHTML=`

Shader Compilation Error in ${i}



-${s}
-
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),o.onclick=()=>{let c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};function Bv(t){return vf(t.source).name||t.id||Fe(`unnamed ${t.stage}-shader`)}var Ei=class t extends Q{static defaultProps={...Q.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,t.defaultProps)}};var Si=class t extends Q{static defaultProps={...Q.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,t.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[i,s]=Array.isArray(e)?e:[e.width,e.height];r=r||s!==this.height||i!==this.width,this.width=i,this.height=s}r&&(O.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(r=>{if(typeof r=="string"){let i=this.createColorTexture(r);return this.attachResource(i),i.view}return r instanceof Se?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof Se?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:Se.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:Se.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Vv={f32:4,f16:2,i32:4,u32:4};function Tf(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,i]=t.split("x"),s=r,n=i?parseInt(i):1,o=lc(s),a={type:s,components:n,byteLength:o.byteLength*n,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function hc(t,e){let r={};for(let i of t.attributes)r[i.name]=Wv(t,e,i.name);return r}function Om(t,e,r=16){let i=hc(t,e),s=new Array(r).fill(null);for(let n of Object.values(i))s[n.location]=n;return s}function Wv(t,e,r){let i=Hv(t,r),s=jv(e,r);if(!i)return null;let n=Im(i.type),o=s?.vertexFormat||n.defaultVertexFormat,a=Tf(o);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,shaderDataType:n.dataType,shaderComponents:n.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:n.integer,stepMode:s?.stepMode||i.stepMode,byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function Hv(t,e){let r=t.attributes.find(i=>i.name===e);return r||O.warn(`shader layout attribute "${e}" not present in shader`),r||null}function jv(t,e){Xv(t);let r=$v(t,e);return r||(r=Yv(t,e),r)?r:(O.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Xv(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&O.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function $v(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function Yv(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let o=Tf(n.format);i+=o.byteLength}let s=r.attributes?.find(n=>n.attribute===e);if(s)return{attributeName:s.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:i}}return null}function Ef(t,e){let r={...t,attributes:t.attributes.map(i=>({...i}))};for(let i of e?.attributes||[]){let s=r.attributes.find(n=>n.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):O.warn(`shader layout attribute ${i.name} not present in shader`)}return r}var Wn=class t extends Q{static defaultProps={...Q.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,t.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Om(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}};var Hn=class t extends Q{static defaultProps={...Q.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,t.defaultProps)}};var jn=class t extends Q{static defaultProps={...Q.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,t.defaultProps)}};var Kv={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Nm(t){let e=Kv[t];return ee(t),e}function Fm(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}var dc;function pc(t){return(!dc||dc.byteLengths.type==="uniform"&&s.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let s of i.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){Lm(this.uniforms[e],r)||(this.uniforms[e]=km(r),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Xn=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,i]of Object.entries(e)){let s=r,n=new gc(i.uniformTypes||{});this.uniformBufferLayouts.set(s,n);let o=new mc({name:r});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e))this.uniformBlocks.get(r).setUniforms(i);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e).byteLength}getUniformBufferData(e){let r=this.uniformBlocks.get(e).getAllUniforms();return this.uniformBufferLayouts.get(e).getData(r)}createUniformBuffer(e,r,i){i&&this.setUniforms(i);let s=this.getUniformBufferByteLength(r),n=e.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:s}),o=this.getUniformBufferData(r);return n.write(o),n}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let i=this.getUniformBufferByteLength(r),s=e.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:i});this.uniformBuffers.set(r,s)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&O.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),s=!1;if(i&&r.needsRedraw){s||=r.needsRedraw;let n=this.getUniformBufferData(e);this.uniformBuffers.get(e).write(n);let a=this.uniformBlocks.get(e).getAllUniforms();O.log(4,`Writing to uniform buffer ${String(e)}`,n,a)()}return s}};function _c(t){let e=ArrayBuffer.isView(t)?t.constructor:t;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function $n(t){switch(t){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(t)}}function wf(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let i=e,s=_c(t);if(s==="uint8"||s==="sint8"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}if(s==="uint16"||s==="sint16"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}return i===1?s:`${s}x${i}`}function Bm(t){return kr(t)!==null||typeof t=="number"||typeof t=="boolean"}function Yn(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let i=t[r];Bm(i)?e.uniforms[r]=i:e.bindings[r]=i}),e}function Pf(t,e,r){let{removedProps:i={},deprecatedProps:s={},replacedProps:n={}}=r;for(let a in i)if(a in e){let l=i[a]?`${t}.${i[a]}`:"N/A";O.removed(`${t}.${a}`,l)()}for(let a in s)if(a in e){let c=s[a];O.deprecated(`${t}.${a}`,`${t}.${c}`)()}let o=null;for(let[a,c]of Object.entries(n))a in e&&(O.deprecated(`${t}.${a}`,`${t}.${c}`)(),o=o||Object.assign({},e),o[c]=e[a],delete o[a]);return o||e}var qv="";async function Cf(t,e){return await new Promise((r,i)=>{try{let s=new Image;s.onload=()=>r(s),s.onerror=()=>i(new Error(`Could not load image ${t}.`)),s.crossOrigin=e?.crossOrigin||"anonymous",s.src=t.startsWith("http")?t:qv+t}catch(s){i(s)}})}async function Kn(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((s,n)=>{i.onload=s,i.onerror=o=>n(new Error(`Unable to load script '${t}': ${o}`)),r.appendChild(i)})}function qn(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}},Mc=class extends gr{constructor(){super()}},Qf=class extends Mc{constructor(e,r){super(),this.selector=e,this.body=r}get astNodeType(){return"case"}},eh=class extends Mc{constructor(e){super(),this.body=e}get astNodeType(){return"default"}},th=class extends gr{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"argument"}},rh=class extends gr{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"elseif"}},ih=class extends gr{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"member"}},Ic=class extends gr{constructor(e,r){super(),this.name=e,this.value=r}get astNodeType(){return"attribute"}},I,w;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(w||(w={}));var A=class{constructor(e,r,i){this.name=e,this.type=r,this.rule=i}toString(){return this.name}},b=class{};I=b;b.none=new A("",w.reserved,"");b.eof=new A("EOF",w.token,"");b.reserved={asm:new A("asm",w.reserved,"asm"),bf16:new A("bf16",w.reserved,"bf16"),do:new A("do",w.reserved,"do"),enum:new A("enum",w.reserved,"enum"),f16:new A("f16",w.reserved,"f16"),f64:new A("f64",w.reserved,"f64"),handle:new A("handle",w.reserved,"handle"),i8:new A("i8",w.reserved,"i8"),i16:new A("i16",w.reserved,"i16"),i64:new A("i64",w.reserved,"i64"),mat:new A("mat",w.reserved,"mat"),premerge:new A("premerge",w.reserved,"premerge"),regardless:new A("regardless",w.reserved,"regardless"),typedef:new A("typedef",w.reserved,"typedef"),u8:new A("u8",w.reserved,"u8"),u16:new A("u16",w.reserved,"u16"),u64:new A("u64",w.reserved,"u64"),unless:new A("unless",w.reserved,"unless"),using:new A("using",w.reserved,"using"),vec:new A("vec",w.reserved,"vec"),void:new A("void",w.reserved,"void")};b.keywords={array:new A("array",w.keyword,"array"),atomic:new A("atomic",w.keyword,"atomic"),bool:new A("bool",w.keyword,"bool"),f32:new A("f32",w.keyword,"f32"),i32:new A("i32",w.keyword,"i32"),mat2x2:new A("mat2x2",w.keyword,"mat2x2"),mat2x3:new A("mat2x3",w.keyword,"mat2x3"),mat2x4:new A("mat2x4",w.keyword,"mat2x4"),mat3x2:new A("mat3x2",w.keyword,"mat3x2"),mat3x3:new A("mat3x3",w.keyword,"mat3x3"),mat3x4:new A("mat3x4",w.keyword,"mat3x4"),mat4x2:new A("mat4x2",w.keyword,"mat4x2"),mat4x3:new A("mat4x3",w.keyword,"mat4x3"),mat4x4:new A("mat4x4",w.keyword,"mat4x4"),ptr:new A("ptr",w.keyword,"ptr"),sampler:new A("sampler",w.keyword,"sampler"),sampler_comparison:new A("sampler_comparison",w.keyword,"sampler_comparison"),struct:new A("struct",w.keyword,"struct"),texture_1d:new A("texture_1d",w.keyword,"texture_1d"),texture_2d:new A("texture_2d",w.keyword,"texture_2d"),texture_2d_array:new A("texture_2d_array",w.keyword,"texture_2d_array"),texture_3d:new A("texture_3d",w.keyword,"texture_3d"),texture_cube:new A("texture_cube",w.keyword,"texture_cube"),texture_cube_array:new A("texture_cube_array",w.keyword,"texture_cube_array"),texture_multisampled_2d:new A("texture_multisampled_2d",w.keyword,"texture_multisampled_2d"),texture_storage_1d:new A("texture_storage_1d",w.keyword,"texture_storage_1d"),texture_storage_2d:new A("texture_storage_2d",w.keyword,"texture_storage_2d"),texture_storage_2d_array:new A("texture_storage_2d_array",w.keyword,"texture_storage_2d_array"),texture_storage_3d:new A("texture_storage_3d",w.keyword,"texture_storage_3d"),texture_depth_2d:new A("texture_depth_2d",w.keyword,"texture_depth_2d"),texture_depth_2d_array:new A("texture_depth_2d_array",w.keyword,"texture_depth_2d_array"),texture_depth_cube:new A("texture_depth_cube",w.keyword,"texture_depth_cube"),texture_depth_cube_array:new A("texture_depth_cube_array",w.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new A("texture_depth_multisampled_2d",w.keyword,"texture_depth_multisampled_2d"),texture_external:new A("texture_external",w.keyword,"texture_external"),u32:new A("u32",w.keyword,"u32"),vec2:new A("vec2",w.keyword,"vec2"),vec3:new A("vec3",w.keyword,"vec3"),vec4:new A("vec4",w.keyword,"vec4"),bitcast:new A("bitcast",w.keyword,"bitcast"),block:new A("block",w.keyword,"block"),break:new A("break",w.keyword,"break"),case:new A("case",w.keyword,"case"),continue:new A("continue",w.keyword,"continue"),continuing:new A("continuing",w.keyword,"continuing"),default:new A("default",w.keyword,"default"),discard:new A("discard",w.keyword,"discard"),else:new A("else",w.keyword,"else"),enable:new A("enable",w.keyword,"enable"),fallthrough:new A("fallthrough",w.keyword,"fallthrough"),false:new A("false",w.keyword,"false"),fn:new A("fn",w.keyword,"fn"),for:new A("for",w.keyword,"for"),function:new A("function",w.keyword,"function"),if:new A("if",w.keyword,"if"),let:new A("let",w.keyword,"let"),const:new A("const",w.keyword,"const"),loop:new A("loop",w.keyword,"loop"),while:new A("while",w.keyword,"while"),private:new A("private",w.keyword,"private"),read:new A("read",w.keyword,"read"),read_write:new A("read_write",w.keyword,"read_write"),return:new A("return",w.keyword,"return"),storage:new A("storage",w.keyword,"storage"),switch:new A("switch",w.keyword,"switch"),true:new A("true",w.keyword,"true"),alias:new A("alias",w.keyword,"alias"),type:new A("type",w.keyword,"type"),uniform:new A("uniform",w.keyword,"uniform"),var:new A("var",w.keyword,"var"),override:new A("override",w.keyword,"override"),workgroup:new A("workgroup",w.keyword,"workgroup"),write:new A("write",w.keyword,"write"),r8unorm:new A("r8unorm",w.keyword,"r8unorm"),r8snorm:new A("r8snorm",w.keyword,"r8snorm"),r8uint:new A("r8uint",w.keyword,"r8uint"),r8sint:new A("r8sint",w.keyword,"r8sint"),r16uint:new A("r16uint",w.keyword,"r16uint"),r16sint:new A("r16sint",w.keyword,"r16sint"),r16float:new A("r16float",w.keyword,"r16float"),rg8unorm:new A("rg8unorm",w.keyword,"rg8unorm"),rg8snorm:new A("rg8snorm",w.keyword,"rg8snorm"),rg8uint:new A("rg8uint",w.keyword,"rg8uint"),rg8sint:new A("rg8sint",w.keyword,"rg8sint"),r32uint:new A("r32uint",w.keyword,"r32uint"),r32sint:new A("r32sint",w.keyword,"r32sint"),r32float:new A("r32float",w.keyword,"r32float"),rg16uint:new A("rg16uint",w.keyword,"rg16uint"),rg16sint:new A("rg16sint",w.keyword,"rg16sint"),rg16float:new A("rg16float",w.keyword,"rg16float"),rgba8unorm:new A("rgba8unorm",w.keyword,"rgba8unorm"),rgba8unorm_srgb:new A("rgba8unorm_srgb",w.keyword,"rgba8unorm_srgb"),rgba8snorm:new A("rgba8snorm",w.keyword,"rgba8snorm"),rgba8uint:new A("rgba8uint",w.keyword,"rgba8uint"),rgba8sint:new A("rgba8sint",w.keyword,"rgba8sint"),bgra8unorm:new A("bgra8unorm",w.keyword,"bgra8unorm"),bgra8unorm_srgb:new A("bgra8unorm_srgb",w.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new A("rgb10a2unorm",w.keyword,"rgb10a2unorm"),rg11b10float:new A("rg11b10float",w.keyword,"rg11b10float"),rg32uint:new A("rg32uint",w.keyword,"rg32uint"),rg32sint:new A("rg32sint",w.keyword,"rg32sint"),rg32float:new A("rg32float",w.keyword,"rg32float"),rgba16uint:new A("rgba16uint",w.keyword,"rgba16uint"),rgba16sint:new A("rgba16sint",w.keyword,"rgba16sint"),rgba16float:new A("rgba16float",w.keyword,"rgba16float"),rgba32uint:new A("rgba32uint",w.keyword,"rgba32uint"),rgba32sint:new A("rgba32sint",w.keyword,"rgba32sint"),rgba32float:new A("rgba32float",w.keyword,"rgba32float"),static_assert:new A("static_assert",w.keyword,"static_assert")};b.tokens={decimal_float_literal:new A("decimal_float_literal",w.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new A("hex_float_literal",w.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new A("int_literal",w.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new A("uint_literal",w.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new A("ident",w.token,/[a-zA-Z][0-9a-zA-Z_]*/),and:new A("and",w.token,"&"),and_and:new A("and_and",w.token,"&&"),arrow:new A("arrow ",w.token,"->"),attr:new A("attr",w.token,"@"),attr_left:new A("attr_left",w.token,"[["),attr_right:new A("attr_right",w.token,"]]"),forward_slash:new A("forward_slash",w.token,"/"),bang:new A("bang",w.token,"!"),bracket_left:new A("bracket_left",w.token,"["),bracket_right:new A("bracket_right",w.token,"]"),brace_left:new A("brace_left",w.token,"{"),brace_right:new A("brace_right",w.token,"}"),colon:new A("colon",w.token,":"),comma:new A("comma",w.token,","),equal:new A("equal",w.token,"="),equal_equal:new A("equal_equal",w.token,"=="),not_equal:new A("not_equal",w.token,"!="),greater_than:new A("greater_than",w.token,">"),greater_than_equal:new A("greater_than_equal",w.token,">="),shift_right:new A("shift_right",w.token,">>"),less_than:new A("less_than",w.token,"<"),less_than_equal:new A("less_than_equal",w.token,"<="),shift_left:new A("shift_left",w.token,"<<"),modulo:new A("modulo",w.token,"%"),minus:new A("minus",w.token,"-"),minus_minus:new A("minus_minus",w.token,"--"),period:new A("period",w.token,"."),plus:new A("plus",w.token,"+"),plus_plus:new A("plus_plus",w.token,"++"),or:new A("or",w.token,"|"),or_or:new A("or_or",w.token,"||"),paren_left:new A("paren_left",w.token,"("),paren_right:new A("paren_right",w.token,")"),semicolon:new A("semicolon",w.token,";"),star:new A("star",w.token,"*"),tilde:new A("tilde",w.token,"~"),underscore:new A("underscore",w.token,"_"),xor:new A("xor",w.token,"^"),plus_equal:new A("plus_equal",w.token,"+="),minus_equal:new A("minus_equal",w.token,"-="),times_equal:new A("times_equal",w.token,"*="),division_equal:new A("division_equal",w.token,"/="),modulo_equal:new A("modulo_equal",w.token,"%="),and_equal:new A("and_equal",w.token,"&="),or_equal:new A("or_equal",w.token,"|="),xor_equal:new A("xor_equal",w.token,"^="),shift_right_equal:new A("shift_right_equal",w.token,">>="),shift_left_equal:new A("shift_left_equal",w.token,"<<=")};b.storage_class=[I.keywords.function,I.keywords.private,I.keywords.workgroup,I.keywords.uniform,I.keywords.storage];b.access_mode=[I.keywords.read,I.keywords.write,I.keywords.read_write];b.sampler_type=[I.keywords.sampler,I.keywords.sampler_comparison];b.sampled_texture_type=[I.keywords.texture_1d,I.keywords.texture_2d,I.keywords.texture_2d_array,I.keywords.texture_3d,I.keywords.texture_cube,I.keywords.texture_cube_array];b.multisampled_texture_type=[I.keywords.texture_multisampled_2d];b.storage_texture_type=[I.keywords.texture_storage_1d,I.keywords.texture_storage_2d,I.keywords.texture_storage_2d_array,I.keywords.texture_storage_3d];b.depth_texture_type=[I.keywords.texture_depth_2d,I.keywords.texture_depth_2d_array,I.keywords.texture_depth_cube,I.keywords.texture_depth_cube_array,I.keywords.texture_depth_multisampled_2d];b.texture_external_type=[I.keywords.texture_external];b.any_texture_type=[...I.sampled_texture_type,...I.multisampled_texture_type,...I.storage_texture_type,...I.depth_texture_type,...I.texture_external_type];b.texel_format=[I.keywords.r8unorm,I.keywords.r8snorm,I.keywords.r8uint,I.keywords.r8sint,I.keywords.r16uint,I.keywords.r16sint,I.keywords.r16float,I.keywords.rg8unorm,I.keywords.rg8snorm,I.keywords.rg8uint,I.keywords.rg8sint,I.keywords.r32uint,I.keywords.r32sint,I.keywords.r32float,I.keywords.rg16uint,I.keywords.rg16sint,I.keywords.rg16float,I.keywords.rgba8unorm,I.keywords.rgba8unorm_srgb,I.keywords.rgba8snorm,I.keywords.rgba8uint,I.keywords.rgba8sint,I.keywords.bgra8unorm,I.keywords.bgra8unorm_srgb,I.keywords.rgb10a2unorm,I.keywords.rg11b10float,I.keywords.rg32uint,I.keywords.rg32sint,I.keywords.rg32float,I.keywords.rgba16uint,I.keywords.rgba16sint,I.keywords.rgba16float,I.keywords.rgba32uint,I.keywords.rgba32sint,I.keywords.rgba32float];b.const_literal=[I.tokens.int_literal,I.tokens.uint_literal,I.tokens.decimal_float_literal,I.tokens.hex_float_literal,I.keywords.true,I.keywords.false];b.literal_or_ident=[I.tokens.ident,I.tokens.int_literal,I.tokens.uint_literal,I.tokens.decimal_float_literal,I.tokens.hex_float_literal];b.element_count_expression=[I.tokens.int_literal,I.tokens.uint_literal,I.tokens.ident];b.template_types=[I.keywords.vec2,I.keywords.vec3,I.keywords.vec4,I.keywords.mat2x2,I.keywords.mat2x3,I.keywords.mat2x4,I.keywords.mat3x2,I.keywords.mat3x3,I.keywords.mat3x4,I.keywords.mat4x2,I.keywords.mat4x3,I.keywords.mat4x4,I.keywords.atomic,I.keywords.bitcast,...I.any_texture_type];b.attribute_name=[I.tokens.ident,I.keywords.block];b.assignment_operators=[I.tokens.equal,I.tokens.plus_equal,I.tokens.minus_equal,I.tokens.times_equal,I.tokens.division_equal,I.tokens.modulo_equal,I.tokens.and_equal,I.tokens.or_equal,I.tokens.xor_equal,I.tokens.shift_right_equal,I.tokens.shift_left_equal];b.increment_operators=[I.tokens.plus_plus,I.tokens.minus_minus];var Oc=class{constructor(e,r,i){this.type=e,this.lexeme=r,this.line=i}toString(){return this.lexeme}isTemplateType(){return b.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==b.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},sh=class{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 Oc(b.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==` +${n} +`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),o.onclick=()=>{let A=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(A)}}};function rD(t){return O1(t.source).name||t.id||pr(`unnamed ${t.stage}-shader`)}var sa=class t extends Ke{static defaultProps={...Ke.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,t.defaultProps)}};var oa=class t extends Ke{static defaultProps={...Ke.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,t.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[i,n]=Array.isArray(e)?e:[e.width,e.height];r=r||n!==this.height||i!==this.width,this.width=i,this.height=n}r&&(le.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(r=>{if(typeof r=="string"){let i=this.createColorTexture(r);return this.attachResource(i),i.view}return r instanceof $t?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof $t?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:$t.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:$t.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},sD={f32:4,f16:2,i32:4,u32:4};function F1(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,i]=t.split("x"),n=r,s=i?parseInt(i):1,o=c0(n),a={type:n,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function u0(t,e){let r={};for(let i of t.attributes)r[i.name]=oD(t,e,i.name);return r}function Tv(t,e,r=16){let i=u0(t,e),n=new Array(r).fill(null);for(let s of Object.values(i))n[s.location]=s;return n}function oD(t,e,r){let i=aD(t,r),n=cD(e,r);if(!i)return null;let s=bv(i.type),o=n?.vertexFormat||s.defaultVertexFormat,a=F1(o);return{attributeName:n?.attributeName||i.name,bufferName:n?.bufferName||i.name,location:i.location,shaderType:i.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:s.integer,stepMode:n?.stepMode||i.stepMode,byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function aD(t,e){let r=t.attributes.find(i=>i.name===e);return r||le.warn(`shader layout attribute "${e}" not present in shader`),r||null}function cD(t,e){lD(t);let r=AD(t,e);return r||(r=uD(t,e),r)?r:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function lD(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function AD(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function uD(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let s of r.attributes||[]){let o=F1(s.format);i+=o.byteLength}let n=r.attributes?.find(s=>s.attribute===e);if(n)return{attributeName:n.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:i}}return null}function L1(t,e){let r={...t,attributes:t.attributes.map(i=>({...i}))};for(let i of e?.attributes||[]){let n=r.attributes.find(s=>s.name===i.name);n?(n.type=i.type||n.type,n.stepMode=i.stepMode||n.stepMode):le.warn(`shader layout attribute ${i.name} not present in shader`)}return r}var jA=class t extends Ke{static defaultProps={...Ke.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,t.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Tv(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}};var XA=class t extends Ke{static defaultProps={...Ke.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,t.defaultProps)}};var YA=class t extends Ke{static defaultProps={...Ke.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,t.defaultProps)}};var fD={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Ev(t){let e=fD[t];return He(t),e}function vv(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}var f0;function h0(t){return(!f0||f0.byteLengthn.type==="uniform"&&n.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let n of i.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){wv(this.uniforms[e],r)||(this.uniforms[e]=Cv(r),this.modifiedUniforms[e]=!0,this.modified=!0)}};var QA=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,i]of Object.entries(e)){let n=r,s=new d0(i.uniformTypes||{});this.uniformBufferLayouts.set(n,s);let o=new p0({name:r});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(n,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e))this.uniformBlocks.get(r).setUniforms(i);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e).byteLength}getUniformBufferData(e){let r=this.uniformBlocks.get(e).getAllUniforms();return this.uniformBufferLayouts.get(e).getData(r)}createUniformBuffer(e,r,i){i&&this.setUniforms(i);let n=this.getUniformBufferByteLength(r),s=e.createBuffer({usage:gt.UNIFORM|gt.COPY_DST,byteLength:n}),o=this.getUniformBufferData(r);return s.write(o),s}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let i=this.getUniformBufferByteLength(r),n=e.createBuffer({usage:gt.UNIFORM|gt.COPY_DST,byteLength:i});this.uniformBuffers.set(r,n)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),n=!1;if(i&&r.needsRedraw){n||=r.needsRedraw;let s=this.getUniformBufferData(e);this.uniformBuffers.get(e).write(s);let a=this.uniformBlocks.get(e).getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,s,a)()}return n}};function g0(t){let e=ArrayBuffer.isView(t)?t.constructor:t;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function qA(t){switch(t){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(t)}}function U1(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let i=e,n=g0(t);if(n==="uint8"||n==="sint8"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(n=n.replace("int","norm")),`${n}x${i}`}if(n==="uint16"||n==="sint16"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(n=n.replace("int","norm")),`${n}x${i}`}return i===1?n:`${n}x${i}`}function Mv(t){return Js(t)!==null||typeof t=="number"||typeof t=="boolean"}function KA(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let i=t[r];Mv(i)?e.uniforms[r]=i:e.bindings[r]=i}),e}function k1(t,e,r){let{removedProps:i={},deprecatedProps:n={},replacedProps:s={}}=r;for(let a in i)if(a in e){let h=i[a]?`${t}.${i[a]}`:"N/A";le.removed(`${t}.${a}`,h)()}for(let a in n)if(a in e){let A=n[a];le.deprecated(`${t}.${a}`,`${t}.${A}`)()}let o=null;for(let[a,A]of Object.entries(s))a in e&&(le.deprecated(`${t}.${a}`,`${t}.${A}`)(),o=o||Object.assign({},e),o[A]=e[a],delete o[a]);return o||e}var hD="";async function V1(t,e){return await new Promise((r,i)=>{try{let n=new Image;n.onload=()=>r(n),n.onerror=()=>i(new Error(`Could not load image ${t}.`)),n.crossOrigin=e?.crossOrigin||"anonymous",n.src=t.startsWith("http")?t:hD+t}catch(n){i(n)}})}async function JA(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((n,s)=>{i.onload=n,i.onerror=o=>s(new Error(`Unable to load script '${t}': ${o}`)),r.appendChild(i)})}function ZA(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}},P0=class extends ps{constructor(){super()}},u_=class extends P0{constructor(e,r){super(),this.selector=e,this.body=r}get astNodeType(){return"case"}},f_=class extends P0{constructor(e){super(),this.body=e}get astNodeType(){return"default"}},h_=class extends ps{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"argument"}},d_=class extends ps{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"elseif"}},p_=class extends ps{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"member"}},I0=class extends ps{constructor(e,r){super(),this.name=e,this.value=r}get astNodeType(){return"attribute"}},ue,K;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(K||(K={}));var q=class{constructor(e,r,i){this.name=e,this.type=r,this.rule=i}toString(){return this.name}},V=class{};ue=V;V.none=new q("",K.reserved,"");V.eof=new q("EOF",K.token,"");V.reserved={asm:new q("asm",K.reserved,"asm"),bf16:new q("bf16",K.reserved,"bf16"),do:new q("do",K.reserved,"do"),enum:new q("enum",K.reserved,"enum"),f16:new q("f16",K.reserved,"f16"),f64:new q("f64",K.reserved,"f64"),handle:new q("handle",K.reserved,"handle"),i8:new q("i8",K.reserved,"i8"),i16:new q("i16",K.reserved,"i16"),i64:new q("i64",K.reserved,"i64"),mat:new q("mat",K.reserved,"mat"),premerge:new q("premerge",K.reserved,"premerge"),regardless:new q("regardless",K.reserved,"regardless"),typedef:new q("typedef",K.reserved,"typedef"),u8:new q("u8",K.reserved,"u8"),u16:new q("u16",K.reserved,"u16"),u64:new q("u64",K.reserved,"u64"),unless:new q("unless",K.reserved,"unless"),using:new q("using",K.reserved,"using"),vec:new q("vec",K.reserved,"vec"),void:new q("void",K.reserved,"void")};V.keywords={array:new q("array",K.keyword,"array"),atomic:new q("atomic",K.keyword,"atomic"),bool:new q("bool",K.keyword,"bool"),f32:new q("f32",K.keyword,"f32"),i32:new q("i32",K.keyword,"i32"),mat2x2:new q("mat2x2",K.keyword,"mat2x2"),mat2x3:new q("mat2x3",K.keyword,"mat2x3"),mat2x4:new q("mat2x4",K.keyword,"mat2x4"),mat3x2:new q("mat3x2",K.keyword,"mat3x2"),mat3x3:new q("mat3x3",K.keyword,"mat3x3"),mat3x4:new q("mat3x4",K.keyword,"mat3x4"),mat4x2:new q("mat4x2",K.keyword,"mat4x2"),mat4x3:new q("mat4x3",K.keyword,"mat4x3"),mat4x4:new q("mat4x4",K.keyword,"mat4x4"),ptr:new q("ptr",K.keyword,"ptr"),sampler:new q("sampler",K.keyword,"sampler"),sampler_comparison:new q("sampler_comparison",K.keyword,"sampler_comparison"),struct:new q("struct",K.keyword,"struct"),texture_1d:new q("texture_1d",K.keyword,"texture_1d"),texture_2d:new q("texture_2d",K.keyword,"texture_2d"),texture_2d_array:new q("texture_2d_array",K.keyword,"texture_2d_array"),texture_3d:new q("texture_3d",K.keyword,"texture_3d"),texture_cube:new q("texture_cube",K.keyword,"texture_cube"),texture_cube_array:new q("texture_cube_array",K.keyword,"texture_cube_array"),texture_multisampled_2d:new q("texture_multisampled_2d",K.keyword,"texture_multisampled_2d"),texture_storage_1d:new q("texture_storage_1d",K.keyword,"texture_storage_1d"),texture_storage_2d:new q("texture_storage_2d",K.keyword,"texture_storage_2d"),texture_storage_2d_array:new q("texture_storage_2d_array",K.keyword,"texture_storage_2d_array"),texture_storage_3d:new q("texture_storage_3d",K.keyword,"texture_storage_3d"),texture_depth_2d:new q("texture_depth_2d",K.keyword,"texture_depth_2d"),texture_depth_2d_array:new q("texture_depth_2d_array",K.keyword,"texture_depth_2d_array"),texture_depth_cube:new q("texture_depth_cube",K.keyword,"texture_depth_cube"),texture_depth_cube_array:new q("texture_depth_cube_array",K.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new q("texture_depth_multisampled_2d",K.keyword,"texture_depth_multisampled_2d"),texture_external:new q("texture_external",K.keyword,"texture_external"),u32:new q("u32",K.keyword,"u32"),vec2:new q("vec2",K.keyword,"vec2"),vec3:new q("vec3",K.keyword,"vec3"),vec4:new q("vec4",K.keyword,"vec4"),bitcast:new q("bitcast",K.keyword,"bitcast"),block:new q("block",K.keyword,"block"),break:new q("break",K.keyword,"break"),case:new q("case",K.keyword,"case"),continue:new q("continue",K.keyword,"continue"),continuing:new q("continuing",K.keyword,"continuing"),default:new q("default",K.keyword,"default"),discard:new q("discard",K.keyword,"discard"),else:new q("else",K.keyword,"else"),enable:new q("enable",K.keyword,"enable"),fallthrough:new q("fallthrough",K.keyword,"fallthrough"),false:new q("false",K.keyword,"false"),fn:new q("fn",K.keyword,"fn"),for:new q("for",K.keyword,"for"),function:new q("function",K.keyword,"function"),if:new q("if",K.keyword,"if"),let:new q("let",K.keyword,"let"),const:new q("const",K.keyword,"const"),loop:new q("loop",K.keyword,"loop"),while:new q("while",K.keyword,"while"),private:new q("private",K.keyword,"private"),read:new q("read",K.keyword,"read"),read_write:new q("read_write",K.keyword,"read_write"),return:new q("return",K.keyword,"return"),storage:new q("storage",K.keyword,"storage"),switch:new q("switch",K.keyword,"switch"),true:new q("true",K.keyword,"true"),alias:new q("alias",K.keyword,"alias"),type:new q("type",K.keyword,"type"),uniform:new q("uniform",K.keyword,"uniform"),var:new q("var",K.keyword,"var"),override:new q("override",K.keyword,"override"),workgroup:new q("workgroup",K.keyword,"workgroup"),write:new q("write",K.keyword,"write"),r8unorm:new q("r8unorm",K.keyword,"r8unorm"),r8snorm:new q("r8snorm",K.keyword,"r8snorm"),r8uint:new q("r8uint",K.keyword,"r8uint"),r8sint:new q("r8sint",K.keyword,"r8sint"),r16uint:new q("r16uint",K.keyword,"r16uint"),r16sint:new q("r16sint",K.keyword,"r16sint"),r16float:new q("r16float",K.keyword,"r16float"),rg8unorm:new q("rg8unorm",K.keyword,"rg8unorm"),rg8snorm:new q("rg8snorm",K.keyword,"rg8snorm"),rg8uint:new q("rg8uint",K.keyword,"rg8uint"),rg8sint:new q("rg8sint",K.keyword,"rg8sint"),r32uint:new q("r32uint",K.keyword,"r32uint"),r32sint:new q("r32sint",K.keyword,"r32sint"),r32float:new q("r32float",K.keyword,"r32float"),rg16uint:new q("rg16uint",K.keyword,"rg16uint"),rg16sint:new q("rg16sint",K.keyword,"rg16sint"),rg16float:new q("rg16float",K.keyword,"rg16float"),rgba8unorm:new q("rgba8unorm",K.keyword,"rgba8unorm"),rgba8unorm_srgb:new q("rgba8unorm_srgb",K.keyword,"rgba8unorm_srgb"),rgba8snorm:new q("rgba8snorm",K.keyword,"rgba8snorm"),rgba8uint:new q("rgba8uint",K.keyword,"rgba8uint"),rgba8sint:new q("rgba8sint",K.keyword,"rgba8sint"),bgra8unorm:new q("bgra8unorm",K.keyword,"bgra8unorm"),bgra8unorm_srgb:new q("bgra8unorm_srgb",K.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new q("rgb10a2unorm",K.keyword,"rgb10a2unorm"),rg11b10float:new q("rg11b10float",K.keyword,"rg11b10float"),rg32uint:new q("rg32uint",K.keyword,"rg32uint"),rg32sint:new q("rg32sint",K.keyword,"rg32sint"),rg32float:new q("rg32float",K.keyword,"rg32float"),rgba16uint:new q("rgba16uint",K.keyword,"rgba16uint"),rgba16sint:new q("rgba16sint",K.keyword,"rgba16sint"),rgba16float:new q("rgba16float",K.keyword,"rgba16float"),rgba32uint:new q("rgba32uint",K.keyword,"rgba32uint"),rgba32sint:new q("rgba32sint",K.keyword,"rgba32sint"),rgba32float:new q("rgba32float",K.keyword,"rgba32float"),static_assert:new q("static_assert",K.keyword,"static_assert")};V.tokens={decimal_float_literal:new q("decimal_float_literal",K.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new q("hex_float_literal",K.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new q("int_literal",K.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new q("uint_literal",K.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new q("ident",K.token,/[a-zA-Z][0-9a-zA-Z_]*/),and:new q("and",K.token,"&"),and_and:new q("and_and",K.token,"&&"),arrow:new q("arrow ",K.token,"->"),attr:new q("attr",K.token,"@"),attr_left:new q("attr_left",K.token,"[["),attr_right:new q("attr_right",K.token,"]]"),forward_slash:new q("forward_slash",K.token,"/"),bang:new q("bang",K.token,"!"),bracket_left:new q("bracket_left",K.token,"["),bracket_right:new q("bracket_right",K.token,"]"),brace_left:new q("brace_left",K.token,"{"),brace_right:new q("brace_right",K.token,"}"),colon:new q("colon",K.token,":"),comma:new q("comma",K.token,","),equal:new q("equal",K.token,"="),equal_equal:new q("equal_equal",K.token,"=="),not_equal:new q("not_equal",K.token,"!="),greater_than:new q("greater_than",K.token,">"),greater_than_equal:new q("greater_than_equal",K.token,">="),shift_right:new q("shift_right",K.token,">>"),less_than:new q("less_than",K.token,"<"),less_than_equal:new q("less_than_equal",K.token,"<="),shift_left:new q("shift_left",K.token,"<<"),modulo:new q("modulo",K.token,"%"),minus:new q("minus",K.token,"-"),minus_minus:new q("minus_minus",K.token,"--"),period:new q("period",K.token,"."),plus:new q("plus",K.token,"+"),plus_plus:new q("plus_plus",K.token,"++"),or:new q("or",K.token,"|"),or_or:new q("or_or",K.token,"||"),paren_left:new q("paren_left",K.token,"("),paren_right:new q("paren_right",K.token,")"),semicolon:new q("semicolon",K.token,";"),star:new q("star",K.token,"*"),tilde:new q("tilde",K.token,"~"),underscore:new q("underscore",K.token,"_"),xor:new q("xor",K.token,"^"),plus_equal:new q("plus_equal",K.token,"+="),minus_equal:new q("minus_equal",K.token,"-="),times_equal:new q("times_equal",K.token,"*="),division_equal:new q("division_equal",K.token,"/="),modulo_equal:new q("modulo_equal",K.token,"%="),and_equal:new q("and_equal",K.token,"&="),or_equal:new q("or_equal",K.token,"|="),xor_equal:new q("xor_equal",K.token,"^="),shift_right_equal:new q("shift_right_equal",K.token,">>="),shift_left_equal:new q("shift_left_equal",K.token,"<<=")};V.storage_class=[ue.keywords.function,ue.keywords.private,ue.keywords.workgroup,ue.keywords.uniform,ue.keywords.storage];V.access_mode=[ue.keywords.read,ue.keywords.write,ue.keywords.read_write];V.sampler_type=[ue.keywords.sampler,ue.keywords.sampler_comparison];V.sampled_texture_type=[ue.keywords.texture_1d,ue.keywords.texture_2d,ue.keywords.texture_2d_array,ue.keywords.texture_3d,ue.keywords.texture_cube,ue.keywords.texture_cube_array];V.multisampled_texture_type=[ue.keywords.texture_multisampled_2d];V.storage_texture_type=[ue.keywords.texture_storage_1d,ue.keywords.texture_storage_2d,ue.keywords.texture_storage_2d_array,ue.keywords.texture_storage_3d];V.depth_texture_type=[ue.keywords.texture_depth_2d,ue.keywords.texture_depth_2d_array,ue.keywords.texture_depth_cube,ue.keywords.texture_depth_cube_array,ue.keywords.texture_depth_multisampled_2d];V.texture_external_type=[ue.keywords.texture_external];V.any_texture_type=[...ue.sampled_texture_type,...ue.multisampled_texture_type,...ue.storage_texture_type,...ue.depth_texture_type,...ue.texture_external_type];V.texel_format=[ue.keywords.r8unorm,ue.keywords.r8snorm,ue.keywords.r8uint,ue.keywords.r8sint,ue.keywords.r16uint,ue.keywords.r16sint,ue.keywords.r16float,ue.keywords.rg8unorm,ue.keywords.rg8snorm,ue.keywords.rg8uint,ue.keywords.rg8sint,ue.keywords.r32uint,ue.keywords.r32sint,ue.keywords.r32float,ue.keywords.rg16uint,ue.keywords.rg16sint,ue.keywords.rg16float,ue.keywords.rgba8unorm,ue.keywords.rgba8unorm_srgb,ue.keywords.rgba8snorm,ue.keywords.rgba8uint,ue.keywords.rgba8sint,ue.keywords.bgra8unorm,ue.keywords.bgra8unorm_srgb,ue.keywords.rgb10a2unorm,ue.keywords.rg11b10float,ue.keywords.rg32uint,ue.keywords.rg32sint,ue.keywords.rg32float,ue.keywords.rgba16uint,ue.keywords.rgba16sint,ue.keywords.rgba16float,ue.keywords.rgba32uint,ue.keywords.rgba32sint,ue.keywords.rgba32float];V.const_literal=[ue.tokens.int_literal,ue.tokens.uint_literal,ue.tokens.decimal_float_literal,ue.tokens.hex_float_literal,ue.keywords.true,ue.keywords.false];V.literal_or_ident=[ue.tokens.ident,ue.tokens.int_literal,ue.tokens.uint_literal,ue.tokens.decimal_float_literal,ue.tokens.hex_float_literal];V.element_count_expression=[ue.tokens.int_literal,ue.tokens.uint_literal,ue.tokens.ident];V.template_types=[ue.keywords.vec2,ue.keywords.vec3,ue.keywords.vec4,ue.keywords.mat2x2,ue.keywords.mat2x3,ue.keywords.mat2x4,ue.keywords.mat3x2,ue.keywords.mat3x3,ue.keywords.mat3x4,ue.keywords.mat4x2,ue.keywords.mat4x3,ue.keywords.mat4x4,ue.keywords.atomic,ue.keywords.bitcast,...ue.any_texture_type];V.attribute_name=[ue.tokens.ident,ue.keywords.block];V.assignment_operators=[ue.tokens.equal,ue.tokens.plus_equal,ue.tokens.minus_equal,ue.tokens.times_equal,ue.tokens.division_equal,ue.tokens.modulo_equal,ue.tokens.and_equal,ue.tokens.or_equal,ue.tokens.xor_equal,ue.tokens.shift_right_equal,ue.tokens.shift_left_equal];V.increment_operators=[ue.tokens.plus_plus,ue.tokens.minus_minus];var R0=class{constructor(e,r,i){this.type=e,this.lexeme=r,this.line=i}toString(){return this.lexeme}isTemplateType(){return V.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==V.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},g_=class{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 R0(V.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==` `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=` `;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let i=1;for(;i>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==` -`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),i--,i==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),i++)}return!0}}let r=b.none;for(;;){let i=this._findType(e),s=this._peekAhead();if(e==">"&&(s==">"||s=="=")){let n=!1,o=this._tokens.length-1;for(let a=0;a<5&&o>=0;++a,--o)if(this._tokens[o].type===b.tokens.less_than){o>0&&this._tokens[o-1].isArrayOrTemplateType()&&(n=!0);break}if(n)return this._addToken(i),!0}if(i===b.none){let n=e,o=0,a=2;for(let c=0;c=this._source.length}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let r=this._source[this._current];return e=e||0,e++,this._current+=e,r}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let r=this._source.substring(this._start,this._current);this._tokens.push(new Oc(e,r,this._line))}},nh=class{constructor(){this._tokens=[],this._current=0,this._context=new If}parse(e){this._initialize(e);let r=[];for(;!this._isAtEnd();){let i=this._global_decl_or_directive();if(!i)break;r.push(i)}return r}_initialize(e){if(e)if(typeof e=="string"){let r=new sh(e);this._tokens=r.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,r){return console.error(e,r),{token:e,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==b.eof}_match(e){if(e instanceof A)return this._check(e)?(this._advance(),!0):!1;for(let r=0,i=e.length;r'.");let s=this._paren_expression();return new Gf(i,s)}let e=this._type_decl(),r=this._argument_expression_list();return new Zf(e,r)}_argument_expression_list(){if(!this._match(b.tokens.paren_left))return null;let e=[];do{if(this._check(b.tokens.paren_right))break;let r=this._short_circuit_or_expression();e.push(r)}while(this._match(b.tokens.comma));return this._consume(b.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(b.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(b.tokens.paren_right),new Cc([e])}_paren_expression(){this._consume(b.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(b.tokens.paren_right,"Expected ')'."),new Cc([e])}_struct_decl(){if(!this._match(b.keywords.struct))return null;let e=this._consume(b.tokens.ident,"Expected name for struct.").toString();this._consume(b.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(b.tokens.brace_right);){let s=this._attribute(),n=this._consume(b.tokens.ident,"Expected variable name.").toString();this._consume(b.tokens.colon,"Expected ':' for struct member type.");let o=this._attribute(),a=this._type_decl();a!=null&&(a.attributes=o),this._check(b.tokens.brace_right)?this._match(b.tokens.comma):this._consume(b.tokens.comma,"Expected ',' for struct member."),r.push(new ih(n,a,s))}this._consume(b.tokens.brace_right,"Expected '}' after struct body.");let i=new pr(e,r);return this._context.structs.set(e,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(b.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(b.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(b.keywords.const))return null;let e=this._consume(b.tokens.ident,"Expected variable name"),r=null;if(this._match(b.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let i=null;if(this._match(b.tokens.equal)){let n=this._short_circuit_or_expression();if(n instanceof wi)i=n;else if(n instanceof wc&&n.initializer instanceof wi)i=n.initializer;else try{let o=n.evaluate(this._context);i=new Pc(o)}catch{i=n}}let s=new vc(e.toString(),r,"","",i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(b.keywords.let))return null;let e=this._consume(b.tokens.ident,"Expected variable name"),r=null;if(this._match(b.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}let i=null;return this._match(b.tokens.equal)&&(i=this._const_expression()),new bc(e.toString(),r,"","",i)}_const_expression(){if(this._match(b.const_literal))return new Ac(this._previous().toString());let e=this._type_decl();this._consume(b.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(b.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(b.tokens.comma));)this._advance();return this._consume(b.tokens.paren_right,"Expected ')'."),new wi(e,r)}_variable_decl(){if(!this._match(b.keywords.var))return null;let e="",r="";this._match(b.tokens.less_than)&&(e=this._consume(b.storage_class,"Expected storage_class.").toString(),this._match(b.tokens.comma)&&(r=this._consume(b.access_mode,"Expected access_mode.").toString()),this._consume(b.tokens.greater_than,"Expected '>'."));let i=this._consume(b.tokens.ident,"Expected variable name"),s=null;if(this._match(b.tokens.colon)){let n=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=n)}return new zr(i.toString(),s,e,r,null)}_override_decl(){if(!this._match(b.keywords.override))return null;let e=this._consume(b.tokens.ident,"Expected variable name"),r=null;if(this._match(b.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}return new yc(e.toString(),r,null)}_enable_directive(){let e=this._consume(b.tokens.ident,"identity expected.");return new Hf(e.toString())}_type_alias(){let e=this._consume(b.tokens.ident,"identity expected.");this._consume(b.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let i=new Tc(e.toString(),r);return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([b.tokens.ident,...b.texel_format,b.keywords.bool,b.keywords.f32,b.keywords.i32,b.keywords.u32])){let i=this._advance(),s=i.toString();return this._context.structs.has(s)?this._context.structs.get(s):this._context.aliases.has(s)?this._context.aliases.get(s).type:new mr(i.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(b.template_types)){let i=this._advance().toString(),s=null,n=null;return this._match(b.tokens.less_than)&&(s=this._type_decl(),n=null,this._match(b.tokens.comma)&&(n=this._consume(b.access_mode,"Expected access_mode for pointer").toString()),this._consume(b.tokens.greater_than,"Expected '>' for type.")),new Ec(i,s,n)}if(this._match(b.keywords.ptr)){let i=this._previous().toString();this._consume(b.tokens.less_than,"Expected '<' for pointer.");let s=this._consume(b.storage_class,"Expected storage_class for pointer");this._consume(b.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),o=null;return this._match(b.tokens.comma)&&(o=this._consume(b.access_mode,"Expected access_mode for pointer").toString()),this._consume(b.tokens.greater_than,"Expected '>' for pointer."),new Yf(i,s.toString(),n,o)}let r=this._attribute();if(this._match(b.keywords.array)){let i=null,s=-1,n=this._previous();if(this._match(b.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let o="";this._match(b.tokens.comma)&&(o=this._shift_expression().evaluate(this._context).toString()),this._consume(b.tokens.greater_than,"Expected '>' for array."),s=o?parseInt(o):0}return new Sc(n.toString(),r,i,s)}return null}_texture_sampler_types(){if(this._match(b.sampler_type))return new Ai(this._previous().toString(),null,null);if(this._match(b.depth_texture_type))return new Ai(this._previous().toString(),null,null);if(this._match(b.sampled_texture_type)||this._match(b.multisampled_texture_type)){let e=this._previous();this._consume(b.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(b.tokens.greater_than,"Expected '>' for sampler type."),new Ai(e.toString(),r,null)}if(this._match(b.storage_texture_type)){let e=this._previous();this._consume(b.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(b.texel_format,"Invalid texel format.").toString();this._consume(b.tokens.comma,"Expected ',' after texel format.");let i=this._consume(b.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(b.tokens.greater_than,"Expected '>' for sampler type."),new Ai(e.toString(),r,i)}return null}_attribute(){let e=[];for(;this._match(b.tokens.attr);){let r=this._consume(b.attribute_name,"Expected attribute name"),i=new Ic(r.toString(),null);if(this._match(b.tokens.paren_left)){if(i.value=this._consume(b.literal_or_ident,"Expected attribute value").toString(),this._check(b.tokens.comma)){this._advance();do{let s=this._consume(b.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(s)}while(this._match(b.tokens.comma))}this._consume(b.tokens.paren_right,"Expected ')'")}e.push(i)}for(;this._match(b.tokens.attr_left);){if(!this._check(b.tokens.attr_right))do{let r=this._consume(b.attribute_name,"Expected attribute name"),i=new Ic(r.toString(),null);if(this._match(b.tokens.paren_left)){if(i.value=[this._consume(b.literal_or_ident,"Expected attribute value").toString()],this._check(b.tokens.comma)){this._advance();do{let s=this._consume(b.literal_or_ident,"Expected attribute value").toString();i.value.push(s)}while(this._match(b.tokens.comma))}this._consume(b.tokens.paren_right,"Expected ')'")}e.push(i)}while(this._match(b.tokens.comma));this._consume(b.tokens.attr_right,"Expected ']]' after attribute declarations")}return e.length==0?null:e}},Vr=class{constructor(e,r){this.name=e,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Nc=class{constructor(e,r,i){this.name=e,this.type=r,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.format: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}},fs=class extends Vr{constructor(e,r){super(e,r),this.members=[],this.align=0}get isStruct(){return!0}},Gn=class extends Vr{constructor(e,r){super(e,r),this.count=0,this.stride=0}get isArray(){return!0}},Fc=class extends Vr{constructor(e,r,i,s){super(e,i),this.format=r,this.access=s}get isTemplate(){return!0}},Ur;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(Ur||(Ur={}));var hs=class{constructor(e,r,i,s,n,o,a){this.name=e,this.type=r,this.group=i,this.binding=s,this.attributes=n,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.format: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}},oh=class{constructor(e,r){this.name=e,this.type=r}},ds=class{constructor(e,r){this.align=e,this.size=r}},ah=class{constructor(e,r,i,s){this.name=e,this.type=r,this.locationType=i,this.location=s,this.interpolation=null}},Dc=class{constructor(e,r,i,s){this.name=e,this.type=r,this.locationType=i,this.location=s}},ch=class{constructor(e,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.name=e,this.stage=r}},lh=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},uh=class{constructor(e,r,i,s){this.name=e,this.type=r,this.attributes=i,this.id=s}},Pi=class t{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new lh,this._types=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let i=new nh().parse(e);for(let s of i){if(s instanceof pr){let n=this._getTypeInfo(s,null);n instanceof fs&&this.structs.push(n);continue}if(s instanceof Tc){this.aliases.push(this._getAliasInfo(s));continue}if(s instanceof yc){let n=s,o=this._getAttributeNum(n.attributes,"id",0),a=n.type!=null?this._getTypeInfo(n.type,n.attributes):null;this.overrides.push(new uh(n.name,a,n.attributes,o));continue}if(this._isUniformVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new hs(n.name,c,o,a,n.attributes,Ur.Uniform,n.access);this.uniforms.push(l);continue}if(this._isStorageVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new hs(n.name,c,o,a,n.attributes,l?Ur.StorageTexture:Ur.Storage,n.access);this.storage.push(u);continue}if(this._isTextureVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new hs(n.name,c,o,a,n.attributes,l?Ur.StorageTexture:Ur.Texture,n.access);l?this.storage.push(u):this.textures.push(u);continue}if(this._isSamplerVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new hs(n.name,c,o,a,n.attributes,Ur.Sampler,n.access);this.samplers.push(l);continue}if(s instanceof xc){let n=this._getAttribute(s,"vertex"),o=this._getAttribute(s,"fragment"),a=this._getAttribute(s,"compute"),c=n||o||a;if(c){let l=new ch(s.name,c.name);l.inputs=this._getInputs(s.args),l.outputs=this._getOutputs(s.returnType),this.entry[c.name].push(l)}continue}}}getBindGroups(){let e=[];function r(i,s){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),s>=e[i].length&&(e[i].length=s+1)}for(let i of this.uniforms){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.storage){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.textures){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.samplers){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}return e}_getOutputs(e,r=void 0){if(r===void 0&&(r=[]),e instanceof pr)this._getStructOutputs(e,r);else{let i=this._getOutputInfo(e);i!==null&&r.push(i)}return r}_getStructOutputs(e,r){for(let i of e.members)if(i.type instanceof pr)this._getStructOutputs(i.type,r);else{let s=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(s!==null){let n=this._getTypeInfo(i.type,i.type.attributes),o=this._parseInt(s.value),a=new Dc(i.name,n,s.name,o);r.push(a)}}}_getOutputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getTypeInfo(e,e.attributes),s=this._parseInt(r.value);return new Dc("",i,r.name,s)}return null}_getInputs(e,r=void 0){r===void 0&&(r=[]);for(let i of e)if(i.type instanceof pr)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}return r}_getStructInputs(e,r){for(let i of e.members)if(i.type instanceof pr)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}}_getInputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getAttribute(e,"interpolation"),s=this._getTypeInfo(e.type,e.attributes),n=this._parseInt(r.value),o=new ah(e.name,s,r.name,n);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]);let r=parseInt(e);return isNaN(r)?e:r}_getAlias(e){for(let r of this.aliases)if(r.name==e)return r.type;return null}_getAliasInfo(e){return new oh(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,r){if(this._types.has(e))return this._types.get(e);if(e instanceof Sc){let s=e,n=this._getTypeInfo(s.format,s.attributes),o=new Gn(s.name,r);return o.format=n,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof pr){let s=e,n=new fs(s.name,r);for(let o of s.members){let a=this._getTypeInfo(o.type,o.attributes);n.members.push(new Nc(o.name,a,o.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof Ai){let s=e,n=s.format instanceof mr,o=s.format?n?this._getTypeInfo(s.format,null):new Vr(s.format,null):null,a=new Fc(s.name,o,r,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof Ec){let s=e,n=s.format?this._getTypeInfo(s.format,null):null,o=new Fc(s.name,n,r,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let i=new Vr(e.name,r);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var r,i;let s=this._getTypeSize(e);if(e.size=(r=s?.size)!==null&&r!==void 0?r:0,e instanceof Gn){let n=this._getTypeSize(e.format);e.stride=(i=n?.size)!==null&&i!==void 0?i:0,this._updateTypeInfo(e.format)}e instanceof fs&&this._updateStructInfo(e)}_updateStructInfo(e){var r;let i=0,s=0,n=0,o=0;for(let a=0,c=e.members.length;at.name);Pi._samplerTypes=b.sampler_type.map(t=>t.name);function fh(t){let e={attributes:[],bindings:[]},r;try{r=Gv(t)}catch(n){return O.error(n.message)(),e}for(let n of r.uniforms){let o=[];for(let a of n.type.members)o.push({name:a.name,type:Um(a.type)});e.bindings.push({type:"uniform",name:n.name,location:n.binding,group:n.group,members:o})}let i=r.entry.vertex[0],s=i?.inputs.length||0;for(let n=0;n`:t.name}function Gv(t){try{return new Pi(t)}catch(e){if(e instanceof Error)throw e;let r="WGSL parse error";throw typeof e=="object"&&e?.message&&(r+=`: ${e.message} `),typeof e=="object"&&e?.token&&(r+=e.token.line||""),new Error(r,{cause:e})}}var Zv=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),i--,i==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),i++)}return!0}}let r=V.none;for(;;){let i=this._findType(e),n=this._peekAhead();if(e==">"&&(n==">"||n=="=")){let s=!1,o=this._tokens.length-1;for(let a=0;a<5&&o>=0;++a,--o)if(this._tokens[o].type===V.tokens.less_than){o>0&&this._tokens[o-1].isArrayOrTemplateType()&&(s=!0);break}if(s)return this._addToken(i),!0}if(i===V.none){let s=e,o=0,a=2;for(let A=0;A=this._source.length}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let r=this._source[this._current];return e=e||0,e++,this._current+=e,r}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let r=this._source.substring(this._start,this._current);this._tokens.push(new R0(e,r,this._line))}},m_=class{constructor(){this._tokens=[],this._current=0,this._context=new G1}parse(e){this._initialize(e);let r=[];for(;!this._isAtEnd();){let i=this._global_decl_or_directive();if(!i)break;r.push(i)}return r}_initialize(e){if(e)if(typeof e=="string"){let r=new g_(e);this._tokens=r.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,r){return console.error(e,r),{token:e,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==V.eof}_match(e){if(e instanceof q)return this._check(e)?(this._advance(),!0):!1;for(let r=0,i=e.length;r'.");let n=this._paren_expression();return new c_(i,n)}let e=this._type_decl(),r=this._argument_expression_list();return new l_(e,r)}_argument_expression_list(){if(!this._match(V.tokens.paren_left))return null;let e=[];do{if(this._check(V.tokens.paren_right))break;let r=this._short_circuit_or_expression();e.push(r)}while(this._match(V.tokens.comma));return this._consume(V.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(V.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(V.tokens.paren_right),new C0([e])}_paren_expression(){this._consume(V.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(V.tokens.paren_right,"Expected ')'."),new C0([e])}_struct_decl(){if(!this._match(V.keywords.struct))return null;let e=this._consume(V.tokens.ident,"Expected name for struct.").toString();this._consume(V.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(V.tokens.brace_right);){let n=this._attribute(),s=this._consume(V.tokens.ident,"Expected variable name.").toString();this._consume(V.tokens.colon,"Expected ':' for struct member type.");let o=this._attribute(),a=this._type_decl();a!=null&&(a.attributes=o),this._check(V.tokens.brace_right)?this._match(V.tokens.comma):this._consume(V.tokens.comma,"Expected ',' for struct member."),r.push(new p_(s,a,n))}this._consume(V.tokens.brace_right,"Expected '}' after struct body.");let i=new ds(e,r);return this._context.structs.set(e,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(V.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(V.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(V.keywords.const))return null;let e=this._consume(V.tokens.ident,"Expected variable name"),r=null;if(this._match(V.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}let i=null;if(this._match(V.tokens.equal)){let s=this._short_circuit_or_expression();if(s instanceof ca)i=s;else if(s instanceof S0&&s.initializer instanceof ca)i=s.initializer;else try{let o=s.evaluate(this._context);i=new w0(o)}catch{i=s}}let n=new x0(e.toString(),r,"","",i);return this._context.constants.set(n.name,n),n}_global_let_decl(){if(!this._match(V.keywords.let))return null;let e=this._consume(V.tokens.ident,"Expected variable name"),r=null;if(this._match(V.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let i=null;return this._match(V.tokens.equal)&&(i=this._const_expression()),new y0(e.toString(),r,"","",i)}_const_expression(){if(this._match(V.const_literal))return new v0(this._previous().toString());let e=this._type_decl();this._consume(V.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(V.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(V.tokens.comma));)this._advance();return this._consume(V.tokens.paren_right,"Expected ')'."),new ca(e,r)}_variable_decl(){if(!this._match(V.keywords.var))return null;let e="",r="";this._match(V.tokens.less_than)&&(e=this._consume(V.storage_class,"Expected storage_class.").toString(),this._match(V.tokens.comma)&&(r=this._consume(V.access_mode,"Expected access_mode.").toString()),this._consume(V.tokens.greater_than,"Expected '>'."));let i=this._consume(V.tokens.ident,"Expected variable name"),n=null;if(this._match(V.tokens.colon)){let s=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=s)}return new eo(i.toString(),n,e,r,null)}_override_decl(){if(!this._match(V.keywords.override))return null;let e=this._consume(V.tokens.ident,"Expected variable name"),r=null;if(this._match(V.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}return new _0(e.toString(),r,null)}_enable_directive(){let e=this._consume(V.tokens.ident,"identity expected.");return new t_(e.toString())}_type_alias(){let e=this._consume(V.tokens.ident,"identity expected.");this._consume(V.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let i=new b0(e.toString(),r);return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([V.tokens.ident,...V.texel_format,V.keywords.bool,V.keywords.f32,V.keywords.i32,V.keywords.u32])){let i=this._advance(),n=i.toString();return this._context.structs.has(n)?this._context.structs.get(n):this._context.aliases.has(n)?this._context.aliases.get(n).type:new gs(i.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(V.template_types)){let i=this._advance().toString(),n=null,s=null;return this._match(V.tokens.less_than)&&(n=this._type_decl(),s=null,this._match(V.tokens.comma)&&(s=this._consume(V.access_mode,"Expected access_mode for pointer").toString()),this._consume(V.tokens.greater_than,"Expected '>' for type.")),new T0(i,n,s)}if(this._match(V.keywords.ptr)){let i=this._previous().toString();this._consume(V.tokens.less_than,"Expected '<' for pointer.");let n=this._consume(V.storage_class,"Expected storage_class for pointer");this._consume(V.tokens.comma,"Expected ',' for pointer.");let s=this._type_decl(),o=null;return this._match(V.tokens.comma)&&(o=this._consume(V.access_mode,"Expected access_mode for pointer").toString()),this._consume(V.tokens.greater_than,"Expected '>' for pointer."),new s_(i,n.toString(),s,o)}let r=this._attribute();if(this._match(V.keywords.array)){let i=null,n=-1,s=this._previous();if(this._match(V.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let o="";this._match(V.tokens.comma)&&(o=this._shift_expression().evaluate(this._context).toString()),this._consume(V.tokens.greater_than,"Expected '>' for array."),n=o?parseInt(o):0}return new E0(s.toString(),r,i,n)}return null}_texture_sampler_types(){if(this._match(V.sampler_type))return new aa(this._previous().toString(),null,null);if(this._match(V.depth_texture_type))return new aa(this._previous().toString(),null,null);if(this._match(V.sampled_texture_type)||this._match(V.multisampled_texture_type)){let e=this._previous();this._consume(V.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(V.tokens.greater_than,"Expected '>' for sampler type."),new aa(e.toString(),r,null)}if(this._match(V.storage_texture_type)){let e=this._previous();this._consume(V.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(V.texel_format,"Invalid texel format.").toString();this._consume(V.tokens.comma,"Expected ',' after texel format.");let i=this._consume(V.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(V.tokens.greater_than,"Expected '>' for sampler type."),new aa(e.toString(),r,i)}return null}_attribute(){let e=[];for(;this._match(V.tokens.attr);){let r=this._consume(V.attribute_name,"Expected attribute name"),i=new I0(r.toString(),null);if(this._match(V.tokens.paren_left)){if(i.value=this._consume(V.literal_or_ident,"Expected attribute value").toString(),this._check(V.tokens.comma)){this._advance();do{let n=this._consume(V.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(n)}while(this._match(V.tokens.comma))}this._consume(V.tokens.paren_right,"Expected ')'")}e.push(i)}for(;this._match(V.tokens.attr_left);){if(!this._check(V.tokens.attr_right))do{let r=this._consume(V.attribute_name,"Expected attribute name"),i=new I0(r.toString(),null);if(this._match(V.tokens.paren_left)){if(i.value=[this._consume(V.literal_or_ident,"Expected attribute value").toString()],this._check(V.tokens.comma)){this._advance();do{let n=this._consume(V.literal_or_ident,"Expected attribute value").toString();i.value.push(n)}while(this._match(V.tokens.comma))}this._consume(V.tokens.paren_right,"Expected ')'")}e.push(i)}while(this._match(V.tokens.comma));this._consume(V.tokens.attr_right,"Expected ']]' after attribute declarations")}return e.length==0?null:e}},to=class{constructor(e,r){this.name=e,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},B0=class{constructor(e,r,i){this.name=e,this.type=r,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.format: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}},wc=class extends to{constructor(e,r){super(e,r),this.members=[],this.align=0}get isStruct(){return!0}},$A=class extends to{constructor(e,r){super(e,r),this.count=0,this.stride=0}get isArray(){return!0}},O0=class extends to{constructor(e,r,i,n){super(e,i),this.format=r,this.access=n}get isTemplate(){return!0}},$s;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})($s||($s={}));var Cc=class{constructor(e,r,i,n,s,o,a){this.name=e,this.type=r,this.group=i,this.binding=n,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.format: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{constructor(e,r){this.name=e,this.type=r}},Mc=class{constructor(e,r){this.align=e,this.size=r}},y_=class{constructor(e,r,i,n){this.name=e,this.type=r,this.locationType=i,this.location=n,this.interpolation=null}},F0=class{constructor(e,r,i,n){this.name=e,this.type=r,this.locationType=i,this.location=n}},x_=class{constructor(e,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.name=e,this.stage=r}},b_=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},T_=class{constructor(e,r,i,n){this.name=e,this.type=r,this.attributes=i,this.id=n}},la=class t{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new b_,this._types=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let i=new m_().parse(e);for(let n of i){if(n instanceof ds){let s=this._getTypeInfo(n,null);s instanceof wc&&this.structs.push(s);continue}if(n instanceof b0){this.aliases.push(this._getAliasInfo(n));continue}if(n instanceof _0){let s=n,o=this._getAttributeNum(s.attributes,"id",0),a=s.type!=null?this._getTypeInfo(s.type,s.attributes):null;this.overrides.push(new T_(s.name,a,s.attributes,o));continue}if(this._isUniformVar(n)){let s=n,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),A=this._getTypeInfo(s.type,s.attributes),h=new Cc(s.name,A,o,a,s.attributes,$s.Uniform,s.access);this.uniforms.push(h);continue}if(this._isStorageVar(n)){let s=n,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),A=this._getTypeInfo(s.type,s.attributes),h=this._isStorageTexture(A),g=new Cc(s.name,A,o,a,s.attributes,h?$s.StorageTexture:$s.Storage,s.access);this.storage.push(g);continue}if(this._isTextureVar(n)){let s=n,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),A=this._getTypeInfo(s.type,s.attributes),h=this._isStorageTexture(A),g=new Cc(s.name,A,o,a,s.attributes,h?$s.StorageTexture:$s.Texture,s.access);h?this.storage.push(g):this.textures.push(g);continue}if(this._isSamplerVar(n)){let s=n,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),A=this._getTypeInfo(s.type,s.attributes),h=new Cc(s.name,A,o,a,s.attributes,$s.Sampler,s.access);this.samplers.push(h);continue}if(n instanceof m0){let s=this._getAttribute(n,"vertex"),o=this._getAttribute(n,"fragment"),a=this._getAttribute(n,"compute"),A=s||o||a;if(A){let h=new x_(n.name,A.name);h.inputs=this._getInputs(n.args),h.outputs=this._getOutputs(n.returnType),this.entry[A.name].push(h)}continue}}}getBindGroups(){let e=[];function r(i,n){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),n>=e[i].length&&(e[i].length=n+1)}for(let i of this.uniforms){r(i.group,i.binding);let n=e[i.group];n[i.binding]=i}for(let i of this.storage){r(i.group,i.binding);let n=e[i.group];n[i.binding]=i}for(let i of this.textures){r(i.group,i.binding);let n=e[i.group];n[i.binding]=i}for(let i of this.samplers){r(i.group,i.binding);let n=e[i.group];n[i.binding]=i}return e}_getOutputs(e,r=void 0){if(r===void 0&&(r=[]),e instanceof ds)this._getStructOutputs(e,r);else{let i=this._getOutputInfo(e);i!==null&&r.push(i)}return r}_getStructOutputs(e,r){for(let i of e.members)if(i.type instanceof ds)this._getStructOutputs(i.type,r);else{let n=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(n!==null){let s=this._getTypeInfo(i.type,i.type.attributes),o=this._parseInt(n.value),a=new F0(i.name,s,n.name,o);r.push(a)}}}_getOutputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getTypeInfo(e,e.attributes),n=this._parseInt(r.value);return new F0("",i,r.name,n)}return null}_getInputs(e,r=void 0){r===void 0&&(r=[]);for(let i of e)if(i.type instanceof ds)this._getStructInputs(i.type,r);else{let n=this._getInputInfo(i);n!==null&&r.push(n)}return r}_getStructInputs(e,r){for(let i of e.members)if(i.type instanceof ds)this._getStructInputs(i.type,r);else{let n=this._getInputInfo(i);n!==null&&r.push(n)}}_getInputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getAttribute(e,"interpolation"),n=this._getTypeInfo(e.type,e.attributes),s=this._parseInt(r.value),o=new y_(e.name,n,r.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]);let r=parseInt(e);return isNaN(r)?e:r}_getAlias(e){for(let r of this.aliases)if(r.name==e)return r.type;return null}_getAliasInfo(e){return new __(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,r){if(this._types.has(e))return this._types.get(e);if(e instanceof E0){let n=e,s=this._getTypeInfo(n.format,n.attributes),o=new $A(n.name,r);return o.format=s,o.count=n.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof ds){let n=e,s=new wc(n.name,r);for(let o of n.members){let a=this._getTypeInfo(o.type,o.attributes);s.members.push(new B0(o.name,a,o.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof aa){let n=e,s=n.format instanceof gs,o=n.format?s?this._getTypeInfo(n.format,null):new to(n.format,null):null,a=new O0(n.name,o,r,n.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof T0){let n=e,s=n.format?this._getTypeInfo(n.format,null):null,o=new O0(n.name,s,r,n.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let i=new to(e.name,r);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var r,i;let n=this._getTypeSize(e);if(e.size=(r=n?.size)!==null&&r!==void 0?r:0,e instanceof $A){let s=this._getTypeSize(e.format);e.stride=(i=s?.size)!==null&&i!==void 0?i:0,this._updateTypeInfo(e.format)}e instanceof wc&&this._updateStructInfo(e)}_updateStructInfo(e){var r;let i=0,n=0,s=0,o=0;for(let a=0,A=e.members.length;at.name);la._samplerTypes=V.sampler_type.map(t=>t.name);function E_(t){let e={attributes:[],bindings:[]},r;try{r=dD(t)}catch(s){return le.error(s.message)(),e}for(let s of r.uniforms){let o=[];for(let a of s.type.members)o.push({name:a.name,type:Pv(a.type)});e.bindings.push({type:"uniform",name:s.name,location:s.binding,group:s.group,members:o})}let i=r.entry.vertex[0],n=i?.inputs.length||0;for(let s=0;s`:t.name}function dD(t){try{return new la(t)}catch(e){if(e instanceof Error)throw e;let r="WGSL parse error";throw typeof e=="object"&&e?.message&&(r+=`: ${e.message} `),typeof e=="object"&&e?.token&&(r+=e.token.line||""),new Error(r,{cause:e})}}var pD=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND const float TWO_PI = 6.2831854820251465; const float PI_2 = 1.5707963705062866; const float PI_16 = 0.1963495463132858; @@ -217,7 +223,7 @@ return tan_taylor_fp32(a); return tan(a); #endif } -`,hh={name:"fp32",vs:Zv};var Jv=new Float32Array([0,1,1,1]),Qv=`uniform pickingUniforms { +`,v_={name:"fp32",vs:pD};var gD=new Float32Array([0,1,1,1]),mD=`uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -269,7 +275,7 @@ if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rgb = value; } } -`,eT=`uniform pickingUniforms { +`,_D=`uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -306,7 +312,7 @@ vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } -`,Lc={name:"picking",vs:Qv,fs:eT,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:new Float32Array([0,0,0]),highlightColor:Jv},getUniforms:tT};function tT(t={},e){let r={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let i=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=i}if(t.highlightColor){let i=Array.from(t.highlightColor,s=>s/255);Number.isFinite(i[3])||(i[3]=1),r.highlightColor=i}return t.isActive!==void 0&&(r.isActive=!!t.isActive,r.isAttribute=!!t.isAttribute),t.useFloatColors!==void 0&&(r.useFloatColors=!!t.useFloatColors),r}function dh(t,e=[],r=0){let i=Math.fround(t),s=t-i;return e[r]=i,e[r+1]=s,e}function zm(t){return t-Math.fround(t)}function Vm(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let s=r*4+i;dh(t[i*4+r],e,s*2)}return e}var Wm=`uniform float ONE; +`,L0={name:"picking",vs:mD,fs:_D,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:new Float32Array([0,0,0]),highlightColor:gD},getUniforms:yD};function yD(t={},e){let r={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let i=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=i}if(t.highlightColor){let i=Array.from(t.highlightColor,n=>n/255);Number.isFinite(i[3])||(i[3]=1),r.highlightColor=i}return t.isActive!==void 0&&(r.isActive=!!t.isActive,r.isAttribute=!!t.isAttribute),t.useFloatColors!==void 0&&(r.useFloatColors=!!t.useFloatColors),r}function S_(t,e=[],r=0){let i=Math.fround(t),n=t-i;return e[r]=i,e[r+1]=n,e}function Iv(t){return t-Math.fround(t)}function Rv(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let n=r*4+i;S_(t[i*4+r],e,n*2)}return e}var Bv=`uniform float ONE; vec2 split(float a) { const float SPLIT = 4097.0; float t = a * SPLIT; @@ -438,7 +444,7 @@ return sum_fp64(split(yn), prod); return sum_fp64(vec2(yn, 0.0), prod); #endif } -`;var rT={ONE:1};function iT(){return rT}var Wr={name:"fp64-arithmetic",vs:Wm,getUniforms:iT,fp64ify:dh,fp64LowPart:zm,fp64ifyMatrix4:Vm};var t9=1/Math.PI*180,r9=1/180*Math.PI,sT={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...sT}};var Me=globalThis.mathgl.config;function ph(t,{precision:e=Me.precision}={}){return t=nT(t),`${parseFloat(t.toPrecision(e))}`}function _r(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function xt(t,e,r){return aT(t,i=>Math.max(e,Math.min(r,i)))}function Rt(t,e,r){return _r(t)?t.map((i,s)=>Rt(i,e[s],r)):r*e+(1-r)*t}function xr(t,e,r){let i=Me.EPSILON;r&&(Me.EPSILON=r);try{if(t===e)return!0;if(_r(t)&&_r(e)){if(t.length!==e.length)return!1;for(let s=0;s0?", ":"")+ph(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r=0&&e=0&&edT,angle:()=>OT,ceil:()=>pT,clone:()=>lT,copy:()=>fT,create:()=>Hm,cross:()=>AT,dist:()=>VT,distance:()=>Ym,div:()=>zT,divide:()=>$m,dot:()=>ST,equals:()=>LT,exactEquals:()=>DT,floor:()=>gT,forEach:()=>jT,fromValues:()=>uT,inverse:()=>TT,len:()=>kT,length:()=>qm,lerp:()=>wT,max:()=>_T,min:()=>mT,mul:()=>UT,multiply:()=>Xm,negate:()=>vT,normalize:()=>ET,random:()=>PT,rotate:()=>IT,round:()=>xT,scale:()=>yT,scaleAndAdd:()=>bT,set:()=>hT,sqrDist:()=>WT,sqrLen:()=>HT,squaredDistance:()=>Km,squaredLength:()=>Gm,str:()=>FT,sub:()=>BT,subtract:()=>jm,transformMat2:()=>CT,transformMat2d:()=>RT,transformMat3:()=>MT,transformMat4:()=>mh,zero:()=>NT});var be=typeof Float32Array<"u"?Float32Array:Array,Gt=Math.random;function yt(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var d9=Math.PI/180;function Hm(){let t=new be(2);return be!=Float32Array&&(t[0]=0,t[1]=0),t}function lT(t){let e=new be(2);return e[0]=t[0],e[1]=t[1],e}function uT(t,e){let r=new be(2);return r[0]=t,r[1]=e,r}function fT(t,e){return t[0]=e[0],t[1]=e[1],t}function hT(t,e,r){return t[0]=e,t[1]=r,t}function dT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function jm(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Xm(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function $m(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function pT(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function gT(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function mT(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function _T(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function xT(t,e){return t[0]=yt(e[0]),t[1]=yt(e[1]),t}function yT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function bT(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function Ym(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function Km(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function qm(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function Gm(t){let e=t[0],r=t[1];return e*e+r*r}function vT(t,e){return t[0]=-e[0],t[1]=-e[1],t}function TT(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function ET(t,e){let r=e[0],i=e[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t}function ST(t,e){return t[0]*e[0]+t[1]*e[1]}function AT(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function wT(t,e,r,i){let s=e[0],n=e[1];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t}function PT(t,e){e=e===void 0?1:e;let r=Gt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function CT(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t}function RT(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s+r[4],t[1]=r[1]*i+r[3]*s+r[5],t}function MT(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t}function mh(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[4]*s+r[12],t[1]=r[1]*i+r[5]*s+r[13],t}function IT(t,e,r,i){let s=e[0]-r[0],n=e[1]-r[1],o=Math.sin(i),a=Math.cos(i);return t[0]=s*a-n*o+r[0],t[1]=s*o+n*a+r[1],t}function OT(t,e){let r=t[0],i=t[1],s=e[0],n=e[1],o=Math.sqrt((r*r+i*i)*(s*s+n*n)),a=o&&(r*s+i*n)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function NT(t){return t[0]=0,t[1]=0,t}function FT(t){return`vec2(${t[0]}, ${t[1]})`}function DT(t,e){return t[0]===e[0]&&t[1]===e[1]}function LT(t,e){let r=t[0],i=t[1],s=e[0],n=e[1];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var kT=qm,BT=jm,UT=Xm,zT=$m,VT=Ym,WT=Km,HT=Gm,jT=function(){let t=Hm();return function(e,r,i,s,n,o){let a,c;for(r||(r=2),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;aqT,angle:()=>Sh,bezier:()=>lE,ceil:()=>GT,clone:()=>XT,copy:()=>YT,create:()=>Qm,cross:()=>xh,dist:()=>xE,distance:()=>s1,div:()=>_E,divide:()=>i1,dot:()=>_h,equals:()=>pE,exactEquals:()=>dE,floor:()=>ZT,forEach:()=>TE,fromValues:()=>$T,hermite:()=>cE,inverse:()=>sE,len:()=>bE,length:()=>e1,lerp:()=>oE,max:()=>QT,min:()=>JT,mul:()=>mE,multiply:()=>r1,negate:()=>iE,normalize:()=>nE,random:()=>uE,rotateX:()=>vh,rotateY:()=>Th,rotateZ:()=>Eh,round:()=>eE,scale:()=>tE,scaleAndAdd:()=>rE,set:()=>KT,slerp:()=>aE,sqrDist:()=>yE,sqrLen:()=>vE,squaredDistance:()=>n1,squaredLength:()=>o1,str:()=>hE,sub:()=>gE,subtract:()=>t1,transformMat3:()=>yh,transformMat4:()=>Jn,transformQuat:()=>bh,zero:()=>fE});function Qm(){let t=new be(3);return be!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function XT(t){let e=new be(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function e1(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function $T(t,e,r){let i=new be(3);return i[0]=t,i[1]=e,i[2]=r,i}function YT(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function KT(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function qT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function t1(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function r1(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function i1(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function GT(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function ZT(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function JT(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function QT(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function eE(t,e){return t[0]=yt(e[0]),t[1]=yt(e[1]),t[2]=yt(e[2]),t}function tE(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function rE(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function s1(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(r*r+i*i+s*s)}function n1(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return r*r+i*i+s*s}function o1(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function iE(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function sE(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function nE(t,e){let r=e[0],i=e[1],s=e[2],n=r*r+i*i+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function _h(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xh(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[0],a=r[1],c=r[2];return t[0]=s*c-n*a,t[1]=n*o-i*c,t[2]=i*a-s*o,t}function oE(t,e,r,i){let s=e[0],n=e[1],o=e[2];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t[2]=o+i*(r[2]-o),t}function aE(t,e,r,i){let s=Math.acos(Math.min(Math.max(_h(e,r),-1),1)),n=Math.sin(s),o=Math.sin((1-i)*s)/n,a=Math.sin(i*s)/n;return t[0]=o*e[0]+a*r[0],t[1]=o*e[1]+a*r[1],t[2]=o*e[2]+a*r[2],t}function cE(t,e,r,i,s,n){let o=n*n,a=o*(2*n-3)+1,c=o*(n-2)+n,l=o*(n-1),u=o*(3-2*n);return t[0]=e[0]*a+r[0]*c+i[0]*l+s[0]*u,t[1]=e[1]*a+r[1]*c+i[1]*l+s[1]*u,t[2]=e[2]*a+r[2]*c+i[2]*l+s[2]*u,t}function lE(t,e,r,i,s,n){let o=1-n,a=o*o,c=n*n,l=a*o,u=3*n*a,f=3*c*o,h=c*n;return t[0]=e[0]*l+r[0]*u+i[0]*f+s[0]*h,t[1]=e[1]*l+r[1]*u+i[1]*f+s[1]*h,t[2]=e[2]*l+r[2]*u+i[2]*f+s[2]*h,t}function uE(t,e){e=e===void 0?1:e;let r=Gt()*2*Math.PI,i=Gt()*2-1,s=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=i*e,t}function Jn(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[3]*i+r[7]*s+r[11]*n+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*s+r[8]*n+r[12])/o,t[1]=(r[1]*i+r[5]*s+r[9]*n+r[13])/o,t[2]=(r[2]*i+r[6]*s+r[10]*n+r[14])/o,t}function yh(t,e,r){let i=e[0],s=e[1],n=e[2];return t[0]=i*r[0]+s*r[3]+n*r[6],t[1]=i*r[1]+s*r[4]+n*r[7],t[2]=i*r[2]+s*r[5]+n*r[8],t}function bh(t,e,r){let i=r[0],s=r[1],n=r[2],o=r[3],a=e[0],c=e[1],l=e[2],u=s*l-n*c,f=n*a-i*l,h=i*c-s*a,d=s*h-n*f,p=n*u-i*h,g=i*f-s*u,_=o*2;return u*=_,f*=_,h*=_,d*=2,p*=2,g*=2,t[0]=a+u+d,t[1]=c+f+p,t[2]=l+h+g,t}function vh(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[0],n[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),n[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Th(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),n[1]=s[1],n[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Eh(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),n[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),n[2]=s[2],t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Sh(t,e){let r=t[0],i=t[1],s=t[2],n=e[0],o=e[1],a=e[2],c=Math.sqrt((r*r+i*i+s*s)*(n*n+o*o+a*a)),l=c&&_h(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function fE(t){return t[0]=0,t[1]=0,t[2]=0,t}function hE(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function dE(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function pE(t,e){let r=t[0],i=t[1],s=t[2],n=e[0],o=e[1],a=e[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var gE=t1,mE=r1,_E=i1,xE=s1,yE=n1,bE=e1,vE=o1,TE=function(){let t=Qm();return function(e,r,i,s,n,o){let a,c;for(r||(r=3),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;aYE,adjoint:()=>CE,clone:()=>SE,copy:()=>AE,create:()=>EE,decompose:()=>BE,determinant:()=>Ch,equals:()=>ZE,exactEquals:()=>GE,frob:()=>$E,fromQuat:()=>Dh,fromQuat2:()=>DE,fromRotation:()=>IE,fromRotationTranslation:()=>c1,fromRotationTranslationScale:()=>UE,fromRotationTranslationScaleOrigin:()=>zE,fromScaling:()=>ME,fromTranslation:()=>RE,fromValues:()=>wE,fromXRotation:()=>OE,fromYRotation:()=>NE,fromZRotation:()=>FE,frustum:()=>Lh,getRotation:()=>kE,getScaling:()=>l1,getTranslation:()=>LE,identity:()=>a1,invert:()=>Ph,lookAt:()=>Uh,mul:()=>JE,multiply:()=>Qn,multiplyScalar:()=>KE,multiplyScalarAndAdd:()=>qE,ortho:()=>Bh,orthoNO:()=>f1,orthoZO:()=>HE,perspective:()=>kh,perspectiveFromFieldOfView:()=>WE,perspectiveNO:()=>u1,perspectiveZO:()=>VE,rotate:()=>Ih,rotateX:()=>Oh,rotateY:()=>Nh,rotateZ:()=>Fh,scale:()=>Mh,set:()=>PE,str:()=>XE,sub:()=>QE,subtract:()=>h1,targetTo:()=>jE,translate:()=>Rh,transpose:()=>wh});function EE(){let t=new be(16);return be!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function SE(t){let e=new be(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function AE(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function wE(t,e,r,i,s,n,o,a,c,l,u,f,h,d,p,g){let _=new be(16);return _[0]=t,_[1]=e,_[2]=r,_[3]=i,_[4]=s,_[5]=n,_[6]=o,_[7]=a,_[8]=c,_[9]=l,_[10]=u,_[11]=f,_[12]=h,_[13]=d,_[14]=p,_[15]=g,_}function PE(t,e,r,i,s,n,o,a,c,l,u,f,h,d,p,g,_){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=n,t[5]=o,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=h,t[12]=d,t[13]=p,t[14]=g,t[15]=_,t}function a1(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wh(t,e){if(t===e){let r=e[1],i=e[2],s=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=n,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ph(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],_=e[14],y=e[15],v=r*a-i*o,T=r*c-s*o,S=r*l-n*o,R=i*c-s*a,M=i*l-n*a,F=s*l-n*c,N=u*g-f*p,D=u*_-h*p,L=u*y-d*p,Y=f*_-h*g,X=f*y-d*g,$=h*y-d*_,Z=v*$-T*X+S*Y+R*L-M*D+F*N;return Z?(Z=1/Z,t[0]=(a*$-c*X+l*Y)*Z,t[1]=(s*X-i*$-n*Y)*Z,t[2]=(g*F-_*M+y*R)*Z,t[3]=(h*M-f*F-d*R)*Z,t[4]=(c*L-o*$-l*D)*Z,t[5]=(r*$-s*L+n*D)*Z,t[6]=(_*S-p*F-y*T)*Z,t[7]=(u*F-h*S+d*T)*Z,t[8]=(o*X-a*L+l*N)*Z,t[9]=(i*L-r*X-n*N)*Z,t[10]=(p*M-g*S+y*v)*Z,t[11]=(f*S-u*M-d*v)*Z,t[12]=(a*D-o*Y-c*N)*Z,t[13]=(r*Y-i*D+s*N)*Z,t[14]=(g*T-p*R-_*v)*Z,t[15]=(u*R-f*T+h*v)*Z,t):null}function CE(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],_=e[14],y=e[15],v=r*a-i*o,T=r*c-s*o,S=r*l-n*o,R=i*c-s*a,M=i*l-n*a,F=s*l-n*c,N=u*g-f*p,D=u*_-h*p,L=u*y-d*p,Y=f*_-h*g,X=f*y-d*g,$=h*y-d*_;return t[0]=a*$-c*X+l*Y,t[1]=s*X-i*$-n*Y,t[2]=g*F-_*M+y*R,t[3]=h*M-f*F-d*R,t[4]=c*L-o*$-l*D,t[5]=r*$-s*L+n*D,t[6]=_*S-p*F-y*T,t[7]=u*F-h*S+d*T,t[8]=o*X-a*L+l*N,t[9]=i*L-r*X-n*N,t[10]=p*M-g*S+y*v,t[11]=f*S-u*M-d*v,t[12]=a*D-o*Y-c*N,t[13]=r*Y-i*D+s*N,t[14]=g*T-p*R-_*v,t[15]=u*R-f*T+h*v,t}function Ch(t){let e=t[0],r=t[1],i=t[2],s=t[3],n=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],_=t[15],y=e*o-r*n,v=e*a-i*n,T=r*a-i*o,S=l*p-u*d,R=l*g-f*d,M=u*g-f*p,F=e*M-r*R+i*S,N=n*M-o*R+a*S,D=l*T-u*v+f*y,L=d*T-p*v+g*y;return c*F-s*N+_*D-h*L}function Qn(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],_=e[13],y=e[14],v=e[15],T=r[0],S=r[1],R=r[2],M=r[3];return t[0]=T*i+S*a+R*f+M*g,t[1]=T*s+S*c+R*h+M*_,t[2]=T*n+S*l+R*d+M*y,t[3]=T*o+S*u+R*p+M*v,T=r[4],S=r[5],R=r[6],M=r[7],t[4]=T*i+S*a+R*f+M*g,t[5]=T*s+S*c+R*h+M*_,t[6]=T*n+S*l+R*d+M*y,t[7]=T*o+S*u+R*p+M*v,T=r[8],S=r[9],R=r[10],M=r[11],t[8]=T*i+S*a+R*f+M*g,t[9]=T*s+S*c+R*h+M*_,t[10]=T*n+S*l+R*d+M*y,t[11]=T*o+S*u+R*p+M*v,T=r[12],S=r[13],R=r[14],M=r[15],t[12]=T*i+S*a+R*f+M*g,t[13]=T*s+S*c+R*h+M*_,t[14]=T*n+S*l+R*d+M*y,t[15]=T*o+S*u+R*p+M*v,t}function Rh(t,e,r){let i=r[0],s=r[1],n=r[2],o,a,c,l,u,f,h,d,p,g,_,y;return e===t?(t[12]=e[0]*i+e[4]*s+e[8]*n+e[12],t[13]=e[1]*i+e[5]*s+e[9]*n+e[13],t[14]=e[2]*i+e[6]*s+e[10]*n+e[14],t[15]=e[3]*i+e[7]*s+e[11]*n+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],p=e[8],g=e[9],_=e[10],y=e[11],t[0]=o,t[1]=a,t[2]=c,t[3]=l,t[4]=u,t[5]=f,t[6]=h,t[7]=d,t[8]=p,t[9]=g,t[10]=_,t[11]=y,t[12]=o*i+u*s+p*n+e[12],t[13]=a*i+f*s+g*n+e[13],t[14]=c*i+h*s+_*n+e[14],t[15]=l*i+d*s+y*n+e[15]),t}function Mh(t,e,r){let i=r[0],s=r[1],n=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ih(t,e,r,i){let s=i[0],n=i[1],o=i[2],a=Math.sqrt(s*s+n*n+o*o),c,l,u,f,h,d,p,g,_,y,v,T,S,R,M,F,N,D,L,Y,X,$,Z,ge;return a<1e-6?null:(a=1/a,s*=a,n*=a,o*=a,l=Math.sin(r),c=Math.cos(r),u=1-c,f=e[0],h=e[1],d=e[2],p=e[3],g=e[4],_=e[5],y=e[6],v=e[7],T=e[8],S=e[9],R=e[10],M=e[11],F=s*s*u+c,N=n*s*u+o*l,D=o*s*u-n*l,L=s*n*u-o*l,Y=n*n*u+c,X=o*n*u+s*l,$=s*o*u+n*l,Z=n*o*u-s*l,ge=o*o*u+c,t[0]=f*F+g*N+T*D,t[1]=h*F+_*N+S*D,t[2]=d*F+y*N+R*D,t[3]=p*F+v*N+M*D,t[4]=f*L+g*Y+T*X,t[5]=h*L+_*Y+S*X,t[6]=d*L+y*Y+R*X,t[7]=p*L+v*Y+M*X,t[8]=f*$+g*Z+T*ge,t[9]=h*$+_*Z+S*ge,t[10]=d*$+y*Z+R*ge,t[11]=p*$+v*Z+M*ge,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Oh(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+l*i,t[5]=o*s+u*i,t[6]=a*s+f*i,t[7]=c*s+h*i,t[8]=l*s-n*i,t[9]=u*s-o*i,t[10]=f*s-a*i,t[11]=h*s-c*i,t}function Nh(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s-l*i,t[1]=o*s-u*i,t[2]=a*s-f*i,t[3]=c*s-h*i,t[8]=n*i+l*s,t[9]=o*i+u*s,t[10]=a*i+f*s,t[11]=c*i+h*s,t}function Fh(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+l*i,t[1]=o*s+u*i,t[2]=a*s+f*i,t[3]=c*s+h*i,t[4]=l*s-n*i,t[5]=u*s-o*i,t[6]=f*s-a*i,t[7]=h*s-c*i,t}function RE(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function ME(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function IE(t,e,r){let i=r[0],s=r[1],n=r[2],o=Math.sqrt(i*i+s*s+n*n),a,c,l;return o<1e-6?null:(o=1/o,i*=o,s*=o,n*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=s*i*l+n*c,t[2]=n*i*l-s*c,t[3]=0,t[4]=i*s*l-n*c,t[5]=s*s*l+a,t[6]=n*s*l+i*c,t[7]=0,t[8]=i*n*l+s*c,t[9]=s*n*l-i*c,t[10]=n*n*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function OE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function NE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function FE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function c1(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3],a=i+i,c=s+s,l=n+n,u=i*a,f=i*c,h=i*l,d=s*c,p=s*l,g=n*l,_=o*a,y=o*c,v=o*l;return t[0]=1-(d+g),t[1]=f+v,t[2]=h-y,t[3]=0,t[4]=f-v,t[5]=1-(u+g),t[6]=p+_,t[7]=0,t[8]=h+y,t[9]=p-_,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function DE(t,e){let r=new be(3),i=-e[0],s=-e[1],n=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+s*s+n*n+o*o;return f>0?(r[0]=(a*o+u*i+c*n-l*s)*2/f,r[1]=(c*o+u*s+l*i-a*n)*2/f,r[2]=(l*o+u*n+a*s-c*i)*2/f):(r[0]=(a*o+u*i+c*n-l*s)*2,r[1]=(c*o+u*s+l*i-a*n)*2,r[2]=(l*o+u*n+a*s-c*i)*2),c1(t,e,r),t}function LE(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function l1(t,e){let r=e[0],i=e[1],s=e[2],n=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return t[0]=Math.sqrt(r*r+i*i+s*s),t[1]=Math.sqrt(n*n+o*o+a*a),t[2]=Math.sqrt(c*c+l*l+u*u),t}function kE(t,e){let r=new be(3);l1(r,e);let i=1/r[0],s=1/r[1],n=1/r[2],o=e[0]*i,a=e[1]*s,c=e[2]*n,l=e[4]*i,u=e[5]*s,f=e[6]*n,h=e[8]*i,d=e[9]*s,p=e[10]*n,g=o+u+p,_=0;return g>0?(_=Math.sqrt(g+1)*2,t[3]=.25*_,t[0]=(f-d)/_,t[1]=(h-c)/_,t[2]=(a-l)/_):o>u&&o>p?(_=Math.sqrt(1+o-u-p)*2,t[3]=(f-d)/_,t[0]=.25*_,t[1]=(a+l)/_,t[2]=(h+c)/_):u>p?(_=Math.sqrt(1+u-o-p)*2,t[3]=(h-c)/_,t[0]=(a+l)/_,t[1]=.25*_,t[2]=(f+d)/_):(_=Math.sqrt(1+p-o-u)*2,t[3]=(a-l)/_,t[0]=(h+c)/_,t[1]=(f+d)/_,t[2]=.25*_),t}function BE(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let s=i[0],n=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],h=i[10];r[0]=Math.sqrt(s*s+n*n+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(u*u+f*f+h*h);let d=1/r[0],p=1/r[1],g=1/r[2],_=s*d,y=n*p,v=o*g,T=a*d,S=c*p,R=l*g,M=u*d,F=f*p,N=h*g,D=_+S+N,L=0;return D>0?(L=Math.sqrt(D+1)*2,t[3]=.25*L,t[0]=(R-F)/L,t[1]=(M-v)/L,t[2]=(y-T)/L):_>S&&_>N?(L=Math.sqrt(1+_-S-N)*2,t[3]=(R-F)/L,t[0]=.25*L,t[1]=(y+T)/L,t[2]=(M+v)/L):S>N?(L=Math.sqrt(1+S-_-N)*2,t[3]=(M-v)/L,t[0]=(y+T)/L,t[1]=.25*L,t[2]=(R+F)/L):(L=Math.sqrt(1+N-_-S)*2,t[3]=(y-T)/L,t[0]=(M+v)/L,t[1]=(R+F)/L,t[2]=.25*L),t}function UE(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=e[3],c=s+s,l=n+n,u=o+o,f=s*c,h=s*l,d=s*u,p=n*l,g=n*u,_=o*u,y=a*c,v=a*l,T=a*u,S=i[0],R=i[1],M=i[2];return t[0]=(1-(p+_))*S,t[1]=(h+T)*S,t[2]=(d-v)*S,t[3]=0,t[4]=(h-T)*R,t[5]=(1-(f+_))*R,t[6]=(g+y)*R,t[7]=0,t[8]=(d+v)*M,t[9]=(g-y)*M,t[10]=(1-(f+p))*M,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function zE(t,e,r,i,s){let n=e[0],o=e[1],a=e[2],c=e[3],l=n+n,u=o+o,f=a+a,h=n*l,d=n*u,p=n*f,g=o*u,_=o*f,y=a*f,v=c*l,T=c*u,S=c*f,R=i[0],M=i[1],F=i[2],N=s[0],D=s[1],L=s[2],Y=(1-(g+y))*R,X=(d+S)*R,$=(p-T)*R,Z=(d-S)*M,ge=(1-(h+y))*M,rt=(_+v)*M,ot=(p+T)*F,Pt=(_-v)*F,Vt=(1-(h+g))*F;return t[0]=Y,t[1]=X,t[2]=$,t[3]=0,t[4]=Z,t[5]=ge,t[6]=rt,t[7]=0,t[8]=ot,t[9]=Pt,t[10]=Vt,t[11]=0,t[12]=r[0]+N-(Y*N+Z*D+ot*L),t[13]=r[1]+D-(X*N+ge*D+Pt*L),t[14]=r[2]+L-($*N+rt*D+Vt*L),t[15]=1,t}function Dh(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=r+r,a=i+i,c=s+s,l=r*o,u=i*o,f=i*a,h=s*o,d=s*a,p=s*c,g=n*o,_=n*a,y=n*c;return t[0]=1-f-p,t[1]=u+y,t[2]=h-_,t[3]=0,t[4]=u-y,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=h+_,t[9]=d-g,t[10]=1-l-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Lh(t,e,r,i,s,n,o){let a=1/(r-e),c=1/(s-i),l=1/(n-o);return t[0]=n*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+i)*c,t[10]=(o+n)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*n*2*l,t[15]=0,t}function u1(t,e,r,i,s){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let o=1/(i-s);t[10]=(s+i)*o,t[14]=2*s*i*o}else t[10]=-1,t[14]=-2*i;return t}var kh=u1;function VE(t,e,r,i,s){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let o=1/(i-s);t[10]=s*o,t[14]=s*i*o}else t[10]=-1,t[14]=-i;return t}function WE(t,e,r,i){let s=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(s+n);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((o-a)*c*.5),t[9]=(s-n)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function f1(t,e,r,i,s,n,o){let a=1/(e-r),c=1/(i-s),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=(o+n)*l,t[15]=1,t}var Bh=f1;function HE(t,e,r,i,s,n,o){let a=1/(e-r),c=1/(i-s),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=n*l,t[15]=1,t}function Uh(t,e,r,i){let s,n,o,a,c,l,u,f,h,d,p=e[0],g=e[1],_=e[2],y=i[0],v=i[1],T=i[2],S=r[0],R=r[1],M=r[2];return Math.abs(p-S)<1e-6&&Math.abs(g-R)<1e-6&&Math.abs(_-M)<1e-6?a1(t):(f=p-S,h=g-R,d=_-M,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,n=v*d-T*h,o=T*f-y*d,a=y*h-v*f,s=Math.sqrt(n*n+o*o+a*a),s?(s=1/s,n*=s,o*=s,a*=s):(n=0,o=0,a=0),c=h*a-d*o,l=d*n-f*a,u=f*o-h*n,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),t[0]=n,t[1]=c,t[2]=f,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(n*p+o*g+a*_),t[13]=-(c*p+l*g+u*_),t[14]=-(f*p+h*g+d*_),t[15]=1,t)}function jE(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=s-r[0],f=n-r[1],h=o-r[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let p=c*h-l*f,g=l*u-a*h,_=a*f-c*u;return d=p*p+g*g+_*_,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,_*=d),t[0]=p,t[1]=g,t[2]=_,t[3]=0,t[4]=f*_-h*g,t[5]=h*p-u*_,t[6]=u*g-f*p,t[7]=0,t[8]=u,t[9]=f,t[10]=h,t[11]=0,t[12]=s,t[13]=n,t[14]=o,t[15]=1,t}function XE(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function $E(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function YE(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function h1(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function KE(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function qE(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function GE(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function ZE(t,e){let r=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],g=t[13],_=t[14],y=t[15],v=e[0],T=e[1],S=e[2],R=e[3],M=e[4],F=e[5],N=e[6],D=e[7],L=e[8],Y=e[9],X=e[10],$=e[11],Z=e[12],ge=e[13],rt=e[14],ot=e[15];return Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(i-T)<=1e-6*Math.max(1,Math.abs(i),Math.abs(T))&&Math.abs(s-S)<=1e-6*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(n-R)<=1e-6*Math.max(1,Math.abs(n),Math.abs(R))&&Math.abs(o-M)<=1e-6*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(a-F)<=1e-6*Math.max(1,Math.abs(a),Math.abs(F))&&Math.abs(c-N)<=1e-6*Math.max(1,Math.abs(c),Math.abs(N))&&Math.abs(l-D)<=1e-6*Math.max(1,Math.abs(l),Math.abs(D))&&Math.abs(u-L)<=1e-6*Math.max(1,Math.abs(u),Math.abs(L))&&Math.abs(f-Y)<=1e-6*Math.max(1,Math.abs(f),Math.abs(Y))&&Math.abs(h-X)<=1e-6*Math.max(1,Math.abs(h),Math.abs(X))&&Math.abs(d-$)<=1e-6*Math.max(1,Math.abs(d),Math.abs($))&&Math.abs(p-Z)<=1e-6*Math.max(1,Math.abs(p),Math.abs(Z))&&Math.abs(g-ge)<=1e-6*Math.max(1,Math.abs(g),Math.abs(ge))&&Math.abs(_-rt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(rt))&&Math.abs(y-ot)<=1e-6*Math.max(1,Math.abs(y),Math.abs(ot))}var JE=Qn,QE=h1;var Jt={};ui(Jt,{add:()=>sS,ceil:()=>nS,clone:()=>eS,copy:()=>rS,create:()=>d1,cross:()=>mS,dist:()=>PS,distance:()=>_1,div:()=>wS,divide:()=>m1,dot:()=>gS,equals:()=>ES,exactEquals:()=>TS,floor:()=>oS,forEach:()=>IS,fromValues:()=>tS,inverse:()=>dS,len:()=>RS,length:()=>y1,lerp:()=>_S,max:()=>cS,min:()=>aS,mul:()=>AS,multiply:()=>g1,negate:()=>hS,normalize:()=>pS,random:()=>xS,round:()=>lS,scale:()=>uS,scaleAndAdd:()=>fS,set:()=>iS,sqrDist:()=>CS,sqrLen:()=>MS,squaredDistance:()=>x1,squaredLength:()=>b1,str:()=>vS,sub:()=>SS,subtract:()=>p1,transformMat4:()=>zh,transformQuat:()=>yS,zero:()=>bS});function d1(){let t=new be(4);return be!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function eS(t){let e=new be(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function tS(t,e,r,i){let s=new be(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=i,s}function rS(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function iS(t,e,r,i,s){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t}function sS(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function p1(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function g1(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function m1(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function nS(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function oS(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function aS(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function cS(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function lS(t,e){return t[0]=yt(e[0]),t[1]=yt(e[1]),t[2]=yt(e[2]),t[3]=yt(e[3]),t}function uS(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function fS(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function _1(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],n=e[3]-t[3];return Math.sqrt(r*r+i*i+s*s+n*n)}function x1(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],n=e[3]-t[3];return r*r+i*i+s*s+n*n}function y1(t){let e=t[0],r=t[1],i=t[2],s=t[3];return Math.sqrt(e*e+r*r+i*i+s*s)}function b1(t){let e=t[0],r=t[1],i=t[2],s=t[3];return e*e+r*r+i*i+s*s}function hS(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function dS(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function pS(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=r*r+i*i+s*s+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=i*o,t[2]=s*o,t[3]=n*o,t}function gS(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function mS(t,e,r,i){let s=r[0]*i[1]-r[1]*i[0],n=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],u=e[0],f=e[1],h=e[2],d=e[3];return t[0]=f*l-h*c+d*a,t[1]=-(u*l)+h*o-d*n,t[2]=u*c-f*o+d*s,t[3]=-(u*a)+f*n-h*s,t}function _S(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=e[3];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t[2]=o+i*(r[2]-o),t[3]=a+i*(r[3]-a),t}function xS(t,e){e=e===void 0?1:e;let r,i,s,n,o,a;do r=Gt()*2-1,i=Gt()*2-1,o=r*r+i*i;while(o>=1);do s=Gt()*2-1,n=Gt()*2-1,a=s*s+n*n;while(a>=1);let c=Math.sqrt((1-o)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*s*c,t[3]=e*n*c,t}function zh(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3];return t[0]=r[0]*i+r[4]*s+r[8]*n+r[12]*o,t[1]=r[1]*i+r[5]*s+r[9]*n+r[13]*o,t[2]=r[2]*i+r[6]*s+r[10]*n+r[14]*o,t[3]=r[3]*i+r[7]*s+r[11]*n+r[15]*o,t}function yS(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[0],a=r[1],c=r[2],l=r[3],u=l*i+a*n-c*s,f=l*s+c*i-o*n,h=l*n+o*s-a*i,d=-o*i-a*s-c*n;return t[0]=u*l+d*-o+f*-c-h*-a,t[1]=f*l+d*-a+h*-o-u*-c,t[2]=h*l+d*-c+u*-a-f*-o,t[3]=e[3],t}function bS(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function vS(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function TS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function ES(t,e){let r=t[0],i=t[1],s=t[2],n=t[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var SS=p1,AS=g1,wS=m1,PS=_1,CS=x1,RS=y1,MS=b1,IS=function(){let t=d1();return function(e,r,i,s,n,o){let a,c;for(r||(r=4),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function kS(t,e,r,i,s,n){let o=2*n/(r-e),a=2*n/(s-i),c=(r+e)/(r-e),l=(s+i)/(s-i),u=-1,f=-1,h=-2*n;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=u,t[11]=f,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}var jh=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +`;var xD={ONE:1};function bD(){return xD}var ro={name:"fp64-arithmetic",vs:Bv,getUniforms:bD,fp64ify:S_,fp64LowPart:Iv,fp64ifyMatrix4:Rv};var TD=1/Math.PI*180,ED=1/180*Math.PI,vD={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...vD}};var Ut=globalThis.mathgl.config;function w_(t,{precision:e=Ut.precision}={}){return t=SD(t),`${parseFloat(t.toPrecision(e))}`}function vi(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function C_(t){return Ov(t)}function M_(t){return Si(t)}function Ov(t,e){return P_(t,r=>r*ED,e)}function Si(t,e){return P_(t,r=>r*TD,e)}function ei(t,e,r){return P_(t,i=>Math.max(e,Math.min(r,i)))}function Fr(t,e,r){return vi(t)?t.map((i,n)=>Fr(i,e[n],r)):r*e+(1-r)*t}function lr(t,e,r){let i=Ut.EPSILON;r&&(Ut.EPSILON=r);try{if(t===e)return!0;if(vi(t)&&vi(e)){if(t.length!==e.length)return!1;for(let n=0;n0?", ":"")+w_(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r=0&&e=0&&eBD,angle:()=>QD,ceil:()=>OD,clone:()=>MD,copy:()=>ID,create:()=>Fv,cross:()=>WD,dist:()=>i9,distance:()=>Uv,div:()=>r9,divide:()=>Dv,dot:()=>GD,equals:()=>ZD,exactEquals:()=>JD,floor:()=>FD,forEach:()=>o9,fromValues:()=>PD,inverse:()=>zD,len:()=>$D,length:()=>Vv,lerp:()=>jD,max:()=>ND,min:()=>LD,mul:()=>t9,multiply:()=>Nv,negate:()=>VD,normalize:()=>HD,random:()=>XD,rotate:()=>YD,round:()=>DD,scale:()=>UD,scaleAndAdd:()=>kD,set:()=>RD,sqrDist:()=>n9,sqrLen:()=>s9,squaredDistance:()=>kv,squaredLength:()=>zv,str:()=>KD,sub:()=>e9,subtract:()=>Lv,transformMat2:()=>I_,transformMat2d:()=>R_,transformMat3:()=>tu,transformMat4:()=>ru,zero:()=>qD});var Ot=typeof Float32Array<"u"?Float32Array:Array,zn=Math.random;function ki(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var NAe=Math.PI/180;function Fv(){let t=new Ot(2);return Ot!=Float32Array&&(t[0]=0,t[1]=0),t}function MD(t){let e=new Ot(2);return e[0]=t[0],e[1]=t[1],e}function PD(t,e){let r=new Ot(2);return r[0]=t,r[1]=e,r}function ID(t,e){return t[0]=e[0],t[1]=e[1],t}function RD(t,e,r){return t[0]=e,t[1]=r,t}function BD(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Lv(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Nv(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Dv(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function OD(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function FD(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function LD(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function ND(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function DD(t,e){return t[0]=ki(e[0]),t[1]=ki(e[1]),t}function UD(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function kD(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function Uv(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function kv(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function Vv(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function zv(t){let e=t[0],r=t[1];return e*e+r*r}function VD(t,e){return t[0]=-e[0],t[1]=-e[1],t}function zD(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function HD(t,e){let r=e[0],i=e[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t}function GD(t,e){return t[0]*e[0]+t[1]*e[1]}function WD(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function jD(t,e,r,i){let n=e[0],s=e[1];return t[0]=n+i*(r[0]-n),t[1]=s+i*(r[1]-s),t}function XD(t,e){e=e===void 0?1:e;let r=zn()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function I_(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t}function R_(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t}function tu(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t}function ru(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t}function YD(t,e,r,i){let n=e[0]-r[0],s=e[1]-r[1],o=Math.sin(i),a=Math.cos(i);return t[0]=n*a-s*o+r[0],t[1]=n*o+s*a+r[1],t}function QD(t,e){let r=t[0],i=t[1],n=e[0],s=e[1],o=Math.sqrt((r*r+i*i)*(n*n+s*s)),a=o&&(r*n+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function qD(t){return t[0]=0,t[1]=0,t}function KD(t){return`vec2(${t[0]}, ${t[1]})`}function JD(t,e){return t[0]===e[0]&&t[1]===e[1]}function ZD(t,e){let r=t[0],i=t[1],n=e[0],s=e[1];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var $D=Vv,e9=Lv,t9=Nv,r9=Dv,i9=Uv,n9=kv,s9=zv,o9=function(){let t=Fv();return function(e,r,i,n,s,o){let a,A;for(r||(r=2),i||(i=0),n?A=Math.min(n*r+i,e.length):A=e.length,a=i;aA9,angle:()=>N_,bezier:()=>E9,ceil:()=>u9,clone:()=>a9,copy:()=>c9,create:()=>k0,cross:()=>ua,dist:()=>B9,distance:()=>Qv,div:()=>R9,divide:()=>Yv,dot:()=>iu,equals:()=>M9,exactEquals:()=>C9,floor:()=>f9,forEach:()=>L9,fromValues:()=>V0,hermite:()=>T9,inverse:()=>y9,len:()=>D_,length:()=>Wv,lerp:()=>x9,max:()=>d9,min:()=>h9,mul:()=>I9,multiply:()=>Xv,negate:()=>_9,normalize:()=>B_,random:()=>v9,rotateX:()=>O_,rotateY:()=>F_,rotateZ:()=>L_,round:()=>p9,scale:()=>g9,scaleAndAdd:()=>m9,set:()=>l9,slerp:()=>b9,sqrDist:()=>O9,sqrLen:()=>F9,squaredDistance:()=>qv,squaredLength:()=>Kv,str:()=>w9,sub:()=>P9,subtract:()=>jv,transformMat3:()=>nu,transformMat4:()=>fa,transformQuat:()=>su,zero:()=>S9});function k0(){let t=new Ot(3);return Ot!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function a9(t){let e=new Ot(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Wv(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function V0(t,e,r){let i=new Ot(3);return i[0]=t,i[1]=e,i[2]=r,i}function c9(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function l9(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function A9(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function jv(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Xv(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Yv(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function u9(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function f9(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function h9(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function d9(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function p9(t,e){return t[0]=ki(e[0]),t[1]=ki(e[1]),t[2]=ki(e[2]),t}function g9(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function m9(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function Qv(t,e){let r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(r*r+i*i+n*n)}function qv(t,e){let r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return r*r+i*i+n*n}function Kv(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function _9(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function y9(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function B_(t,e){let r=e[0],i=e[1],n=e[2],s=r*r+i*i+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function iu(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ua(t,e,r){let i=e[0],n=e[1],s=e[2],o=r[0],a=r[1],A=r[2];return t[0]=n*A-s*a,t[1]=s*o-i*A,t[2]=i*a-n*o,t}function x9(t,e,r,i){let n=e[0],s=e[1],o=e[2];return t[0]=n+i*(r[0]-n),t[1]=s+i*(r[1]-s),t[2]=o+i*(r[2]-o),t}function b9(t,e,r,i){let n=Math.acos(Math.min(Math.max(iu(e,r),-1),1)),s=Math.sin(n),o=Math.sin((1-i)*n)/s,a=Math.sin(i*n)/s;return t[0]=o*e[0]+a*r[0],t[1]=o*e[1]+a*r[1],t[2]=o*e[2]+a*r[2],t}function T9(t,e,r,i,n,s){let o=s*s,a=o*(2*s-3)+1,A=o*(s-2)+s,h=o*(s-1),g=o*(3-2*s);return t[0]=e[0]*a+r[0]*A+i[0]*h+n[0]*g,t[1]=e[1]*a+r[1]*A+i[1]*h+n[1]*g,t[2]=e[2]*a+r[2]*A+i[2]*h+n[2]*g,t}function E9(t,e,r,i,n,s){let o=1-s,a=o*o,A=s*s,h=a*o,g=3*s*a,_=3*A*o,x=A*s;return t[0]=e[0]*h+r[0]*g+i[0]*_+n[0]*x,t[1]=e[1]*h+r[1]*g+i[1]*_+n[1]*x,t[2]=e[2]*h+r[2]*g+i[2]*_+n[2]*x,t}function v9(t,e){e=e===void 0?1:e;let r=zn()*2*Math.PI,i=zn()*2-1,n=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=i*e,t}function fa(t,e,r){let i=e[0],n=e[1],s=e[2],o=r[3]*i+r[7]*n+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*n+r[8]*s+r[12])/o,t[1]=(r[1]*i+r[5]*n+r[9]*s+r[13])/o,t[2]=(r[2]*i+r[6]*n+r[10]*s+r[14])/o,t}function nu(t,e,r){let i=e[0],n=e[1],s=e[2];return t[0]=i*r[0]+n*r[3]+s*r[6],t[1]=i*r[1]+n*r[4]+s*r[7],t[2]=i*r[2]+n*r[5]+s*r[8],t}function su(t,e,r){let i=r[0],n=r[1],s=r[2],o=r[3],a=e[0],A=e[1],h=e[2],g=n*h-s*A,_=s*a-i*h,x=i*A-n*a,T=n*x-s*_,v=s*g-i*x,S=i*_-n*g,C=o*2;return g*=C,_*=C,x*=C,T*=2,v*=2,S*=2,t[0]=a+g+T,t[1]=A+_+v,t[2]=h+x+S,t}function O_(t,e,r,i){let n=[],s=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],s[0]=n[0],s[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),s[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function F_(t,e,r,i){let n=[],s=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],s[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),s[1]=n[1],s[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function L_(t,e,r,i){let n=[],s=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],s[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),s[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),s[2]=n[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function N_(t,e){let r=t[0],i=t[1],n=t[2],s=e[0],o=e[1],a=e[2],A=Math.sqrt((r*r+i*i+n*n)*(s*s+o*o+a*a)),h=A&&iu(t,e)/A;return Math.acos(Math.min(Math.max(h,-1),1))}function S9(t){return t[0]=0,t[1]=0,t[2]=0,t}function w9(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function C9(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function M9(t,e){let r=t[0],i=t[1],n=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))}var P9=jv,I9=Xv,R9=Yv,B9=Qv,O9=qv,D_=Wv,F9=Kv,L9=function(){let t=k0();return function(e,r,i,n,s,o){let a,A;for(r||(r=3),i||(i=0),n?A=Math.min(n*r+i,e.length):A=e.length,a=i;a0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(N9)}fromObject(e){return this.check()}fromQuaternion(e){return iS(this,e),this.check()}set(e,r,i,n,s,o,a,A,h){return this[0]=e,this[1]=r,this[2]=i,this[3]=n,this[4]=s,this[5]=o,this[6]=a,this[7]=A,this[8]=h,this.check()}setRowMajor(e,r,i,n,s,o,a,A,h){return this[0]=e,this[1]=n,this[2]=a,this[3]=r,this[4]=s,this[5]=A,this[6]=i,this[7]=o,this[8]=h,this.check()}determinant(){return eS(this)}transpose(){return Zv(this,this),this.check()}invert(){return $v(this,this),this.check()}multiplyLeft(e){return k_(this,e,this),this.check()}multiplyRight(e){return k_(this,this,e),this.check()}rotate(e){return rS(this,this,e),this.check()}scale(e){return Array.isArray(e)?V_(this,this,e):V_(this,this,[e,e]),this.check()}translate(e){return tS(this,this,e),this.check()}transform(e,r){let i;switch(e.length){case 2:i=tu(r||[-0,-0],e,this);break;case 3:i=nu(r||[-0,-0,-0],e,this);break;case 4:i=U0(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return no(i,e.length),i}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},W0,j0=null;function D9(){return W0||(W0=new wt([0,0,0,0,0,0,0,0,0]),Object.freeze(W0)),W0}function U9(){return j0||(j0=new wt,Object.freeze(j0)),j0}var ir={};dr(ir,{add:()=>l7,adjoint:()=>W9,clone:()=>V9,copy:()=>z9,create:()=>k9,decompose:()=>e7,determinant:()=>W_,equals:()=>h7,exactEquals:()=>f7,frob:()=>c7,fromQuat:()=>J_,fromQuat2:()=>J9,fromRotation:()=>Y9,fromRotationTranslation:()=>oS,fromRotationTranslationScale:()=>t7,fromRotationTranslationScaleOrigin:()=>r7,fromScaling:()=>X9,fromTranslation:()=>j9,fromValues:()=>H9,fromXRotation:()=>Q9,fromYRotation:()=>q9,fromZRotation:()=>K9,frustum:()=>Z_,getRotation:()=>$9,getScaling:()=>aS,getTranslation:()=>Z9,identity:()=>sS,invert:()=>G_,lookAt:()=>t2,mul:()=>d7,multiply:()=>ou,multiplyScalar:()=>A7,multiplyScalarAndAdd:()=>u7,ortho:()=>e2,orthoNO:()=>lS,orthoZO:()=>s7,perspective:()=>$_,perspectiveFromFieldOfView:()=>n7,perspectiveNO:()=>cS,perspectiveZO:()=>i7,rotate:()=>Y_,rotateX:()=>Q_,rotateY:()=>q_,rotateZ:()=>K_,scale:()=>X_,set:()=>G9,str:()=>a7,sub:()=>p7,subtract:()=>AS,targetTo:()=>o7,translate:()=>j_,transpose:()=>H_});function k9(){let t=new Ot(16);return Ot!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function V9(t){let e=new Ot(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function z9(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function H9(t,e,r,i,n,s,o,a,A,h,g,_,x,T,v,S){let C=new Ot(16);return C[0]=t,C[1]=e,C[2]=r,C[3]=i,C[4]=n,C[5]=s,C[6]=o,C[7]=a,C[8]=A,C[9]=h,C[10]=g,C[11]=_,C[12]=x,C[13]=T,C[14]=v,C[15]=S,C}function G9(t,e,r,i,n,s,o,a,A,h,g,_,x,T,v,S,C){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t[4]=s,t[5]=o,t[6]=a,t[7]=A,t[8]=h,t[9]=g,t[10]=_,t[11]=x,t[12]=T,t[13]=v,t[14]=S,t[15]=C,t}function sS(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function H_(t,e){if(t===e){let r=e[1],i=e[2],n=e[3],s=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=s,t[11]=e[14],t[12]=n,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function G_(t,e){let r=e[0],i=e[1],n=e[2],s=e[3],o=e[4],a=e[5],A=e[6],h=e[7],g=e[8],_=e[9],x=e[10],T=e[11],v=e[12],S=e[13],C=e[14],M=e[15],R=r*a-i*o,B=r*A-n*o,k=r*h-s*o,Q=i*A-n*a,$=i*h-s*a,re=n*h-s*A,Y=g*S-_*v,H=g*C-x*v,L=g*M-T*v,ae=_*C-x*S,fe=_*M-T*S,he=x*M-T*C,ye=R*he-B*fe+k*ae+Q*L-$*H+re*Y;return ye?(ye=1/ye,t[0]=(a*he-A*fe+h*ae)*ye,t[1]=(n*fe-i*he-s*ae)*ye,t[2]=(S*re-C*$+M*Q)*ye,t[3]=(x*$-_*re-T*Q)*ye,t[4]=(A*L-o*he-h*H)*ye,t[5]=(r*he-n*L+s*H)*ye,t[6]=(C*k-v*re-M*B)*ye,t[7]=(g*re-x*k+T*B)*ye,t[8]=(o*fe-a*L+h*Y)*ye,t[9]=(i*L-r*fe-s*Y)*ye,t[10]=(v*$-S*k+M*R)*ye,t[11]=(_*k-g*$-T*R)*ye,t[12]=(a*H-o*ae-A*Y)*ye,t[13]=(r*ae-i*H+n*Y)*ye,t[14]=(S*B-v*Q-C*R)*ye,t[15]=(g*Q-_*B+x*R)*ye,t):null}function W9(t,e){let r=e[0],i=e[1],n=e[2],s=e[3],o=e[4],a=e[5],A=e[6],h=e[7],g=e[8],_=e[9],x=e[10],T=e[11],v=e[12],S=e[13],C=e[14],M=e[15],R=r*a-i*o,B=r*A-n*o,k=r*h-s*o,Q=i*A-n*a,$=i*h-s*a,re=n*h-s*A,Y=g*S-_*v,H=g*C-x*v,L=g*M-T*v,ae=_*C-x*S,fe=_*M-T*S,he=x*M-T*C;return t[0]=a*he-A*fe+h*ae,t[1]=n*fe-i*he-s*ae,t[2]=S*re-C*$+M*Q,t[3]=x*$-_*re-T*Q,t[4]=A*L-o*he-h*H,t[5]=r*he-n*L+s*H,t[6]=C*k-v*re-M*B,t[7]=g*re-x*k+T*B,t[8]=o*fe-a*L+h*Y,t[9]=i*L-r*fe-s*Y,t[10]=v*$-S*k+M*R,t[11]=_*k-g*$-T*R,t[12]=a*H-o*ae-A*Y,t[13]=r*ae-i*H+n*Y,t[14]=S*B-v*Q-C*R,t[15]=g*Q-_*B+x*R,t}function W_(t){let e=t[0],r=t[1],i=t[2],n=t[3],s=t[4],o=t[5],a=t[6],A=t[7],h=t[8],g=t[9],_=t[10],x=t[11],T=t[12],v=t[13],S=t[14],C=t[15],M=e*o-r*s,R=e*a-i*s,B=r*a-i*o,k=h*v-g*T,Q=h*S-_*T,$=g*S-_*v,re=e*$-r*Q+i*k,Y=s*$-o*Q+a*k,H=h*B-g*R+_*M,L=T*B-v*R+S*M;return A*re-n*Y+C*H-x*L}function ou(t,e,r){let i=e[0],n=e[1],s=e[2],o=e[3],a=e[4],A=e[5],h=e[6],g=e[7],_=e[8],x=e[9],T=e[10],v=e[11],S=e[12],C=e[13],M=e[14],R=e[15],B=r[0],k=r[1],Q=r[2],$=r[3];return t[0]=B*i+k*a+Q*_+$*S,t[1]=B*n+k*A+Q*x+$*C,t[2]=B*s+k*h+Q*T+$*M,t[3]=B*o+k*g+Q*v+$*R,B=r[4],k=r[5],Q=r[6],$=r[7],t[4]=B*i+k*a+Q*_+$*S,t[5]=B*n+k*A+Q*x+$*C,t[6]=B*s+k*h+Q*T+$*M,t[7]=B*o+k*g+Q*v+$*R,B=r[8],k=r[9],Q=r[10],$=r[11],t[8]=B*i+k*a+Q*_+$*S,t[9]=B*n+k*A+Q*x+$*C,t[10]=B*s+k*h+Q*T+$*M,t[11]=B*o+k*g+Q*v+$*R,B=r[12],k=r[13],Q=r[14],$=r[15],t[12]=B*i+k*a+Q*_+$*S,t[13]=B*n+k*A+Q*x+$*C,t[14]=B*s+k*h+Q*T+$*M,t[15]=B*o+k*g+Q*v+$*R,t}function j_(t,e,r){let i=r[0],n=r[1],s=r[2],o,a,A,h,g,_,x,T,v,S,C,M;return e===t?(t[12]=e[0]*i+e[4]*n+e[8]*s+e[12],t[13]=e[1]*i+e[5]*n+e[9]*s+e[13],t[14]=e[2]*i+e[6]*n+e[10]*s+e[14],t[15]=e[3]*i+e[7]*n+e[11]*s+e[15]):(o=e[0],a=e[1],A=e[2],h=e[3],g=e[4],_=e[5],x=e[6],T=e[7],v=e[8],S=e[9],C=e[10],M=e[11],t[0]=o,t[1]=a,t[2]=A,t[3]=h,t[4]=g,t[5]=_,t[6]=x,t[7]=T,t[8]=v,t[9]=S,t[10]=C,t[11]=M,t[12]=o*i+g*n+v*s+e[12],t[13]=a*i+_*n+S*s+e[13],t[14]=A*i+x*n+C*s+e[14],t[15]=h*i+T*n+M*s+e[15]),t}function X_(t,e,r){let i=r[0],n=r[1],s=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Y_(t,e,r,i){let n=i[0],s=i[1],o=i[2],a=Math.sqrt(n*n+s*s+o*o),A,h,g,_,x,T,v,S,C,M,R,B,k,Q,$,re,Y,H,L,ae,fe,he,ye,Ne;return a<1e-6?null:(a=1/a,n*=a,s*=a,o*=a,h=Math.sin(r),A=Math.cos(r),g=1-A,_=e[0],x=e[1],T=e[2],v=e[3],S=e[4],C=e[5],M=e[6],R=e[7],B=e[8],k=e[9],Q=e[10],$=e[11],re=n*n*g+A,Y=s*n*g+o*h,H=o*n*g-s*h,L=n*s*g-o*h,ae=s*s*g+A,fe=o*s*g+n*h,he=n*o*g+s*h,ye=s*o*g-n*h,Ne=o*o*g+A,t[0]=_*re+S*Y+B*H,t[1]=x*re+C*Y+k*H,t[2]=T*re+M*Y+Q*H,t[3]=v*re+R*Y+$*H,t[4]=_*L+S*ae+B*fe,t[5]=x*L+C*ae+k*fe,t[6]=T*L+M*ae+Q*fe,t[7]=v*L+R*ae+$*fe,t[8]=_*he+S*ye+B*Ne,t[9]=x*he+C*ye+k*Ne,t[10]=T*he+M*ye+Q*Ne,t[11]=v*he+R*ye+$*Ne,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Q_(t,e,r){let i=Math.sin(r),n=Math.cos(r),s=e[4],o=e[5],a=e[6],A=e[7],h=e[8],g=e[9],_=e[10],x=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*n+h*i,t[5]=o*n+g*i,t[6]=a*n+_*i,t[7]=A*n+x*i,t[8]=h*n-s*i,t[9]=g*n-o*i,t[10]=_*n-a*i,t[11]=x*n-A*i,t}function q_(t,e,r){let i=Math.sin(r),n=Math.cos(r),s=e[0],o=e[1],a=e[2],A=e[3],h=e[8],g=e[9],_=e[10],x=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n-h*i,t[1]=o*n-g*i,t[2]=a*n-_*i,t[3]=A*n-x*i,t[8]=s*i+h*n,t[9]=o*i+g*n,t[10]=a*i+_*n,t[11]=A*i+x*n,t}function K_(t,e,r){let i=Math.sin(r),n=Math.cos(r),s=e[0],o=e[1],a=e[2],A=e[3],h=e[4],g=e[5],_=e[6],x=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n+h*i,t[1]=o*n+g*i,t[2]=a*n+_*i,t[3]=A*n+x*i,t[4]=h*n-s*i,t[5]=g*n-o*i,t[6]=_*n-a*i,t[7]=x*n-A*i,t}function j9(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function X9(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Y9(t,e,r){let i=r[0],n=r[1],s=r[2],o=Math.sqrt(i*i+n*n+s*s),a,A,h;return o<1e-6?null:(o=1/o,i*=o,n*=o,s*=o,A=Math.sin(e),a=Math.cos(e),h=1-a,t[0]=i*i*h+a,t[1]=n*i*h+s*A,t[2]=s*i*h-n*A,t[3]=0,t[4]=i*n*h-s*A,t[5]=n*n*h+a,t[6]=s*n*h+i*A,t[7]=0,t[8]=i*s*h+n*A,t[9]=n*s*h-i*A,t[10]=s*s*h+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function Q9(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function q9(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function K9(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function oS(t,e,r){let i=e[0],n=e[1],s=e[2],o=e[3],a=i+i,A=n+n,h=s+s,g=i*a,_=i*A,x=i*h,T=n*A,v=n*h,S=s*h,C=o*a,M=o*A,R=o*h;return t[0]=1-(T+S),t[1]=_+R,t[2]=x-M,t[3]=0,t[4]=_-R,t[5]=1-(g+S),t[6]=v+C,t[7]=0,t[8]=x+M,t[9]=v-C,t[10]=1-(g+T),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function J9(t,e){let r=new Ot(3),i=-e[0],n=-e[1],s=-e[2],o=e[3],a=e[4],A=e[5],h=e[6],g=e[7],_=i*i+n*n+s*s+o*o;return _>0?(r[0]=(a*o+g*i+A*s-h*n)*2/_,r[1]=(A*o+g*n+h*i-a*s)*2/_,r[2]=(h*o+g*s+a*n-A*i)*2/_):(r[0]=(a*o+g*i+A*s-h*n)*2,r[1]=(A*o+g*n+h*i-a*s)*2,r[2]=(h*o+g*s+a*n-A*i)*2),oS(t,e,r),t}function Z9(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function aS(t,e){let r=e[0],i=e[1],n=e[2],s=e[4],o=e[5],a=e[6],A=e[8],h=e[9],g=e[10];return t[0]=Math.sqrt(r*r+i*i+n*n),t[1]=Math.sqrt(s*s+o*o+a*a),t[2]=Math.sqrt(A*A+h*h+g*g),t}function $9(t,e){let r=new Ot(3);aS(r,e);let i=1/r[0],n=1/r[1],s=1/r[2],o=e[0]*i,a=e[1]*n,A=e[2]*s,h=e[4]*i,g=e[5]*n,_=e[6]*s,x=e[8]*i,T=e[9]*n,v=e[10]*s,S=o+g+v,C=0;return S>0?(C=Math.sqrt(S+1)*2,t[3]=.25*C,t[0]=(_-T)/C,t[1]=(x-A)/C,t[2]=(a-h)/C):o>g&&o>v?(C=Math.sqrt(1+o-g-v)*2,t[3]=(_-T)/C,t[0]=.25*C,t[1]=(a+h)/C,t[2]=(x+A)/C):g>v?(C=Math.sqrt(1+g-o-v)*2,t[3]=(x-A)/C,t[0]=(a+h)/C,t[1]=.25*C,t[2]=(_+T)/C):(C=Math.sqrt(1+v-o-g)*2,t[3]=(a-h)/C,t[0]=(x+A)/C,t[1]=(_+T)/C,t[2]=.25*C),t}function e7(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let n=i[0],s=i[1],o=i[2],a=i[4],A=i[5],h=i[6],g=i[8],_=i[9],x=i[10];r[0]=Math.sqrt(n*n+s*s+o*o),r[1]=Math.sqrt(a*a+A*A+h*h),r[2]=Math.sqrt(g*g+_*_+x*x);let T=1/r[0],v=1/r[1],S=1/r[2],C=n*T,M=s*v,R=o*S,B=a*T,k=A*v,Q=h*S,$=g*T,re=_*v,Y=x*S,H=C+k+Y,L=0;return H>0?(L=Math.sqrt(H+1)*2,t[3]=.25*L,t[0]=(Q-re)/L,t[1]=($-R)/L,t[2]=(M-B)/L):C>k&&C>Y?(L=Math.sqrt(1+C-k-Y)*2,t[3]=(Q-re)/L,t[0]=.25*L,t[1]=(M+B)/L,t[2]=($+R)/L):k>Y?(L=Math.sqrt(1+k-C-Y)*2,t[3]=($-R)/L,t[0]=(M+B)/L,t[1]=.25*L,t[2]=(Q+re)/L):(L=Math.sqrt(1+Y-C-k)*2,t[3]=(M-B)/L,t[0]=($+R)/L,t[1]=(Q+re)/L,t[2]=.25*L),t}function t7(t,e,r,i){let n=e[0],s=e[1],o=e[2],a=e[3],A=n+n,h=s+s,g=o+o,_=n*A,x=n*h,T=n*g,v=s*h,S=s*g,C=o*g,M=a*A,R=a*h,B=a*g,k=i[0],Q=i[1],$=i[2];return t[0]=(1-(v+C))*k,t[1]=(x+B)*k,t[2]=(T-R)*k,t[3]=0,t[4]=(x-B)*Q,t[5]=(1-(_+C))*Q,t[6]=(S+M)*Q,t[7]=0,t[8]=(T+R)*$,t[9]=(S-M)*$,t[10]=(1-(_+v))*$,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function r7(t,e,r,i,n){let s=e[0],o=e[1],a=e[2],A=e[3],h=s+s,g=o+o,_=a+a,x=s*h,T=s*g,v=s*_,S=o*g,C=o*_,M=a*_,R=A*h,B=A*g,k=A*_,Q=i[0],$=i[1],re=i[2],Y=n[0],H=n[1],L=n[2],ae=(1-(S+M))*Q,fe=(T+k)*Q,he=(v-B)*Q,ye=(T-k)*$,Ne=(1-(x+M))*$,nt=(C+R)*$,it=(v+B)*re,et=(C-R)*re,st=(1-(x+S))*re;return t[0]=ae,t[1]=fe,t[2]=he,t[3]=0,t[4]=ye,t[5]=Ne,t[6]=nt,t[7]=0,t[8]=it,t[9]=et,t[10]=st,t[11]=0,t[12]=r[0]+Y-(ae*Y+ye*H+it*L),t[13]=r[1]+H-(fe*Y+Ne*H+et*L),t[14]=r[2]+L-(he*Y+nt*H+st*L),t[15]=1,t}function J_(t,e){let r=e[0],i=e[1],n=e[2],s=e[3],o=r+r,a=i+i,A=n+n,h=r*o,g=i*o,_=i*a,x=n*o,T=n*a,v=n*A,S=s*o,C=s*a,M=s*A;return t[0]=1-_-v,t[1]=g+M,t[2]=x-C,t[3]=0,t[4]=g-M,t[5]=1-h-v,t[6]=T+S,t[7]=0,t[8]=x+C,t[9]=T-S,t[10]=1-h-_,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Z_(t,e,r,i,n,s,o){let a=1/(r-e),A=1/(n-i),h=1/(s-o);return t[0]=s*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s*2*A,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(n+i)*A,t[10]=(o+s)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*s*2*h,t[15]=0,t}function cS(t,e,r,i,n){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let o=1/(i-n);t[10]=(n+i)*o,t[14]=2*n*i*o}else t[10]=-1,t[14]=-2*i;return t}var $_=cS;function i7(t,e,r,i,n){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let o=1/(i-n);t[10]=n*o,t[14]=n*i*o}else t[10]=-1,t[14]=-i;return t}function n7(t,e,r,i){let n=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),A=2/(o+a),h=2/(n+s);return t[0]=A,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=h,t[6]=0,t[7]=0,t[8]=-((o-a)*A*.5),t[9]=(n-s)*h*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function lS(t,e,r,i,n,s,o){let a=1/(e-r),A=1/(i-n),h=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*A,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*a,t[13]=(n+i)*A,t[14]=(o+s)*h,t[15]=1,t}var e2=lS;function s7(t,e,r,i,n,s,o){let a=1/(e-r),A=1/(i-n),h=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*A,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=h,t[11]=0,t[12]=(e+r)*a,t[13]=(n+i)*A,t[14]=s*h,t[15]=1,t}function t2(t,e,r,i){let n,s,o,a,A,h,g,_,x,T,v=e[0],S=e[1],C=e[2],M=i[0],R=i[1],B=i[2],k=r[0],Q=r[1],$=r[2];return Math.abs(v-k)<1e-6&&Math.abs(S-Q)<1e-6&&Math.abs(C-$)<1e-6?sS(t):(_=v-k,x=S-Q,T=C-$,n=1/Math.sqrt(_*_+x*x+T*T),_*=n,x*=n,T*=n,s=R*T-B*x,o=B*_-M*T,a=M*x-R*_,n=Math.sqrt(s*s+o*o+a*a),n?(n=1/n,s*=n,o*=n,a*=n):(s=0,o=0,a=0),A=x*a-T*o,h=T*s-_*a,g=_*o-x*s,n=Math.sqrt(A*A+h*h+g*g),n?(n=1/n,A*=n,h*=n,g*=n):(A=0,h=0,g=0),t[0]=s,t[1]=A,t[2]=_,t[3]=0,t[4]=o,t[5]=h,t[6]=x,t[7]=0,t[8]=a,t[9]=g,t[10]=T,t[11]=0,t[12]=-(s*v+o*S+a*C),t[13]=-(A*v+h*S+g*C),t[14]=-(_*v+x*S+T*C),t[15]=1,t)}function o7(t,e,r,i){let n=e[0],s=e[1],o=e[2],a=i[0],A=i[1],h=i[2],g=n-r[0],_=s-r[1],x=o-r[2],T=g*g+_*_+x*x;T>0&&(T=1/Math.sqrt(T),g*=T,_*=T,x*=T);let v=A*x-h*_,S=h*g-a*x,C=a*_-A*g;return T=v*v+S*S+C*C,T>0&&(T=1/Math.sqrt(T),v*=T,S*=T,C*=T),t[0]=v,t[1]=S,t[2]=C,t[3]=0,t[4]=_*C-x*S,t[5]=x*v-g*C,t[6]=g*S-_*v,t[7]=0,t[8]=g,t[9]=_,t[10]=x,t[11]=0,t[12]=n,t[13]=s,t[14]=o,t[15]=1,t}function a7(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function c7(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function l7(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function AS(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function A7(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function u7(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function f7(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function h7(t,e){let r=t[0],i=t[1],n=t[2],s=t[3],o=t[4],a=t[5],A=t[6],h=t[7],g=t[8],_=t[9],x=t[10],T=t[11],v=t[12],S=t[13],C=t[14],M=t[15],R=e[0],B=e[1],k=e[2],Q=e[3],$=e[4],re=e[5],Y=e[6],H=e[7],L=e[8],ae=e[9],fe=e[10],he=e[11],ye=e[12],Ne=e[13],nt=e[14],it=e[15];return Math.abs(r-R)<=1e-6*Math.max(1,Math.abs(r),Math.abs(R))&&Math.abs(i-B)<=1e-6*Math.max(1,Math.abs(i),Math.abs(B))&&Math.abs(n-k)<=1e-6*Math.max(1,Math.abs(n),Math.abs(k))&&Math.abs(s-Q)<=1e-6*Math.max(1,Math.abs(s),Math.abs(Q))&&Math.abs(o-$)<=1e-6*Math.max(1,Math.abs(o),Math.abs($))&&Math.abs(a-re)<=1e-6*Math.max(1,Math.abs(a),Math.abs(re))&&Math.abs(A-Y)<=1e-6*Math.max(1,Math.abs(A),Math.abs(Y))&&Math.abs(h-H)<=1e-6*Math.max(1,Math.abs(h),Math.abs(H))&&Math.abs(g-L)<=1e-6*Math.max(1,Math.abs(g),Math.abs(L))&&Math.abs(_-ae)<=1e-6*Math.max(1,Math.abs(_),Math.abs(ae))&&Math.abs(x-fe)<=1e-6*Math.max(1,Math.abs(x),Math.abs(fe))&&Math.abs(T-he)<=1e-6*Math.max(1,Math.abs(T),Math.abs(he))&&Math.abs(v-ye)<=1e-6*Math.max(1,Math.abs(v),Math.abs(ye))&&Math.abs(S-Ne)<=1e-6*Math.max(1,Math.abs(S),Math.abs(Ne))&&Math.abs(C-nt)<=1e-6*Math.max(1,Math.abs(C),Math.abs(nt))&&Math.abs(M-it)<=1e-6*Math.max(1,Math.abs(M),Math.abs(it))}var d7=ou,p7=AS;var fi={};dr(fi,{add:()=>r2,ceil:()=>g7,clone:()=>fS,copy:()=>dS,create:()=>uS,cross:()=>v7,dist:()=>B7,distance:()=>yS,div:()=>R7,divide:()=>_S,dot:()=>s2,equals:()=>M7,exactEquals:()=>bS,floor:()=>m7,forEach:()=>N7,fromValues:()=>hS,inverse:()=>E7,len:()=>F7,length:()=>X0,lerp:()=>o2,max:()=>y7,min:()=>_7,mul:()=>I7,multiply:()=>mS,negate:()=>T7,normalize:()=>n2,random:()=>S7,round:()=>x7,scale:()=>i2,scaleAndAdd:()=>b7,set:()=>pS,sqrDist:()=>O7,sqrLen:()=>L7,squaredDistance:()=>xS,squaredLength:()=>Y0,str:()=>C7,sub:()=>P7,subtract:()=>gS,transformMat4:()=>a2,transformQuat:()=>c2,zero:()=>w7});function uS(){let t=new Ot(4);return Ot!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function fS(t){let e=new Ot(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function hS(t,e,r,i){let n=new Ot(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n}function dS(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function pS(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function r2(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function gS(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function mS(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function _S(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function g7(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function m7(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function _7(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function y7(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function x7(t,e){return t[0]=ki(e[0]),t[1]=ki(e[1]),t[2]=ki(e[2]),t[3]=ki(e[3]),t}function i2(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function b7(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function yS(t,e){let r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],s=e[3]-t[3];return Math.sqrt(r*r+i*i+n*n+s*s)}function xS(t,e){let r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],s=e[3]-t[3];return r*r+i*i+n*n+s*s}function X0(t){let e=t[0],r=t[1],i=t[2],n=t[3];return Math.sqrt(e*e+r*r+i*i+n*n)}function Y0(t){let e=t[0],r=t[1],i=t[2],n=t[3];return e*e+r*r+i*i+n*n}function T7(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function E7(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function n2(t,e){let r=e[0],i=e[1],n=e[2],s=e[3],o=r*r+i*i+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=i*o,t[2]=n*o,t[3]=s*o,t}function s2(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function v7(t,e,r,i){let n=r[0]*i[1]-r[1]*i[0],s=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],A=r[1]*i[3]-r[3]*i[1],h=r[2]*i[3]-r[3]*i[2],g=e[0],_=e[1],x=e[2],T=e[3];return t[0]=_*h-x*A+T*a,t[1]=-(g*h)+x*o-T*s,t[2]=g*A-_*o+T*n,t[3]=-(g*a)+_*s-x*n,t}function o2(t,e,r,i){let n=e[0],s=e[1],o=e[2],a=e[3];return t[0]=n+i*(r[0]-n),t[1]=s+i*(r[1]-s),t[2]=o+i*(r[2]-o),t[3]=a+i*(r[3]-a),t}function S7(t,e){e=e===void 0?1:e;let r,i,n,s,o,a;do r=zn()*2-1,i=zn()*2-1,o=r*r+i*i;while(o>=1);do n=zn()*2-1,s=zn()*2-1,a=n*n+s*s;while(a>=1);let A=Math.sqrt((1-o)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*n*A,t[3]=e*s*A,t}function a2(t,e,r){let i=e[0],n=e[1],s=e[2],o=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*s+r[12]*o,t[1]=r[1]*i+r[5]*n+r[9]*s+r[13]*o,t[2]=r[2]*i+r[6]*n+r[10]*s+r[14]*o,t[3]=r[3]*i+r[7]*n+r[11]*s+r[15]*o,t}function c2(t,e,r){let i=e[0],n=e[1],s=e[2],o=r[0],a=r[1],A=r[2],h=r[3],g=h*i+a*s-A*n,_=h*n+A*i-o*s,x=h*s+o*n-a*i,T=-o*i-a*n-A*s;return t[0]=g*h+T*-o+_*-A-x*-a,t[1]=_*h+T*-a+x*-o-g*-A,t[2]=x*h+T*-A+g*-a-_*-o,t[3]=e[3],t}function w7(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function C7(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function bS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function M7(t,e){let r=t[0],i=t[1],n=t[2],s=t[3],o=e[0],a=e[1],A=e[2],h=e[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-A)<=1e-6*Math.max(1,Math.abs(n),Math.abs(A))&&Math.abs(s-h)<=1e-6*Math.max(1,Math.abs(s),Math.abs(h))}var P7=gS,I7=mS,R7=_S,B7=yS,O7=xS,F7=X0,L7=Y0,N7=function(){let t=uS();return function(e,r,i,n,s,o){let a,A;for(r||(r=4),i||(i=0),n?A=Math.min(n*r+i,e.length):A=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function H7(t,e,r,i,n,s){let o=2*s/(r-e),a=2*s/(n-i),A=(r+e)/(r-e),h=(n+i)/(n-i),g=-1,_=-1,x=-2*s;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=A,t[9]=h,t[10]=g,t[11]=_,t[12]=0,t[13]=0,t[14]=x,t[15]=0,t}function ES(){let t=new Ot(4);return Ot!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function vS(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function f2(t,e,r){r=r*.5;let i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t}function h2(t,e,r){let i=e[0],n=e[1],s=e[2],o=e[3],a=r[0],A=r[1],h=r[2],g=r[3];return t[0]=i*g+o*a+n*h-s*A,t[1]=n*g+o*A+s*a-i*h,t[2]=s*g+o*h+i*A-n*a,t[3]=o*g-i*a-n*A-s*h,t}function SS(t,e,r){r*=.5;let i=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(r),A=Math.cos(r);return t[0]=i*A+o*a,t[1]=n*A+s*a,t[2]=s*A-n*a,t[3]=o*A-i*a,t}function wS(t,e,r){r*=.5;let i=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(r),A=Math.cos(r);return t[0]=i*A-s*a,t[1]=n*A+o*a,t[2]=s*A+i*a,t[3]=o*A-n*a,t}function CS(t,e,r){r*=.5;let i=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(r),A=Math.cos(r);return t[0]=i*A+n*a,t[1]=n*A-i*a,t[2]=s*A+o*a,t[3]=o*A-s*a,t}function MS(t,e){let r=e[0],i=e[1],n=e[2];return t[0]=r,t[1]=i,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),t}function au(t,e,r,i){let n=e[0],s=e[1],o=e[2],a=e[3],A=r[0],h=r[1],g=r[2],_=r[3],x,T,v,S,C;return x=n*A+s*h+o*g+a*_,x<0&&(x=-x,A=-A,h=-h,g=-g,_=-_),1-x>1e-6?(T=Math.acos(x),C=Math.sin(T),v=Math.sin((1-i)*T)/C,S=Math.sin(i*T)/C):(v=1-i,S=i),t[0]=v*n+S*A,t[1]=v*s+S*h,t[2]=v*o+S*g,t[3]=v*a+S*_,t}function PS(t,e){let r=e[0],i=e[1],n=e[2],s=e[3],o=r*r+i*i+n*n+s*s,a=o?1/o:0;return t[0]=-r*a,t[1]=-i*a,t[2]=-n*a,t[3]=s*a,t}function IS(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function d2(t,e){let r=e[0]+e[4]+e[8],i;if(r>0)i=Math.sqrt(r+1),t[3]=.5*i,i=.5/i,t[0]=(e[5]-e[7])*i,t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{let n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);let s=(n+1)%3,o=(n+2)%3;i=Math.sqrt(e[n*3+n]-e[s*3+s]-e[o*3+o]+1),t[n]=.5*i,i=.5/i,t[3]=(e[s*3+o]-e[o*3+s])*i,t[s]=(e[s*3+n]+e[n*3+s])*i,t[o]=(e[o*3+n]+e[n*3+o])*i}return t}var RS=r2;var BS=i2,OS=s2,FS=o2,LS=X0;var NS=Y0;var DS=n2;var US=function(){let t=k0(),e=V0(1,0,0),r=V0(0,1,0);return function(i,n,s){let o=iu(n,s);return o<-.999999?(ua(t,e,n),D_(t)<1e-6&&ua(t,r,n),B_(t,t),f2(i,t,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(ua(t,n,s),i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=1+o,DS(i,i))}}(),bue=function(){let t=ES(),e=ES();return function(r,i,n,s,o,a){return au(t,i,o,a),au(e,n,s,a),au(r,t,e,2*a*(1-a)),r}}(),Tue=function(){let t=Jv();return function(e,r,i,n){return t[0]=i[0],t[3]=i[1],t[6]=i[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],DS(e,d2(e,t))}}();var W7=[0,0,0,1],Vi=class extends io{constructor(e=0,r=0,i=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,i,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,i,n){return this[0]=e,this[1]=r,this[2]=i,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return d2(this,e),this.check()}fromAxisRotation(e,r){return f2(this,e,r),this.check()}identity(){return vS(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=ut(e)}get y(){return this[1]}set y(e){this[1]=ut(e)}get z(){return this[2]}set z(e){this[2]=ut(e)}get w(){return this[3]}set w(e){this[3]=ut(e)}len(){return LS(this)}lengthSquared(){return NS(this)}dot(e){return OS(this,e)}rotationTo(e,r){return US(this,e,r),this.check()}add(e){return RS(this,this,e),this.check()}calculateW(){return MS(this,this),this.check()}conjugate(){return IS(this,this),this.check()}invert(){return PS(this,this),this.check()}lerp(e,r,i){return i===void 0?this.lerp(this,e,r):(FS(this,e,r,i),this.check())}multiplyRight(e){return h2(this,this,e),this.check()}multiplyLeft(e){return h2(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return SS(this,this,e),this.check()}rotateY(e){return wS(this,this,e),this.check()}rotateZ(e){return CS(this,this,e),this.check()}scale(e){return BS(this,this,e),this.check()}slerp(e,r,i){let n,s,o;switch(arguments.length){case 1:({start:n=W7,target:s,ratio:o}=e);break;case 2:n=this,s=e,o=r;break;default:n=e,s=r,o=i}return au(this,n,s,o),this.check()}transformVector4(e,r=new G0){return c2(r,e,this),no(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var nn={};dr(nn,{EPSILON1:()=>j7,EPSILON10:()=>eU,EPSILON11:()=>tU,EPSILON12:()=>rU,EPSILON13:()=>iU,EPSILON14:()=>nU,EPSILON15:()=>sU,EPSILON16:()=>oU,EPSILON17:()=>aU,EPSILON18:()=>cU,EPSILON19:()=>lU,EPSILON2:()=>X7,EPSILON20:()=>AU,EPSILON3:()=>Y7,EPSILON4:()=>Q7,EPSILON5:()=>q7,EPSILON6:()=>K7,EPSILON7:()=>J7,EPSILON8:()=>Z7,EPSILON9:()=>$7,PI_OVER_FOUR:()=>fU,PI_OVER_SIX:()=>hU,PI_OVER_TWO:()=>uU,TWO_PI:()=>dU});var j7=.1,X7=.01,Y7=.001,Q7=1e-4,q7=1e-5,K7=1e-6,J7=1e-7,Z7=1e-8,$7=1e-9,eU=1e-10,tU=1e-11,rU=1e-12,iU=1e-13,nU=1e-14,sU=1e-15,oU=1e-16,aU=1e-17,cU=1e-18,lU=1e-19,AU=1e-20,uU=Math.PI/2,fU=Math.PI/4,hU=Math.PI/6,dU=Math.PI*2;var p2=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; @@ -463,7 +469,7 @@ return pointLight.attenuation.x + pointLight.attenuation.z * distance * distance; } #endif -`;var BS={lightSources:{}};function Xh(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/255)}function US({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let i={};return t?i["lighting_uAmbientLight.color"]=Xh(t):i["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((s,n)=>{i[`lighting_uPointLight[${n}].color`]=Xh(s),i[`lighting_uPointLight[${n}].position`]=s.position,i[`lighting_uPointLight[${n}].attenuation`]=s.attenuation||[1,0,0]}),i.lighting_uPointLightCount=e.length,r.forEach((s,n)=>{i[`lighting_uDirectionalLight[${n}].color`]=Xh(s),i[`lighting_uDirectionalLight[${n}].direction`]=s.direction}),i.lighting_uDirectionalLightCount=r.length,i}function T1(t=BS){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:i}=t.lightSources||{};return e||r&&r.length>0||i&&i.length>0?Object.assign({},US({ambientLight:e,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return T1({lightSources:e})}return{}}var $h={name:"lights",vs:jh,fs:jh,getUniforms:T1,defines:{MAX_LIGHTS:3}};var Yh=`uniform float lighting_uAmbient; +`;var pU={lightSources:{}};function g2(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/255)}function gU({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let i={};return t?i["lighting_uAmbientLight.color"]=g2(t):i["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((n,s)=>{i[`lighting_uPointLight[${s}].color`]=g2(n),i[`lighting_uPointLight[${s}].position`]=n.position,i[`lighting_uPointLight[${s}].attenuation`]=n.attenuation||[1,0,0]}),i.lighting_uPointLightCount=e.length,r.forEach((n,s)=>{i[`lighting_uDirectionalLight[${s}].color`]=g2(n),i[`lighting_uDirectionalLight[${s}].direction`]=n.direction}),i.lighting_uDirectionalLightCount=r.length,i}function kS(t=pU){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:i}=t.lightSources||{};return e||r&&r.length>0||i&&i.length>0?Object.assign({},gU({ambientLight:e,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return kS({lightSources:e})}return{}}var cu={name:"lights",vs:p2,fs:p2,getUniforms:kS,defines:{MAX_LIGHTS:3}};var m2=`uniform float lighting_uAmbient; uniform float lighting_uDiffuse; uniform float lighting_uShininess; uniform vec3 lighting_uSpecularColor; @@ -526,8 +532,309 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, } return lightColor; } -`;var zS={};function VS(t){let{ambient:e=.35,diffuse:r=.6,shininess:i=32,specularColor:s=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:i,lighting_uSpecularColor:s.map(n=>n/255)}}function E1(t=zS){if(!("material"in t))return{};let{material:e}=t;return e?VS(e):{lighting_uEnabled:!1}}var Mt={name:"gouraud-lighting",dependencies:[$h],vs:Yh,defines:{LIGHTING_VERTEX:1},getUniforms:E1},eo={name:"phong-lighting",dependencies:[$h],fs:Yh,defines:{LIGHTING_FRAGMENT:1},getUniforms:E1};var S1="#define SMOOTH_EDGE_RADIUS 0.5",WS=` -${S1} +`;var mU={};function _U(t){let{ambient:e=.35,diffuse:r=.6,shininess:i=32,specularColor:n=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:i,lighting_uSpecularColor:n.map(s=>s/255)}}function VS(t=mU){if(!("material"in t))return{};let{material:e}=t;return e?_U(e):{lighting_uEnabled:!1}}var sn={name:"gouraud-lighting",dependencies:[cu],vs:m2,defines:{LIGHTING_VERTEX:1},getUniforms:VS},ha={name:"phong-lighting",dependencies:[cu],fs:m2,defines:{LIGHTING_FRAGMENT:1},getUniforms:VS};var zS=`uniform mat4 u_MVPMatrix; +uniform mat4 u_ModelMatrix; +uniform mat4 u_NormalMatrix; +out vec3 pbr_vPosition; +out vec2 pbr_vUV; +#ifdef HAS_NORMALS +# ifdef HAS_TANGENTS +out mat3 pbr_vTBN; +# else +out vec3 pbr_vNormal; +# endif +#endif +void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) +{ +vec4 pos = u_ModelMatrix * position; +pbr_vPosition = vec3(pos.xyz) / pos.w; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0))); +vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0))); +vec3 bitangentW = cross(normalW, tangentW) * tangent.w; +pbr_vTBN = mat3(tangentW, bitangentW, normalW); +#else +pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0))); +#endif +#endif +#ifdef HAS_UV +pbr_vUV = uv; +#else +pbr_vUV = vec2(0.,0.); +#endif +} +`;var HS=`precision highp float; +uniform bool pbr_uUnlit; +#ifdef USE_IBL +uniform samplerCube u_DiffuseEnvSampler; +uniform samplerCube u_SpecularEnvSampler; +uniform sampler2D u_brdfLUT; +uniform vec2 u_ScaleIBLAmbient; +#endif +#ifdef HAS_BASECOLORMAP +uniform sampler2D u_BaseColorSampler; +#endif +#ifdef HAS_NORMALMAP +uniform sampler2D u_NormalSampler; +uniform float u_NormalScale; +#endif +#ifdef HAS_EMISSIVEMAP +uniform sampler2D u_EmissiveSampler; +uniform vec3 u_EmissiveFactor; +#endif +#ifdef HAS_METALROUGHNESSMAP +uniform sampler2D u_MetallicRoughnessSampler; +#endif +#ifdef HAS_OCCLUSIONMAP +uniform sampler2D u_OcclusionSampler; +uniform float u_OcclusionStrength; +#endif +#ifdef ALPHA_CUTOFF +uniform float u_AlphaCutoff; +#endif +uniform vec2 u_MetallicRoughnessValues; +uniform vec4 u_BaseColorFactor; +uniform vec3 u_Camera; +#ifdef PBR_DEBUG +uniform vec4 u_ScaleDiffBaseMR; +uniform vec4 u_ScaleFGDSpec; +#endif +in vec3 pbr_vPosition; +in vec2 pbr_vUV; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +in mat3 pbr_vTBN; +#else +in vec3 pbr_vNormal; +#endif +#endif +struct PBRInfo +{ +float NdotL; +float NdotV; +float NdotH; +float LdotH; +float VdotH; +float perceptualRoughness; +float metalness; +vec3 reflectance0; +vec3 reflectance90; +float alphaRoughness; +vec3 diffuseColor; +vec3 specularColor; +vec3 n; +vec3 v; +}; +const float M_PI = 3.141592653589793; +const float c_MinRoughness = 0.04; +vec4 SRGBtoLINEAR(vec4 srgbIn) +{ +#ifdef MANUAL_SRGB +#ifdef SRGB_FAST_APPROXIMATION +vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); +#else +vec3 bLess = step(vec3(0.04045),srgbIn.xyz); +vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); +#endif +return vec4(linOut,srgbIn.w);; +#else +return srgbIn; +#endif +} +vec3 getNormal() +{ +#ifndef HAS_TANGENTS +vec3 pos_dx = dFdx(pbr_vPosition); +vec3 pos_dy = dFdy(pbr_vPosition); +vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); +vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); +vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); +#ifdef HAS_NORMALS +vec3 ng = normalize(pbr_vNormal); +#else +vec3 ng = cross(pos_dx, pos_dy); +#endif +t = normalize(t - ng * dot(ng, t)); +vec3 b = normalize(cross(ng, t)); +mat3 tbn = mat3(t, b, ng); +#else +mat3 tbn = pbr_vTBN; +#endif +#ifdef HAS_NORMALMAP +vec3 n = texture(u_NormalSampler, pbr_vUV).rgb; +n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0))); +#else +vec3 n = normalize(tbn[2].xyz); +#endif +return n; +} +#ifdef USE_IBL +vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) +{ +float mipCount = 9.0; +float lod = (pbrInputs.perceptualRoughness * mipCount); +vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT, +vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb; +vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb; +#ifdef USE_TEX_LOD +vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb; +#else +vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb; +#endif +vec3 diffuse = diffuseLight * pbrInputs.diffuseColor; +vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); +diffuse *= u_ScaleIBLAmbient.x; +specular *= u_ScaleIBLAmbient.y; +return diffuse + specular; +} +#endif +vec3 diffuse(PBRInfo pbrInputs) +{ +return pbrInputs.diffuseColor / M_PI; +} +vec3 specularReflection(PBRInfo pbrInputs) +{ +return pbrInputs.reflectance0 + +(pbrInputs.reflectance90 - pbrInputs.reflectance0) * +pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); +} +float geometricOcclusion(PBRInfo pbrInputs) +{ +float NdotL = pbrInputs.NdotL; +float NdotV = pbrInputs.NdotV; +float r = pbrInputs.alphaRoughness; +float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); +float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); +return attenuationL * attenuationV; +} +float microfacetDistribution(PBRInfo pbrInputs) +{ +float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; +float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; +return roughnessSq / (M_PI * f * f); +} +void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) { +pbrInputs.NdotL = 1.0; +pbrInputs.NdotH = 0.0; +pbrInputs.LdotH = 0.0; +pbrInputs.VdotH = 1.0; +} +void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) { +vec3 n = pbrInputs.n; +vec3 v = pbrInputs.v; +vec3 l = normalize(lightDirection); +vec3 h = normalize(l+v); +pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0); +pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0); +pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0); +pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0); +} +void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) { +vec3 light_direction = normalize(pointLight.position - pbr_vPosition); +PBRInfo_setDirectionalLight(pbrInputs, light_direction); +} +vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) { +vec3 F = specularReflection(pbrInputs); +float G = geometricOcclusion(pbrInputs); +float D = microfacetDistribution(pbrInputs); +vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); +vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV); +return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib); +} +vec4 pbr_filterColor(vec4 colorUnused) +{ +#ifdef HAS_BASECOLORMAP +vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor; +#else +vec4 baseColor = u_BaseColorFactor; +#endif +#ifdef ALPHA_CUTOFF +if (baseColor.a < u_AlphaCutoff) { +discard; +} +#endif +vec3 color = vec3(0, 0, 0); +if(pbr_uUnlit){ +color.rgb = baseColor.rgb; +} +else{ +float perceptualRoughness = u_MetallicRoughnessValues.y; +float metallic = u_MetallicRoughnessValues.x; +#ifdef HAS_METALROUGHNESSMAP +vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV); +perceptualRoughness = mrSample.g * perceptualRoughness; +metallic = mrSample.b * metallic; +#endif +perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); +metallic = clamp(metallic, 0.0, 1.0); +float alphaRoughness = perceptualRoughness * perceptualRoughness; +vec3 f0 = vec3(0.04); +vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); +diffuseColor *= 1.0 - metallic; +vec3 specularColor = mix(f0, baseColor.rgb, metallic); +float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); +float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); +vec3 specularEnvironmentR0 = specularColor.rgb; +vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; +vec3 n = getNormal(); +vec3 v = normalize(u_Camera - pbr_vPosition); +float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); +vec3 reflection = -normalize(reflect(v, n)); +PBRInfo pbrInputs = PBRInfo( +0.0, +NdotV, +0.0, +0.0, +0.0, +perceptualRoughness, +metallic, +specularEnvironmentR0, +specularEnvironmentR90, +alphaRoughness, +diffuseColor, +specularColor, +n, +v +); +#ifdef USE_LIGHTS +PBRInfo_setAmbientLight(pbrInputs); +color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); +for(int i = 0; i < lighting_uDirectionalLightCount; i++) { +if (i < lighting_uDirectionalLightCount) { +PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); +color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); +} +} +for(int i = 0; i < lighting_uPointLightCount; i++) { +if (i < lighting_uPointLightCount) { +PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); +float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); +color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation); +} +} +#endif +#ifdef USE_IBL +color += getIBLContribution(pbrInputs, n, reflection); +#endif +#ifdef HAS_OCCLUSIONMAP +float ao = texture(u_OcclusionSampler, pbr_vUV).r; +color = mix(color, color * ao, u_OcclusionStrength); +#endif +#ifdef HAS_EMISSIVEMAP +vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor; +color += emissive; +#endif +#ifdef PBR_DEBUG +color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y); +color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z); +color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w); +#endif +} +return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); +} +`;var _2={name:"pbr",vs:zS,fs:HS,defines:{LIGHTING_FRAGMENT:1},dependencies:[cu]};var GS="#define SMOOTH_EDGE_RADIUS 0.5",yU=` +${GS} struct VertexGeometry { vec4 position; @@ -544,8 +851,8 @@ struct VertexGeometry { vec2(0.0), vec3(0.0) ); -`,HS=` -${S1} +`,xU=` +${GS} struct FragmentGeometry { vec2 uv; @@ -554,9 +861,9 @@ struct FragmentGeometry { float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,A1={name:"geometry",vs:WS,fs:HS};var q={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(q,"IDENTITY",{get:()=>(U.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var Ge={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},pe={common:0,meters:1,pixels:2},to={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var jS=Object.keys(q).map(t=>`const int COORDINATE_SYSTEM_${t} = ${q[t]};`).join(""),XS=Object.keys(Ge).map(t=>`const int PROJECTION_MODE_${t} = ${Ge[t]};`).join(""),$S=Object.keys(pe).map(t=>`const int UNIT_${t.toUpperCase()} = ${pe[t]};`).join(""),w1=`${jS} -${XS} -${$S} +`,WS={name:"geometry",vs:yU,fs:xU};var Oe={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Oe,"IDENTITY",{get:()=>(me.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var Wr={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Yt={common:0,meters:1,pixels:2},lu={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var bU=Object.keys(Oe).map(t=>`const int COORDINATE_SYSTEM_${t} = ${Oe[t]};`).join(""),TU=Object.keys(Wr).map(t=>`const int PROJECTION_MODE_${t} = ${Wr[t]};`).join(""),EU=Object.keys(Yt).map(t=>`const int UNIT_${t.toUpperCase()} = ${Yt[t]};`).join(""),jS=`${bU} +${TU} +${EU} uniform int project_uCoordinateSystem; uniform int project_uProjectionMode; uniform float project_uScale; @@ -743,7 +1050,7 @@ return pixels / project_uScale; vec2 project_pixel_size(vec2 pixels) { return pixels / project_uScale; } -`;function YS(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i{for(let s in i)if(!YS(i[s],e[s])){r=t(i),e=i;break}return r}}var P1=[0,0,0,0],KS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],C1=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],qS=[0,0,0],R1=[0,0,0],GS=Qt(JS);function Kh(t,e,r=R1){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,n=!0;switch(e===q.LNGLAT_OFFSETS||e===q.METER_OFFSETS?s=r:s=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case Ge.WEB_MERCATOR:(e===q.LNGLAT||e===q.CARTESIAN)&&(s=[0,0,0],n=!1);break;case Ge.WEB_MERCATOR_AUTO_OFFSET:e===q.LNGLAT?i=s:e===q.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],s=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case Ge.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case Ge.GLOBE:n=!1,s=null;break;default:n=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:n}}function ZS(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:s}=t,{viewMatrix:n,viewProjectionMatrix:o}=t,a=P1,c=P1,l=t.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=Kh(t,e,r);return h&&(c=t.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Jt.transformMat4([],c,o),n=i||n,o=Pe.multiply([],s,n),o=Pe.multiply([],o,KS)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function M1({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=q.DEFAULT,coordinateOrigin:s=R1,autoWrapLongitude:n=!1}){i===q.DEFAULT&&(i=t.isGeospatial?q.LNGLAT:q.CARTESIAN);let o=GS({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:s});return o.project_uWrapLongitude=n,o.project_uModelMatrix=r||C1,o}function JS({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:s,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=ZS(t,r,i),u=t.getDistanceScales(),f=[t.width*e,t.height*e],h=Jt.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={project_uCoordinateSystem:r,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:s,project_uPseudoMeters:!!t._pseudoMeters,project_uViewportSize:f,project_uDevicePixelRatio:e,project_uFocalDistance:h,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:qS,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:n,project_uModelMatrix:C1,project_uCameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case q.METER_OFFSETS:d.project_uCommonUnitsPerWorldUnit=p.unitsPerMeter,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case q.LNGLAT:case q.LNGLAT_OFFSETS:t._pseudoMeters||(d.project_uCommonUnitsPerMeter=p.unitsPerMeter),d.project_uCommonUnitsPerWorldUnit=p.unitsPerDegree,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case q.CARTESIAN:d.project_uCommonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.project_uCommonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var QS={};function eA(t=QS){return"viewport"in t?M1(t):{}}var Ci={name:"project",dependencies:[hh,A1],vs:w1,getUniforms:eA};var tA=` +`;function vU(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i{for(let n in i)if(!vU(i[n],e[n])){r=t(i),e=i;break}return r}}var XS=[0,0,0,0],SU=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],YS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],wU=[0,0,0],QS=[0,0,0],CU=Gn(PU);function y2(t,e,r=QS){r.length<3&&(r=[r[0],r[1],0]);let i=r,n,s=!0;switch(e===Oe.LNGLAT_OFFSETS||e===Oe.METER_OFFSETS?n=r:n=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case Wr.WEB_MERCATOR:(e===Oe.LNGLAT||e===Oe.CARTESIAN)&&(n=[0,0,0],s=!1);break;case Wr.WEB_MERCATOR_AUTO_OFFSET:e===Oe.LNGLAT?i=n:e===Oe.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],n=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case Wr.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case Wr.GLOBE:s=!1,n=null;break;default:s=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:i,offsetMode:s}}function MU(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:n}=t,{viewMatrix:s,viewProjectionMatrix:o}=t,a=XS,A=XS,h=t.cameraPosition,{geospatialOrigin:g,shaderCoordinateOrigin:_,offsetMode:x}=y2(t,e,r);return x&&(A=t.projectPosition(g||_),h=[h[0]-A[0],h[1]-A[1],h[2]-A[2]],A[3]=1,a=fi.transformMat4([],A,o),s=i||s,o=ir.multiply([],n,s),o=ir.multiply([],o,SU)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:A,cameraPosCommon:h,shaderCoordinateOrigin:_,geospatialOrigin:g}}function qS({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=Oe.DEFAULT,coordinateOrigin:n=QS,autoWrapLongitude:s=!1}){i===Oe.DEFAULT&&(i=t.isGeospatial?Oe.LNGLAT:Oe.CARTESIAN);let o=CU({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:n});return o.project_uWrapLongitude=s,o.project_uModelMatrix=r||YS,o}function PU({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:n,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:A,geospatialOrigin:h}=MU(t,r,i),g=t.getDistanceScales(),_=[t.width*e,t.height*e],x=fi.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,T={project_uCoordinateSystem:r,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:A,project_uCommonOrigin:o.slice(0,3),project_uCenter:n,project_uPseudoMeters:!!t._pseudoMeters,project_uViewportSize:_,project_uDevicePixelRatio:e,project_uFocalDistance:x,project_uCommonUnitsPerMeter:g.unitsPerMeter,project_uCommonUnitsPerWorldUnit:g.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:wU,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:s,project_uModelMatrix:YS,project_uCameraPosition:a};if(h){let v=t.getDistanceScales(h);switch(r){case Oe.METER_OFFSETS:T.project_uCommonUnitsPerWorldUnit=v.unitsPerMeter,T.project_uCommonUnitsPerWorldUnit2=v.unitsPerMeter2;break;case Oe.LNGLAT:case Oe.LNGLAT_OFFSETS:t._pseudoMeters||(T.project_uCommonUnitsPerMeter=v.unitsPerMeter),T.project_uCommonUnitsPerWorldUnit=v.unitsPerDegree,T.project_uCommonUnitsPerWorldUnit2=v.unitsPerDegree2;break;case Oe.CARTESIAN:T.project_uCommonUnitsPerWorldUnit=[1,1,v.unitsPerMeter[2]],T.project_uCommonUnitsPerWorldUnit2=[0,0,v.unitsPerMeter2[2]];break;default:break}}return T}var IU={};function RU(t=IU){return"viewport"in t?qS(t):{}}var da={name:"project",dependencies:[v_,WS],vs:jS,getUniforms:RU};var BU=` vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { @@ -764,7 +1071,7 @@ vec4 project_position_to_clipspace( vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } -`,ae={name:"project32",dependencies:[Ci],vs:tA};function qh(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Hr(t,e){let r=Jt.transformMat4([],e,t);return Jt.scale(r,r,1/r[3]),r}function Gh(t,e){let r=t%e;return r<0?e+r:r}function ro(t,e,r){return tr?r:t}function rA(t){return Math.log(t)*Math.LOG2E}var _s=Math.log2||rA;function It(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Ot=Math.PI,I1=Ot/4,bt=Ot/180,Zh=180/Ot,xs=512,Xc=4003e4,ys=85.051129,O1=1.5;function Jh(t){return _s(t)}function Ze(t){let[e,r]=t;It(Number.isFinite(e)),It(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*bt,s=r*bt,n=xs*(i+Ot)/(2*Ot),o=xs*(Ot+Math.log(Math.tan(I1+s*.5)))/(2*Ot);return[n,o]}function it(t){let[e,r]=t,i=e/xs*(2*Ot)-Ot,s=2*(Math.atan(Math.exp(r/xs*(2*Ot)-Ot))-I1);return[i*Zh,s*Zh]}function Qh(t){let{latitude:e}=t;It(Number.isFinite(e));let r=Math.cos(e*bt);return Jh(Xc*r)-9}function Mi(t){let e=Math.cos(t*bt);return xs/Xc/e}function bs(t){let{latitude:e,longitude:r,highPrecision:i=!1}=t;It(Number.isFinite(e)&&Number.isFinite(r));let s=xs,n=Math.cos(e*bt),o=s/360,a=o/n,c=s/Xc/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=bt*Math.tan(e*bt)/n,f=o*u/2,h=s/Xc*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function io(t,e){let[r,i,s]=t,[n,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=bs({longitude:r,latitude:i,highPrecision:!0}),u=Ze(t);u[0]+=n*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=it(u),h=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[f[0],f[1],h]:f}function $c(t){let{height:e,pitch:r,bearing:i,altitude:s,scale:n,center:o}=t,a=qh();Pe.translate(a,a,[0,0,-s]),Pe.rotateX(a,a,-r*bt),Pe.rotateZ(a,a,i*bt);let c=n/e;return Pe.scale(a,a,[c,c,c]),o&&Pe.translate(a,a,ms.negate([],o)),a}function ed(t){let{width:e,height:r,altitude:i,pitch:s=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:u=Ri(O1)}=t;i!==void 0&&(u=Ri(i));let f=u*bt,h=s*bt,d=so(u),p=d;o&&(p+=o[2]*a/Math.cos(h)/r);let g=f*(.5+(n?n[1]:0)/r),_=Math.sin(g)*p/Math.sin(ro(Math.PI/2-h-g,.01,Math.PI-.01)),y=Math.sin(h)*_+p,v=p*10,T=Math.min(y*l,v);return{fov:f,aspect:e/r,focalDistance:d,near:c,far:T}}function Ri(t){return 2*Math.atan(.5/t)*Zh}function so(t){return .5/Math.tan(.5*t*bt)}function vs(t,e){let[r,i,s=0]=t;return It(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(s)),Hr(e,[r,i,s,1])}function jr(t,e,r=0){let[i,s,n]=t;if(It(Number.isFinite(i)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(n))return Hr(e,[i,s,n,1]);let o=Hr(e,[i,s,0,1]),a=Hr(e,[i,s,1,1]),c=o[2],l=a[2],u=c===l?0:((r||0)-c)/(l-c);return Zt.lerp([],o,a,u)}function Yc(t){let{width:e,height:r,bounds:i,minExtent:s=0,maxZoom:n=24,offset:o=[0,0]}=t,[[a,c],[l,u]]=i,f=iA(t.padding),h=Ze([a,ro(u,-ys,ys)]),d=Ze([l,ro(c,-ys,ys)]),p=[Math.max(Math.abs(d[0]-h[0]),s),Math.max(Math.abs(d[1]-h[1]),s)],g=[e-f.left-f.right-Math.abs(o[0])*2,r-f.top-f.bottom-Math.abs(o[1])*2];It(g[0]>0&&g[1]>0);let _=g[0]/p[0],y=g[1]/p[1],v=(f.right-f.left)/2/_,T=(f.top-f.bottom)/2/y,S=[(d[0]+h[0])/2+v,(d[1]+h[1])/2+T],R=it(S),M=Math.min(n,_s(Math.abs(Math.min(_,y))));return It(Number.isFinite(M)),{longitude:R[0],latitude:R[1],zoom:M}}function iA(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(It(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var N1=Math.PI/180;function Kc(t,e=0){let{width:r,height:i,unproject:s}=t,n={targetZ:e},o=s([0,i],n),a=s([r,i],n),c,l,u=t.fovy?.5*t.fovy*N1:Math.atan(.5/t.altitude),f=(90-t.pitch)*N1;return u>f-.01?(c=F1(t,0,e),l=F1(t,r,e)):(c=s([0,0],n),l=s([r,0],n)),[o,a,l,c]}function F1(t,e,r){let{pixelUnprojectionMatrix:i}=t,s=Hr(i,[e,0,1,1]),n=Hr(i,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-s[2])/(n[2]-s[2]),c=Zt.lerp([],s,n,a),l=it(c);return l.push(r),l}var L1=512;function td(t){let{width:e,height:r,pitch:i=0}=t,{longitude:s,latitude:n,zoom:o,bearing:a=0}=t;(s<-180||s>180)&&(s=Gh(s+180,360)-180),(a<-180||a>180)&&(a=Gh(a+180,360)-180);let c=_s(r/L1);if(o<=c)o=c,n=0;else{let l=r/2/Math.pow(2,o),u=it([0,l])[1];if(nf&&(n=f)}}return{width:e,height:r,longitude:s,latitude:n,zoom:o,pitch:i,bearing:a}}var oA=` +`,xt={name:"project32",dependencies:[da],vs:BU};function x2(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function oo(t,e){let r=fi.transformMat4([],e,t);return fi.scale(r,r,1/r[3]),r}function b2(t,e){let r=t%e;return r<0?e+r:r}function Au(t,e,r){return tr?r:t}function OU(t){return Math.log(t)*Math.LOG2E}var Bc=Math.log2||OU;function on(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var an=Math.PI,KS=an/4,zi=an/180,T2=180/an,Oc=512,K0=4003e4,Fc=85.051129,JS=1.5;function E2(t){return Bc(t)}function gr(t){let[e,r]=t;on(Number.isFinite(e)),on(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*zi,n=r*zi,s=Oc*(i+an)/(2*an),o=Oc*(an+Math.log(Math.tan(KS+n*.5)))/(2*an);return[s,o]}function jr(t){let[e,r]=t,i=e/Oc*(2*an)-an,n=2*(Math.atan(Math.exp(r/Oc*(2*an)-an))-KS);return[i*T2,n*T2]}function v2(t){let{latitude:e}=t;on(Number.isFinite(e));let r=Math.cos(e*zi);return E2(K0*r)-9}function ga(t){let e=Math.cos(t*zi);return Oc/K0/e}function Lc(t){let{latitude:e,longitude:r,highPrecision:i=!1}=t;on(Number.isFinite(e)&&Number.isFinite(r));let n=Oc,s=Math.cos(e*zi),o=n/360,a=o/s,A=n/K0/s,h={unitsPerMeter:[A,A,A],metersPerUnit:[1/A,1/A,1/A],unitsPerDegree:[o,a,A],degreesPerUnit:[1/o,1/a,1/A]};if(i){let g=zi*Math.tan(e*zi)/s,_=o*g/2,x=n/K0*g,T=x/a*A;h.unitsPerDegree2=[0,_,x],h.unitsPerMeter2=[T,0,T]}return h}function uu(t,e){let[r,i,n]=t,[s,o,a]=e,{unitsPerMeter:A,unitsPerMeter2:h}=Lc({longitude:r,latitude:i,highPrecision:!0}),g=gr(t);g[0]+=s*(A[0]+h[0]*o),g[1]+=o*(A[1]+h[1]*o);let _=jr(g),x=(n||0)+(a||0);return Number.isFinite(n)||Number.isFinite(a)?[_[0],_[1],x]:_}function J0(t){let{height:e,pitch:r,bearing:i,altitude:n,scale:s,center:o}=t,a=x2();ir.translate(a,a,[0,0,-n]),ir.rotateX(a,a,-r*zi),ir.rotateZ(a,a,i*zi);let A=s/e;return ir.scale(a,a,[A,A,A]),o&&ir.translate(a,a,Lr.negate([],o)),a}function S2(t){let{width:e,height:r,altitude:i,pitch:n=0,offset:s,center:o,scale:a,nearZMultiplier:A=1,farZMultiplier:h=1}=t,{fovy:g=pa(JS)}=t;i!==void 0&&(g=pa(i));let _=g*zi,x=n*zi,T=fu(g),v=T;o&&(v+=o[2]*a/Math.cos(x)/r);let S=_*(.5+(s?s[1]:0)/r),C=Math.sin(S)*v/Math.sin(Au(Math.PI/2-x-S,.01,Math.PI-.01)),M=Math.sin(x)*C+v,R=v*10,B=Math.min(M*h,R);return{fov:_,aspect:e/r,focalDistance:T,near:A,far:B}}function pa(t){return 2*Math.atan(.5/t)*T2}function fu(t){return .5/Math.tan(.5*t*zi)}function Nc(t,e){let[r,i,n=0]=t;return on(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(n)),oo(e,[r,i,n,1])}function ao(t,e,r=0){let[i,n,s]=t;if(on(Number.isFinite(i)&&Number.isFinite(n),"invalid pixel coordinate"),Number.isFinite(s))return oo(e,[i,n,s,1]);let o=oo(e,[i,n,0,1]),a=oo(e,[i,n,1,1]),A=o[2],h=a[2],g=A===h?0:((r||0)-A)/(h-A);return Hn.lerp([],o,a,g)}function Z0(t){let{width:e,height:r,bounds:i,minExtent:n=0,maxZoom:s=24,offset:o=[0,0]}=t,[[a,A],[h,g]]=i,_=FU(t.padding),x=gr([a,Au(g,-Fc,Fc)]),T=gr([h,Au(A,-Fc,Fc)]),v=[Math.max(Math.abs(T[0]-x[0]),n),Math.max(Math.abs(T[1]-x[1]),n)],S=[e-_.left-_.right-Math.abs(o[0])*2,r-_.top-_.bottom-Math.abs(o[1])*2];on(S[0]>0&&S[1]>0);let C=S[0]/v[0],M=S[1]/v[1],R=(_.right-_.left)/2/C,B=(_.top-_.bottom)/2/M,k=[(T[0]+x[0])/2+R,(T[1]+x[1])/2+B],Q=jr(k),$=Math.min(s,Bc(Math.abs(Math.min(C,M))));return on(Number.isFinite($)),{longitude:Q[0],latitude:Q[1],zoom:$}}function FU(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(on(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var ZS=Math.PI/180;function $0(t,e=0){let{width:r,height:i,unproject:n}=t,s={targetZ:e},o=n([0,i],s),a=n([r,i],s),A,h,g=t.fovy?.5*t.fovy*ZS:Math.atan(.5/t.altitude),_=(90-t.pitch)*ZS;return g>_-.01?(A=$S(t,0,e),h=$S(t,r,e)):(A=n([0,0],s),h=n([r,0],s)),[o,a,h,A]}function $S(t,e,r){let{pixelUnprojectionMatrix:i}=t,n=oo(i,[e,0,1,1]),s=oo(i,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-n[2])/(s[2]-n[2]),A=Hn.lerp([],n,s,a),h=jr(A);return h.push(r),h}var tw=512;function w2(t){let{width:e,height:r,pitch:i=0}=t,{longitude:n,latitude:s,zoom:o,bearing:a=0}=t;(n<-180||n>180)&&(n=b2(n+180,360)-180),(a<-180||a>180)&&(a=b2(a+180,360)-180);let A=Bc(r/tw);if(o<=A)o=A,s=0;else{let h=r/2/Math.pow(2,o),g=jr([0,h])[1];if(s_&&(s=_)}}return{width:e,height:r,longitude:n,latitude:s,zoom:o,pitch:i,bearing:a}}var DU=` const int max_lights = 2; uniform mat4 shadow_uViewProjectionMatrices[max_lights]; uniform vec4 shadow_uProjectCenters[max_lights]; @@ -789,7 +1096,7 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) { } return gl_Position; } -`,aA=` +`,UU=` const int max_lights = 2; uniform bool shadow_uDrawShadowMap; uniform bool shadow_uUseShadowMap; @@ -833,11 +1140,11 @@ vec4 shadow_filterShadowColor(vec4 color) { } return color; } -`,cA=Qt(dA),lA=Qt(pA),uA=[0,0,0,1],fA=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function hA(t,e){let[r,i,s]=t,n=jr([r,i,s],e);return Number.isFinite(s)?n:[n[0],n[1],0]}function dA({viewport:t,center:e}){return new De(t.viewProjectionMatrix).invert().transform(e)}function pA({viewport:t,shadowMatrices:e}){let r=[],i=t.pixelUnprojectionMatrix,s=t.isGeospatial?void 0:1,n=[[0,0,s],[t.width,0,s],[0,t.height,s],[t.width,t.height,s],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(o=>hA(o,i));for(let o of e){let a=o.clone().translate(new Ue(t.center).negate()),c=n.map(u=>a.transform(u)),l=new De().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});r.push(l.multiplyRight(o))}return r}function gA(t,e){let{shadowEnabled:r=!0}=t;if(!r||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let i={shadow_uDrawShadowMap:!!t.drawToShadowMap,shadow_uUseShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,shadow_uColor:t.shadowColor||uA,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},s=cA({viewport:t.viewport,center:e.project_uCenter}),n=[],o=lA({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let a=0;aGU(o,i));for(let o of e){let a=o.clone().translate(new X(t.center).negate()),A=s.map(g=>a.transform(g)),h=new Fe().ortho({left:Math.min(...A.map(g=>g[0])),right:Math.max(...A.map(g=>g[0])),bottom:Math.min(...A.map(g=>g[1])),top:Math.max(...A.map(g=>g[1])),near:Math.min(...A.map(g=>-g[2])),far:Math.max(...A.map(g=>-g[2]))});r.push(h.multiplyRight(o))}return r}function XU(t,e){let{shadowEnabled:r=!0}=t;if(!r||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let i={shadow_uDrawShadowMap:!!t.drawToShadowMap,shadow_uUseShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,shadow_uColor:t.shadowColor||zU,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},n=kU({viewport:t.viewport,center:e.project_uCenter}),s=[],o=VU({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let a=0;a"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?gA(t,e):{}};var ue={...Lc,defaultUniforms:{...Lc.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":` + `},getUniforms:(t={},e={})=>"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?XU(t,e):{}};var Mt={...L0,defaultUniforms:{...L0.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` @@ -848,8 +1155,8 @@ vec4 shadow_filterShadowColor(vec4 color) { // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); - `}}};var mA=[Ci],_A=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function no(){let t=yi.getDefaultShaderAssembler();for(let e of mA)t.addDefaultModule(e);for(let e of _A)t.addShaderHook(e);return t}var xA=[255,255,255],yA=1,bA=0,Gc=class{constructor(e={}){this.type="ambient";let{color:r=xA}=e,{intensity:i=yA}=e;this.id=e.id||`ambient-${bA++}`,this.color=r,this.intensity=i}};var vA=[255,255,255],TA=1,EA=[0,0,-1],SA=0,oo=class{constructor(e={}){this.type="directional";let{color:r=vA}=e,{intensity:i=TA}=e,{direction:s=EA}=e,{_shadow:n=!1}=e;this.id=e.id||`directional-${SA++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new Ue(s).normalize().toArray(),this.shadow=n}getProjectedLight(e){return this}};var ao=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var yr=class extends ao{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[r,i]=this.device.canvasContext.getDrawingBufferSize(),s=e.clearCanvas??!0,n=e.clearColor??(s?[0,0,0,0]:!1),o=s?1:!1,a=s?0:!1,c=e.colorMask??15,l={viewport:[0,0,r,i]};e.colorMask&&(l.colorMask=c),e.scissorRect&&(l.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:n,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,e)}finally{u.end()}}_drawLayers(e,r){let{target:i,moduleParameters:s,viewports:n,views:o,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let u of n){let f=o&&o[u.id];a?.(u);let h=this._getDrawLayerParams(u,r),d=u.subViewports||[u];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,moduleParameters:s,viewport:p,view:f,pass:r.pass,layers:r.layers},h);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:s=!1,layerFilter:n,cullRect:o,effects:a,moduleParameters:c},l=!1){let u=[],f=k1(this._lastRenderIndex+1),h={layer:r[0],viewport:e,isPicking:s,renderPass:i,cullRect:o},d={};for(let p=0;pthis.device.clearWebGL(f))}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let f=0;f{let o=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&i(s.parent,!1),c in r){let u=r[c]=r[c]||k1(e[c],e);l=u(s,n),r[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),r[a]=null):l=t;return n&&l>=t&&(t=l+1),e[a]=l,l};return i}function AA(t,{moduleParameters:e,target:r,viewport:i}){let s=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,n]=t.canvasContext.getDrawingBufferSize(),o=r?r.height:n,a=i;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}var co=class extends yr{constructor(e,r){super(e,r),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],n=s.width*i,o=s.height*i,a=[1,1,1,1];(n!==r.width||o!==r.height)&&r.resize({width:n,height:o}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}};var wA={color:[255,255,255],intensity:1},B1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],PA=[0,0,0,200/255],Ts=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=PA,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(qc),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oi.getProjectedLight({layer:e})),pointLights:this.pointLights.map(i=>i.getProjectedLight({layer:e}))},r}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(qc))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new De().lookAt({eye:new Ue(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;rs&&(n=s);let o=this._pool,a=e.BYTES_PER_ELEMENT*n,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:s}=i,n=r.findIndex(o=>o.byteLength>=s);n<0?r.push(i):(n>0||r.lengththis.opts.poolSize&&r.shift()}},Nt=new rd;function Ss(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function z1(t){return[t[12],t[13],t[14]]}function V1(t){return{left:Es(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Es(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Es(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Es(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Es(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Es(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var U1=new Ue;function Es(t,e,r,i){U1.set(t,e,r);let s=U1.len();return{distance:i/s,normal:new Ue(-t/s,-e/s,-r/s)}}function Ii(t){return t-Math.fround(t)}var lo;function Zc(t,e){let{size:r=1,startIndex:i=0}=e,s=e.endIndex!==void 0?e.endIndex:t.length,n=(s-i)/r;lo=Nt.allocate(lo,n,{type:Float32Array,size:r*2});let o=i,a=0;for(;o=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let s of r)this._setChannelTime(s,this.time);let i=this.animations.values();for(let s of i){let{animation:n,channel:o}=s;n.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=FA++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let i=r-e.delay,s=e.duration*e.repeat;i>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};var DA=0,LA={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:dr.stats.get(`animation-loop-${DA++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},uo=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...LA,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new dt({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Rf(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Mf(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],i=1,s=this.device?.canvasContext?.canvas;return s&&s.clientHeight?i=s.clientWidth/s.clientHeight:e>0&&r>0&&(i=e/r),{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var Jc=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Fe("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&ee(this.indices.usage===ie.INDEX)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function $1(t,e){if(e instanceof Jc)return e;let r=kA(t,e),{attributes:i,bufferLayout:s}=BA(t,e);return new Jc({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:r,attributes:i})}function kA(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:ie.INDEX,data:r})}function BA(t,e){let r=[],i={};for(let[n,o]of Object.entries(e.attributes)){let a=n;switch(n){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}i[a]=t.createBuffer({data:o.value,id:`${n}-buffer`});let{value:c,size:l,normalized:u}=o;r.push({name:a,format:wf(c,l,u)})}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:s}}var Qc=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){let r=xi(Object.values(e).filter(i=>i.dependencies));for(let i of r)e[i.name]=i;O.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[i,s]of Object.entries(e)){let n=i;this.moduleUniforms[n]=s.defaultUniforms||{},this.moduleBindings[n]={}}}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,s=e[i],n=this.modules[i];if(!n){O.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[i],a=n.getUniforms?.(s,this.moduleUniforms[i])||s;this.moduleUniforms[i]={...o,...a}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[s,n]of Object.entries(i))e[`${r}.${s}`]={type:this.modules[r].uniformTypes?.[s],value:String(n)};return e}};var el=class t{static defaultProps={...qt.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new t(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){let r={...qt.defaultProps,...e},i=this._hashRenderPipeline(r);if(!this._renderPipelineCache[i]){let s=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._renderPipelineCache[i]={pipeline:s,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){let r={...us.defaultProps,...e},i=this._hashComputePipeline(r);if(!this._computePipelineCache[i]){let s=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._computePipelineCache[i]={pipeline:s,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){let r=e.hash,i=e instanceof us?this._computePipelineCache:this._renderPipelineCache;i[r].useCount--,i[r].useCount===0&&(i[r].pipeline.destroy(),delete i[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,s="-",n=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${i}V${s}BL${n}`;default:let o=this._getHash(JSON.stringify(e.parameters));return`${r}/${i}V${s}T${e.topology}P${o}BL${n}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};var tl=class t{static defaultProps={...Ti.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new t(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){let r=this._hashShader(e),i=this._cache[r];if(!i){let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={shader:s,useCount:0}}return i.useCount++,i.shader}release(e){let r=this._hashShader(e),i=this._cache[r];i&&(i.useCount--,i.useCount===0&&(delete this._cache[r],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}};function Y1(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let s of t.attributes)if(s){let n=`${s.location} ${s.name}: ${s.type}`;r[`in ${n}`]={[i]:s.stepMode||"vertex"}}for(let s of t.varyings||[]){let n=`${s.location} ${s.name}`;r[`out ${n}`]={[i]:JSON.stringify(s.accessor)}}return r}var Ie=null,nd=null;function K1(t,{id:e,minimap:r,opaque:i,top:s="0",left:n="0",rgbaScale:o=1}){Ie||(Ie=document.createElement("canvas"),Ie.id=e,Ie.title=e,Ie.style.zIndex="100",Ie.style.position="absolute",Ie.style.top=s,Ie.style.left=n,Ie.style.border="blue 1px solid",Ie.style.transform="scaleY(-1)",document.body.appendChild(Ie),nd=Ie.getContext("2d")),(Ie.width!==t.width||Ie.height!==t.height)&&(Ie.width=t.width/2,Ie.height=t.height/2,Ie.style.width="400px",Ie.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),c=nd.createImageData(t.width,t.height),l=0;for(let u=0;u[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new Qc(i));let s=zA(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=fh(this.props.source);let{source:a,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:s,...this.props,modules:n});this.source=a,this._getModuleUniforms=c}else{let{vs:a,fs:c,getUniforms:l}=this.props.shaderAssembler.assembleShaderPair({platformInfo:s,...this.props,modules:n});this.vs=a,this.fs=c,this._getModuleUniforms=l}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,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||el.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||tl.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){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(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let r;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),Br(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,s=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),r?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",r}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&$1(this.device,e);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=q1(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)),this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?q1(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){qn(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 Xn(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),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,r){e.indices&&O.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[i,s]of Object.entries(e)){let n=this.bufferLayout.find(c=>G1(c).includes(i));if(!n){O.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let o=G1(n),a=!1;for(let c of o){let l=this._attributeInfos[c];l&&(this.vertexArray.setBuffer(l.location,s),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&O.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,s]of Object.entries(e)){let n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,s):(r?.disableWarnings??this.props.disableWarnings)||O.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){Br(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){let{bindings:r,uniforms:i}=Yn(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof vi?e=Math.max(e,r.texture.updateTimestamp):r instanceof ie||r instanceof Se?e=Math.max(e,r.updateTimestamp):r instanceof Ei||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(O.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),s=null;this.source?s=i:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:s}),this._attributeInfos=hc(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=O.level>3?0:UA;O.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:O.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=Y1(this.pipeline.shaderLayout,this.id);O.table(As,e)();let r=this.shaderInputs.getDebugTable();for(let[s,n]of Object.entries(this.uniforms))r[s]={value:n};O.table(As,r)();let i=this._getAttributeDebugTable();O.table(As,this._attributeInfos)(),O.table(As,i)(),O.groupEnd(As)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=O.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let i=e.props.framebuffer;i&&K1(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos))e[i.location]={name:r,type:i.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[i.location],i.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=$n(r);return(e instanceof ie?new i(e.debugData):e).toString()}};function q1(t,e){let r=[...t];for(let i of e){let s=r.findIndex(n=>n.name===i.name);s<0?r.push(i):r[s]=i}return r}function zA(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function G1(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}var Xr=class t{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=te.defaultProps){ee(t.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new te(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||Dn(),topology:r.topology||"point-list",...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(r instanceof ie)return r.readAsync();let{buffer:i,byteOffset:s=0,byteLength:n=i.byteLength}=r;return i.readAsync(s,n)}};var VA="transform_output",$r=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new te(this.device,{id:r.id||"texture-transform-model",fs:r.fs||Dn({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:VA}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getData({packed:e=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:i,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),s){e.targetTexture=s;let{width:n,height:o}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:o,colorAttachments:[s]}),e.framebuffer.resize({width:n,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var fe=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:s=null}=e;this.id=e.id||Fe("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[n,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;ee(ArrayBuffer.isView(a.value),`${this._print(n)}: must be typed array or object with value as typed array`),(n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"?(ee(!this.indices),this.indices=a):this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let s of Object.values(e)){let{value:n,size:o,constant:a}=s;!a&&n&&o>=1&&(i=Math.min(i,n.length/o))}return ee(Number.isFinite(i)),i}};var Fi=class extends fe{constructor(e={}){let{id:r=Fe("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:WA},attributes:{...qA,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...GA,...e.attributes}})}},WA=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),HA=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),jA=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),XA=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),$A=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),YA=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),KA=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),qA={POSITION:{size:3,value:HA},NORMAL:{size:3,value:jA},TEXCOORD_0:{size:2,value:XA}},GA={POSITION:{size:3,value:$A},TEXCOORD_0:{size:2,value:YA},COLOR_0:{size:3,value:KA}};var ZA={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},Di=class extends yr{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:n,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:u},cullRect:f,effects:h,pass:d="picking",pickZ:p,moduleParameters:g}){this.pickZ=p;let _=this._resetColorEncoder(p),y=[a,c,l,u],v=super.render({target:o,layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:n,cullRect:f,effects:h?.filter(S=>S.useInPicking),pass:d,isPicking:!0,moduleParameters:g,clearColor:[0,0,0,0],colorMask:15,scissorRect:y});return this._colorEncoderState=null,{decodePickingColor:_&&QA.bind(null,_),stats:v}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,r,i){let s={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:n,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?s.blend=!1:n&&o.includes("draw")&&(Object.assign(s,ZA),s.blend=!0,s.blendColor=JA(this._colorEncoderState,e,i)),s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function JA(t,e,r){let{byLayer:i,byAlpha:s}=t,n,o=i.get(e);return o?(o.viewports.push(r),n=o.a):(n=i.size+1,n<=255?(o={a:n,layer:e,viewports:[r]},i.set(e,o),s[n]=o):(U.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function QA(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var Yr={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},ws=Symbol.for("component"),vt=Symbol.for("propTypes"),rl=Symbol.for("deprecatedProps"),br=Symbol.for("asyncPropDefaults"),tr=Symbol.for("asyncPropOriginal"),Ft=Symbol.for("asyncPropResolved");function Tt(t,e=()=>!0){return Array.isArray(t)?Z1(t,e,[]):e(t)?[t]:[]}function Z1(t,e,r){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,s=e;typeof e=="string"&&(s=Lr(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let n of this._subscribers)n.onChange(this.getData())}};var ho=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:i=!1,persistent:s=!0}){let n=this._resources[e];n?n.setData(r,i):(n=new fo(e,r,this._context),this._resources[e]=n),n.persistent=s}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let s=r[i],n=this._resources[s.resourceId];n&&n.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:s="default"}){let{_resources:n,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),n[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=n[e];if(this._track(i,s,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,i,s){let n=this._consumers,o=n[e]=n[e]||{},a=o[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=s,a.resourceId=i.id):a={onChange:s,resourceId:i.id},o[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var ew="layerManager.setLayers",tw="layerManager.activateViewport",po=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{ye(tw,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:s,viewport:n,timeline:o}=r||{};this.layers=[],this.resourceManager=new ho({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:no(),defaultShaderModules:[],renderPass:void 0,stats:s||new dt({id:"deck.gl"}),viewport:n||new Oi({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Ni,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let s=i.getNeedsRedraw(e);r=r||s}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){ye(ew,this,r,e),this._lastRenderedLayers=e;let i=Tt(e,Boolean);for(let s of i)s.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(s=>s.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let o of e)i[o.id]?U.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(r,i,s),this._finalizeOldLayers(i);let n=!1;for(let o of s)if(o.hasUniformTransition()){n=`Uniform transition in ${o}`;break}this._needsUpdate=n,this.layers=s}_updateSublayersRecursively(e,r,i){for(let s of e){s.context=this.context;let n=r[s.id];n===null&&U.warn(`Multiple new layers with same id ${s.id}`)(),r[s.id]=null;let o=null;try{this._debug&&n!==s&&s.validateProps(),n?(this._transferLayerState(n,s),this._updateLayer(s)):this._initializeLayer(s),i.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Yr.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=Yr.MATCHED,r!==e&&(e.lifecycle=Yr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Yr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Yr.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function Le(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;ir.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),s={x:e[0],y:e[1]};for(let n=i.length-1;n>=0;--n){let o=i[n];if(o.containsPixel(s)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Tt(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Le(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):U.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(e.id)?.makeViewport({viewState:n,width:this.width,height:this.height})})}_updateController(e,r,i,s){let n=e.controller;if(n&&i){let o={...r,...n,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!s||s.constructor!==n.type)&&(s=this._createController(e,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let s=e.length;s--;){let n=e[s],o=this.getViewState(n),a=n.makeViewport({viewState:o,width:this.width,height:this.height}),c=r[n.id],l=!!n.controller;l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,o,a,c),a&&this._viewports.unshift(a)}for(let s in r){let n=r[s];n&&!this.controllers[s]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,s)=>!e[s].equals(r[s]))}};var rw=/([0-9]+\.?[0-9]*)(%|px)/;function vr(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":let e=rw.exec(t);if(e&&e.length>=3){let r=e[2]==="%",i=parseFloat(e[1]);return{position:r?i/100:i,relative:r}}default:throw new Error(`Could not parse position string ${t}`)}}function Tr(t,e){return t.relative?Math.round(t.position*e):t.position}var mo=class{constructor(e){let{id:r,x:i=0,y:s=0,width:n="100%",height:o="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=vr(i),this._y=vr(s),this._width=vr(n),this._height=vr(o),this._padding=a&&{left:vr(a.left||0),right:vr(a.right||0),top:vr(a.top||0),bottom:vr(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&Le(this.props,e.props,2)}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let s=this.getDimensions({width:e,height:r});return!s.height||!s.width?null:new this.ViewportType({...i,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let r={...e};for(let i in this.props.viewState)i!=="id"&&(r[i]=this.props.viewState[i]);return r}return e}getDimensions({width:e,height:r}){let i={x:Tr(this._x,e),y:Tr(this._y,r),width:Tr(this._width,e),height:Tr(this._height,r)};return this._padding&&(i.padding={left:Tr(this._padding.left,e),top:Tr(this._padding.top,r),right:Tr(this._padding.right,e),bottom:Tr(this._padding.bottom,r)}),i}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var Dt=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var J1=()=>{},ad={BREAK:1,SNAP_TO_END:2,IGNORE:3},iw=t=>t,sw=ad.BREAK,_o=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:s,startProps:n,endProps:o,duration:a,easing:c}}=r,l=c(i/a),u=s.interpolateProps(n,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Dt(e.timeline),this.onViewStateChange=e.onViewStateChange||J1,this.onStateChange=e.onStateChange||J1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let s=i;if(this.transition.inProgress){let{interruption:n,endProps:o}=this.transition.settings;s={...i,...n===ad.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(s,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===ad.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),s=this.getControllerState(r).shortestPathFrom(i),n=r.transitionInterpolator,o=n.getDuration?n.getDuration(e,r):r.transitionDuration;if(o===0)return;let a=n.initializeProps(e,s);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||iw,interpolator:n,interruption:r.transitionInterruption||sw,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function oe(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var xo=class{constructor(e){let{compare:r,extract:i,required:s}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=s}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!xr(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},s={};for(let n of this._propsToExtract)(n in e||n in r)&&(i[n]=e[n],s[n]=r[n]);return this._checkRequiredProps(i),this._checkRequiredProps(s),{start:i,end:s}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];oe(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var nw=["longitude","latitude","zoom","bearing","pitch"],ow=["longitude","latitude","zoom"],Li=class extends xo{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:nw,required:ow},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:s,around:n}=this.opts;if(s&&n){let o=s(e),a=s(r),c=o.unproject(n);i.start.around=n,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let s={};for(let n of this._propsToExtract)s[n]=Rt(e[n]||0,r[n]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...s});Object.assign(s,n.panByPosition(r.aroundPosition,Rt(e.around,r.around,i)))}return s}};var Kr={transitionDuration:0},aw=300,il=t=>1-(1-t)*(1-t),Ps={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},ki={},yo=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new _o({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return r?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:i}=this.props,{offsetCenter:s}=e;return[s.x-r,s.y-i]}isPointInBounds(e,r){let{width:i,height:s}=this.props;if(r&&r.handled)return!1;let n=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=s;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(e){let{srcEvent:r}=e;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:r}=e;this.inertia=Number.isFinite(r)?r:r===!0?aw:0;let{scrollZoom:i=!0,dragPan:s=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=!!this.onViewStateChange;this.toggleEvents(Ps.WHEEL,u&&i),this.toggleEvents(Ps.PAN,u),this.toggleEvents(Ps.PINCH,u&&(a||c)),this.toggleEvents(Ps.TRIPLE_PAN,u&&c),this.toggleEvents(Ps.DOUBLE_TAP,u&&o),this.toggleEvents(Ps.KEYBOARD,u&&l),this.scrollZoom=i,this.dragPan=s,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let s={...e.getViewportProps(),...r},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),n){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let s=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(s,Kr,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:il},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:il},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=e,o=2/(1+Math.exp(-Math.abs(n*i)));n<0&&o!==0&&(o=1/o);let a=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(a,{...this._getTransitionProps({around:r}),transitionDuration:s?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,Kr,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),s=[i[0],i[1]+=e.velocityY*r/2],n=this.controllerState.rotate({pos:s});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:il},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return ki._startPinchRotation=e.rotation,ki._lastPinchEvent=e,this.updateViewport(i,Kr,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,s=this.getCenter(e);r=r.zoom({pos:s,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:ki._startPinchRotation-i})}return this.updateViewport(r,Kr,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ki._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=ki;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let s=this.getCenter(e),n=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,o+a*r/2);n=n.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:il},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return ki._startPinchRotation=null,ki._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(s,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:s,rotateSpeedX:n,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Kr:e?{...r,transitionInterpolator:new Li({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var bo=class{constructor(e,r){this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var Q1=5,cw=1.2,cd=class extends bo{constructor(e){let{width:r,height:i,latitude:s,longitude:n,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:_,startRotatePos:y,startBearing:v,startPitch:T,startZoom:S,normalize:R=!0}=e;oe(Number.isFinite(n)),oe(Number.isFinite(s)),oe(Number.isFinite(o)),super({width:r,height:i,latitude:s,longitude:n,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:h,maxPitch:d,minPitch:p,normalize:R,position:u},{startPanLngLat:g,startZoomLngLat:_,startRotatePos:y,startBearing:v,startPitch:T,startZoom:S}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:n,startPitch:o}=this.getState();if(!s||n===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,s,o,n):a={bearing:n+r,pitch:o+i},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomLngLat:n}=this.getState();if(n||(s=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=s+Math.log2(i);c=xt(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:n}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(e){let{maxZoom:r,minZoom:i,zoom:s}=e;e.zoom=xt(s,i,r);let{maxPitch:n,minPitch:o,pitch:a}=e;e.pitch=xt(a,o,n);let{normalize:c=!0}=e;return c&&Object.assign(e,td(e)),e}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_getNewRotation(e,r,i,s){let n=e[0]-r[0],o=e[1]-r[1],a=e[1],c=r[1],{width:l,height:u}=this.getViewportProps(),f=n/l,h=0;o>0?Math.abs(u-c)>Q1&&(h=o/(c-u)*cw):o<0&&c>Q1&&(h=1-a/c),h=xt(h,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=s+180*f,_=i;return h>0?_=i+h*(p-i):h<0&&(_=i-h*(d-i)),{pitch:_,bearing:g}}},vo=class extends yo{constructor(){super(...arguments),this.ControllerState=cd,this.transition={transitionDuration:300,transitionInterpolator:new Li({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let r=this.props;super.setProps(e),(!r||r.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var qr=class extends mo{static{this.displayName="MapView"}constructor(e={}){super(e)}get ViewportType(){return er}get ControllerType(){return vo}};var lw=new Ts;function uw(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var To=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(s=>uw(s,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Le(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let s of this.effects)r[s.id]=s;let i=[];for(let s of e){let n=r[s.id],o=s;n&&n!==s?n.setProps?(n.setProps(s.props),o=n):n.cleanup(this._context):n||s.setup(this._context),i.push(o),delete r[s.id]}for(let s in r)r[s].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(s=>s instanceof Ts)||this._resolvedEffects.push(lw),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Eo=class extends yr{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}};var fw="deckRenderer.renderLayers",So=class{constructor(e){this.device=e,this.gl=e.gl,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Eo(e),this.pickLayersPass=new Di(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let s=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let n=r.render({...i,target:s});i.effects&&this._postRender(i.effects,i),this.renderCount++,ye(fw,this,n,e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(i=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[s]}))});for(let i of e)i.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,s={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let n of e)if(n.postRender){s.target=n.id===this.lastPostProcessEffect?r.target:void 0;let o=n.postRender(s);s.inputBuffer=o,s.swapBuffer=o===i[0]?i[1]:i[0]}}};var hw={pickedColor:null,pickedObjectIndex:-1};function e0({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:s,deviceRect:n}){let{x:o,y:a,width:c,height:l}=n,u=s*s,f=-1,h=0;for(let d=0;du)h+=4*c;else for(let _=0;_=0){let v=_+o-r,T=v*v+g;T<=u&&(u=T,f=h)}h+=4}}if(f>=0){let d=t.slice(f,f+4),p=e(d);if(p){let g=Math.floor(f/4/c),_=f/4-g*c;return{...p,pickedColor:d,pickedX:o+_,pickedY:a+g}}U.error("Picked non-existent layer. Is picking buffer corrupt?")()}return hw}function t0({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i=0){let n=t.slice(i,i+4),o=n.join(",");if(!r.has(o)){let a=e(n);a?r.set(o,{...a,color:n}):U.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function ld({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:s,z:n}){let o=e[0];e.length>1&&(o=dw(t?.pickedViewports||e,{x:i,y:s}));let a;if(o){let c=[i-o.x,s-o.y];n!==void 0&&(c[2]=n),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:s,pixel:[i,s],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function r0(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:s}=t,{pickedColor:n,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=r.index,h=r.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let p=s.find(g=>g.props.id===h);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=ld(t),u=new Map;return u.set(null,l),c.forEach(f=>{let h={...l};f===o&&(h.color=n,h.index=a,h.picked=!0),h=ud({layer:f,info:h,mode:i});let d=h.layer;f===o&&i==="hover"&&(r.info=h),u.set(d.id,h),i==="hover"&&d.updateAutoHighlight(h)}),u}function ud({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function dw(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var Ao=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Di(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:i,viewports:s},n=this.lastPickedInfo.info){let o=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=o?i.find(h=>h.id===o):null,l=a&&s.find(h=>h.id===a)||s[0],u=l&&l.unproject([e-l.x,r-l.y]);return{...n,...{x:e,y:r,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let e=this.device.gl;this.pickingFBO?.resize({width:e.canvas.width,height:e.canvas.height}),this.depthFBO?.resize({width:e.canvas.width,height:e.canvas.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}_pickClosestObject({layers:e,views:r,viewports:i,x:s,y:n,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:ld({viewports:i,x:s,y:n,pixelRatio:h})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],_=Math.round(o*h),{width:y,height:v}=this.pickingFBO,T=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:y,deviceHeight:v}),S={x:s-o,y:n-o,width:o*2+1,height:o*2+1},R,M=[],F=new Set;for(let N=0;N=l);L++){let Y=M[L],X={color:Y.pickedColor,layer:null,index:Y.pickedObjectIndex,picked:!0,x:s,y:n,pixelRatio:d};X=ud({layer:Y.pickedLayer,info:X,mode:c});let $=X.layer.id;F.has($)||F.set($,new Set);let Z=F.get($),ge=X.object??X.index;Z.has(ge)||(Z.add(ge),N.push(X))}return N}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:n,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:u,deviceRect:n,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{}};for(let v of a)v.useInPicking&&(f.preRenderStats[v.id]=v.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:p,width:g,height:_}=n,y=new(l?Float32Array:Uint8Array)(g*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:p,sourceWidth:g,sourceHeight:_,target:y}),{pickedColors:y,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:s,deviceHeight:n}){let o=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(s,e+i+1)-o,l=Math.min(n,r+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var pw={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},gw="top-left",i0="__root",sl=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Le(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(let e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let s=r[i.id];s?s.viewId!==i.viewId||s.placement!==i.placement?(this._remove(s),this._add(i)):i!==s&&(s.setProps(i.props),i=s):this._add(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let s=r[i];s&&this._remove(s)}this.widgets=e}_add(e){let{viewId:r=null,placement:i=gw}=e,s=e.onAdd({deck:this.deck,viewId:r});s&&this._getContainer(r,i).append(s),e._element=s}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,r){let i=e||i0,s=this.containers[i];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[i]=s);let n=s.querySelector(`.${r}`);return n||(n=document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,pw[r]),s.append(n)),n}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let s=this.lastViewports[i]||null,n=i===i0||s,o=this.containers[i];n?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:e}px`,o.style.height=`${s?s.height:r}px`):o.style.display="none"}}onRedraw({viewports:e,layers:r}){let i=e.reduce((n,o)=>(n[o.id]=o,n),{}),{lastViewports:s}=this;for(let n of this.getWidgets()){let{viewId:o}=n;if(o){let a=i[o];a&&(n.onViewportChange&&!a.equals(s[o])&&n.onViewportChange(a),n.onRedraw?.({viewports:[a],layers:r}))}else{if(n.onViewportChange)for(let a of e)a.equals(s[a.id])||n.onViewportChange(a);n.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:s}=i;(!s||s===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=to[r.type];if(i)for(let s of this.getWidgets()){let{viewId:n}=s;(!n||n===e.viewport?.id)&&s[i.handler]?.(e,r)}}};var mw={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},wo=class{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){let r=document.createElement("div");return r.className="deck-tooltip",Object.assign(r.style,mw),this.deck=e,this.element=r,r}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let s=i(e);this.lastViewport=e.viewport,this.setTooltip(s,e.x,e.y)}setTooltip(e,r,i){let s=this.element;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};var Gr;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Gr||(Gr={}));var Co={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},Ae=(t,e,r)=>e?t.enable(r):t.disable(r),s0=(t,e,r)=>t.hint(r,e),st=(t,e,r)=>t.pixelStorei(r,e),n0=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},Po=(t,e,r)=>{let s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];t.bindBuffer(s,e)};function fd(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var o0={3042:Ae,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:Ae,2885:(t,e)=>t.cullFace(e),2929:Ae,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:Ae,35723:s0,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>t.bindTransformFeedback?.(36386,e),34229:(t,e)=>t.bindVertexArray(e),36006:n0,36010:n0,34964:Po,36662:Po,36663:Po,35053:Po,35055:Po,2886:(t,e)=>t.frontFace(e),33170:s0,2849:(t,e)=>t.lineWidth(e),32823:Ae,32824:"polygonOffset",10752:"polygonOffset",35977:Ae,32926:Ae,32928:Ae,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ae,3088:(t,e)=>t.scissor(...e),2960:Ae,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.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:(t,e)=>t.viewport(...e),34383:Ae,10754:Ae,12288:Ae,12289:Ae,12290:Ae,12291:Ae,12292:Ae,12293:Ae,12294:Ae,12295:Ae,3333:st,3317:st,37440:st,37441:st,37443:st,3330:st,3332:st,3331:st,3314:st,32878:st,3316:st,3315:st,32877:st,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=fd(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=fd(e)&&e.length===3?[...e,...e]:e;let[r,i,s,n,o,a]=e;t.stencilFuncSeparate(1028,r,i,s),t.stencilFuncSeparate(1029,n,o,a)},stencilOp:(t,e)=>{e=fd(e)&&e.length===3?[...e,...e]:e;let[r,i,s,n,o,a]=e;t.stencilOpSeparate(1028,r,i,s),t.stencilOpSeparate(1029,n,o,a)},viewport:(t,e)=>t.viewport(...e)};function ve(t,e,r){return e[t]!==void 0?e[t]:r[t]}var a0={blendEquation:(t,e,r)=>t.blendEquationSeparate(ve(32777,e,r),ve(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(ve(32969,e,r),ve(32968,e,r),ve(32971,e,r),ve(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(ve(32824,e,r),ve(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(ve(32938,e,r),ve(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,ve(2962,e,r),ve(2967,e,r),ve(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,ve(34816,e,r),ve(36003,e,r),ve(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,ve(2964,e,r),ve(2965,e,r),ve(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,ve(34817,e,r),ve(34818,e,r),ve(34819,e,r))},hd={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,r)=>t({36007:r}),bindTransformFeedback:(t,e,r)=>t({36389:r}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({36006:r,36010:r});case 36009:return t({36006:r});case 36008:return t({36010:r});default:return null}},bindBuffer:(t,e,r)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,s)=>t({32773:new Float32Array([e,r,i,s])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,r)=>t({32777:e,34877:r}),blendFunc:(t,e,r)=>t({32969:e,32968:r,32971:e,32970:r}),blendFuncSeparate:(t,e,r,i,s)=>t({32969:e,32968:r,32971:i,32970:s}),clearColor:(t,e,r,i,s)=>t({3106:new Float32Array([e,r,i,s])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,r,i,s)=>t({3107:[e,r,i,s]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,r)=>t({2928:new Float32Array([e,r])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,r)=>t({32824:e,10752:r}),sampleCoverage:(t,e,r)=>t({32938:e,32939:r}),scissor:(t,e,r,i,s)=>t({3088:new Int32Array([e,r,i,s])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({2962:e,2967:r,2963:i,34816:e,36003:r,36004:i}),stencilFuncSeparate:(t,e,r,i,s)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:s}),stencilOp:(t,e,r,i)=>t({2964:e,2965:r,2966:i,34817:e,34818:r,34819:i}),stencilOpSeparate:(t,e,r,i,s)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:s}),viewport:(t,e,r,i,s)=>t({2978:[e,r,i,s]})},rr=(t,e)=>t.isEnabled(e),dd={3042:rr,2884:rr,2929:rr,3024:rr,32823:rr,32926:rr,32928:rr,3089:rr,2960:rr,35977:rr},c0=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 Lt(t,e){if(_w(e))return;let r={};for(let s in e){let n=Number(s),o=o0[s];o&&(typeof o=="string"?r[o]=!0:o(t,e[s],n))}let i=t.state&&t.state.cache;if(i)for(let s in r){let n=a0[s];n(t,e,i)}}function nl(t,e=Co){if(typeof e=="number"){let s=e,n=dd[s];return n?n(t,s):t.getParameter(s)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let s of r){let n=dd[s];i[s]=n?n(t,Number(s)):t.getParameter(Number(s))}return i}function l0(t){Lt(t,Co)}function _w(t){for(let e in t)return!1;return!0}function u0(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),i=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&i&&t.length===e.length){for(let s=0;s{}}={}){this.gl=e,this.cache=r?nl(e):Object.assign({},Co),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){ee(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];Lt(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in e){ee(n!==void 0);let o=e[n],a=this.cache[n];u0(o,a)||(r=!0,i=a,s&&!(n in s)&&(s[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:i}}};function Bi(t){return t.state}function gd(t,e){let{enable:r=!0,copyState:i}=e;if(ee(i!==void 0),!t.state){t.state=new pd(t,{copyState:i}),yw(t);for(let n in hd){let o=hd[n];xw(t,n,o)}f0(t,"getParameter"),f0(t,"isEnabled")}let s=Bi(t);return s.enable=r,t}function Zr(t){let e=Bi(t);e||(gd(t,{copyState:!1}),e=Bi(t)),e.push()}function Er(t){let e=Bi(t);ee(e),e.pop()}function f0(t,e){let r=t[e].bind(t);t[e]=function(s){if(s===void 0||c0.has(s))return r(s);let n=Bi(t);return s in n.cache||(n.cache[s]=r(s)),n.enable?n.cache[s]:r(s)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function xw(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...n){let o=Bi(t),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&i(...n),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function yw(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let s=Bi(t);s.program!==i&&(e(i),s.program=i)}}var bw={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function h0(t,e){e={...bw,...e};let r=null,i=n=>r=n.statusMessage||r;t.addEventListener("webglcontextcreationerror",i,!1);let s=null;if(s||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",i,!1),!s)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:n}=e;t.addEventListener("webglcontextlost",o=>n(o),!1)}if(e.onContextRestored){let{onContextRestored:n}=e;t.addEventListener("webglcontextrestored",o=>n(o),!1)}return s}function Et(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function d0(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);Et(t,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,n=t.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=t.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||i,l=t.getParameter(7938),u=p0(a,c),f=vw(a,c),h=Tw(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function p0(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function vw(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function Tw(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(p0(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ol(t){switch(t){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(t))}var ze="texture-compression-bc",ce="texture-compression-astc",ir="texture-compression-etc2",Ew="texture-compression-etc1-webgl",al="texture-compression-pvrtc-webgl",md="texture-compression-atc-webgl",Ro="float32-renderable-webgl",_d="float16-renderable-webgl",Sw="rgb9e5ufloat_renderable-webgl",xd="snorm8-renderable-webgl",Mo="norm16-renderable-webgl",yd="snorm16-renderable-webgl",cl="float32-filterable",g0="float16-filterable-webgl",Io="WEBGL_compressed_texture_s3tc",Oo="WEBGL_compressed_texture_s3tc_srgb",Cs="EXT_texture_compression_rgtc",Rs="EXT_texture_compression_bptc",Aw="WEBGL_compressed_texture_etc",ww="WEBGL_compressed_texture_astc",Pw="WEBGL_compressed_texture_etc1",Cw="WEBGL_compressed_texture_pvrtc",Rw="WEBGL_compressed_texture_atc",m0="EXT_texture_norm16",_0="EXT_render_snorm",Mw="EXT_color_buffer_float",ll={"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":[_0],"norm16-renderable-webgl":[m0],"snorm16-renderable-webgl":[m0,_0],"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":[Io,Oo,Cs,Rs],"texture-compression-bc5-webgl":[Cs],"texture-compression-bc7-webgl":[Rs],"texture-compression-etc2":[Aw],"texture-compression-astc":[ww],"texture-compression-etc1-webgl":[Pw],"texture-compression-pvrtc-webgl":[Cw],"texture-compression-atc-webgl":[Rw]};function x0(t){return t in ll}function y0(t,e,r){return(ll[e]||[]).every(s=>Et(t,s,r))}var ul={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:xd},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:xd},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:_d,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Mo,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:yd},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:xd},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:_d,filter:g0,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Mo},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:yd},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Ro,filter:cl},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:Sw},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Ro,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Mo},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Mo},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Ro,filter:cl,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:_d,filter:g0},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Mo,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:yd},"rgb32float-webgl":{gl:34837,render:Ro,filter:cl,gl2ext:Mw,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Ro,filter:cl,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Io,f:ze},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Oo,f:ze},"bc1-rgba-unorm":{gl:33777,x:Io,f:ze},"bc1-rgba-unorm-srgb":{gl:35916,x:Oo,f:ze},"bc2-rgba-unorm":{gl:33778,x:Io,f:ze},"bc2-rgba-unorm-srgb":{gl:35918,x:Oo,f:ze},"bc3-rgba-unorm":{gl:33779,x:Io,f:ze},"bc3-rgba-unorm-srgb":{gl:35919,x:Oo,f:ze},"bc4-r-unorm":{gl:36283,x:Cs,f:ze},"bc4-r-snorm":{gl:36284,x:Cs,f:ze},"bc5-rg-unorm":{gl:36285,x:Cs,f:ze},"bc5-rg-snorm":{gl:36286,x:Cs,f:ze},"bc6h-rgb-ufloat":{gl:36495,x:Rs,f:ze},"bc6h-rgb-float":{gl:36494,x:Rs,f:ze},"bc7-rgba-unorm":{gl:36492,x:Rs,f:ze},"bc7-rgba-unorm-srgb":{gl:36493,x:Rs,f:ze},"etc2-rgb8unorm":{gl:37492,f:ir},"etc2-rgb8unorm-srgb":{gl:37494,f:ir},"etc2-rgb8a1unorm":{gl:37496,f:ir},"etc2-rgb8a1unorm-srgb":{gl:37497,f:ir},"etc2-rgba8unorm":{gl:37493,f:ir},"etc2-rgba8unorm-srgb":{gl:37495,f:ir},"eac-r11unorm":{gl:37488,f:ir},"eac-r11snorm":{gl:37489,f:ir},"eac-rg11unorm":{gl:37490,f:ir},"eac-rg11snorm":{gl:37491,f:ir},"astc-4x4-unorm":{gl:37808,f:ce},"astc-4x4-unorm-srgb":{gl:37840,f:ce},"astc-5x4-unorm":{gl:37809,f:ce},"astc-5x4-unorm-srgb":{gl:37841,f:ce},"astc-5x5-unorm":{gl:37810,f:ce},"astc-5x5-unorm-srgb":{gl:37842,f:ce},"astc-6x5-unorm":{gl:37811,f:ce},"astc-6x5-unorm-srgb":{gl:37843,f:ce},"astc-6x6-unorm":{gl:37812,f:ce},"astc-6x6-unorm-srgb":{gl:37844,f:ce},"astc-8x5-unorm":{gl:37813,f:ce},"astc-8x5-unorm-srgb":{gl:37845,f:ce},"astc-8x6-unorm":{gl:37814,f:ce},"astc-8x6-unorm-srgb":{gl:37846,f:ce},"astc-8x8-unorm":{gl:37815,f:ce},"astc-8x8-unorm-srgb":{gl:37847,f:ce},"astc-10x5-unorm":{gl:37819,f:ce},"astc-10x5-unorm-srgb":{gl:37851,f:ce},"astc-10x6-unorm":{gl:37817,f:ce},"astc-10x6-unorm-srgb":{gl:37849,f:ce},"astc-10x8-unorm":{gl:37818,f:ce},"astc-10x8-unorm-srgb":{gl:37850,f:ce},"astc-10x10-unorm":{gl:37819,f:ce},"astc-10x10-unorm-srgb":{gl:37851,f:ce},"astc-12x10-unorm":{gl:37820,f:ce},"astc-12x10-unorm-srgb":{gl:37852,f:ce},"astc-12x12-unorm":{gl:37821,f:ce},"astc-12x12-unorm-srgb":{gl:37853,f:ce},"pvrtc-rgb4unorm-webgl":{gl:35840,f:al},"pvrtc-rgba4unorm-webgl":{gl:35842,f:al},"pvrtc-rbg2unorm-webgl":{gl:35841,f:al},"pvrtc-rgba2unorm-webgl":{gl:35843,f:al},"etc1-rbg-unorm-webgl":{gl:36196,f:Ew},"atc-rgb-unorm-webgl":{gl:35986,f:md},"atc-rgba-unorm-webgl":{gl:35986,f:md},"atc-rgbai-unorm-webgl":{gl:34798,f:md}},Iw={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},Ow={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function fl(t,e,r){let i=ul[e];if(!i||i.gl===void 0)return!1;let s=i.x||i.gl2ext;return s?!!Et(t,s,r):!0}function bd(t){let r=ul[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function b0(t,e,r){if(!fl(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(uc(e).signed)return!1}catch{return!1}return e.endsWith("32float")?!!Et(t,"OES_texture_float_linear, extensions",r):e.endsWith("16float")?!!Et(t,"OES_texture_half_float_linear, extensions",r):!0}function v0(t,e,r){return!(!fl(t,e,r)||typeof e=="number")}function Ms(t){let e=ul[t],r=bd(t),i=uc(t);return{format:r,dataFormat:e?.dataFormat||Nw(i.format,i.integer,i.normalized,r),type:i.dataType?ol(i.dataType):e?.types?.[0]||5121,compressed:i.compressed}}function T0(t){let e=ul[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function vd(t){let e=Ms(t),r=Iw[e.dataFormat]||4,i=Ow[e.type]||1;return r*i}function Nw(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;default:return 6408}}var E0={"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"},hl=class extends kn{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,Et(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),x0(e)&&y0(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(E0),...Object.keys(ll)]}getWebGLFeature(e){let r=E0[e];return typeof r=="string"?!!Et(this.gl,r,this.extensions):!!r}};var dl=class extends Ln{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 maxInterStageShaderComponents(){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}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};function St(t,e,r){if(Fw(e))return r(t);let{nocatch:i=!0}=e;Zr(t),Lt(t,e);let s;if(i)s=r(t),Er(t);else try{s=r(t)}finally{Er(t)}return s}function Fw(t){for(let e in t)return!1;return!0}function A0(t,e,r,i){if(Br(e))return i(t);let s=t;Zr(s.gl);try{return Dw(t,e),Lt(s.gl,r),i(t)}finally{Er(s.gl)}}function Dw(t,e){let r=t,{gl:i}=r;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(Ui("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Ui("provokingVertex",e.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Ui("polygonMode",e.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,o),n?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(t.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(kw("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(gl("depthCompare",e.depthCompare))),e.stencilWriteMask){let s=e.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&O.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,n=gl("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,s),i.stencilFuncSeparate(1029,n,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=Td("stencilPassOperation",e.stencilPassOperation),n=Td("stencilFailOperation",e.stencilFailOperation),o=Td("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,o,s),i.stencilOpSeparate(1029,n,o,s)}if(e.blendColorOperation||e.blendAlphaOperation){i.enable(3042);let s=S0("blendColorOperation",e.blendColorOperation||"add"),n=S0("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(s,n);let o=pl("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=pl("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=pl("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=pl("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function gl(t,e){return Ui(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Td(t,e){return Ui(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function S0(t,e){return Ui(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function pl(t,e){return Ui(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function Lw(t,e){return`Illegal parameter ${e} for ${t}`}function Ui(t,e,r){if(!(e in r))throw new Error(Lw(t,e));return r[e]}function kw(t,e){return e}function ml(t){let e={};return t.addressModeU&&(e[10242]=Ed(t.addressModeU)),t.addressModeV&&(e[10243]=Ed(t.addressModeV)),t.addressModeW&&(e[32882]=Ed(t.addressModeW)),t.magFilter&&(e[10240]=w0(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=Bw(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=gl("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Ed(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function w0(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function Bw(t,e){if(!e)return w0(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}var Xe=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Uw(this.props.usage),this.glUsage=zw(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,i=e.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){ee(e>=0);let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,e),this.gl.bindBuffer(36663,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}};function Uw(t){return t&ie.INDEX?34963:t&ie.VERTEX?34962:t&ie.UNIFORM?35345:34962}function zw(t){return t&ie.INDEX||t&ie.VERTEX?35044:t&ie.UNIFORM?35048:35044}var zi=class extends Ei{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=ml(r),this.handle=this.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(e){for(let[r,i]of Object.entries(e)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}};var kt=class extends vi{device;gl;handle;texture;constructor(e,r){super(e,{...Se.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var Vw={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Je=class t extends Se{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...Vw,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=Ww(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Cf(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new kt(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(_=>this.initialize(Object.assign({},e,{pixels:_,data:_}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyStatethis.initialize(e)),this;let{parameters:s={}}=e,{pixels:n=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:c=!0}=e;r||(r=n);let{width:l,height:u,dataFormat:f,type:h,compressed:d=!1}=e,{depth:p=0}=e,g=bd(e.format);return{width:l,height:u,compressed:d,dataFormat:f,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:f,compressed:d,data:r,width:l,height:u}),this.width=l,this.height=u,this.glFormat=g,this.type=h,this.dataFormat=f,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=c,this.setImageData({data:r,width:l,height:u,depth:p,format:g,type:h,dataFormat:f,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(s),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),c&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:r,parameters:s,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let r;e instanceof zi?(this.sampler=e,r=e.props):(this.sampler=new zi(this.device,e),r=e);let i=ml(r);return this._setSamplerParameters(i),this}resize(e){let{height:r,width:i,mipmaps:s=!1}=e;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:s}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:s=0,glFormat:n=this.glFormat,offset:o=0,parameters:a={}}=e,{data:c=null,type:l=this.type,width:u=this.width,height:f=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;c||(c=i),{type:l,dataFormat:h,compressed:d,width:u,height:f}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:c,width:u,height:f});let{gl:p}=this;p.bindTexture(this.target,this.handle);let g=null;if({data:c,dataType:g}=this._getDataType({data:c,compressed:d}),St(this.gl,a,()=>{switch(g){case"null":p.texImage2D(r,s,n,u,f,0,h,l,c);break;case"typed-array":p.texImage2D(r,s,n,u,f,0,h,l,c,o);break;case"buffer":this.device.gl.bindBuffer(35052,c.handle||c),this.device.gl.texImage2D(r,s,n,u,f,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":p.texImage2D(r,s,n,u,f,0,h,l,c);break;case"compressed":for(let[_,y]of c.entries())p.compressedTexImage2D(r,_,y.format,y.width,y.height,0,y.data);break;default:ee(!1,"Unknown image data type")}}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let _=vd(this.props.format);this.trackAllocatedMemory(this.width*this.height*_,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:i=null,x:s=0,y:n=0,width:o=this.width,height:a=this.height,level:c=0,glFormat:l=this.glFormat,type:u=this.type,dataFormat:f=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if({type:u,dataFormat:f,compressed:h,width:o,height:a}=this._deduceParameters({format:this.props.format,type:u,dataFormat:f,compressed:h,data:i,width:o,height:a}),ee(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=r),i&&i.data){let g=i;i=g.data,o=g.shape[0],a=g.shape[1]}i instanceof Xe&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),St(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,c,s,n,o,a,l,i):i===null?this.gl.texSubImage2D(e,c,s,n,o,a,f,u,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,c,s,n,o,a,f,u,i,d):typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,c,s,n,o,a,f,u,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,c,s,n,o,a,f,u,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return O.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Xe?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:i}=e,{width:s,height:n,dataFormat:o,type:a,compressed:c}=e,l=Ms(r);return o=o||l.dataFormat,a=a||l.type,c=c||l.compressed,{width:s,height:n}=this._deduceImageSize(i,s,n),{dataFormat:o,type:a,compressed:c,width:s,height:n,format:r,data:i}}_deduceImageSize(e,r,i){let s;return typeof ImageData<"u"&&e instanceof ImageData?s={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?s={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?s={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?s={width:e.videoWidth,height:e.videoHeight}:e?s={width:r,height:i}:s={width:r>=0?r:1,height:i>=0?i:1},ee(s,"Could not deduced texture size"),ee(r===void 0||s.width===r,"Deduced texture width does not match supplied width"),ee(i===void 0||s.height===i,"Deduced texture height does not match supplied height"),s}async setCubeMapImageData(e){let{gl:r}=this,{width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=e,l=n||o,u=await Promise.all(t.FACES.map(f=>{let h=l[f];return Promise.all(Array.isArray(h)?h:[h])}));this.bind(),t.FACES.forEach((f,h)=>{u[h].length>1&&this.props.mipmaps!==!1&&O.warn(`${this.id} has mipmap and multiple LODs.`)(),u[h].forEach((d,p)=>{i&&s?r.texImage2D(f,p,a,i,s,0,a,c,d):r.texImage2D(f,p,a,a,c,d)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=e,{gl:l}=this,u=n||o;return this.bind(),u instanceof Promise?u.then(f=>this.setImageDataForFace(Object.assign({},e,{face:r,data:f,pixels:f}))):this.width||this.height?l.texImage2D(r,0,a,i,s,0,a,c,u):l.texImage2D(r,0,a,a,c,u),this}setImageData3D(e){let{level:r=0,dataFormat:i,format:s,type:n,width:o,height:a,depth:c=1,offset:l=0,data:u,parameters:f={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let h=Ms(s);if(St(this.gl,f,()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,r,h.format,o,a,c,0,h.dataFormat,h.type,u),u instanceof Xe&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,r,i,o,a,c,0,s,n,l))}),u&&u.byteLength)this.trackAllocatedMemory(u.byteLength,"Texture");else{let d=vd(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Br(e)){Hw(e),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(e)){let s=Number(r),n=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.target,s,n);break;default:this.gl.texParameteri(this.target,s,n);break}}this.gl.bindTexture(this.target,null)}}};function Ww(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function Hw(t){O.log(1,"texture sampler parameters",t)()}var sr=class extends Si{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let i=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let s=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;nO.info("Spector capture started:",e)()),Qe?.onCapture.add(e=>{O.info("Spector capture complete:",e)(),Qe?.getResultUI(),Qe?.resultView.display(),Qe?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return Qe;Qe?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{O.info("Spector capture stopped after 2 seconds")(),Qe?.stopCapture()})}return Qe}var qw="https://unpkg.com/webgl-debug@2.0.1/index.js";function M0(t){return t.luma=t.luma||{},t.luma}async function I0(){ke()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Kn(qw))}function O0(t,e={}){return t?e.debug?Zw(t,e):Gw(t):null}function Gw(t){let e=M0(t);return e.realContext?e.realContext:t}function Zw(t,e){if(!globalThis.WebGLDebugUtils)return O.warn("webgl-debug not loaded")(),t;let r=M0(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Gr,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,Jw.bind(null,e),Qw.bind(null,e));for(let o in Gr)!(o in i)&&typeof Gr[o]=="number"&&(i[o]=Gr[o]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,i);let n=Object.create(s);return r.realContext=t,r.debugContext=n,n.debug=!0,n}function Sd(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Jw(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),o=`${s} in gl.${r}(${n})`;O.error(o)();debugger;if(t.throwOnError)throw new Error(o)}function Qw(t,e,r){let i="";if(O.level>=1&&(i=Sd(e,r),O.log(1,i)()),t.break&&t.break.length>0&&(i=i||Sd(e,r),t.break.every(n=>i.indexOf(n)!==-1)))debugger;for(let s of r)if(s===void 0){if(i=i||Sd(e,r),t.throwOnError)throw new Error(`Undefined argument: ${i}`);O.error(`Undefined argument: ${i}`)();debugger}}function F0(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let s=i.split(":");if(s.length===2){let[f,h]=s;r.push({message:h.trim(),type:N0(f),lineNum:0,linePos:0});continue}let[n,o,a,...c]=s,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),r.push({message:c.join(":").trim(),type:N0(n),lineNum:l,linePos:u})}return r}function N0(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var xl=class extends Ti{device;handle;constructor(e,r){switch(super(e,r),this.device=e,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)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return F0(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(s=>s.startsWith("#version ")?s:`#version 100 -${s}`)(e);let{gl:i}=this.device;if(i.shaderSource(this.handle,e),i.compileShader(this.handle),O.level===0){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}O.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),O.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var e5=256,t5=1024,r5=16384,Ad=6144,i5=[1,2,4,8],yl=class extends Un{device;glParameters;constructor(e,r){super(e,r),this.device=e,Zr(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Er(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=i5.map(i=>!!(i&e.colorMask))),this.glParameters=r,Lt(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=r5,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=e5,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=t5,e.clearStencil=this.props.clearStencil),r!==0&&St(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){St(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(Ad,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(Ad,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(Ad,e,r);break}})}};var s5="Failed to deduce GL constant from typed array";function D0(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(s5)}}function No(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var n5={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},o5={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},bl=class t{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return No(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return ee(e.size),No(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new t(n5,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return t.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return t.getBytesPerVertex(this)}_assign(e={}){return e=Pf("Accessor",e,o5),e.type!==void 0&&(this.type=e.type,(e.type===5124||e.type===5125)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function L0(t){return a5.includes(t)}var a5=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],k0={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function wd(t){let e=k0[t];if(!e)throw new Error("uniform");let[r,i,,s]=e;return{format:s,components:i,glType:r}}function B0(t){let e=k0[t];if(!e)throw new Error("attribute");let[,r,,i,s]=e;return{attributeType:i,vertexFormat:s,components:r}}function U0(t,e){let r={attributes:[],bindings:[]};r.attributes=c5(t,e);let i=f5(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=u5(t,e),n=0;for(let a of s)if(L0(a.type)){let{viewDimension:c,sampleType:l}=d5(a.type);r.bindings.push({type:"texture",name:a.name,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}s.length&&(r.uniforms=s);let o=l5(t,e);return o?.length&&(r.varyings=o),r}function c5(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let s=0;s=0){let{attributeType:l}=B0(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:u,type:l})}}return r.sort((s,n)=>s.location-n.location),r}function l5(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let s=0;ss.location-n.location),r}function u5(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let s=0;s1)for(let d=0;dt.getActiveUniformBlockParameter(e,n,o),i=[],s=t.getProgramParameter(e,35382);for(let n=0;nn.location-o.location),i}var h5={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function d5(t){let e=h5[t];if(!e)throw new Error("sampler");let[r,i]=e;return{viewDimension:r,sampleType:i}}function p5(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:!!r[2]}}function z0(t,e,r,i){let s=t,n=i;n===!0&&(n=1),n===!1&&(n=0);let o=typeof n=="number"?[n]:n;switch(r){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 t.uniform1i(e,i);case 5126:return t.uniform1fv(e,o);case 35664:return t.uniform2fv(e,o);case 35665:return t.uniform3fv(e,o);case 35666:return t.uniform4fv(e,o);case 5124:return t.uniform1iv(e,o);case 35667:return t.uniform2iv(e,o);case 35668:return t.uniform3iv(e,o);case 35669:return t.uniform4iv(e,o);case 35670:return t.uniform1iv(e,o);case 35671:return t.uniform2iv(e,o);case 35672:return t.uniform3iv(e,o);case 35673:return t.uniform4iv(e,o);case 5125:return s.uniform1uiv(e,o,1);case 36294:return s.uniform2uiv(e,o,2);case 36295:return s.uniform3uiv(e,o,3);case 36296:return s.uniform4uiv(e,o,4);case 35674:return t.uniformMatrix2fv(e,!1,o);case 35675:return t.uniformMatrix3fv(e,!1,o);case 35676:return t.uniformMatrix4fv(e,!1,o);case 35685:return s.uniformMatrix2x3fv(e,!1,o);case 35686:return s.uniformMatrix2x4fv(e,!1,o);case 35687:return s.uniformMatrix3x2fv(e,!1,o);case 35688:return s.uniformMatrix3x4fv(e,!1,o);case 35689:return s.uniformMatrix4x2fv(e,!1,o);case 35690:return s.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function V0(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(t)}}function W0(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(t)}}var H0=4,vl=class extends qt{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:i,bufferMode:s=35981}=r;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,s)),this._linkShaders(),O.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=U0(this.device.gl,this.handle),O.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=Ef(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":O.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[i,s]of Object.entries(e)){let n=this.shaderLayout.bindings.find(o=>o.name===i)||this.shaderLayout.bindings.find(o=>o.name===`${i}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||O.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(s||O.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(s instanceof Xe)&&!(s.buffer instanceof Xe))throw new Error("buffer value");break;case"texture":if(!(s instanceof kt||s instanceof Je||s instanceof sr))throw new Error("texture value");break;case"sampler":O.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(n.type)}this.bindings[i]=s}}draw(e){let{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=e,f=V0(s),h=!!n.indexBuffer,d=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return O.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return O.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return O.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let p=r;return A0(this.device,i,p.glParameters,()=>{h&&c?this.device.gl.drawElementsInstanced(f,o||0,d,l,a||0):h?this.device.gl.drawElements(f,o||0,d,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=Yn(e);Object.keys(r).forEach(i=>{O.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),O.time(H0,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),O.timeEnd(H0,`linkProgram for ${this.id}`)(),O.level,!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}O.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),O.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof Je&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=0;for(let s of this.shaderLayout.bindings){let n=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:o}=s,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,a),n instanceof Xe?e.bindBufferBase(35345,i,n.handle):e.bindBufferRange(35345,i,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),i+=1;break;case"texture":if(!(n instanceof kt||n instanceof Je||n instanceof sr))throw new Error("texture");let c;if(n instanceof kt)c=n.texture;else if(n instanceof Je)c=n;else if(n instanceof sr&&n.colorAttachments[0]instanceof kt)O.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=n.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(c.target,c.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:s,textureUnit:n}=e,o=this.uniforms[r]??n;o!==void 0&&z0(this.device.gl,i,s,o)}}};var Tl=class extends Vn{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":g5(this.device,r.options);break;case"copy-buffer-to-texture":m5(this.device,r.options);break;case"copy-texture-to-buffer":_5(this.device,r.options);break;case"copy-texture-to-texture":x5(this.device,r.options);break}}};function g5(t,e){let r=e.source,i=e.destination;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function m5(t,e){throw new Error("Not implemented")}function _5(t,e){let{source:r,mipLevel:i=0,aspect:s="all",width:n=e.source.width,height:o=e.source.height,depthOrArrayLayers:a=0,origin:c=[0,0],destination:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(s!=="all")throw new Error("not supported");if(i!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=j0(r),g;try{let _=l,y=n||d.width,v=o||d.height,T=Ms(d.texture.props.format),S=T.dataFormat,R=T.type;t.gl.bindBuffer(35051,_.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],y,v,S,R,u)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function x5(t,e){let{source:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:n=[0,0],destination:o}=e,{width:a=e.destination.width,height:c=e.destination.height}=e,{framebuffer:l,destroyFramebuffer:u}=j0(r),[f,h]=s,[d,p,g]=n,_=t.gl.bindFramebuffer(36160,l.handle),y=null,v;if(o instanceof Je)y=o,a=Number.isFinite(a)?a:y.width,c=Number.isFinite(c)?c:y.height,y.bind(0),v=y.target;else throw new Error("invalid destination");switch(v){case 3553:case 34067:t.gl.copyTexSubImage2D(v,i,d,p,f,h,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(v,i,d,p,g,f,h,a,c);break;default:}y&&y.unbind(),t.gl.bindFramebuffer(36160,_),u&&l.destroy()}function j0(t){if(t instanceof Se){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var El=class extends zn{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new Tl(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,i){}};var Sl=class t extends Wn{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Mu()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:n,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,s,n,o,a):this.device.gl.vertexAttribPointer(e,s,n,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:s,byteLength:n,byteOffset:o}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=s,O.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:s,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(i,s,o,n)}getBuffer(e){if(X0(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Xe)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(e){if(X0(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,s,i)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,s){let n=r&&r.handle;!n||s===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,i,s)}};function X0(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var wl=class extends jn{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,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;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((i,s)=>{let n=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):r++>e?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}};function Pd(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return ee(!1),0}}function $0(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ee(!1),0}}function Y0(t,e){let{sourceX:r=0,sourceY:i=0,sourceFormat:s=6408,sourceAttachment:n=36064}=e||{},{target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=q0(t);ee(u);let{gl:h,handle:d}=u;a=a||u.width,c=c||u.height;let p=n-36064;l=l||u.colorAttachments[p]?.texture?.type||5121,o=T5(o,l,s,a,c),l=l||D0(o);let g=h.bindFramebuffer(36160,d);return h.readPixels(r,i,a,c,s,l,o),h.bindFramebuffer(36160,g||null),f&&u.destroy(),o}function K0(t,e){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:n=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=q0(t);ee(u),a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=r;if(!d){let g=Pd(n),_=$0(l),y=o+a*c*g*_;d=h.device.createBuffer({byteLength:y})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({source:t,width:a,height:c,origin:[i,s],destination:d,byteOffset:o}),p.destroy(),f&&u.destroy(),d}function q0(t){return t instanceof Si?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:v5(t),deleteFramebuffer:!0}}function v5(t,e){let{device:r,width:i,height:s,id:n}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:i,height:s,colorAttachments:[t]})}function T5(t,e,r,i,s){if(t)return t;e=e||5121;let n=No(e,{clamped:!1}),o=Pd(r);return new n(i*s*o)}var E5=256,S5=1024,A5=16384;var w5="clear: bad arguments";function G0(t,e){let{framebuffer:r=null,color:i=null,depth:s=null,stencil:n=null}=e||{},o={};r&&(o.framebuffer=r);let a=0;i&&(a|=A5,i!==!0&&(o.clearColor=i)),s&&(a|=E5,s!==!0&&(o.clearDepth=s)),n&&(a|=S5,s!==!0&&(o.clearStencil=s)),ee(a!==0,w5);let c=t.gl;St(c,o,()=>{c.clear(a)})}var Fo=1,Vi=class t extends hr{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof t)return e;if(e?.device instanceof hr)return e.device;if(!P5(e))throw new Error("Invalid WebGL2RenderingContext");return new t({gl:e})}static async create(e={}){O.groupCollapsed(Fo,"WebGLDevice created")();let r=[];e.debug&&r.push(I0()),e.spector&&r.push(C0()),typeof e.canvas=="string"&&r.push(bi.pageLoaded);let i=await Promise.allSettled(r);for(let o of i)o.status==="rejected"&&O.error(`Failed to initialize debug libraries ${o.reason}`)();if(O.probe(Fo+1,"DOM is loaded")(),e.gl?.device)return O.warn("reattaching existing device")(),t.attach(e.gl);let s=new t(e),n=`Created ${s.type}${s.debug?" debug":""} context: ${s.info.vendor}, ${s.info.renderer} for canvas: ${s.canvasContext.id}`;return O.probe(Fo,n)(),O.table(Fo,s.info)(),O.groupEnd(Fo)(),s}constructor(e){super({...e,id:e.id||Fe("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let i=e.gl?.canvas||e.canvas;this.canvasContext=new _l(this,{...e,canvas:i}),this.lost=new Promise(a=>{this._resolveContextLost=a});let s=e.gl||null;if(s||=h0(this.canvasContext.canvas,{...e,onContextLost:a=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!s)throw new Error("WebGL context creation failed");this.handle=s,this.gl=s,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=R0({...this.props,canvas:this.handle.canvas})),this.info=d0(this.gl,this._extensions),this.limits=new dl(this.gl),this.features=new hl(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:n=!0,copyState:o=!1}=e;gd(this.gl,{enable:n,copyState:o,log:(...a)=>O.log(1,...a)()}),e.debug&&(this.gl=O0(this.gl,{...e,throwOnError:!0}),this.debug=!0,O.level=Math.max(O.level,1),O.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return fl(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return b0(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return v0(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new Xe(this,r)}_createTexture(e){return new Je(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new zi(this,e)}createShader(e){return new xl(this,e)}createFramebuffer(e){return new sr(this,e)}createVertexArray(e){return new Sl(this,e)}createTransformFeedback(e){return new Al(this,e)}createQuerySet(e){return new wl(this,e)}createRenderPipeline(e){return new vl(this,e)}beginRenderPass(e){return new yl(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new El(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return Y0(e,r)}readPixelsToBufferWebGL(e,r){return K0(e,r)}setParametersWebGL(e){Lt(this.gl,e)}getParametersWebGL(e){return nl(this.gl,e)}withParametersWebGL(e,r){return St(this.gl,e,r)}clearWebGL(e){G0(this,e)}resetWebGL(){O.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),l0(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Zr(this.gl)}popState(){Er(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let i=Number(e);for(let s in r)if(r[s]===i)return`GL.${s}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[e];switch(s&&I5(s,r)&&O.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:C5(this,e,r);break;case Int32Array:R5(this,e,r);break;case Uint32Array:M5(this,e,r);break;default:ee(!1)}}getExtension(e){return Et(this.gl,e,this._extensions),this._extensions}};function P5(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&Number.isFinite(t._version))}function C5(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:ee(!1)}}function R5(t,e,r){t.gl.vertexAttribI4iv(e,r)}function M5(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function I5(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r0&&i.type==="pointerdown"&&(N5(s,n=>n.pointerId===i.pointerId)||s.push(i)),e.call(this,i)}}function Q0(t){t.prototype.handler=function(r){let i=O5[r.type];i&1&&r.button>=0&&(this.pressed=!0),i&2&&r.buttons===0&&(i=4),this.pressed&&(i&4&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}J0(Wi.PointerEventInput);Q0(Wi.MouseInput);var e_=Wi.Manager,Bt=Wi;var Ut=class{constructor(e,r,i){this.element=e,this.callback=r,this.options={enable:!0,...i}}};var t_=Bt?[[Bt.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Bt.Rotate,{enable:!1}],[Bt.Pinch,{enable:!1}],[Bt.Swipe,{enable:!1}],[Bt.Pan,{threshold:0,enable:!1}],[Bt.Press,{enable:!1}],[Bt.Tap,{event:"doubletap",taps:2,enable:!1}],[Bt.Tap,{event:"anytap",enable:!1}],[Bt.Tap,{enable:!1}]]:null,Cd={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},r_={doubletap:["tap"]},i_={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Is={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},s_={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},Rd={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var n_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Hi=typeof window<"u"?window:global;var Cl=!1;try{let t={get passive(){return Cl=!0,!0}};Hi.addEventListener("test",null,t),Hi.removeEventListener("test",null)}catch{Cl=!1}var F5=n_.indexOf("firefox")!==-1,{WHEEL_EVENTS:D5}=Is,o_="wheel",a_=4.000244140625,L5=40,k5=.25,Do=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{if(!this.options.enable)return;let n=s.deltaY;Hi.WheelEvent&&(F5&&s.deltaMode===Hi.WheelEvent.DOM_DELTA_PIXEL&&(n/=Hi.devicePixelRatio),s.deltaMode===Hi.WheelEvent.DOM_DELTA_LINE&&(n*=L5)),n!==0&&n%a_===0&&(n=Math.floor(n/a_)),s.shiftKey&&n&&(n=n*k5),this.callback({type:o_,center:{x:s.clientX,y:s.clientY},delta:-n,srcEvent:s,pointerType:"mouse",target:s.target})},this.events=(this.options.events||[]).concat(D5),this.events.forEach(s=>e.addEventListener(s,this.handleEvent,Cl?{passive:!1}:!1))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===o_&&(this.options.enable=r)}};var{MOUSE_EVENTS:B5}=Is,c_="pointermove",l_="pointerover",u_="pointerout",f_="pointerenter",h_="pointerleave",Lo=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,this.events=(this.options.events||[]).concat(B5),this.events.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===c_&&(this.enableMoveEvent=r),e===l_&&(this.enableOverEvent=r),e===u_&&(this.enableOutEvent=r),e===f_&&(this.enableEnterEvent=r),e===h_&&(this.enableLeaveEvent=r)}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit(l_,e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit(u_,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit(f_,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit(h_,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(c_,e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var{KEY_EVENTS:U5}=Is,d_="keydown",p_="keyup",ko=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{let n=s.target||s.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:d_,srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:p_,srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(U5),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===d_&&(this.enableDownEvent=r),e===p_&&(this.enableUpEvent=r)}};var g_="contextmenu",Bo=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{this.options.enable&&this.callback({type:g_,center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e===g_&&(this.options.enable=r)}};var z5={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},V5=0,W5=1,H5=2,j5=1,X5=2,$5=4;function m_(t){let e=z5[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,s=!1,n=!1,o=!1;return e===2?(s=!!(r&j5),n=!!(r&$5),o=!!(r&X5)):(s=i===V5,n=i===W5,o=i===H5),{leftButton:s,middleButton:n,rightButton:o}}function __(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),s=i.width/e.offsetWidth||1,n=i.height/e.offsetHeight||1,o={x:(r.x-i.left-e.clientLeft)/s,y:(r.y-i.top-e.clientTop)/n};return{center:r,offsetCenter:o}}var Md={srcElement:"root",priority:0},Uo=class{constructor(e){this.handleEvent=r=>{if(this.isEmpty())return;let i=this._normalizeEvent(r),s=r.srcEvent.target;for(;s&&s!==i.rootElement;){if(this._emit(i,s),i.handled)return;s=s.parentNode}this._emit(i,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,s=!1,n=!1){let{handlers:o,handlersByElement:a}=this,c=Md;typeof i=="string"||i&&i.addEventListener?c={...Md,srcElement:i}:i&&(c={...Md,...i});let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};s&&(u.once=!0),n&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,r){let{handlers:i,handlersByElement:s}=this;for(let n=i.length-1;n>=0;n--){let o=i[n];if(o.type===e&&o.handler===r){i.splice(n,1);let a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=i.some(n=>!n.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let s=!1,n=()=>{e.handled=!0},o=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var Y5={events:null,recognizers:null,recognizerOptions:{},Manager:e_,touchAction:"none",tabIndex:0},Os=class{constructor(e=null,r){this._onBasicInput=s=>{let{srcEvent:n}=s,o=i_[n.type];o&&this.manager.emit(o,s)},this._onOtherEvent=s=>{this.manager.emit(s.type,s)},this.options={...Y5,...r},this.events=new Map,this.setElement(e);let{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;let{options:r}=this,i=r.Manager;this.manager=new i(e,{touchAction:r.touchAction,recognizers:r.recognizers||t_}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys(Cd).forEach(s=>{let n=this.manager.get(s);n&&Cd[s].forEach(o=>{n.recognizeWith(o)})});for(let s in r.recognizerOptions){let n=this.manager.get(s);if(n){let o=r.recognizerOptions[s];delete o.enable,n.set(o)}}this.wheelInput=new Do(e,this._onOtherEvent,{enable:!1}),this.moveInput=new Lo(e,this._onOtherEvent,{enable:!1}),this.keyInput=new ko(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new Bo(e,this._onOtherEvent,{enable:!1});for(let[s,n]of this.events)n.isEmpty()||(this._toggleRecognizer(n.recognizerName,!0),this.manager.on(s,n.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let s=i.get(e);if(s&&s.options.enable!==r){s.set({enable:r});let n=r_[e];n&&!this.options.recognizers&&n.forEach(o=>{let a=i.get(o);r?(a.requireFailure(e),s.dropRequireFailure(o)):a.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,r),this.moveInput.enableEventType(e,r),this.keyInput.enableEventType(e,r),this.contextmenuInput.enableEventType(e,r)}_addEventHandler(e,r,i,s,n){if(typeof e!="string"){i=r;for(let u in e)this._addEventHandler(u,e[u],i,s,n);return}let{manager:o,events:a}=this,c=Rd[e]||e,l=a.get(c);l||(l=new Uo(this),a.set(c,l),l.recognizerName=s_[c]||c,o&&o.on(c,l.handleEvent)),l.add(e,r,i,s,n),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let o in e)this._removeEventHandler(o,e[o]);return}let{events:i}=this,s=Rd[e]||e,n=i.get(s);if(n&&(n.remove(e,r),n.isEmpty())){let{recognizerName:o}=n,a=!1;for(let c of i.values())if(c.recognizerName===o&&!c.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function Jr(){}var K5=({isDragging:t})=>t?"grabbing":"grab",x_={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Jr,onWebGLInitialized:Jr,onResize:Jr,onViewStateChange:Jr,onInteractionStateChange:Jr,onBeforeRender:Jr,onAfterRender:Jr,onLoad:Jr,onError:t=>U.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:K5,getTooltip:null,debug:!1,drawPickingColors:!1},Sr=class{static{this.defaultProps=x_}static{this.VERSION=em}constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new dt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=i=>{let{_pickRequest:s}=this;if(i.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(i.leftButton||i.rightButton)return;{let n=i.offsetCenter;if(!n)return;s.x=n.x,s.y=n.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=i},this._onEvent=i=>{let s=to[i.type],n=i.offsetCenter;if(!s||!n||!this.layerManager)return;let o=this.layerManager.getLayers(),a=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:o,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:c}=a,l=c&&(c[s.handler]||c.props[s.handler]),u=this.props[s.handler],f=!1;l&&(f=l.call(c,a,i)),f||(u?.(a,i),this.widgetManager.onEvent(a,i))},this._onPointerDown=i=>{let s=i.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo},this.props={...x_,...e},e=this.props,e.viewState&&e.initialViewState&&U.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&U.error("WebGL1 context not supported.")(),this.device=Vi.attach(e.gl));let r=this.device;r||(dr.registerDevices([Vi]),r=dr.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Nt.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&U.removed("onLayerHover","onHover")(),"onLayerClick"in e&&U.removed("onLayerClick","onClick")(),e.initialViewState&&!Le(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(r),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return r=r||i||s||n||o,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return oe(this.viewManager),this.viewManager.views}getViewports(e){return oe(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,r,i){oe(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),n}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),oe(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let s=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=s}if(i||i===0){let s=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:s,useDevicePixels:n}=r;return new uo({device:e,useDevicePixels:n,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:s})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new qr({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let{result:r,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=r.length>0;let s=i,n=!1;for(let o of r)s=o,n=o.layer?.onHover(o,e.event)||n;n||(this.props.onHover?.(s,e.event),this.widgetManager.onHover(s,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof Vi&&this.props.onWebGLInitialized(this.device.gl);let r=new Ni;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new Os(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in to)this.eventManager.on(s,this._onEvent);this.viewManager=new go({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new po(this.device,{deck:this,stats:this.stats,viewport:i,timeline:r}),this.effectManager=new To({deck:this,device:this.device}),this.deckRenderer=new So(this.device),this.deckPicker=new Ao(this.device),this.widgetManager=new sl({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new wo),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:s});let n={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:i,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),U.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=dr.stats.get("Memory Usage");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};function y_(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return $n(t)}}var b_=_c;function zo(t,e){return{attribute:t,format:e.size>1?`${e.type}x${e.size}`:e.type,byteOffset:e.offset||0}}function Qr(t){return t.stride||t.size*t.bytesPerElement}function v_(t,e){return t.type===e.type&&t.size===e.size&&Qr(t)===Qr(e)&&(t.offset||0)===(e.offset||0)}function Id(t,e){e.offset&&U.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Qr(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,s=e.elementOffset||0,n=i*r+s*t.bytesPerElement+(t.offset||0);return{...e,offset:n,stride:r}}function q5(t,e){let r=Id(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Vo=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let s=r.logicalType||r.type,n=s==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=y_(s||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Qr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Nt.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let s=this.value;if(r){let n=Id(this.getAccessor(),r),o=n.offset/s.BYTES_PER_ELEMENT,a=n.size||this.size;i[e]=s.subarray(o,o+a)}else i[e]=s}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),s=[],n={name:this.id,byteStride:Qr(i),attributes:s};if(this.doublePrecision){let o=q5(i,r||{});s.push(zo(e,{...i,...o.high}),zo(`${e}64Low`,{...i,...o.low}))}else if(r){let o=Id(i,r);s.push(zo(e,{...i,...o}))}else s.push(zo(e,i));return n}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:s}=this,n=i*s;if(r&&n&&r.length>=n){let o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof ie?i={buffer:e}:i=e;let s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{let o=b_(i.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=Qr(s)}if(r.bounds=null,i.constant){let n=i.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(i.buffer){let n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this,a=Qr(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=Zc(n,s)),this.settings.isIndexed){let u=this.settings.defaultType;n.constructor!==u&&(n=new u(n))}let l=n.byteLength+c+a*2;(!o||o.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:s,size:n}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let o=n;for(;--o>=0;)r[i+o]=s[o];return r}switch(n){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let o=n;for(;--o>=0;)r[i+o]=Number.isFinite(e[o])?e[o]:s[o]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let s=0;s0&&(E_.length=t.length,i=E_):i=T_,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),s.index=e-1),{iterable:i,objectInfo:s}}function Rl(t){return t&&t[Symbol.asyncIterator]}function Ml(t,e){let{size:r,stride:i,offset:s,startIndices:n,nested:o}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,u=Math.floor((t.length-l)/c);return(f,{index:h,target:d})=>{if(!n){let y=h*c+l;for(let v=0;v=e[1]))return t;let r=[],i=t.length,s=0;for(let n=0;ne[1]?r.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return r.splice(s,0,e),r}var Z5={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Il(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...Z5[r],...e,...t,type:r}}var ji=class extends Vo{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Wo}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){this.state.layoutChanged||=!v_(e,this.getAccessor()),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?e[r.find(n=>e[n])]:e[r];return Il(s,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=A_(this.state.updateRanges,[i,s])}else this.state.updateRanges=Wo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=S_}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==Wo),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of n)o.call(s,this,{data:r,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(T,g):(e._normalizeValue(T,y.target,0),od({target:l,source:y.target,start:g,count:S}));g+=S*u}else e._normalizeValue(T,l,g),g+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function Od(t){let{source:e,target:r,start:i=0,size:s,getData:n}=t,o=t.end||r.length,a=e.length,c=o-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!n)return;let l=a;for(;li(u+a,f)),l=Math.min(s.length,n.length);for(let u=1;ua}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,u=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,f=r.startIndices,h=n&&f,d=r.isConstant;if(!h&&e&&i>=s)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let T=o;o=(S,R)=>r.normalizeConstant(T(S,R))}let _=d?(T,S)=>o(g,S):(T,S)=>o(g.subarray(T+l,T+l+c),S),y=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),v=new Float32Array(s);return w_({source:y,target:v,sourceStartIndices:n,targetStartIndices:f,size:c,getData:_}),(!e||e.byteLengththis.device.clearWebGL(_))}let g={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:h});for(let _=0;_{let o=n.props._offset,a=n.id,A=n.parent&&n.parent.id,h;if(A&&!(A in e)&&i(n.parent,!1),A in r){let g=r[A]=r[A]||rw(e[A],e);h=g(n,s),r[a]=g}else Number.isFinite(o)?(h=o+(e[A]||0),r[a]=null):h=t;return s&&h>=t&&(t=h+1),e[a]=h,h};return i}function rk(t,{moduleParameters:e,target:r,viewport:i}){let n=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,s]=t.canvasContext.getDrawingBufferSize(),o=r?r.height:s,a=i;return[a.x*n,o-(a.y+a.height)*n,a.width*n,a.height*n]}var gu=class extends ms{constructor(e,r){super(e,r),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],s=n.width*i,o=n.height*i,a=[1,1,1,1];(s!==r.width||o!==r.height)&&r.resize({width:s,height:o}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}};var ik={color:[255,255,255],intensity:1},iw=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],nk=[0,0,0,200/255],Dc=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=nk,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(ed),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:n,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oi.getProjectedLight({layer:e})),pointLights:this.pointLights.map(i=>i.getProjectedLight({layer:e}))},r}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(ed))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new Fe().lookAt({eye:new X(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;rn&&(s=n);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,A=o.findIndex(h=>h.byteLength>=a);if(A>=0){let h=new e(o.splice(A,1)[0],0,s);return i&&h.fill(0),h}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:n}=i,s=r.findIndex(o=>o.byteLength>=n);s<0?r.push(i):(s>0||r.lengththis.opts.poolSize&&r.shift()}},cn=new C2;function kc(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function sw(t){return[t[12],t[13],t[14]]}function ow(t){return{left:Uc(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Uc(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Uc(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Uc(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Uc(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Uc(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var nw=new X;function Uc(t,e,r,i){nw.set(t,e,r);let n=nw.len();return{distance:i/n,normal:new X(-t/n,-e/n,-r/n)}}function ma(t){return t-Math.fround(t)}var mu;function rd(t,e){let{size:r=1,startIndex:i=0}=e,n=e.endIndex!==void 0?e.endIndex:t.length,s=(n-i)/r;mu=cn.allocate(mu,s,{type:Float32Array,size:r*2});let o=i,a=0;for(;o=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let n of r)this._setChannelTime(n,this.time);let i=this.animations.values();for(let n of i){let{animation:s,channel:o}=n;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=uk++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let i=r-e.delay,n=e.duration*e.repeat;i>=n?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};var fk=0,hk={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:hs.stats.get(`animation-loop-${fk++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},_u=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...hk,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new Gr({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=z1(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(H1(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],i=1,n=this.device?.canvasContext?.canvas;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:e>0&&r>0&&(i=e/r),{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var id=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||pr("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&He(this.indices.usage===gt.INDEX)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function uw(t,e){if(e instanceof id)return e;let r=dk(t,e),{attributes:i,bufferLayout:n}=pk(t,e);return new id({topology:e.topology||"triangle-list",bufferLayout:n,vertexCount:e.vertexCount,indices:r,attributes:i})}function dk(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:gt.INDEX,data:r})}function pk(t,e){let r=[],i={};for(let[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}i[a]=t.createBuffer({data:o.value,id:`${s}-buffer`});let{value:A,size:h,normalized:g}=o;r.push({name:a,format:U1(A,h,g)})}let n=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:n}}var nd=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){let r=ea(Object.values(e).filter(i=>i.dependencies));for(let i of r)e[i.name]=i;le.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[i,n]of Object.entries(e)){let s=i;this.moduleUniforms[s]=n.defaultUniforms||{},this.moduleBindings[s]={}}}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,n=e[i],s=this.modules[i];if(!s){le.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[i],a=s.getUniforms?.(n,this.moduleUniforms[i])||n;this.moduleUniforms[i]={...o,...a}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[n,s]of Object.entries(i))e[`${r}.${n}`]={type:this.modules[r].uniformTypes?.[n],value:String(s)};return e}};var sd=class t{static defaultProps={...Vn.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new t(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){let r={...Vn.defaultProps,...e},i=this._hashRenderPipeline(r);if(!this._renderPipelineCache[i]){let n=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});n.hash=i,this._renderPipelineCache[i]={pipeline:n,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){let r={...Sc.defaultProps,...e},i=this._hashComputePipeline(r);if(!this._computePipelineCache[i]){let n=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});n.hash=i,this._computePipelineCache[i]={pipeline:n,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){let r=e.hash,i=e instanceof Sc?this._computePipelineCache:this._renderPipelineCache;i[r].useCount--,i[r].useCount===0&&(i[r].pipeline.destroy(),delete i[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,n="-",s=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${i}V${n}BL${s}`;default:let o=this._getHash(JSON.stringify(e.parameters));return`${r}/${i}V${n}T${e.topology}P${o}BL${s}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};var od=class t{static defaultProps={...na.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new t(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){let r=this._hashShader(e),i=this._cache[r];if(!i){let n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={shader:n,useCount:0}}return i.useCount++,i.shader}release(e){let r=this._hashShader(e),i=this._cache[r];i&&(i.useCount--,i.useCount===0&&(delete this._cache[r],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}};function fw(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let n of t.attributes)if(n){let s=`${n.location} ${n.name}: ${n.type}`;r[`in ${s}`]={[i]:n.stepMode||"vertex"}}for(let n of t.varyings||[]){let s=`${n.location} ${n.name}`;r[`out ${s}`]={[i]:JSON.stringify(n.accessor)}}return r}var Pr=null,I2=null;function hw(t,{id:e,minimap:r,opaque:i,top:n="0",left:s="0",rgbaScale:o=1}){Pr||(Pr=document.createElement("canvas"),Pr.id=e,Pr.title=e,Pr.style.zIndex="100",Pr.style.position="absolute",Pr.style.top=n,Pr.style.left=s,Pr.style.border="blue 1px solid",Pr.style.transform="scaleY(-1)",document.body.appendChild(Pr),I2=Pr.getContext("2d")),(Pr.width!==t.width||Pr.height!==t.height)&&(Pr.width=t.width/2,Pr.height=t.height/2,Pr.style.width="400px",Pr.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),A=I2.createImageData(t.width,t.height),h=0;for(let g=0;g[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new nd(i));let n=mk(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=E_(this.props.source);let{source:a,getUniforms:A}=this.props.shaderAssembler.assembleShader({platformInfo:n,...this.props,modules:s});this.source=a,this._getModuleUniforms=A}else{let{vs:a,fs:A,getUniforms:h}=this.props.shaderAssembler.assembleShaderPair({platformInfo:n,...this.props,modules:s});this.vs=a,this.fs=A,this._getModuleUniforms=h}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,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||sd.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||od.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){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(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let r;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),Zs(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,n=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:n,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),r?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",r}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&uw(this.device,e);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=dw(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)),this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?dw(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){ZA(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 QA(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),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,r){e.indices&&le.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[i,n]of Object.entries(e)){let s=this.bufferLayout.find(A=>pw(A).includes(i));if(!s){le.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let o=pw(s),a=!1;for(let A of o){let h=this._attributeInfos[A];h&&(this.vertexArray.setBuffer(h.location,n),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&le.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,n]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,n):(r?.disableWarnings??this.props.disableWarnings)||le.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){Zs(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){let{bindings:r,uniforms:i}=KA(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof ia?e=Math.max(e,r.texture.updateTimestamp):r instanceof gt||r instanceof $t?e=Math.max(e,r.updateTimestamp):r instanceof sa||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(n=>n.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(le.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),n=null;this.source?n=i:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:n}),this._attributeInfos=u0(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=le.level>3?0:gk;le.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:le.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=fw(this.pipeline.shaderLayout,this.id);le.table(Vc,e)();let r=this.shaderInputs.getDebugTable();for(let[n,s]of Object.entries(this.uniforms))r[n]={value:s};le.table(Vc,r)();let i=this._getAttributeDebugTable();le.table(Vc,this._attributeInfos)(),le.table(Vc,i)(),le.groupEnd(Vc)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=le.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let i=e.props.framebuffer;i&&hw(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos))e[i.location]={name:r,type:i.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[i.location],i.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=qA(r);return(e instanceof gt?new i(e.debugData):e).toString()}};function dw(t,e){let r=[...t];for(let i of e){let n=r.findIndex(s=>s.name===i.name);n<0?r.push(i):r[n]=i}return r}function mk(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function pw(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}var co=class t{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=Qe.defaultProps){He(t.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new Qe(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||UA(),topology:r.topology||"point-list",...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(r instanceof gt)return r.readAsync();let{buffer:i,byteOffset:n=0,byteLength:s=i.byteLength}=r;return i.readAsync(n,s)}};var _k="transform_output",lo=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Qe(this.device,{id:r.id||"texture-transform-model",fs:r.fs||UA({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:_k}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getData({packed:e=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:i,targetTexture:n}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),n){e.targetTexture=n;let{width:s,height:o}=n;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:s,height:o,colorAttachments:[n]}),e.framebuffer.resize({width:s,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var mt=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:n=null}=e;this.id=e.id||pr("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;He(ArrayBuffer.isView(a.value),`${this._print(s)}: must be typed array or object with value as typed array`),(s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"?(He(!this.indices),this.indices=a):this.attributes[s]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let n of Object.values(e)){let{value:s,size:o,constant:a}=n;!a&&s&&o>=1&&(i=Math.min(i,s.length/o))}return He(Number.isFinite(i)),i}};var Wn=class{id;matrix=new Fe;display=!0;position=new X;rotation=new X;scale=new X(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||pr(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return He(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return He(e.length===3,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return He(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:i,scale:n,update:s=!0}=e;return r&&this.setPosition(r),i&&this.setRotation(i),n&&this.setScale(n),s&&this.updateMatrix(),this}updateMatrix(){let e=this.position,r=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(r),this.matrix.scale(i),this}update(e={}){let{position:r,rotation:i,scale:n}=e;return r&&this.setPosition(r),i&&this.setRotation(i),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,r){He(e),r=r||this.matrix;let i=new Fe(e).multiplyRight(r),n=i.invert(),s=n.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:n,worldInverseTransposeMatrix:s}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};var ys=class t extends Wn{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;le.assert(r.every(i=>i instanceof Wn),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let n=r.getBounds();if(!n)return;let[s,o]=n,a=new X(s).add(o).divide([2,2,2]);i.transformAsPoint(a,a);let A=new X(o).subtract(s).divide([2,2,2]);i.transformAsVector(A,A);for(let h=0;h<8;h++){let g=new X(h&1?-1:1,h&2?-1:1,h&4?-1:1).multiply(A).add(a);for(let _=0;_<3;_++)e[0][_]=Math.min(e[0][_],g[_]),e[1][_]=Math.max(e[1][_],g[_])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,i=r.indexOf(e);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new Fe}={}){let i=new Fe(r).multiplyRight(this.matrix);for(let n of this.children)n instanceof t?n.traverse(e,{worldMatrix:i}):e(n,{worldMatrix:i})}};var Ao=class extends Wn{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}};var ya=class extends mt{constructor(e={}){let{id:r=pr("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:yk},attributes:{...wk,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...Ck,...e.attributes}})}},yk=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),xk=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),bk=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),Tk=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Ek=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),vk=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),Sk=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),wk={POSITION:{size:3,value:xk},NORMAL:{size:3,value:bk},TEXCOORD_0:{size:2,value:Tk}},Ck={POSITION:{size:3,value:Ek},TEXCOORD_0:{size:2,value:vk},COLOR_0:{size:3,value:Sk}};var Mk={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},xa=class extends ms{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:n,onViewportActive:s,pickingFBO:o,deviceRect:{x:a,y:A,width:h,height:g},cullRect:_,effects:x,pass:T="picking",pickZ:v,moduleParameters:S}){this.pickZ=v;let C=this._resetColorEncoder(v),M=[a,A,h,g],R=super.render({target:o,layers:e,layerFilter:r,views:i,viewports:n,onViewportActive:s,cullRect:_,effects:x?.filter(k=>k.useInPicking),pass:T,isPicking:!0,moduleParameters:S,clearColor:[0,0,0,0],colorMask:15,scissorRect:M});return this._colorEncoderState=null,{decodePickingColor:C&&Ik.bind(null,C),stats:R}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,r,i){let n={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:s,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?n.blend=!1:s&&o.includes("draw")&&(Object.assign(n,Mk),n.blend=!0,n.blendColor=Pk(this._colorEncoderState,e,i)),n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function Pk(t,e,r){let{byLayer:i,byAlpha:n}=t,s,o=i.get(e);return o?(o.viewports.push(r),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[r]},i.set(e,o),n[s]=o):(me.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function Ik(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var uo={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},zc=Symbol.for("component"),Hi=Symbol.for("propTypes"),ad=Symbol.for("deprecatedProps"),xs=Symbol.for("asyncPropDefaults"),jn=Symbol.for("asyncPropOriginal"),ln=Symbol.for("asyncPropResolved");function hi(t,e=()=>!0){return Array.isArray(t)?gw(t,e,[]):e(t)?[t]:[]}function gw(t,e,r){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,n=e;typeof e=="string"&&(n=Cr(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var xu=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:i=!1,persistent:n=!0}){let s=this._resources[e];s?s.setData(r,i):(s=new yu(e,r,this._context),this._resources[e]=s),s.persistent=n}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let n=r[i],s=this._resources[n.resourceId];s&&s.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:n="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,n,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,i,n){let s=this._consumers,o=s[e]=s[e]||{},a=o[r],A=a&&a.resourceId&&this._resources[a.resourceId];A&&(A.unsubscribe(a),this.prune()),i&&(a?(a.onChange=n,a.resourceId=i.id):a={onChange:n,resourceId:i.id},o[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var Rk="layerManager.setLayers",Bk="layerManager.activateViewport",bu=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Zt(Bk,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:n,viewport:s,timeline:o}=r||{};this.layers=[],this.resourceManager=new xu({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:hu(),defaultShaderModules:[],renderPass:void 0,stats:n||new Gr({id:"deck.gl"}),viewport:s||new _s({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new _a,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let n=i.getNeedsRedraw(e);r=r||n}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){Zt(Rk,this,r,e),this._lastRenderedLayers=e;let i=hi(e,Boolean);for(let n of i)n.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(n=>n.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let o of e)i[o.id]?me.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let n=[];this._updateSublayersRecursively(r,i,n),this._finalizeOldLayers(i);let s=!1;for(let o of n)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=n}_updateSublayersRecursively(e,r,i){for(let n of e){n.context=this.context;let s=r[n.id];s===null&&me.warn(`Multiple new layers with same id ${n.id}`)(),r[n.id]=null;let o=null;try{this._debug&&s!==n&&n.validateProps(),s?(this._transferLayerState(s,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),o=n.isComposite?n.getSubLayers():null}catch(a){this._handleError("matching",a,n)}o&&this._updateSublayersRecursively(o,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=uo.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=uo.MATCHED,r!==e&&(e.lifecycle=uo.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=uo.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=uo.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function er(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;ir.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),n={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(n)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=hi(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!er(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):me.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,width:this.width,height:this.height})})}_updateController(e,r,i,n){let s=e.controller;if(s&&i){let o={...r,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!n||n.constructor!==s.type)&&(n=this._createController(e,o)),n&&n.setProps(o),n}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=e.length;n--;){let s=e[n],o=this.getViewState(s),a=s.makeViewport({viewState:o,width:this.width,height:this.height}),A=r[s.id],h=!!s.controller;h&&!A&&(i=!0),(i||!h)&&A&&(A.finalize(),A=null),this.controllers[s.id]=this._updateController(s,o,a,A),a&&this._viewports.unshift(a)}for(let n in r){let s=r[n];s&&!this.controllers[n]&&s.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,n)=>!e[n].equals(r[n]))}};var Ok=/([0-9]+\.?[0-9]*)(%|px)/;function bs(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":let e=Ok.exec(t);if(e&&e.length>=3){let r=e[2]==="%",i=parseFloat(e[1]);return{position:r?i/100:i,relative:r}}default:throw new Error(`Could not parse position string ${t}`)}}function Ts(t,e){return t.relative?Math.round(t.position*e):t.position}var Eu=class{constructor(e){let{id:r,x:i=0,y:n=0,width:s="100%",height:o="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=bs(i),this._y=bs(n),this._width=bs(s),this._height=bs(o),this._padding=a&&{left:bs(a.left||0),right:bs(a.right||0),top:bs(a.top||0),bottom:bs(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&er(this.props,e.props,2)}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let n=this.getDimensions({width:e,height:r});return!n.height||!n.width?null:new this.ViewportType({...i,...this.props,...n})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let r={...e};for(let i in this.props.viewState)i!=="id"&&(r[i]=this.props.viewState[i]);return r}return e}getDimensions({width:e,height:r}){let i={x:Ts(this._x,e),y:Ts(this._y,r),width:Ts(this._width,e),height:Ts(this._height,r)};return this._padding&&(i.padding={left:Ts(this._padding.left,e),top:Ts(this._padding.top,r),right:Ts(this._padding.right,e),bottom:Ts(this._padding.bottom,r)}),i}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var An=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var mw=()=>{},B2={BREAK:1,SNAP_TO_END:2,IGNORE:3},Fk=t=>t,Lk=B2.BREAK,vu=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:n,startProps:s,endProps:o,duration:a,easing:A}}=r,h=A(i/a),g=n.interpolateProps(s,o,h);this.propsInTransition=this.getControllerState({...this.props,...g}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new An(e.timeline),this.onViewStateChange=e.onViewStateChange||mw,this.onStateChange=e.onStateChange||mw}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let n=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;n={...i,...s===B2.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(n,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===B2.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),n=this.getControllerState(r).shortestPathFrom(i),s=r.transitionInterpolator,o=s.getDuration?s.getDuration(e,r):r.transitionDuration;if(o===0)return;let a=s.initializeProps(e,n);this.propsInTransition={};let A={duration:o,easing:r.transitionEasing||Fk,interpolator:s,interruption:r.transitionInterruption||Lk,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(A),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function Rt(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var Su=class{constructor(e){let{compare:r,extract:i,required:n}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=n}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!lr(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},n={};for(let s of this._propsToExtract)(s in e||s in r)&&(i[s]=e[s],n[s]=r[s]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];Rt(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var Nk=["longitude","latitude","zoom","bearing","pitch"],Dk=["longitude","latitude","zoom"],ba=class extends Su{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Nk,required:Dk},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:n,around:s}=this.opts;if(n&&s){let o=n(e),a=n(r),A=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(A),aroundPosition:A,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let n={};for(let s of this._propsToExtract)n[s]=Fr(e[s]||0,r[s]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...r,...n});Object.assign(n,s.panByPosition(r.aroundPosition,Fr(e.around,r.around,i)))}return n}};var fo={transitionDuration:0},Uk=300,cd=t=>1-(1-t)*(1-t),Hc={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},Ta={},wu=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new vu({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return r?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:i}=this.props,{offsetCenter:n}=e;return[n.x-r,n.y-i]}isPointInBounds(e,r){let{width:i,height:n}=this.props;if(r&&r.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=n;return s&&r&&r.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:r}=e;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:r}=e;this.inertia=Number.isFinite(r)?r:r===!0?Uk:0;let{scrollZoom:i=!0,dragPan:n=!0,dragRotate:s=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:A=!1,keyboard:h=!0}=e,g=!!this.onViewStateChange;this.toggleEvents(Hc.WHEEL,g&&i),this.toggleEvents(Hc.PAN,g),this.toggleEvents(Hc.PINCH,g&&(a||A)),this.toggleEvents(Hc.TRIPLE_PAN,g&&A),this.toggleEvents(Hc.DOUBLE_TAP,g&&o),this.toggleEvents(Hc.KEYBOARD,g&&h),this.scrollZoom=i,this.dragPan=n,this.dragRotate=s,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=A,this.keyboard=h}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let n={...e.getViewportProps(),...r},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let n=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(n,fo,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,fo,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),n=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],s=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:cd},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,fo,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),n=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],s=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:cd},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:n=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(a,{...this._getTransitionProps({around:r}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,fo,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,fo,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),n=[i[0],i[1]+=e.velocityY*r/2],s=this.controllerState.rotate({pos:n});this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:cd},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return Ta._startPinchRotation=e.rotation,Ta._lastPinchEvent=e,this.updateViewport(i,fo,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,n=this.getCenter(e);r=r.zoom({pos:n,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:Ta._startPinchRotation-i})}return this.updateViewport(r,fo,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Ta._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=Ta;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let n=this.getCenter(e),s=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),A=Math.pow(2,o+a*r/2);s=s.zoom({pos:n,scale:A}).zoomEnd(),this.updateViewport(s,{...this._getTransitionProps({around:n}),transitionDuration:r,transitionEasing:cd},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let n=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Ta._startPinchRotation=null,Ta._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:s,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,A,h={};switch(e.srcEvent.code){case"Minus":A=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),h.isZooming=!0;break;case"Equal":A=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),h.isZooming=!0;break;case"ArrowLeft":r?(A=a.rotateLeft(s),h.isRotating=!0):(A=a.moveLeft(n),h.isPanning=!0);break;case"ArrowRight":r?(A=a.rotateRight(s),h.isRotating=!0):(A=a.moveRight(n),h.isPanning=!0);break;case"ArrowUp":r?(A=a.rotateUp(o),h.isRotating=!0):(A=a.moveUp(n),h.isPanning=!0);break;case"ArrowDown":r?(A=a.rotateDown(o),h.isRotating=!0):(A=a.moveDown(n),h.isPanning=!0);break;default:return!1}return this.updateViewport(A,this._getTransitionProps(),h),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?fo:e?{...r,transitionInterpolator:new ba({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Cu=class{constructor(e,r){this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var _w=5,kk=1.2,O2=class extends Cu{constructor(e){let{width:r,height:i,latitude:n,longitude:s,zoom:o,bearing:a=0,pitch:A=0,altitude:h=1.5,position:g=[0,0,0],maxZoom:_=20,minZoom:x=0,maxPitch:T=60,minPitch:v=0,startPanLngLat:S,startZoomLngLat:C,startRotatePos:M,startBearing:R,startPitch:B,startZoom:k,normalize:Q=!0}=e;Rt(Number.isFinite(s)),Rt(Number.isFinite(n)),Rt(Number.isFinite(o)),super({width:r,height:i,latitude:n,longitude:s,zoom:o,bearing:a,pitch:A,altitude:h,maxZoom:_,minZoom:x,maxPitch:T,minPitch:v,normalize:Q,position:g},{startPanLngLat:S,startZoomLngLat:C,startRotatePos:M,startBearing:R,startPitch:B,startZoom:k}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let s=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(s)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:n,startBearing:s,startPitch:o}=this.getState();if(!n||s===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,n,o,s):a={bearing:s+r,pitch:o+i},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:n,startZoomLngLat:s}=this.getState();if(s||(n=this.getViewportProps().zoom,s=this._unproject(r)||this._unproject(e)),!s)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),A=n+Math.log2(i);A=ei(A,a,o);let h=this.makeViewport({...this.getViewportProps(),zoom:A});return this._getUpdatedState({zoom:A,...h.panByPosition(s,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:s}=i;return Math.abs(n-r.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(s-r.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e){let{maxZoom:r,minZoom:i,zoom:n}=e;e.zoom=ei(n,i,r);let{maxPitch:s,minPitch:o,pitch:a}=e;e.pitch=ei(a,o,s);let{normalize:A=!0}=e;return A&&Object.assign(e,w2(e)),e}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_getNewRotation(e,r,i,n){let s=e[0]-r[0],o=e[1]-r[1],a=e[1],A=r[1],{width:h,height:g}=this.getViewportProps(),_=s/h,x=0;o>0?Math.abs(g-A)>_w&&(x=o/(A-g)*kk):o<0&&A>_w&&(x=1-a/A),x=ei(x,-1,1);let{minPitch:T,maxPitch:v}=this.getViewportProps(),S=n+180*_,C=i;return x>0?C=i+x*(v-i):x<0&&(C=i-x*(T-i)),{pitch:C,bearing:S}}},Mu=class extends wu{constructor(){super(...arguments),this.ControllerState=O2,this.transition={transitionDuration:300,transitionInterpolator:new ba({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let r=this.props;super.setProps(e),(!r||r.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var ho=class extends Eu{static{this.displayName="MapView"}constructor(e={}){super(e)}get ViewportType(){return wi}get ControllerType(){return Mu}};var Vk=new Dc;function zk(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var Pu=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(n=>zk(n,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(er(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let n of this.effects)r[n.id]=n;let i=[];for(let n of e){let s=r[n.id],o=n;s&&s!==n?s.setProps?(s.setProps(n.props),o=s):s.cleanup(this._context):s||n.setup(this._context),i.push(o),delete r[n.id]}for(let n in r)r[n].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(n=>n instanceof Dc)||this._resolvedEffects.push(Vk),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Iu=class extends ms{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}};var Hk="deckRenderer.renderLayers",Ru=class{constructor(e){this.device=e,this.gl=e.gl,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Iu(e),this.pickLayersPass=new xa(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let n=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=r.render({...i,target:n});i.effects&&this._postRender(i.effects,i),this.renderCount++,Zt(Hk,this,s,e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(i=>{let n=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[n]}))});for(let i of e)i.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,n={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let s of e)if(s.postRender){n.target=s.id===this.lastPostProcessEffect?r.target:void 0;let o=s.postRender(n);n.inputBuffer=o,n.swapBuffer=o===i[0]?i[1]:i[0]}}};var Gk={pickedColor:null,pickedObjectIndex:-1};function yw({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:n,deviceRect:s}){let{x:o,y:a,width:A,height:h}=s,g=n*n,_=-1,x=0;for(let T=0;Tg)x+=4*A;else for(let C=0;C=0){let R=C+o-r,B=R*R+S;B<=g&&(g=B,_=x)}x+=4}}if(_>=0){let T=t.slice(_,_+4),v=e(T);if(v){let S=Math.floor(_/4/A),C=_/4-S*A;return{...v,pickedColor:T,pickedX:o+C,pickedY:a+S}}me.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Gk}function xw({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i=0){let s=t.slice(i,i+4),o=s.join(",");if(!r.has(o)){let a=e(s);a?r.set(o,{...a,color:s}):me.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function F2({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:n,z:s}){let o=e[0];e.length>1&&(o=Wk(t?.pickedViewports||e,{x:i,y:n}));let a;if(o){let A=[i-o.x,n-o.y];s!==void 0&&(A[2]=s),a=o.unproject(A)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:n,pixel:[i,n],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function bw(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:n}=t,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,A=o?[o]:[];if(i==="hover"){let _=r.index,x=r.layerId,T=o?o.props.id:null;if(T!==x||a!==_){if(T!==x){let v=n.find(S=>S.props.id===x);v&&A.unshift(v)}r.layerId=T,r.index=a,r.info=null}}let h=F2(t),g=new Map;return g.set(null,h),A.forEach(_=>{let x={...h};_===o&&(x.color=s,x.index=a,x.picked=!0),x=L2({layer:_,info:x,mode:i});let T=x.layer;_===o&&i==="hover"&&(r.info=x),g.set(T.id,x),i==="hover"&&T.updateAutoHighlight(x)}),g}function L2({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function Wk(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var Bu=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new xa(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:i,viewports:n},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,A=o?i.find(x=>x.id===o):null,h=a&&n.find(x=>x.id===a)||n[0],g=h&&h.unproject([e-h.x,r-h.y]);return{...s,...{x:e,y:r,viewport:h,coordinate:g,layer:A}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let e=this.device.gl;this.pickingFBO?.resize({width:e.canvas.width,height:e.canvas.height}),this.depthFBO?.resize({width:e.canvas.width,height:e.canvas.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}_pickClosestObject({layers:e,views:r,viewports:i,x:n,y:s,radius:o=0,depth:a=1,mode:A="query",unproject3D:h,onViewportActive:g,effects:_}){let x=this.device.canvasContext.cssToDeviceRatio(),T=this._getPickable(e);if(!T||i.length===0)return{result:[],emptyInfo:F2({viewports:i,x:n,y:s,pixelRatio:x})};this._resizeBuffer();let v=this.device.canvasContext.cssToDevicePixels([n,s],!0),S=[v.x+Math.floor(v.width/2),v.y+Math.floor(v.height/2)],C=Math.round(o*x),{width:M,height:R}=this.pickingFBO,B=this._getPickingRect({deviceX:S[0],deviceY:S[1],deviceRadius:C,deviceWidth:M,deviceHeight:R}),k={x:n-o,y:s-o,width:o*2+1,height:o*2+1},Q,$=[],re=new Set;for(let Y=0;Y=h);L++){let ae=$[L],fe={color:ae.pickedColor,layer:null,index:ae.pickedObjectIndex,picked:!0,x:n,y:s,pixelRatio:T};fe=L2({layer:ae.pickedLayer,info:fe,mode:A});let he=fe.layer.id;re.has(he)||re.set(he,new Set);let ye=re.get(he),Ne=fe.object??fe.index;ye.has(Ne)||(ye.add(Ne),Y.push(fe))}return Y}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:n,deviceRect:s,cullRect:o,effects:a,pass:A},h=!1){let g=h?this.depthFBO:this.pickingFBO,_={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:n,pickingFBO:g,deviceRect:s,cullRect:o,effects:a,pass:A,pickZ:h,preRenderStats:{}};for(let R of a)R.useInPicking&&(_.preRenderStats[R.id]=R.preRender(_));let{decodePickingColor:x}=this.pickLayersPass.render(_),{x:T,y:v,width:S,height:C}=s,M=new(h?Float32Array:Uint8Array)(S*C*4);return this.device.readPixelsToArrayWebGL(g,{sourceX:T,sourceY:v,sourceWidth:S,sourceHeight:C,target:M}),{pickedColors:M,decodePickingColor:x}}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:n,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,r-i),A=Math.min(n,e+i+1)-o,h=Math.min(s,r+i+1)-a;return A<=0||h<=0?null:{x:o,y:a,width:A,height:h}}};var jk={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Xk="top-left",Tw="__root",ld=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!er(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(let e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let n=r[i.id];n?n.viewId!==i.viewId||n.placement!==i.placement?(this._remove(n),this._add(i)):i!==n&&(n.setProps(i.props),i=n):this._add(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let n=r[i];n&&this._remove(n)}this.widgets=e}_add(e){let{viewId:r=null,placement:i=Xk}=e,n=e.onAdd({deck:this.deck,viewId:r});n&&this._getContainer(r,i).append(n),e._element=n}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,r){let i=e||Tw,n=this.containers[i];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[i]=n);let s=n.querySelector(`.${r}`);return s||(s=document.createElement("div"),s.className=r,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,jk[r]),n.append(s)),s}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let n=this.lastViewports[i]||null,s=i===Tw||n,o=this.containers[i];s?(o.style.display="block",o.style.left=`${n?n.x:0}px`,o.style.top=`${n?n.y:0}px`,o.style.width=`${n?n.width:e}px`,o.style.height=`${n?n.height:r}px`):o.style.display="none"}}onRedraw({viewports:e,layers:r}){let i=e.reduce((s,o)=>(s[o.id]=o,s),{}),{lastViewports:n}=this;for(let s of this.getWidgets()){let{viewId:o}=s;if(o){let a=i[o];a&&(s.onViewportChange&&!a.equals(n[o])&&s.onViewportChange(a),s.onRedraw?.({viewports:[a],layers:r}))}else{if(s.onViewportChange)for(let a of e)a.equals(n[a.id])||s.onViewportChange(a);s.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:n}=i;(!n||n===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=lu[r.type];if(i)for(let n of this.getWidgets()){let{viewId:s}=n;(!s||s===e.viewport?.id)&&n[i.handler]?.(e,r)}}};var Yk={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Ou=class{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){let r=document.createElement("div");return r.className="deck-tooltip",Object.assign(r.style,Yk),this.deck=e,this.element=r,r}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let n=i(e);this.lastViewport=e.viewport,this.setTooltip(n,e.x,e.y)}setTooltip(e,r,i){let n=this.element;if(n){if(typeof e=="string")n.innerText=e;else if(e)e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className);else{this.isVisible=!1,n.style.display="none";return}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(n.style,e.style)}}};var po;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(po||(po={}));var Lu={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},Ar=(t,e,r)=>e?t.enable(r):t.disable(r),Ew=(t,e,r)=>t.hint(r,e),Ci=(t,e,r)=>t.pixelStorei(r,e),vw=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},Fu=(t,e,r)=>{let n={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];t.bindBuffer(n,e)};function N2(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var Sw={3042:Ar,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:Ar,2885:(t,e)=>t.cullFace(e),2929:Ar,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:Ar,35723:Ew,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>t.bindTransformFeedback?.(36386,e),34229:(t,e)=>t.bindVertexArray(e),36006:vw,36010:vw,34964:Fu,36662:Fu,36663:Fu,35053:Fu,35055:Fu,2886:(t,e)=>t.frontFace(e),33170:Ew,2849:(t,e)=>t.lineWidth(e),32823:Ar,32824:"polygonOffset",10752:"polygonOffset",35977:Ar,32926:Ar,32928:Ar,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ar,3088:(t,e)=>t.scissor(...e),2960:Ar,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.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:(t,e)=>t.viewport(...e),34383:Ar,10754:Ar,12288:Ar,12289:Ar,12290:Ar,12291:Ar,12292:Ar,12293:Ar,12294:Ar,12295:Ar,3333:Ci,3317:Ci,37440:Ci,37441:Ci,37443:Ci,3330:Ci,3332:Ci,3331:Ci,3314:Ci,32878:Ci,3316:Ci,3315:Ci,32877:Ci,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=N2(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=N2(e)&&e.length===3?[...e,...e]:e;let[r,i,n,s,o,a]=e;t.stencilFuncSeparate(1028,r,i,n),t.stencilFuncSeparate(1029,s,o,a)},stencilOp:(t,e)=>{e=N2(e)&&e.length===3?[...e,...e]:e;let[r,i,n,s,o,a]=e;t.stencilOpSeparate(1028,r,i,n),t.stencilOpSeparate(1029,s,o,a)},viewport:(t,e)=>t.viewport(...e)};function tr(t,e,r){return e[t]!==void 0?e[t]:r[t]}var ww={blendEquation:(t,e,r)=>t.blendEquationSeparate(tr(32777,e,r),tr(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(tr(32969,e,r),tr(32968,e,r),tr(32971,e,r),tr(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(tr(32824,e,r),tr(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(tr(32938,e,r),tr(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,tr(2962,e,r),tr(2967,e,r),tr(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,tr(34816,e,r),tr(36003,e,r),tr(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,tr(2964,e,r),tr(2965,e,r),tr(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,tr(34817,e,r),tr(34818,e,r),tr(34819,e,r))},D2={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,r)=>t({36007:r}),bindTransformFeedback:(t,e,r)=>t({36389:r}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({36006:r,36010:r});case 36009:return t({36006:r});case 36008:return t({36010:r});default:return null}},bindBuffer:(t,e,r)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,n)=>t({32773:new Float32Array([e,r,i,n])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,r)=>t({32777:e,34877:r}),blendFunc:(t,e,r)=>t({32969:e,32968:r,32971:e,32970:r}),blendFuncSeparate:(t,e,r,i,n)=>t({32969:e,32968:r,32971:i,32970:n}),clearColor:(t,e,r,i,n)=>t({3106:new Float32Array([e,r,i,n])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,r,i,n)=>t({3107:[e,r,i,n]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,r)=>t({2928:new Float32Array([e,r])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,r)=>t({32824:e,10752:r}),sampleCoverage:(t,e,r)=>t({32938:e,32939:r}),scissor:(t,e,r,i,n)=>t({3088:new Int32Array([e,r,i,n])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({2962:e,2967:r,2963:i,34816:e,36003:r,36004:i}),stencilFuncSeparate:(t,e,r,i,n)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:n}),stencilOp:(t,e,r,i)=>t({2964:e,2965:r,2966:i,34817:e,34818:r,34819:i}),stencilOpSeparate:(t,e,r,i,n)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:n}),viewport:(t,e,r,i,n)=>t({2978:[e,r,i,n]})},Xn=(t,e)=>t.isEnabled(e),U2={3042:Xn,2884:Xn,2929:Xn,3024:Xn,32823:Xn,32926:Xn,32928:Xn,3089:Xn,2960:Xn,35977:Xn},Cw=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(t,e){if(Qk(e))return;let r={};for(let n in e){let s=Number(n),o=Sw[n];o&&(typeof o=="string"?r[o]=!0:o(t,e[n],s))}let i=t.state&&t.state.cache;if(i)for(let n in r){let s=ww[n];s(t,e,i)}}function Ad(t,e=Lu){if(typeof e=="number"){let n=e,s=U2[n];return s?s(t,n):t.getParameter(n)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let n of r){let s=U2[n];i[n]=s?s(t,Number(n)):t.getParameter(Number(n))}return i}function Mw(t){un(t,Lu)}function Qk(t){for(let e in t)return!1;return!0}function Pw(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),i=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&i&&t.length===e.length){for(let n=0;n{}}={}){this.gl=e,this.cache=r?Ad(e):Object.assign({},Lu),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){He(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];un(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,i,n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){He(s!==void 0);let o=e[s],a=this.cache[s];Pw(o,a)||(r=!0,i=a,n&&!(s in n)&&(n[s]=a),this.cache[s]=o)}return{valueChanged:r,oldValue:i}}};function Ea(t){return t.state}function V2(t,e){let{enable:r=!0,copyState:i}=e;if(He(i!==void 0),!t.state){t.state=new k2(t,{copyState:i}),Kk(t);for(let s in D2){let o=D2[s];qk(t,s,o)}Iw(t,"getParameter"),Iw(t,"isEnabled")}let n=Ea(t);return n.enable=r,t}function go(t){let e=Ea(t);e||(V2(t,{copyState:!1}),e=Ea(t)),e.push()}function Es(t){let e=Ea(t);He(e),e.pop()}function Iw(t,e){let r=t[e].bind(t);t[e]=function(n){if(n===void 0||Cw.has(n))return r(n);let s=Ea(t);return n in s.cache||(s.cache[n]=r(n)),s.enable?s.cache[n]:r(n)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function qk(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...s){let o=Ea(t),{valueChanged:a,oldValue:A}=r(o._updateCache,...s);return a&&i(...s),A},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function Kk(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let n=Ea(t);n.program!==i&&(e(i),n.program=i)}}var Jk={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Rw(t,e){e={...Jk,...e};let r=null,i=s=>r=s.statusMessage||r;t.addEventListener("webglcontextcreationerror",i,!1);let n=null;if(n||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",i,!1),!n)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;t.addEventListener("webglcontextlost",o=>s(o),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;t.addEventListener("webglcontextrestored",o=>s(o),!1)}return n}function Gi(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function Bw(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);Gi(t,"WEBGL_debug_renderer_info",e);let n=e.WEBGL_debug_renderer_info,s=t.getParameter(n?n.UNMASKED_VENDOR_WEBGL:7936),o=t.getParameter(n?n.UNMASKED_RENDERER_WEBGL:7937),a=s||r,A=o||i,h=t.getParameter(7938),g=Ow(a,A),_=Zk(a,A),x=$k(a,A);return{type:"webgl",gpu:g,gpuType:x,gpuBackend:_,vendor:a,renderer:A,version:h,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Ow(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function Zk(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function $k(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(Ow(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ud(t){switch(t){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(t))}var Xr="texture-compression-bc",Ft="texture-compression-astc",Yn="texture-compression-etc2",eV="texture-compression-etc1-webgl",fd="texture-compression-pvrtc-webgl",z2="texture-compression-atc-webgl",Nu="float32-renderable-webgl",H2="float16-renderable-webgl",tV="rgb9e5ufloat_renderable-webgl",G2="snorm8-renderable-webgl",Du="norm16-renderable-webgl",W2="snorm16-renderable-webgl",hd="float32-filterable",Fw="float16-filterable-webgl",Uu="WEBGL_compressed_texture_s3tc",ku="WEBGL_compressed_texture_s3tc_srgb",Gc="EXT_texture_compression_rgtc",Wc="EXT_texture_compression_bptc",rV="WEBGL_compressed_texture_etc",iV="WEBGL_compressed_texture_astc",nV="WEBGL_compressed_texture_etc1",sV="WEBGL_compressed_texture_pvrtc",oV="WEBGL_compressed_texture_atc",Lw="EXT_texture_norm16",Nw="EXT_render_snorm",aV="EXT_color_buffer_float",dd={"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":[Nw],"norm16-renderable-webgl":[Lw],"snorm16-renderable-webgl":[Lw,Nw],"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":[Uu,ku,Gc,Wc],"texture-compression-bc5-webgl":[Gc],"texture-compression-bc7-webgl":[Wc],"texture-compression-etc2":[rV],"texture-compression-astc":[iV],"texture-compression-etc1-webgl":[nV],"texture-compression-pvrtc-webgl":[sV],"texture-compression-atc-webgl":[oV]};function Dw(t){return t in dd}function Uw(t,e,r){return(dd[e]||[]).every(n=>Gi(t,n,r))}var pd={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:G2},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:G2},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:H2,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Du,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:W2},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:G2},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:H2,filter:Fw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Du},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:W2},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Nu,filter:hd},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:tV},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Nu,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Du},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Du},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Nu,filter:hd,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:H2,filter:Fw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Du,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:W2},"rgb32float-webgl":{gl:34837,render:Nu,filter:hd,gl2ext:aV,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Nu,filter:hd,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Uu,f:Xr},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:ku,f:Xr},"bc1-rgba-unorm":{gl:33777,x:Uu,f:Xr},"bc1-rgba-unorm-srgb":{gl:35916,x:ku,f:Xr},"bc2-rgba-unorm":{gl:33778,x:Uu,f:Xr},"bc2-rgba-unorm-srgb":{gl:35918,x:ku,f:Xr},"bc3-rgba-unorm":{gl:33779,x:Uu,f:Xr},"bc3-rgba-unorm-srgb":{gl:35919,x:ku,f:Xr},"bc4-r-unorm":{gl:36283,x:Gc,f:Xr},"bc4-r-snorm":{gl:36284,x:Gc,f:Xr},"bc5-rg-unorm":{gl:36285,x:Gc,f:Xr},"bc5-rg-snorm":{gl:36286,x:Gc,f:Xr},"bc6h-rgb-ufloat":{gl:36495,x:Wc,f:Xr},"bc6h-rgb-float":{gl:36494,x:Wc,f:Xr},"bc7-rgba-unorm":{gl:36492,x:Wc,f:Xr},"bc7-rgba-unorm-srgb":{gl:36493,x:Wc,f:Xr},"etc2-rgb8unorm":{gl:37492,f:Yn},"etc2-rgb8unorm-srgb":{gl:37494,f:Yn},"etc2-rgb8a1unorm":{gl:37496,f:Yn},"etc2-rgb8a1unorm-srgb":{gl:37497,f:Yn},"etc2-rgba8unorm":{gl:37493,f:Yn},"etc2-rgba8unorm-srgb":{gl:37495,f:Yn},"eac-r11unorm":{gl:37488,f:Yn},"eac-r11snorm":{gl:37489,f:Yn},"eac-rg11unorm":{gl:37490,f:Yn},"eac-rg11snorm":{gl:37491,f:Yn},"astc-4x4-unorm":{gl:37808,f:Ft},"astc-4x4-unorm-srgb":{gl:37840,f:Ft},"astc-5x4-unorm":{gl:37809,f:Ft},"astc-5x4-unorm-srgb":{gl:37841,f:Ft},"astc-5x5-unorm":{gl:37810,f:Ft},"astc-5x5-unorm-srgb":{gl:37842,f:Ft},"astc-6x5-unorm":{gl:37811,f:Ft},"astc-6x5-unorm-srgb":{gl:37843,f:Ft},"astc-6x6-unorm":{gl:37812,f:Ft},"astc-6x6-unorm-srgb":{gl:37844,f:Ft},"astc-8x5-unorm":{gl:37813,f:Ft},"astc-8x5-unorm-srgb":{gl:37845,f:Ft},"astc-8x6-unorm":{gl:37814,f:Ft},"astc-8x6-unorm-srgb":{gl:37846,f:Ft},"astc-8x8-unorm":{gl:37815,f:Ft},"astc-8x8-unorm-srgb":{gl:37847,f:Ft},"astc-10x5-unorm":{gl:37819,f:Ft},"astc-10x5-unorm-srgb":{gl:37851,f:Ft},"astc-10x6-unorm":{gl:37817,f:Ft},"astc-10x6-unorm-srgb":{gl:37849,f:Ft},"astc-10x8-unorm":{gl:37818,f:Ft},"astc-10x8-unorm-srgb":{gl:37850,f:Ft},"astc-10x10-unorm":{gl:37819,f:Ft},"astc-10x10-unorm-srgb":{gl:37851,f:Ft},"astc-12x10-unorm":{gl:37820,f:Ft},"astc-12x10-unorm-srgb":{gl:37852,f:Ft},"astc-12x12-unorm":{gl:37821,f:Ft},"astc-12x12-unorm-srgb":{gl:37853,f:Ft},"pvrtc-rgb4unorm-webgl":{gl:35840,f:fd},"pvrtc-rgba4unorm-webgl":{gl:35842,f:fd},"pvrtc-rbg2unorm-webgl":{gl:35841,f:fd},"pvrtc-rgba2unorm-webgl":{gl:35843,f:fd},"etc1-rbg-unorm-webgl":{gl:36196,f:eV},"atc-rgb-unorm-webgl":{gl:35986,f:z2},"atc-rgba-unorm-webgl":{gl:35986,f:z2},"atc-rgbai-unorm-webgl":{gl:34798,f:z2}},cV={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},lV={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function gd(t,e,r){let i=pd[e];if(!i||i.gl===void 0)return!1;let n=i.x||i.gl2ext;return n?!!Gi(t,n,r):!0}function j2(t){let r=pd[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function kw(t,e,r){if(!gd(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(l0(e).signed)return!1}catch{return!1}return e.endsWith("32float")?!!Gi(t,"OES_texture_float_linear, extensions",r):e.endsWith("16float")?!!Gi(t,"OES_texture_half_float_linear, extensions",r):!0}function Vw(t,e,r){return!(!gd(t,e,r)||typeof e=="number")}function jc(t){let e=pd[t],r=j2(t),i=l0(t);return{format:r,dataFormat:e?.dataFormat||AV(i.format,i.integer,i.normalized,r),type:i.dataType?ud(i.dataType):e?.types?.[0]||5121,compressed:i.compressed}}function zw(t){let e=pd[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function X2(t){let e=jc(t),r=cV[e.dataFormat]||4,i=lV[e.type]||1;return r*i}function AV(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;default:return 6408}}var Hw={"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"},md=class extends VA{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,Gi(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Dw(e)&&Uw(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(Hw),...Object.keys(dd)]}getWebGLFeature(e){let r=Hw[e];return typeof r=="string"?!!Gi(this.gl,r,this.extensions):!!r}};var _d=class extends kA{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 maxInterStageShaderComponents(){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}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};function Wi(t,e,r){if(uV(e))return r(t);let{nocatch:i=!0}=e;go(t),un(t,e);let n;if(i)n=r(t),Es(t);else try{n=r(t)}finally{Es(t)}return n}function uV(t){for(let e in t)return!1;return!0}function Ww(t,e,r,i){if(Zs(e))return i(t);let n=t;go(n.gl);try{return fV(t,e),un(n.gl,r),i(t)}finally{Es(n.gl)}}function fV(t,e){let r=t,{gl:i}=r;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(va("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=va("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=va("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(t.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(dV("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(xd("depthCompare",e.depthCompare))),e.stencilWriteMask){let n=e.stencilWriteMask;i.stencilMaskSeparate(1028,n),i.stencilMaskSeparate(1029,n)}if(e.stencilReadMask&&le.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let n=e.stencilReadMask||4294967295,s=xd("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,n),i.stencilFuncSeparate(1029,s,0,n)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let n=Y2("stencilPassOperation",e.stencilPassOperation),s=Y2("stencilFailOperation",e.stencilFailOperation),o=Y2("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,n),i.stencilOpSeparate(1029,s,o,n)}if(e.blendColorOperation||e.blendAlphaOperation){i.enable(3042);let n=Gw("blendColorOperation",e.blendColorOperation||"add"),s=Gw("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(n,s);let o=yd("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=yd("blendColorDstFactor",e.blendColorDstFactor||"zero"),A=yd("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),h=yd("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,A,h)}}function xd(t,e){return va(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Y2(t,e){return va(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Gw(t,e){return va(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function yd(t,e){return va(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function hV(t,e){return`Illegal parameter ${e} for ${t}`}function va(t,e,r){if(!(e in r))throw new Error(hV(t,e));return r[e]}function dV(t,e){return e}function bd(t){let e={};return t.addressModeU&&(e[10242]=Q2(t.addressModeU)),t.addressModeV&&(e[10243]=Q2(t.addressModeV)),t.addressModeW&&(e[32882]=Q2(t.addressModeW)),t.magFilter&&(e[10240]=jw(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=pV(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=xd("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Q2(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function jw(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function pV(t,e){if(!e)return jw(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}var ti=class extends gt{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=gV(this.props.usage),this.glUsage=mV(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,i=e.byteLength+r){let n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.glUsage),this.gl.bufferSubData(n,r,e),this.gl.bindBuffer(n,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){He(e>=0);let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,e),this.gl.bindBuffer(36663,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),n=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,n,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}};function gV(t){return t>.INDEX?34963:t>.VERTEX?34962:t>.UNIFORM?35345:34962}function mV(t){return t>.INDEX||t>.VERTEX?35044:t>.UNIFORM?35048:35044}var Sa=class extends sa{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=bd(r),this.handle=this.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(e){for(let[r,i]of Object.entries(e)){let n=Number(r);switch(n){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,n,i);break;default:this.device.gl.samplerParameteri(this.handle,n,i);break}}}};var fn=class extends ia{device;gl;handle;texture;constructor(e,r){super(e,{...$t.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var _V={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},di=class t extends $t{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{..._V,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=yV(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:V1(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new fn(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(C=>this.initialize(Object.assign({},e,{pixels:C,data:C}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyStatethis.initialize(e)),this;let{parameters:n={}}=e,{pixels:s=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:A=!0}=e;r||(r=s);let{width:h,height:g,dataFormat:_,type:x,compressed:T=!1}=e,{depth:v=0}=e,S=j2(e.format);return{width:h,height:g,compressed:T,dataFormat:_,type:x}=this._deduceParameters({format:e.format,type:x,dataFormat:_,compressed:T,data:r,width:h,height:g}),this.width=h,this.height=g,this.glFormat=S,this.type=x,this.dataFormat=_,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=A,this.setImageData({data:r,width:h,height:g,depth:v,format:S,type:x,dataFormat:_,parameters:o,compressed:T}),this.setSampler(e.sampler),this._setSamplerParameters(n),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),A&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:r,parameters:n,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let r;e instanceof Sa?(this.sampler=e,r=e.props):(this.sampler=new Sa(this.device,e),r=e);let i=bd(r);return this._setSamplerParameters(i),this}resize(e){let{height:r,width:i,mipmaps:n=!1}=e;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:n}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:n=0,glFormat:s=this.glFormat,offset:o=0,parameters:a={}}=e,{data:A=null,type:h=this.type,width:g=this.width,height:_=this.height,dataFormat:x=this.dataFormat,compressed:T=!1}=e;A||(A=i),{type:h,dataFormat:x,compressed:T,width:g,height:_}=this._deduceParameters({format:this.props.format,type:h,dataFormat:x,compressed:T,data:A,width:g,height:_});let{gl:v}=this;v.bindTexture(this.target,this.handle);let S=null;if({data:A,dataType:S}=this._getDataType({data:A,compressed:T}),Wi(this.gl,a,()=>{switch(S){case"null":v.texImage2D(r,n,s,g,_,0,x,h,A);break;case"typed-array":v.texImage2D(r,n,s,g,_,0,x,h,A,o);break;case"buffer":this.device.gl.bindBuffer(35052,A.handle||A),this.device.gl.texImage2D(r,n,s,g,_,0,x,h,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":v.texImage2D(r,n,s,g,_,0,x,h,A);break;case"compressed":for(let[C,M]of A.entries())v.compressedTexImage2D(r,C,M.format,M.width,M.height,0,M.data);break;default:He(!1,"Unknown image data type")}}),A&&A.byteLength)this.trackAllocatedMemory(A.byteLength,"Texture");else{let C=X2(this.props.format);this.trackAllocatedMemory(this.width*this.height*C,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:i=null,x:n=0,y:s=0,width:o=this.width,height:a=this.height,level:A=0,glFormat:h=this.glFormat,type:g=this.type,dataFormat:_=this.dataFormat,compressed:x=!1,offset:T=0,parameters:v={}}){if({type:g,dataFormat:_,compressed:x,width:o,height:a}=this._deduceParameters({format:this.props.format,type:g,dataFormat:_,compressed:x,data:i,width:o,height:a}),He(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=r),i&&i.data){let S=i;i=S.data,o=S.shape[0],a=S.shape[1]}i instanceof ti&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Wi(this.gl,v,()=>{x?this.gl.compressedTexSubImage2D(e,A,n,s,o,a,h,i):i===null?this.gl.texSubImage2D(e,A,n,s,o,a,_,g,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,A,n,s,o,a,_,g,i,T):typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,A,n,s,o,a,_,g,T),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,A,n,s,o,a,_,g,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return le.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof ti?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:i}=e,{width:n,height:s,dataFormat:o,type:a,compressed:A}=e,h=jc(r);return o=o||h.dataFormat,a=a||h.type,A=A||h.compressed,{width:n,height:s}=this._deduceImageSize(i,n,s),{dataFormat:o,type:a,compressed:A,width:n,height:s,format:r,data:i}}_deduceImageSize(e,r,i){let n;return typeof ImageData<"u"&&e instanceof ImageData?n={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?n={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?n={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?n={width:e.videoWidth,height:e.videoHeight}:e?n={width:r,height:i}:n={width:r>=0?r:1,height:i>=0?i:1},He(n,"Could not deduced texture size"),He(r===void 0||n.width===r,"Deduced texture width does not match supplied width"),He(i===void 0||n.height===i,"Deduced texture height does not match supplied height"),n}async setCubeMapImageData(e){let{gl:r}=this,{width:i,height:n,pixels:s,data:o,format:a=6408,type:A=5121}=e,h=s||o,g=await Promise.all(t.FACES.map(_=>{let x=h[_];return Promise.all(Array.isArray(x)?x:[x])}));this.bind(),t.FACES.forEach((_,x)=>{g[x].length>1&&this.props.mipmaps!==!1&&le.warn(`${this.id} has mipmap and multiple LODs.`)(),g[x].forEach((T,v)=>{i&&n?r.texImage2D(_,v,a,i,n,0,a,A,T):r.texImage2D(_,v,a,a,A,T)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:i,height:n,pixels:s,data:o,format:a=6408,type:A=5121}=e,{gl:h}=this,g=s||o;return this.bind(),g instanceof Promise?g.then(_=>this.setImageDataForFace(Object.assign({},e,{face:r,data:_,pixels:_}))):this.width||this.height?h.texImage2D(r,0,a,i,n,0,a,A,g):h.texImage2D(r,0,a,a,A,g),this}setImageData3D(e){let{level:r=0,dataFormat:i,format:n,type:s,width:o,height:a,depth:A=1,offset:h=0,data:g,parameters:_={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let x=jc(n);if(Wi(this.gl,_,()=>{ArrayBuffer.isView(g)&&this.gl.texImage3D(this.target,r,x.format,o,a,A,0,x.dataFormat,x.type,g),g instanceof ti&&(this.gl.bindBuffer(35052,g.handle),this.gl.texImage3D(this.target,r,i,o,a,A,0,n,s,h))}),g&&g.byteLength)this.trackAllocatedMemory(g.byteLength,"Texture");else{let T=X2(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*T,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Zs(e)){xV(e),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(e)){let n=Number(r),s=i;switch(n){case 33082:case 33083:this.gl.texParameterf(this.target,n,s);break;default:this.gl.texParameteri(this.target,n,s);break}}this.gl.bindTexture(this.target,null)}}};function yV(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function xV(t){le.log(1,"texture sampler parameters",t)()}var Qn=class extends oa{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let i=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let n=this.gl.bindFramebuffer(36160,this.handle);for(let s=0;sle.info("Spector capture started:",e)()),pi?.onCapture.add(e=>{le.info("Spector capture complete:",e)(),pi?.getResultUI(),pi?.resultView.display(),pi?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return pi;pi?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{le.info("Spector capture stopped after 2 seconds")(),pi?.stopCapture()})}return pi}var wV="https://unpkg.com/webgl-debug@2.0.1/index.js";function qw(t){return t.luma=t.luma||{},t.luma}async function Kw(){Hr()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await JA(wV))}function Jw(t,e={}){return t?e.debug?MV(t,e):CV(t):null}function CV(t){let e=qw(t);return e.realContext?e.realContext:t}function MV(t,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),t;let r=qw(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...po,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,PV.bind(null,e),IV.bind(null,e));for(let o in po)!(o in i)&&typeof po[o]=="number"&&(i[o]=po[o]);class n{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(n,i);let s=Object.create(n);return r.realContext=t,r.debugContext=s,s.debug=!0,s}function q2(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function PV(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let n=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),o=`${n} in gl.${r}(${s})`;le.error(o)();debugger;if(t.throwOnError)throw new Error(o)}function IV(t,e,r){let i="";if(le.level>=1&&(i=q2(e,r),le.log(1,i)()),t.break&&t.break.length>0&&(i=i||q2(e,r),t.break.every(s=>i.indexOf(s)!==-1)))debugger;for(let n of r)if(n===void 0){if(i=i||q2(e,r),t.throwOnError)throw new Error(`Undefined argument: ${i}`);le.error(`Undefined argument: ${i}`)();debugger}}function $w(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let n=i.split(":");if(n.length===2){let[_,x]=n;r.push({message:x.trim(),type:Zw(_),lineNum:0,linePos:0});continue}let[s,o,a,...A]=n,h=parseInt(a,10);isNaN(h)&&(h=0);let g=parseInt(o,10);isNaN(g)&&(g=0),r.push({message:A.join(":").trim(),type:Zw(s),lineNum:h,linePos:g})}return r}function Zw(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var Ed=class extends na{device;handle;constructor(e,r){switch(super(e,r),this.device=e,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)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return $w(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(n=>n.startsWith("#version ")?n:`#version 100 +${n}`)(e);let{gl:i}=this.device;if(i.shaderSource(this.handle,e),i.compileShader(this.handle),le.level===0){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}le.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),le.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async n=>await new Promise(s=>setTimeout(s,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var RV=256,BV=1024,OV=16384,K2=6144,FV=[1,2,4,8],vd=class extends HA{device;glParameters;constructor(e,r){super(e,r),this.device=e,go(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Es(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=FV.map(i=>!!(i&e.colorMask))),this.glParameters=r,un(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=OV,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=RV,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=BV,e.clearStencil=this.props.clearStencil),r!==0&&Wi(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){Wi(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(K2,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(K2,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(K2,e,r);break}})}};var LV="Failed to deduce GL constant from typed array";function eC(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(LV)}}function Vu(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var NV={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},DV={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Sd=class t{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Vu(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return He(e.size),Vu(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new t(NV,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return t.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return t.getBytesPerVertex(this)}_assign(e={}){return e=k1("Accessor",e,DV),e.type!==void 0&&(this.type=e.type,(e.type===5124||e.type===5125)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function tC(t){return UV.includes(t)}var UV=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],rC={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function J2(t){let e=rC[t];if(!e)throw new Error("uniform");let[r,i,,n]=e;return{format:n,components:i,glType:r}}function iC(t){let e=rC[t];if(!e)throw new Error("attribute");let[,r,,i,n]=e;return{attributeType:i,vertexFormat:n,components:r}}function nC(t,e){let r={attributes:[],bindings:[]};r.attributes=kV(t,e);let i=HV(t,e);for(let a of i){let A=a.uniforms.map(h=>({name:h.name,format:h.format,byteOffset:h.byteOffset,byteStride:h.byteStride,arrayLength:h.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:A})}let n=zV(t,e),s=0;for(let a of n)if(tC(a.type)){let{viewDimension:A,sampleType:h}=WV(a.type);r.bindings.push({type:"texture",name:a.name,location:s,viewDimension:A,sampleType:h}),a.textureUnit=s,s+=1}n.length&&(r.uniforms=n);let o=VV(t,e);return o?.length&&(r.varyings=o),r}function kV(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let n=0;n=0){let{attributeType:h}=iC(a),g=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:A,stepMode:g,type:h})}}return r.sort((n,s)=>n.location-s.location),r}function VV(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let n=0;nn.location-s.location),r}function zV(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let n=0;n1)for(let T=0;Tt.getActiveUniformBlockParameter(e,s,o),i=[],n=t.getProgramParameter(e,35382);for(let s=0;ss.location-o.location),i}var GV={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function WV(t){let e=GV[t];if(!e)throw new Error("sampler");let[r,i]=e;return{viewDimension:r,sampleType:i}}function jV(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:!!r[2]}}function sC(t,e,r,i){let n=t,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(r){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 t.uniform1i(e,i);case 5126:return t.uniform1fv(e,o);case 35664:return t.uniform2fv(e,o);case 35665:return t.uniform3fv(e,o);case 35666:return t.uniform4fv(e,o);case 5124:return t.uniform1iv(e,o);case 35667:return t.uniform2iv(e,o);case 35668:return t.uniform3iv(e,o);case 35669:return t.uniform4iv(e,o);case 35670:return t.uniform1iv(e,o);case 35671:return t.uniform2iv(e,o);case 35672:return t.uniform3iv(e,o);case 35673:return t.uniform4iv(e,o);case 5125:return n.uniform1uiv(e,o,1);case 36294:return n.uniform2uiv(e,o,2);case 36295:return n.uniform3uiv(e,o,3);case 36296:return n.uniform4uiv(e,o,4);case 35674:return t.uniformMatrix2fv(e,!1,o);case 35675:return t.uniformMatrix3fv(e,!1,o);case 35676:return t.uniformMatrix4fv(e,!1,o);case 35685:return n.uniformMatrix2x3fv(e,!1,o);case 35686:return n.uniformMatrix2x4fv(e,!1,o);case 35687:return n.uniformMatrix3x2fv(e,!1,o);case 35688:return n.uniformMatrix3x4fv(e,!1,o);case 35689:return n.uniformMatrix4x2fv(e,!1,o);case 35690:return n.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function oC(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(t)}}function aC(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(t)}}var cC=4,wd=class extends Vn{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:i,bufferMode:n=35981}=r;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,n)),this._linkShaders(),le.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=nC(this.device.gl,this.handle),le.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=L1(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":le.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[i,n]of Object.entries(e)){let s=this.shaderLayout.bindings.find(o=>o.name===i)||this.shaderLayout.bindings.find(o=>o.name===`${i}Uniforms`);if(!s){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||le.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(n||le.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),s.type){case"uniform":if(!(n instanceof ti)&&!(n.buffer instanceof ti))throw new Error("buffer value");break;case"texture":if(!(n instanceof fn||n instanceof di||n instanceof Qn))throw new Error("texture value");break;case"sampler":le.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(s.type)}this.bindings[i]=n}}draw(e){let{renderPass:r,parameters:i=this.props.parameters,topology:n=this.props.topology,vertexArray:s,vertexCount:o,instanceCount:a,isInstanced:A=!1,firstVertex:h=0,transformFeedback:g}=e,_=oC(n),x=!!s.indexBuffer,T=s.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return le.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return le.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return le.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),s.bindBeforeRender(r),g&&g.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let v=r;return Ww(this.device,i,v.glParameters,()=>{x&&A?this.device.gl.drawElementsInstanced(_,o||0,T,h,a||0):x?this.device.gl.drawElements(_,o||0,T,h):A?this.device.gl.drawArraysInstanced(_,h,o||0,a||0):this.device.gl.drawArrays(_,h,o||0),g&&g.end()}),s.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=KA(e);Object.keys(r).forEach(i=>{le.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),le.time(cC,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),le.timeEnd(cC,`linkProgram for ${this.id}`)(),le.level,!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}le.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),le.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async n=>await new Promise(s=>setTimeout(s,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof di&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=0;for(let n of this.shaderLayout.bindings){let s=this.bindings[n.name]||this.bindings[n.name.replace(/Uniforms$/,"")];if(!s)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":let{name:o}=n,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,a),s instanceof ti?e.bindBufferBase(35345,i,s.handle):e.bindBufferRange(35345,i,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),i+=1;break;case"texture":if(!(s instanceof fn||s instanceof di||s instanceof Qn))throw new Error("texture");let A;if(s instanceof fn)A=s.texture;else if(s instanceof di)A=s;else if(s instanceof Qn&&s.colorAttachments[0]instanceof fn)le.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),A=s.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(A.target,A.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:n,textureUnit:s}=e,o=this.uniforms[r]??s;o!==void 0&&sC(this.device.gl,i,n,o)}}};var Cd=class extends WA{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":XV(this.device,r.options);break;case"copy-buffer-to-texture":YV(this.device,r.options);break;case"copy-texture-to-buffer":QV(this.device,r.options);break;case"copy-texture-to-texture":qV(this.device,r.options);break}}};function XV(t,e){let r=e.source,i=e.destination;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function YV(t,e){throw new Error("Not implemented")}function QV(t,e){let{source:r,mipLevel:i=0,aspect:n="all",width:s=e.source.width,height:o=e.source.height,depthOrArrayLayers:a=0,origin:A=[0,0],destination:h,byteOffset:g=0,bytesPerRow:_,rowsPerImage:x}=e;if(n!=="all")throw new Error("not supported");if(i!==0||a!==0||_||x)throw new Error("not implemented");let{framebuffer:T,destroyFramebuffer:v}=lC(r),S;try{let C=h,M=s||T.width,R=o||T.height,B=jc(T.texture.props.format),k=B.dataFormat,Q=B.type;t.gl.bindBuffer(35051,C.handle),S=t.gl.bindFramebuffer(36160,T.handle),t.gl.readPixels(A[0],A[1],M,R,k,Q,g)}finally{t.gl.bindBuffer(35051,null),S!==void 0&&t.gl.bindFramebuffer(36160,S),v&&T.destroy()}}function qV(t,e){let{source:r,destinationMipLevel:i=0,origin:n=[0,0],destinationOrigin:s=[0,0],destination:o}=e,{width:a=e.destination.width,height:A=e.destination.height}=e,{framebuffer:h,destroyFramebuffer:g}=lC(r),[_,x]=n,[T,v,S]=s,C=t.gl.bindFramebuffer(36160,h.handle),M=null,R;if(o instanceof di)M=o,a=Number.isFinite(a)?a:M.width,A=Number.isFinite(A)?A:M.height,M.bind(0),R=M.target;else throw new Error("invalid destination");switch(R){case 3553:case 34067:t.gl.copyTexSubImage2D(R,i,T,v,_,x,a,A);break;case 35866:case 32879:t.gl.copyTexSubImage3D(R,i,T,v,S,_,x,a,A);break;default:}M&&M.unbind(),t.gl.bindFramebuffer(36160,C),g&&h.destroy()}function lC(t){if(t instanceof $t){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var Md=class extends GA{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new Cd(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,i){}};var Pd=class t extends jA{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Dm()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:n,type:s,stride:o,offset:a,normalized:A,integer:h,divisor:g}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),h?this.device.gl.vertexAttribIPointer(e,n,s,o,a):this.device.gl.vertexAttribPointer(e,n,s,A,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,g||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:n,byteLength:s,byteOffset:o}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=n,le.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:n,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,n,o,s)}getBuffer(e){if(AC(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof ti)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:n}}_getVaryingIndex(e){if(AC(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:i,byteOffset:n}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,n,i)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,n){let s=r&&r.handle;!s||n===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,n)}};function AC(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var Rd=class extends YA{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,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;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((i,n)=>{let s=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):r++>e?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(s)};requestAnimationFrame(s)}),this._pollingPromise}};function Z2(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return He(!1),0}}function uC(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return He(!1),0}}function fC(t,e){let{sourceX:r=0,sourceY:i=0,sourceFormat:n=6408,sourceAttachment:s=36064}=e||{},{target:o=null,sourceWidth:a,sourceHeight:A,sourceType:h}=e||{},{framebuffer:g,deleteFramebuffer:_}=dC(t);He(g);let{gl:x,handle:T}=g;a=a||g.width,A=A||g.height;let v=s-36064;h=h||g.colorAttachments[v]?.texture?.type||5121,o=$V(o,h,n,a,A),h=h||eC(o);let S=x.bindFramebuffer(36160,T);return x.readPixels(r,i,a,A,n,h,o),x.bindFramebuffer(36160,S||null),_&&g.destroy(),o}function hC(t,e){let{target:r,sourceX:i=0,sourceY:n=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:A,sourceType:h}=e||{},{framebuffer:g,deleteFramebuffer:_}=dC(t);He(g),a=a||g.width,A=A||g.height;let x=g;h=h||5121;let T=r;if(!T){let S=Z2(s),C=uC(h),M=o+a*A*S*C;T=x.device.createBuffer({byteLength:M})}let v=t.device.createCommandEncoder();return v.copyTextureToBuffer({source:t,width:a,height:A,origin:[i,n],destination:T,byteOffset:o}),v.destroy(),_&&g.destroy(),T}function dC(t){return t instanceof oa?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:ZV(t),deleteFramebuffer:!0}}function ZV(t,e){let{device:r,width:i,height:n,id:s}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:n,colorAttachments:[t]})}function $V(t,e,r,i,n){if(t)return t;e=e||5121;let s=Vu(e,{clamped:!1}),o=Z2(r);return new s(i*n*o)}var ez=256,tz=1024,rz=16384;var iz="clear: bad arguments";function pC(t,e){let{framebuffer:r=null,color:i=null,depth:n=null,stencil:s=null}=e||{},o={};r&&(o.framebuffer=r);let a=0;i&&(a|=rz,i!==!0&&(o.clearColor=i)),n&&(a|=ez,n!==!0&&(o.clearDepth=n)),s&&(a|=tz,n!==!0&&(o.clearStencil=n)),He(a!==0,iz);let A=t.gl;Wi(A,o,()=>{A.clear(a)})}var zu=1,wa=class t extends fs{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof t)return e;if(e?.device instanceof fs)return e.device;if(!nz(e))throw new Error("Invalid WebGL2RenderingContext");return new t({gl:e})}static async create(e={}){le.groupCollapsed(zu,"WebGLDevice created")();let r=[];e.debug&&r.push(Kw()),e.spector&&r.push(Yw()),typeof e.canvas=="string"&&r.push(ra.pageLoaded);let i=await Promise.allSettled(r);for(let o of i)o.status==="rejected"&&le.error(`Failed to initialize debug libraries ${o.reason}`)();if(le.probe(zu+1,"DOM is loaded")(),e.gl?.device)return le.warn("reattaching existing device")(),t.attach(e.gl);let n=new t(e),s=`Created ${n.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return le.probe(zu,s)(),le.table(zu,n.info)(),le.groupEnd(zu)(),n}constructor(e){super({...e,id:e.id||pr("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let i=e.gl?.canvas||e.canvas;this.canvasContext=new Td(this,{...e,canvas:i}),this.lost=new Promise(a=>{this._resolveContextLost=a});let n=e.gl||null;if(n||=Rw(this.canvasContext.canvas,{...e,onContextLost:a=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!n)throw new Error("WebGL context creation failed");this.handle=n,this.gl=n,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=Qw({...this.props,canvas:this.handle.canvas})),this.info=Bw(this.gl,this._extensions),this.limits=new _d(this.gl),this.features=new md(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:s=!0,copyState:o=!1}=e;V2(this.gl,{enable:s,copyState:o,log:(...a)=>le.log(1,...a)()}),e.debug&&(this.gl=Jw(this.gl,{...e,throwOnError:!0}),this.debug=!0,le.level=Math.max(le.level,1),le.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return gd(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return kw(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return Vw(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new ti(this,r)}_createTexture(e){return new di(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new Sa(this,e)}createShader(e){return new Ed(this,e)}createFramebuffer(e){return new Qn(this,e)}createVertexArray(e){return new Pd(this,e)}createTransformFeedback(e){return new Id(this,e)}createQuerySet(e){return new Rd(this,e)}createRenderPipeline(e){return new wd(this,e)}beginRenderPass(e){return new vd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new Md(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return fC(e,r)}readPixelsToBufferWebGL(e,r){return hC(e,r)}setParametersWebGL(e){un(this.gl,e)}getParametersWebGL(e){return Ad(this.gl,e)}withParametersWebGL(e,r){return Wi(this.gl,e,r)}clearWebGL(e){pC(this,e)}resetWebGL(){le.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Mw(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){go(this.gl)}popState(){Es(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let i=Number(e);for(let n in r)if(r[n]===i)return`GL.${n}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let n=this._constants[e];switch(n&&cz(n,r)&&le.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:sz(this,e,r);break;case Int32Array:oz(this,e,r);break;case Uint32Array:az(this,e,r);break;default:He(!1)}}getExtension(e){return Gi(this.gl,e,this._extensions),this._extensions}};function nz(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&Number.isFinite(t._version))}function sz(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:He(!1)}}function oz(t,e,r){t.gl.vertexAttribI4iv(e,r)}function az(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function cz(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r0&&i.type==="pointerdown"&&(Az(n,s=>s.pointerId===i.pointerId)||n.push(i)),e.call(this,i)}}function _C(t){t.prototype.handler=function(r){let i=lz[r.type];i&1&&r.button>=0&&(this.pressed=!0),i&2&&r.buttons===0&&(i=4),this.pressed&&(i&4&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}mC(Ca.PointerEventInput);_C(Ca.MouseInput);var yC=Ca.Manager,hn=Ca;var dn=class{constructor(e,r,i){this.element=e,this.callback=r,this.options={enable:!0,...i}}};var xC=hn?[[hn.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[hn.Rotate,{enable:!1}],[hn.Pinch,{enable:!1}],[hn.Swipe,{enable:!1}],[hn.Pan,{threshold:0,enable:!1}],[hn.Press,{enable:!1}],[hn.Tap,{event:"doubletap",taps:2,enable:!1}],[hn.Tap,{event:"anytap",enable:!1}],[hn.Tap,{enable:!1}]]:null,$2={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},bC={doubletap:["tap"]},TC={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Xc={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},EC={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ey={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var vC=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Ma=typeof window<"u"?window:global;var Od=!1;try{let t={get passive(){return Od=!0,!0}};Ma.addEventListener("test",null,t),Ma.removeEventListener("test",null)}catch{Od=!1}var uz=vC.indexOf("firefox")!==-1,{WHEEL_EVENTS:fz}=Xc,SC="wheel",wC=4.000244140625,hz=40,dz=.25,Hu=class extends dn{constructor(e,r,i){super(e,r,i),this.handleEvent=n=>{if(!this.options.enable)return;let s=n.deltaY;Ma.WheelEvent&&(uz&&n.deltaMode===Ma.WheelEvent.DOM_DELTA_PIXEL&&(s/=Ma.devicePixelRatio),n.deltaMode===Ma.WheelEvent.DOM_DELTA_LINE&&(s*=hz)),s!==0&&s%wC===0&&(s=Math.floor(s/wC)),n.shiftKey&&s&&(s=s*dz),this.callback({type:SC,center:{x:n.clientX,y:n.clientY},delta:-s,srcEvent:n,pointerType:"mouse",target:n.target})},this.events=(this.options.events||[]).concat(fz),this.events.forEach(n=>e.addEventListener(n,this.handleEvent,Od?{passive:!1}:!1))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===SC&&(this.options.enable=r)}};var{MOUSE_EVENTS:pz}=Xc,CC="pointermove",MC="pointerover",PC="pointerout",IC="pointerenter",RC="pointerleave",Gu=class extends dn{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:n}=this.options;this.enableMoveEvent=n,this.enableLeaveEvent=n,this.enableEnterEvent=n,this.enableOutEvent=n,this.enableOverEvent=n,this.events=(this.options.events||[]).concat(pz),this.events.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===CC&&(this.enableMoveEvent=r),e===MC&&(this.enableOverEvent=r),e===PC&&(this.enableOutEvent=r),e===IC&&(this.enableEnterEvent=r),e===RC&&(this.enableLeaveEvent=r)}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit(MC,e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit(PC,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit(IC,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit(RC,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(CC,e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var{KEY_EVENTS:gz}=Xc,BC="keydown",OC="keyup",Wu=class extends dn{constructor(e,r,i){super(e,r,i),this.handleEvent=n=>{let s=n.target||n.srcElement;s.tagName==="INPUT"&&s.type==="text"||s.tagName==="TEXTAREA"||(this.enableDownEvent&&n.type==="keydown"&&this.callback({type:BC,srcEvent:n,key:n.key,target:n.target}),this.enableUpEvent&&n.type==="keyup"&&this.callback({type:OC,srcEvent:n,key:n.key,target:n.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(gz),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===BC&&(this.enableDownEvent=r),e===OC&&(this.enableUpEvent=r)}};var FC="contextmenu",ju=class extends dn{constructor(e,r,i){super(e,r,i),this.handleEvent=n=>{this.options.enable&&this.callback({type:FC,center:{x:n.clientX,y:n.clientY},srcEvent:n,pointerType:"mouse",target:n.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e===FC&&(this.options.enable=r)}};var mz={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},_z=0,yz=1,xz=2,bz=1,Tz=2,Ez=4;function LC(t){let e=mz[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,n=!1,s=!1,o=!1;return e===2?(n=!!(r&bz),s=!!(r&Ez),o=!!(r&Tz)):(n=i===_z,s=i===yz,o=i===xz),{leftButton:n,middleButton:s,rightButton:o}}function NC(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),n=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(r.x-i.left-e.clientLeft)/n,y:(r.y-i.top-e.clientTop)/s};return{center:r,offsetCenter:o}}var ty={srcElement:"root",priority:0},Xu=class{constructor(e){this.handleEvent=r=>{if(this.isEmpty())return;let i=this._normalizeEvent(r),n=r.srcEvent.target;for(;n&&n!==i.rootElement;){if(this._emit(i,n),i.handled)return;n=n.parentNode}this._emit(i,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,n=!1,s=!1){let{handlers:o,handlersByElement:a}=this,A=ty;typeof i=="string"||i&&i.addEventListener?A={...ty,srcElement:i}:i&&(A={...ty,...i});let h=a.get(A.srcElement);h||(h=[],a.set(A.srcElement,h));let g={type:e,handler:r,srcElement:A.srcElement,priority:A.priority};n&&(g.once=!0),s&&(g.passive=!0),o.push(g),this._active=this._active||!g.passive;let _=h.length-1;for(;_>=0&&!(h[_].priority>=g.priority);)_--;h.splice(_+1,0,g)}remove(e,r){let{handlers:i,handlersByElement:n}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===r){i.splice(s,1);let a=n.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&n.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let n=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,n=!0},a=[];for(let A=0;A{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var vz={events:null,recognizers:null,recognizerOptions:{},Manager:yC,touchAction:"none",tabIndex:0},Yc=class{constructor(e=null,r){this._onBasicInput=n=>{let{srcEvent:s}=n,o=TC[s.type];o&&this.manager.emit(o,n)},this._onOtherEvent=n=>{this.manager.emit(n.type,n)},this.options={...vz,...r},this.events=new Map,this.setElement(e);let{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;let{options:r}=this,i=r.Manager;this.manager=new i(e,{touchAction:r.touchAction,recognizers:r.recognizers||xC}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys($2).forEach(n=>{let s=this.manager.get(n);s&&$2[n].forEach(o=>{s.recognizeWith(o)})});for(let n in r.recognizerOptions){let s=this.manager.get(n);if(s){let o=r.recognizerOptions[n];delete o.enable,s.set(o)}}this.wheelInput=new Hu(e,this._onOtherEvent,{enable:!1}),this.moveInput=new Gu(e,this._onOtherEvent,{enable:!1}),this.keyInput=new Wu(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new ju(e,this._onOtherEvent,{enable:!1});for(let[n,s]of this.events)s.isEmpty()||(this._toggleRecognizer(s.recognizerName,!0),this.manager.on(n,s.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let n=i.get(e);if(n&&n.options.enable!==r){n.set({enable:r});let s=bC[e];s&&!this.options.recognizers&&s.forEach(o=>{let a=i.get(o);r?(a.requireFailure(e),n.dropRequireFailure(o)):a.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,r),this.moveInput.enableEventType(e,r),this.keyInput.enableEventType(e,r),this.contextmenuInput.enableEventType(e,r)}_addEventHandler(e,r,i,n,s){if(typeof e!="string"){i=r;for(let g in e)this._addEventHandler(g,e[g],i,n,s);return}let{manager:o,events:a}=this,A=ey[e]||e,h=a.get(A);h||(h=new Xu(this),a.set(A,h),h.recognizerName=EC[A]||A,o&&o.on(A,h.handleEvent)),h.add(e,r,i,n,s),h.isEmpty()||this._toggleRecognizer(h.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let o in e)this._removeEventHandler(o,e[o]);return}let{events:i}=this,n=ey[e]||e,s=i.get(n);if(s&&(s.remove(e,r),s.isEmpty())){let{recognizerName:o}=s,a=!1;for(let A of i.values())if(A.recognizerName===o&&!A.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function mo(){}var Sz=({isDragging:t})=>t?"grabbing":"grab",DC={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:mo,onWebGLInitialized:mo,onResize:mo,onViewStateChange:mo,onInteractionStateChange:mo,onBeforeRender:mo,onAfterRender:mo,onLoad:mo,onError:t=>me.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Sz,getTooltip:null,debug:!1,drawPickingColors:!1},vs=class{static{this.defaultProps=DC}static{this.VERSION=WE}constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Gr({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=i=>{let{_pickRequest:n}=this;if(i.type==="pointerleave")n.x=-1,n.y=-1,n.radius=0;else{if(i.leftButton||i.rightButton)return;{let s=i.offsetCenter;if(!s)return;n.x=s.x,n.y=s.y,n.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:n.x,y:n.y}),n.event=i},this._onEvent=i=>{let n=lu[i.type],s=i.offsetCenter;if(!n||!s||!this.layerManager)return;let o=this.layerManager.getLayers(),a=this.deckPicker.getLastPickedObject({x:s.x,y:s.y,layers:o,viewports:this.getViewports(s)},this._lastPointerDownInfo),{layer:A}=a,h=A&&(A[n.handler]||A.props[n.handler]),g=this.props[n.handler],_=!1;h&&(_=h.call(A,a,i)),_||(g?.(a,i),this.widgetManager.onEvent(a,i))},this._onPointerDown=i=>{let n=i.offsetCenter,s=this._pick("pickObject","pickObject Time",{x:n.x,y:n.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=s.result[0]||s.emptyInfo},this.props={...DC,...e},e=this.props,e.viewState&&e.initialViewState&&me.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&me.error("WebGL1 context not supported.")(),this.device=wa.attach(e.gl));let r=this.device;r||(hs.registerDevices([wa]),r=hs.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&cn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&me.removed("onLayerHover","onHover")(),"onLayerClick"in e&&me.removed("onLayerClick","onClick")(),e.initialViewState&&!er(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(r),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),n=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return r=r||i||n||s||o,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Rt(this.viewManager),this.viewManager.views}getViewports(e){return Rt(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,r,i){Rt(this.deckPicker);let{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(r).timeStart();let s=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return n.get(r).timeEnd(),s}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),Rt(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let n=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=n}if(i||i===0){let n=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=n}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:n,useDevicePixels:s}=r;return new _u({device:e,useDevicePixels:s,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:n})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new ho({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let{result:r,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=r.length>0;let n=i,s=!1;for(let o of r)n=o,s=o.layer?.onHover(o,e.event)||s;s||(this.props.onHover?.(n,e.event),this.widgetManager.onHover(n,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof wa&&this.props.onWebGLInitialized(this.device.gl);let r=new _a;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new Yc(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let n in lu)this.eventManager.on(n,this._onEvent);this.viewManager=new Tu({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new bu(this.device,{deck:this,stats:this.stats,viewport:i,timeline:r}),this.effectManager=new Pu({deck:this,device:this.device}),this.deckRenderer=new Ru(this.device),this.deckPicker=new Bu(this.device),this.widgetManager=new ld({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Ou),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:n}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:n});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(s),s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:n})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),me.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=hs.stats.get("Memory Usage");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};function UC(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return qA(t)}}var kC=g0;function Yu(t,e){return{attribute:t,format:e.size>1?`${e.type}x${e.size}`:e.type,byteOffset:e.offset||0}}function _o(t){return t.stride||t.size*t.bytesPerElement}function VC(t,e){return t.type===e.type&&t.size===e.size&&_o(t)===_o(e)&&(t.offset||0)===(e.offset||0)}function ry(t,e){e.offset&&me.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=_o(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,n=e.elementOffset||0,s=i*r+n*t.bytesPerElement+(t.offset||0);return{...e,offset:s,stride:r}}function wz(t,e){let r=ry(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Qu=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let n=r.logicalType||r.type,s=n==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!n&&r.isIndexed?a="uint32":a=n||"float32";let A=UC(n||a);this.doublePrecision=s,s&&r.fp64===!1&&(A=Float32Array),this.value=null,this.settings={...r,defaultType:A,defaultValue:o,logicalType:n,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:A.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*_o(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),cn.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let n=this.value;if(r){let s=ry(this.getAccessor(),r),o=s.offset/n.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=n.subarray(o,o+a)}else i[e]=n}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),n=[],s={name:this.id,byteStride:_o(i),attributes:n};if(this.doublePrecision){let o=wz(i,r||{});n.push(Yu(e,{...i,...o.high}),Yu(`${e}64Low`,{...i,...o.low}))}else if(r){let o=ry(i,r);n.push(Yu(e,{...i,...o}))}else n.push(Yu(e,i));return s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:n}=this,s=i*n;if(r&&s&&r.length>=s){let o=new Array(n).fill(1/0),a=new Array(n).fill(-1/0);for(let A=0;Aa[h]&&(a[h]=g)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof gt?i={buffer:e}:i=e;let n={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)n.type="float32";else{let o=kC(i.value);n.type=n.normalized?o.replace("int","norm"):o}n.bytesPerElement=i.value.BYTES_PER_ELEMENT,n.stride=_o(n)}if(r.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!r.constant||!this._areValuesEqual(s,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;r.externalBuffer=s,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value;r.externalBuffer=null,r.constant=!1,this.value=s;let{buffer:o}=this,a=_o(n),A=(n.vertexOffset||0)*a;if(this.doublePrecision&&s instanceof Float64Array&&(s=rd(s,n)),this.settings.isIndexed){let g=this.settings.defaultType;s.constructor!==g&&(s=new g(s))}let h=s.byteLength+A+a*2;(!o||o.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:n,size:s}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let o=s;for(;--o>=0;)r[i+o]=n[o];return r}switch(s){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:n[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:n[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:n[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:n[0];break;default:let o=s;for(;--o>=0;)r[i+o]=Number.isFinite(e[o])?e[o]:n[o]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let n=0;n0&&(HC.length=t.length,i=HC):i=zC,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),n.index=e-1),{iterable:i,objectInfo:n}}function Fd(t){return t&&t[Symbol.asyncIterator]}function Ld(t,e){let{size:r,stride:i,offset:n,startIndices:s,nested:o}=e,a=t.BYTES_PER_ELEMENT,A=i?i/a:r,h=n?n/a:0,g=Math.floor((t.length-h)/A);return(_,{index:x,target:T})=>{if(!s){let M=x*A+h;for(let R=0;R=e[1]))return t;let r=[],i=t.length,n=0;for(let s=0;se[1]?r.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return r.splice(n,0,e),r}var Mz={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Nd(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...Mz[r],...e,...t,type:r}}var Pa=class extends Qu{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:qu}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){this.state.layoutChanged||=!VC(e,this.getAccessor()),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,n=Array.isArray(r)?e[r.find(s=>e[s])]:e[r];return Nd(n,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:n=1/0}=r;this.state.updateRanges=WC(this.state.updateRanges,[i,n])}else this.state.updateRanges=qu}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=GC}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==qu),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:n}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,A=!0;if(o){for(let[h,g]of s)o.call(n,this,{data:r,startRow:h,endRow:g,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthg?h.set(B,S):(e._normalizeValue(B,M.target,0),R2({target:h,source:M.target,start:S,count:k}));S+=k*g}else e._normalizeValue(B,h,S),S+=g}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function iy(t){let{source:e,target:r,start:i=0,size:n,getData:s}=t,o=t.end||r.length,a=e.length,A=o-i;if(a>A){r.set(e.subarray(0,A),i);return}if(r.set(e,i),!s)return;let h=a;for(;hi(g+a,_)),h=Math.min(n.length,s.length);for(let g=1;ga}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,A=r.size*a,h=r.byteOffset,g=r.settings.bytesPerElement<4?h/r.settings.bytesPerElement*4:h,_=r.startIndices,x=s&&_,T=r.isConstant;if(!x&&e&&i>=n)return e;let v=r.value instanceof Float64Array?Float32Array:r.value.constructor,S=T?r.value:new v(r.getBuffer().readSyncWebGL(h,n*v.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!T){let B=o;o=(k,Q)=>r.normalizeConstant(B(k,Q))}let C=T?(B,k)=>o(S,k):(B,k)=>o(S.subarray(B+h,B+h+A),k),M=e?new Float32Array(e.readSyncWebGL(g,i*4).buffer):new Float32Array(0),R=new Float32Array(n);return jC({source:M,target:R,sourceStartIndices:s,targetStartIndices:_,size:A,getData:C}),(!e||e.byteLength0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},t4=`#version 300 es +`;function QC(t){return t.doublePrecision&&t.value instanceof Float64Array}function Rz(t,e){let r=e.size,i=Dd(r),n=Ud(r),s=e.getBufferLayout();return QC(e)?new co(t,{vs:Iz,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:n,byteOffset:0},{attribute:"aFrom64Low",format:n,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:n,byteOffset:0},{attribute:"aTo64Low",format:n,byteOffset:4*r}]}],modules:[ro],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new co(t,{vs:Pz,bufferLayout:[{name:"aFrom",format:n},{name:"aTo",format:s.attributes[0].format}],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}var Ju=class extends Qc{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="spring",this.texture=Lz(e),this.framebuffer=Nz(e,this.texture),this.transform=Fz(e,r)}start(e,r){let i=this.currentLength,n=this.currentStartIndices;super.start(e,r);let{buffers:s,attribute:o}=this;for(let A=0;A<2;A++)s[A]=zd({device:this.device,buffer:s[A],attribute:o,fromLength:i,toLength:this.currentLength,fromStartIndices:n,getData:e.enter});s[2]=Vd({device:this.device,source:s[0],target:s[2]}),this.setBuffer(s[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:e,transform:r,framebuffer:i,transition:n}=this,s=this.settings;r.model.setAttributes({aPrev:e[0],aCur:e[1]}),r.transformFeedback.setBuffers({vNext:e[2]}),r.model.setUniforms({stiffness:s.stiffness,damping:s.damping}),r.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),kd(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||n.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},Bz=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 @@ -914,7 +1221,7 @@ void main(void) { gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } -`,r4=`#version 300 es +`,Oz=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; @@ -926,7 +1233,7 @@ void main(void) { discard; } fragColor = vec4(1.0); -}`;function i4(t,e){let r=Ol(e.size),i=Nl(e.size);return new Xr(t,{vs:t4,fs:r4,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function s4(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function n4(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var o4={interpolation:Ho,spring:jo},Xo=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let s in e){let n=e[s],o=n.getTransitionSetting(r);o&&this._updateAttribute(s,n,o)}for(let s in this.transitions){let n=e[s];(!n||!n.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,i){let s=this.transitions[e],n=!s||s.type!==i.type;if(n){s&&this._removeTransition(e);let o=o4[i.type];o?this.transitions[e]=new o({attribute:r,timeline:this.timeline,device:this.device}):(U.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var M_="attributeManager.invalidate",a4="attributeManager.updateStart",c4="attributeManager.updateEnd",l4="attribute.updateStart",u4="attribute.allocate",f4="attribute.updateEnd",nr=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=Qt(W1),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Xo(e,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);ye(M_,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);ye(M_,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:s,props:n={},buffers:o={},context:a={}}){let c=!1;ye(a4,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=r,n[l]&&U.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(n[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:r,data:e,props:n,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&ye(c4,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(let n in r){let o=r[n];o.needsRedraw(e)&&!i.hasAttribute(n)&&(s[n]=o)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let s=e[i],n={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new ji(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:s}=this,n=s[e];return n&&n.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(ye(l4,r),r.constant){r.setConstantValue(r.value);return}r.allocate(i)&&ye(u4,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,ye(f4,r,i))}};var $o=class extends Dt{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:s,easing:n}}=this,o=n(e/s);this._value=Rt(r,i,o)}};var I_=1e-5;function O_(t,e,r,i,s){let n=e-t,a=(r-e)*s,c=-n*i;return a+c+n+e}function h4(t,e,r,i,s){if(Array.isArray(r)){let n=[];for(let o=0;o0}add(e,r,i,s){let{transitions:n}=this;if(n.has(e)){let c=n.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(s=Il(s),!s)return;let o=d4[s.type];if(!o){U.error(`unsupported transition type '${s.type}'`)();return}let a=new o(this.timeline);a.start({...s,fromValue:r,toValue:i}),n.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function D_(t){let e=t[vt];for(let r in e){let i=e[r],{validate:s}=i;if(s&&!s(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function L_(t,e){let r=qo({newProps:t,oldProps:e,propTypes:t[vt],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=g4(t,e),s=!1;return i||(s=m4(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:_4(t,e),transitionsChanged:p4(t,e)}}function p4(t,e){if(!t.transitions)return!1;let r={},i=t[vt],s=!1;for(let n in t.transitions){let o=i[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Nd(t[n],e[n],o)&&(r[n]=!0,s=!0)}return s?r:!1}function qo({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${s}.${n} added`;let o=Nd(t[n],e[n],i[n]);if(o)return`${s}.${n} ${o}`}for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${s}.${n} dropped`;if(!Object.hasOwnProperty.call(t,n)){let o=Nd(t[n],e[n],i[n]);if(o)return`${s}.${n} ${o}`}}return!1}function Nd(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function g4(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:s}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&s&&(r=s(t.data,e.data)||r),r}function m4(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&F_(t,e,"all"))return{all:!0};let r={},i=!1;for(let s in t.updateTriggers)s!=="all"&&F_(t,e,s)&&(r[s]=!0,i=!0);return i?r:!1}function _4(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;si.name==="project64"))){let i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let s in e.inject)i[s]=(i[s]||"")+e.inject[s];r.inject=i}return r}var T4={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Fd={};function B_(t,e,r,i){if(r instanceof Se)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let n=e.createTexture({...r,sampler:{...T4,...s,...i}});return Fd[n.id]=t,n}function U_(t,e){!e||!(e instanceof Se)||Fd[e.id]===t&&(e.delete(),delete Fd[e.id])}var E4={boolean:{validate(t,e){return!0},equal(t,e,r){return!!t==!!e}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||Dd(t)&&(t.length===3||t.length===4)},equal(t,e,r){return Le(t,e,1)}},accessor:{validate(t,e){let r=kl(t);return r==="function"||r===kl(e.value)},equal(t,e,r){return typeof e=="function"?!0:Le(t,e,1)}},array:{validate(t,e){return e.optional&&!t||Dd(t)},equal(t,e,r){let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Le(t,e,s):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Le(t,e,s):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:B_(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{U_(r.id,t)}}};function z_(t){let e={},r={},i={};for(let[s,n]of Object.entries(t)){let o=n?.deprecatedFor;if(o)i[s]=Array.isArray(o)?o:[o];else{let a=S4(s,n);e[s]=a,r[s]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function S4(t,e){switch(kl(e)){case"object":return Go(t,e);case"array":return Go(t,{type:"array",value:e,compare:!1});case"boolean":return Go(t,{type:"boolean",value:e});case"number":return Go(t,{type:"number",value:e});case"function":return Go(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Go(t,e){return"type"in e?{name:t,...E4[e.type],...e}:"value"in e?{name:t,type:kl(e.value),...e}:{name:t,type:"object",value:e}}function Dd(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function kl(t){return Dd(t)?"array":t===null?"null":typeof t}function V_(t,e){let r;for(let n=e.length-1;n>=0;n--){let o=e[n];"extensions"in o&&(r=o.extensions)}let i=Ld(t.constructor,r),s=Object.create(i);s[ws]=t,s[tr]={},s[Ft]={};for(let n=0;n{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||N4}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[ws]||this.component;let r=e[Ft]||{},i=e[tr]||e,s=e[br]||{};for(let n in r){let o=r[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(let n in i){let o=i[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(Rl(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let s=this.asyncProps[e];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let s=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(e,n,s),this._onResolve(e,n))}).catch(n=>{this._onError(e,n)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let s=i.pendingLoadCount,n=[],o=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(e,n,s)}this._onResolve(e,n)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let s=this.component&&this.component.props[vt];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Qo=class extends Jo{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,s=i?.props.fetch;return s?s(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let s=i.props.onDataLoad;e==="data"&&s&&s(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var F4="layer.changeFlag",D4="layer.initialize",L4="layer.update",k4="layer.finalize",B4="layer.matched",H_=2**24-1,U4=Object.freeze([]),z4=Qt(({oldViewport:t,viewport:e})=>t.equals(e)),or=new Uint8ClampedArray(0),V4={data:{type:"data",value:U4,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:i,loadOptions:s,signal:n})=>{let{resourceManager:o}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,n&&(s={...s,fetch:{...s?.fetch,signal:n}});let a=o.contains(t);return!a&&!s&&(o.add({resourceId:t,data:Lr(t,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):Lr(t,i,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:q.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ne=class extends Zo{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Yr.NO_STATE,this.parent=null}static{this.defaultProps=V4}static{this.layerName="Layer"}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){oe(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=sd(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,n,o]=vs(i,r.pixelProjectionMatrix);return e.length===2?[s,n]:[s,n,o]}unproject(e){return oe(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){oe(this.internalState);let i=this.internalState.viewport||this.context.viewport;return X1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(let r of this.getModels())r.updateModuleSettings(e)}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===q.DEFAULT||e===q.LNGLAT||e===q.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){oe(e instanceof Uint8Array);let[r,i,s]=e;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:k_(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=Fs(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=Fs(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let s of i)r.invalidateAll(s);else r.invalidateAll();if(r){let{props:s}=e,n=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||s.pickable||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!z4({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),s=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(or.length/4);if(this.internalState.usesPickingColorCache=!0,iH_&&U.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),or=Nt.allocate(or,r,{size:4,copy:!0,maxCount:Math.max(r,H_)});let s=Math.floor(or.length/4),n=[];for(let o=i;o(U.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Ko(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){ye(B4,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(ye(L4,this,e),!e)return;let r=this.props,i=this.context,s=this.internalState,n=i.viewport,o=this._updateUniformTransition();s.propsInTransition=o,i.viewport=s.viewport||n,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=n,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){ye(k4,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();let n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;let a=this.props.opacity;i.opacity=Math.pow(a,1/2.2);try{if(r){let{isActive:u,isAttribute:f}=r.picking;this.setModuleParameters(r),this.setShaderModuleProps({picking:{isActive:u,isAttribute:f}})}let{getPolygonOffset:c}=this.props,l=c&&c(i)||[0,0];o.device.setParametersWebGL({polygonOffset:l});for(let u of this.getModels())u.setParameters(s);o.device.withParametersWebGL(s,()=>{let u={renderPass:e,moduleParameters:r,uniforms:i,parameters:s,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)})}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let s in e)if(e[s]){let n=!1;switch(s){case"dataChanged":let o=e[s],a=r[s];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[s]||(r[s]=e[s],n=!0)}n&&ye(F4,this,s,e)}let i=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=L_(e,r);if(i.updateTriggersChanged)for(let s in i.updateTriggersChanged)i.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(i.transitionsChanged)for(let s in i.transitionsChanged)this.internalState.uniformTransitions.add(s,r[s],e[s],e.transitions?.[s]);return this.setChangeFlags(i)}validateProps(){D_(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new nr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:s}=e;this.setNeedsRedraw(),this._updateAttributes();let n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};o||(l.highlightedObjectColor=null),Array.isArray(c)&&(l.highlightColor=c),(r||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),s=i?i.getNeedsRedraw(e):!1;if(r=r||s,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};var W4="compositeLayer.renderLayers",et=class extends ne{static{this.layerName="CompositeLayer"}get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,s)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:_,operation:y,_subLayerProps:v}=this.props,T={id:"",updateTriggers:{},opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:_,operation:y},S=v&&e.id&&v[e.id],R=S&&S.updateTriggers,M=e.id||"sublayer";if(S){let F=this.props[vt],N=e.type?e.type._propTypes:{};for(let D in S){let L=N[D]||F[D];L&&L.type==="accessor"&&(S[D]=this.getSubLayerAccessor(S[D]))}}Object.assign(T,e,S),T.id=`${this.props.id}-${M}`,T.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...R};for(let F of g){let N=F.getSubLayerProps.call(this,F);N&&Object.assign(T,N,{updateTriggers:Object.assign(T.updateTriggers,N.updateTriggers)})}return T}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,s=!i||this.needsUpdate();if(s){let n=this.renderLayers();i=Tt(n,Boolean),this.internalState.subLayers=i}ye(W4,this,s,i);for(let n of i)n.parent=this}};var ei=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Nt,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:s,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(oe(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Ml(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:s,_attributeDefs:n,typedArrayManager:o}=this;for(let a in n)if(a in s)o.release(i[a]),i[a]=null;else{let c=n[a];c.copy=r,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:s,getGeometry:n}=this,{iterable:o,objectInfo:a}=$e(s,r,i);for(let c of o){a.index++;let l=n?n(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this,{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,i[h+1]=i[h]+(d?this.getGeometrySize(d):0)},a,c),s=i[i.length-1];else if(i=n.startIndices,s=i[n.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof ie){let f=this.positionSize*4;s=s||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;s=s||f.length/h}this._allocate(s,!!e),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=i[h],u.indexStart=r[h];let p=h{t.triggerRepaint(),i?.("")}}),o;return(!r||r.props.gl===e)&&(Object.assign(n,{gl:e,width:null,height:null,touchAction:"unset",viewState:Ds(t)}),r?.isInitialized?j_(r,t):n.onLoad=()=>{s?.(),j_(o,t)}),r?(o=r,r.setProps(n),r.userData.isExternal=!0):(o=new Sr(n),t.on("remove",()=>{Ud(t)})),o.userData.mapboxLayers=new Set,t.__deck=o,t.on("render",()=>{o.isInitialized&&X4(o,t)}),o}function j_(t,e){let r=()=>{t.isInitialized?$4(t,e):e.off("move",r)};e.on("move",r)}function Ud(t){t.__deck?.finalize(),t.__deck=null}function zd(t){return{...t,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...t.parameters},views:t.views||[new qr({id:"mapbox"})]}}function X_(t,e){t.userData.mapboxLayers.add(e),Vd(t)}function $_(t,e){t.userData.mapboxLayers.delete(e),Vd(t)}function Y_(t,e){Vd(t)}function K_(t,e,r){let{currentViewport:i}=t.userData,s=!1;i||(i=q_(t,e,!0),t.userData.currentViewport=i,s=!0),t.isInitialized&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:({layer:n})=>r.id===n.id||n.props.operation.includes("terrain"),clearStack:s,clearCanvas:!1})}function Ds(t){let{lng:e,lat:r}=t.getCenter(),i={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&j4(t,i),i}function j4(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let i=t.transform.height,{longitude:s,latitude:n,pitch:o}=e,a=r.x*Bd,c=(1-r.y)*Bd,l=r.z*Bd,u=Ze([s,n]),f=a-u[0],h=c-u[1],d=Math.sqrt(f*f+h*h),p=o*H4,g=1.5*i,_=p<.001?g*Math.cos(p)/l:g*Math.sin(p)/d;e.zoom=Math.log2(_);let y=g*Math.cos(p)/_,v=l-y;e.position=[0,0,v/Mi(n)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function q_(t,e,r=!0){return new er({id:"mapbox",x:0,y:0,width:t.width,height:t.height,...Ds(e),nearZMultiplier:r?.02:.1,nearZ:e.transform._nearZ/e.transform.height,farZ:e.transform._farZ/e.transform.height})}function X4(t,e){let{mapboxLayers:r,isExternal:i}=t.userData;if(i){let s=Array.from(r,u=>u.id),o=Tt(t.props.layers,Boolean).some(u=>u&&!s.includes(u.id)),a=t.getViewports(),c=a.findIndex(u=>u.id==="mapbox"),l=a.length>1||c<0;(o||l)&&(c>=0&&(a=a.slice(),a[c]=q_(t,e,!1)),t._drawLayers("mapbox-repaint",{viewports:a,layerFilter:u=>(!t.props.layerFilter||t.props.layerFilter(u))&&(u.viewport.id!=="mapbox"||!s.includes(u.layer.id)),clearCanvas:!1}))}t.userData.currentViewport=null}function $4(t,e){t.setProps({viewState:Ds(e)}),t.needsRedraw({clearRedrawFlags:!0})}function Vd(t){if(t.userData.isExternal)return;let e=[];t.userData.mapboxLayers.forEach(r=>{let i=r.props.type,s=new i(r.props);e.push(s)}),t.setProps({layers:e})}var ea=class{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,r){this.map=e,this.deck=Bl({map:e,gl:r,deck:this.props.deck}),X_(this.deck,this)}onRemove(){this.deck&&$_(this.deck,this)}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&Y_(this.deck,this)}render(){K_(this.deck,this.map,this)}};var Wd="__UNDEFINED__";function ta(t,e,r,i){if(!t||!e||!t.style||!t.style._loaded)return;let s=Tt(i,Boolean);if(r!==i){let a=Tt(r,Boolean),c=new Set(a.map(l=>l.id));for(let l of s)c.delete(l.id);for(let l of c)t.getLayer(l)&&t.removeLayer(l)}for(let a of s){let c=t.getLayer(a.id);c?c.implementation.setProps(a.props):t.addLayer(new ea({id:a.id,deck:e}),a.props.beforeId)}let n=t.style._order,o={};for(let a of s){let{beforeId:c}=a.props;(!c||!n.includes(c))&&(c=Wd),o[c]=o[c]||[],o[c].push(a.id)}for(let a in o){let c=o[a],l=a===Wd?n.length:n.indexOf(a),u=a===Wd?void 0:a;for(let f=c.length-1;f>=0;f--){let h=c[f],d=n.indexOf(h);d!==l-1&&(t.moveLayer(h,u),d>l&&l++),l--,u=h}}}var Ls=class{constructor(e){this._handleStyleChange=()=>{ta(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:s,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${s}px`,height:`${n}px`})}},this._updateViewState=()=>{let s=this._deck;s&&(s.setProps({viewState:Ds(this._map)}),s.isInitialized&&s.redraw())},this._handleMouseEvent=s=>{let n=this._deck;if(!n||!n.isInitialized)return;let o={type:s.type,offsetCenter:s.point,srcEvent:s},a=this._lastMouseDownPoint;switch(!s.point&&a&&(o.deltaX=s.originalEvent.clientX-a.clientX,o.deltaY=s.originalEvent.clientY-a.clientY,o.offsetCenter={x:a.x+o.deltaX,y:a.y+o.deltaY}),o.type){case"mousedown":n._onPointerDown(o),this._lastMouseDownPoint={...s.point,clientX:s.originalEvent.clientX,clientY:s.originalEvent.clientY};break;case"dragstart":o.type="panstart",n._onEvent(o);break;case"drag":o.type="panmove",n._onEvent(o);break;case"dragend":o.type="panend",n._onEvent(o);break;case"click":o.tapCount=1,n._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,n._onEvent(o);break;case"mousemove":o.type="pointermove",n._onPointerMove(o);break;case"mouseout":o.type="pointerleave",n._onPointerMove(o);break;default:return}};let{interleaved:r=!1,...i}=e;this._interleaved=r,this._props=i}setProps(e){this._interleaved&&e.layers&&ta(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?zd(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new Sr({...this._props,parent:r,viewState:Ds(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&U.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=Bl({map:e,gl:r,deck:new Sr({...this._props,gl:r})}),e.on("styledata",this._handleStyleChange),ta(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),ta(e,this._deck,this._props.layers,[]),Ud(e)}getDefaultPosition(){return"top-left"}pickObject(e){return oe(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return oe(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return oe(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}};function ks(t,e=""){if(!t)throw new Error(`JSON conversion error ${e}`)}function Z_(t,e){let r=K4(e),i=t;for(let s of r)i=Y4(i)?i[s]:void 0;return i}function Y4(t){return t!==null&&typeof t=="object"}var G_={};function K4(t){if(typeof t=="string"){let e=G_[t];return e||(e=t.split("."),G_[t]=e),e}return Array.isArray(t)?t:[t]}var jd={};ui(jd,{addBinaryOp:()=>Q4,addUnaryOp:()=>J4,compile:()=>G4,compileAsync:()=>Z4,eval:()=>Oe,evalAsync:()=>ia,parse:()=>r2.default});var Bs=Ya(Hd()),r2=Ya(Hd()),ia=function t(e,r){try{var i,s=e;switch(s.type){case"ArrayExpression":return Promise.resolve(Q_(s.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([t(s.left,r),t(s.right,r)])).then(function(d){return Us[s.operator](d[0],d[1])});case"CallExpression":var n,o,a,c=function(){if(typeof o=="function"){var d=o,p=d.apply,g=n;return Promise.resolve(Q_(s.arguments,r)).then(function(_){return Promise.resolve(p.call(d,g,_))})}},l=s.callee.type==="MemberExpression"?Promise.resolve(J_(s.callee,r)).then(function(d){n=(a=d)[0],o=a[1]}):Promise.resolve(t(s.callee,r)).then(function(d){o=d});return Promise.resolve(l&&l.then?l.then(c):c());case"ConditionalExpression":return Promise.resolve(t(s.test,r)).then(function(d){return Promise.resolve(t(d?s.consequent:s.alternate,r))});case"Identifier":return Promise.resolve(r[s.name]);case"Literal":return Promise.resolve(s.value);case"LogicalExpression":var u=function(d){return i?d:Promise.resolve(Promise.all([t(s.left,r),t(s.right,r)])).then(function(p){return Us[s.operator](p[0],p[1])})},f=s.operator==="||"?(i=1,Promise.resolve(t(s.left,r)).then(function(d){return d||Promise.resolve(t(s.right,r))})):function(){if(s.operator==="&&")return i=1,Promise.resolve(t(s.left,r)).then(function(d){return d&&Promise.resolve(t(s.right,r))})}();return Promise.resolve(f&&f.then?f.then(u):u(f));case"MemberExpression":return Promise.resolve(J_(s,r)).then(function(d){return d[1]});case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var h=zl[s.operator];return Promise.resolve(t(s.argument,r)).then(function(d){return h.call(zl,d)});default:return Promise.resolve(void 0)}}catch(d){return Promise.reject(d)}},J_=function(t,e){try{return Promise.resolve(ia(t.object,e)).then(function(r){function i(){if(/^__proto__|prototype|constructor$/.test(s))throw Error('Access to member "'+s+'" disallowed.');return[r,r[s]]}var s,n=function(){if(t.computed)return Promise.resolve(ia(t.property,e)).then(function(o){s=o});s=t.property.name}();return n&&n.then?n.then(i):i()})}catch(r){return Promise.reject(r)}},Q_=function(t,e){try{return Promise.resolve(Promise.all(t.map(function(r){return ia(r,e)})))}catch(r){return Promise.reject(r)}},q4={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Us={"||":function(t,e){return t||e},"&&":function(t,e){return t&&e},"|":function(t,e){return t|e},"^":function(t,e){return t^e},"&":function(t,e){return t&e},"==":function(t,e){return t==e},"!=":function(t,e){return t!=e},"===":function(t,e){return t===e},"!==":function(t,e){return t!==e},"<":function(t,e){return t":function(t,e){return t>e},"<=":function(t,e){return t<=e},">=":function(t,e){return t>=e},"<<":function(t,e){return t<>":function(t,e){return t>>e},">>>":function(t,e){return t>>>e},"+":function(t,e){return t+e},"-":function(t,e){return t-e},"*":function(t,e){return t*e},"/":function(t,e){return t/e},"%":function(t,e){return t%e}},zl={"-":function(t){return-t},"+":function(t){return+t},"~":function(t){return~t},"!":function(t){return!t}};function e2(t,e){return t.map(function(r){return Oe(r,e)})}function t2(t,e){var r,i=Oe(t.object,e);if(r=t.computed?Oe(t.property,e):t.property.name,/^__proto__|prototype|constructor$/.test(r))throw Error('Access to member "'+r+'" disallowed.');return[i,i[r]]}function Oe(t,e){var r=t;switch(r.type){case"ArrayExpression":return e2(r.elements,e);case"BinaryExpression":return Us[r.operator](Oe(r.left,e),Oe(r.right,e));case"CallExpression":var i,s,n;return r.callee.type==="MemberExpression"?(i=(n=t2(r.callee,e))[0],s=n[1]):s=Oe(r.callee,e),typeof s!="function"?void 0:s.apply(i,e2(r.arguments,e));case"ConditionalExpression":return Oe(r.test,e)?Oe(r.consequent,e):Oe(r.alternate,e);case"Identifier":return e[r.name];case"Literal":return r.value;case"LogicalExpression":return r.operator==="||"?Oe(r.left,e)||Oe(r.right,e):r.operator==="&&"?Oe(r.left,e)&&Oe(r.right,e):Us[r.operator](Oe(r.left,e),Oe(r.right,e));case"MemberExpression":return t2(r,e)[1];case"ThisExpression":return e;case"UnaryExpression":return zl[r.operator](Oe(r.argument,e));default:return}}function G4(t){return Oe.bind(null,(0,Bs.default)(t))}function Z4(t){return ia.bind(null,(0,Bs.default)(t))}function J4(t,e){Bs.default.addUnaryOp(t),zl[t]=e}function Q4(t,e,r){r?(Bs.default.addBinaryOp(t,e),Us[t]=r):(Bs.default.addBinaryOp(t,q4[t]||1),Us[t]=e)}var{parse:eP,eval:tP}=jd,Xd={"-":t=>t};function sa(t,e){if(t in Xd)return Xd[t];let r,i=eP(t);return i.type==="Identifier"?r=s=>Z_(s,t):($d(i,s=>{if(s.type==="CallExpression")throw new Error("Function calls not allowed in JSON expressions")}),r=s=>tP(i,s)),Xd[t]=r,r}function $d(t,e){if(Array.isArray(t))t.forEach(r=>$d(r,e));else if(t&&typeof t=="object"){t.type&&e(t);for(let r in t)$d(t[r],e)}}var zs="@@=",Yd="@@#",i2="@@type",Vl="@@function";var s2=t=>t&&typeof t=="object",ar=class{constructor(...e){this.typeKey=i2,this.functionKey=Vl,this.log=console,this.classes={},this.reactComponents={},this.enumerations={},this.constants={},this.functions={},this.React=null,this.convertFunction=sa,this.preProcessClassProps=(r,i)=>i,this.postProcessConvertedJson=r=>r;for(let r of e)this.merge(r)}merge(e){for(let r in e)switch(r){case"layers":case"views":Object.assign(this.classes,e[r]);break;default:if(r in this){let i=e[r];this[r]=s2(this[r])?Object.assign(this[r],i):i}}}validate(e){return ks(!this.typeKey||typeof this.typeKey=="string"),ks(s2(this.classes)),!0}};function rP(t){return typeof t=="string"&&t.startsWith(zs)}function iP(t){return t.replace(zs,"")}function Wl(t,e){let r={};for(let i in t){let s=t[i];rP(s)&&(s=iP(s),s=sa(s,e)),r[i]=s}return r}function n2(t,e,r){let i=r.classes[t],s=r.reactComponents[t];if(!i&&!s){let{log:n}=r;if(n){let o=JSON.stringify(e,null,0).slice(0,40);n.warn(`JSON converter: No registered class of type ${t}(${o}...) `)}return null}return i?sP(i,e,r):nP(s,e,r)}function sP(t,e,r){return r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=Wl(e,r),new t(e)}function nP(t,e,r){let{React:i}=r,{children:s=[]}=e;return delete e.children,r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=Wl(e,r),i.createElement(t,e,s)}function o2(t,e,r){let i=r.functions[t];if(!i){let{log:s}=r;if(s){let n=JSON.stringify(e,null,0).slice(0,40);s.warn(`JSON converter: No registered function ${t}(${n}...) `)}return null}return i(e)}function Kd(t){return typeof t=="string"?JSON.parse(t):t}var qd=t=>t&&typeof t=="object",Vs=class{constructor(e){this.log=console,this.onJSONChange=()=>{},this.json=null,this.convertedJson=null,this.setProps(e)}finalize(){}setProps(e){"configuration"in e&&(this.configuration=e.configuration instanceof ar?e.configuration:new ar(e.configuration)),"onJSONChange"in e&&(this.onJSONChange=e.onJSONChange)}mergeConfiguration(e){this.configuration.merge(e)}convert(e){if(!e||e===this.json)return this.convertedJson;this.json=e;let r=Kd(e),i=oP(r,this.configuration);return i=this.configuration.postProcessConvertedJson(i),this.convertedJson=i,i}convertJson(e){return this.convert(e)}};function oP(t,e){return e=new ar(e),Gd(t,"",e)}function Gd(t,e,r){return Array.isArray(t)?t.map((i,s)=>Gd(i,String(s),r)):aP(t,r)?cP(t,r):qd(t)?Vl in t?lP(t,r):Zd(t,r):typeof t=="string"?uP(t,e,r):t}function aP(t,e){let{typeKey:r}=e;return qd(t)&&!!t[r]}function cP(t,e){let{typeKey:r}=e,i=t[r],s={...t};return delete s[r],s=Zd(s,e),n2(i,s,e)}function lP(t,e){let{functionKey:r}=e,i=t[r],s={...t};return delete s[r],s=Zd(s,e),o2(i,s,e)}function Zd(t,e){ks(qd(t));let r={};for(let i in t){let s=t[i];r[i]=Gd(s,i,e)}return r}function uP(t,e,r){if(t.startsWith(zs)&&r.convertFunction)return t=t.replace(zs,""),r.convertFunction(t,r);if(t.startsWith(Yd)){if(t=t.replace(Yd,""),r.constants[t])return r.constants[t];let[i,s]=t.split(".");return r.enumerations[i][s]}return t}var Sp={};ui(Sp,{AGGREGATION_OPERATION:()=>le,ArcLayer:()=>na,BitmapLayer:()=>oa,CPUGridLayer:()=>ni,ColumnLayer:()=>wr,ContourLayer:()=>Ia,GPUGridLayer:()=>oi,GeoJsonLayer:()=>wa,GridCellLayer:()=>Ki,GridLayer:()=>Na,HeatmapLayer:()=>Da,HexagonLayer:()=>Ra,IconLayer:()=>Ar,LineLayer:()=>Xi,PathLayer:()=>Pr,PointCloudLayer:()=>la,PolygonLayer:()=>va,ScatterplotLayer:()=>$i,ScreenGridLayer:()=>Ca,SolidPolygonLayer:()=>zt,TextLayer:()=>Qi,_AggregationLayer:()=>nt,_BinSorter:()=>Cr,_CPUAggregator:()=>Mr,_GPUGridAggregator:()=>Ce,_MultiIconLayer:()=>Gi,_TextBackgroundLayer:()=>Ji});var a2=`#version 300 es +}`;function Fz(t,e){let r=Dd(e.size),i=Ud(e.size);return new co(t,{vs:Bz,fs:Oz,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function Lz(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function Nz(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var Dz={interpolation:Ku,spring:Ju},Zu=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let n in e){let s=e[n],o=s.getTransitionSetting(r);o&&this._updateAttribute(n,s,o)}for(let n in this.transitions){let s=e[n];(!s||!s.getTransitionSetting(r))&&this._removeTransition(n)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,i){let n=this.transitions[e],s=!n||n.type!==i.type;if(s){n&&this._removeTransition(e);let o=Dz[i.type];o?this.transitions[e]=new o({attribute:r,timeline:this.timeline,device:this.device}):(me.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var qC="attributeManager.invalidate",Uz="attributeManager.updateStart",kz="attributeManager.updateEnd",Vz="attribute.updateStart",zz="attribute.allocate",Hz="attribute.updateEnd",qn=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:n}={}){this.mergeBoundsMemoized=Gn(aw),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Zu(e,{id:`${r}-transitions`,timeline:n}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);Zt(qC,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);Zt(qC,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:n,props:s={},buffers:o={},context:a={}}){let A=!1;Zt(Uz,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let h in this.attributes){let g=this.attributes[h],_=g.settings.accessor;g.startIndices=i,g.numInstances=r,s[h]&&me.removed(`props.${h}`,`data.attributes.${h}`)(),g.setExternalBuffer(o[h])||g.setBinaryValue(typeof _=="string"?o[_]:void 0,e.startIndices)||typeof _=="string"&&!o[_]&&g.setConstantValue(s[_])||g.needsUpdate()&&(A=!0,this._updateAttribute({attribute:g,numInstances:r,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||g.needsRedraw()}A&&Zt(kz,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:n})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,n={...i.getAttributes()};for(let s in r){let o=r[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(n[s]=o)}return n}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let n=e[i],s={...n,id:i,size:n.isIndexed&&1||n.size||1,...r};this.attributes[i]=new Pa(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:n}=this,s=n[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,r)}),s}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(Zt(Vz,r),r.constant){r.setConstantValue(r.value);return}r.allocate(i)&&Zt(zz,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,Zt(Hz,r,i))}};var $u=class extends An{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:n,easing:s}}=this,o=s(e/n);this._value=Fr(r,i,o)}};var KC=1e-5;function JC(t,e,r,i,n){let s=e-t,a=(r-e)*n,A=-s*i;return a+A+s+e}function Gz(t,e,r,i,n){if(Array.isArray(r)){let s=[];for(let o=0;o0}add(e,r,i,n){let{transitions:s}=this;if(s.has(e)){let A=s.get(e),{value:h=A.settings.fromValue}=A;r=h,this.remove(e)}if(n=Nd(n),!n)return;let o=Wz[n.type];if(!o){me.error(`unsupported transition type '${n.type}'`)();return}let a=new o(this.timeline);a.start({...n,fromValue:r,toValue:i}),s.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function e4(t){let e=t[Hi];for(let r in e){let i=e[r],{validate:n}=i;if(n&&!n(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function t4(t,e){let r=rf({newProps:t,oldProps:e,propTypes:t[Hi],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=Xz(t,e),n=!1;return i||(n=Yz(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:n,extensionsChanged:Qz(t,e),transitionsChanged:jz(t,e)}}function jz(t,e){if(!t.transitions)return!1;let r={},i=t[Hi],n=!1;for(let s in t.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&ny(t[s],e[s],o)&&(r[s]=!0,n=!0)}return n?r:!1}function rf({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:n="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${n} changed shallowly`;if(typeof e!="object"||e===null)return`${n} changed shallowly`;for(let s of Object.keys(t))if(!(s in r)){if(!(s in e))return`${n}.${s} added`;let o=ny(t[s],e[s],i[s]);if(o)return`${n}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in r)){if(!(s in t))return`${n}.${s} dropped`;if(!Object.hasOwnProperty.call(t,s)){let o=ny(t[s],e[s],i[s]);if(o)return`${n}.${s} ${o}`}}return!1}function ny(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function Xz(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:n}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&n&&(r=n(t.data,e.data)||r),r}function Yz(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&$C(t,e,"all"))return{all:!0};let r={},i=!1;for(let n in t.updateTriggers)n!=="all"&&$C(t,e,n)&&(r[n]=!0,i=!0);return i?r:!1}function Qz(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let n=0;ni.name==="project64"))){let i=r.modules.findIndex(n=>n.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let n in e.inject)i[n]=(i[n]||"")+e.inject[n];r.inject=i}return r}var $z={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},sy={};function i4(t,e,r,i){if(r instanceof $t)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let n=null;r.compressed&&(n={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let s=e.createTexture({...r,sampler:{...$z,...n,...i}});return sy[s.id]=t,s}function n4(t,e){!e||!(e instanceof $t)||sy[e.id]===t&&(e.delete(),delete sy[e.id])}var eH={boolean:{validate(t,e){return!0},equal(t,e,r){return!!t==!!e}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||oy(t)&&(t.length===3||t.length===4)},equal(t,e,r){return er(t,e,1)}},accessor:{validate(t,e){let r=Hd(t);return r==="function"||r===Hd(e.value)},equal(t,e,r){return typeof e=="function"?!0:er(t,e,1)}},array:{validate(t,e){return e.optional&&!t||oy(t)},equal(t,e,r){let{compare:i}=r,n=Number.isInteger(i)?i:i?1:0;return i?er(t,e,n):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,n=Number.isInteger(i)?i:i?1:0;return i?er(t,e,n):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:i4(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{n4(r.id,t)}}};function s4(t){let e={},r={},i={};for(let[n,s]of Object.entries(t)){let o=s?.deprecatedFor;if(o)i[n]=Array.isArray(o)?o:[o];else{let a=tH(n,s);e[n]=a,r[n]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function tH(t,e){switch(Hd(e)){case"object":return nf(t,e);case"array":return nf(t,{type:"array",value:e,compare:!1});case"boolean":return nf(t,{type:"boolean",value:e});case"number":return nf(t,{type:"number",value:e});case"function":return nf(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function nf(t,e){return"type"in e?{name:t,...eH[e.type],...e}:"value"in e?{name:t,type:Hd(e.value),...e}:{name:t,type:"object",value:e}}function oy(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function Hd(t){return oy(t)?"array":t===null?"null":typeof t}function o4(t,e){let r;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(r=o.extensions)}let i=ay(t.constructor,r),n=Object.create(i);n[zc]=t,n[jn]={},n[ln]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||AH}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[zc]||this.component;let r=e[ln]||{},i=e[jn]||e,n=e[xs]||{};for(let s in r){let o=r[s];this._createAsyncPropData(s,n[s]),this._updateAsyncProp(s,o),r[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,n[s]),this._updateAsyncProp(s,o)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(Fd(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let n=this.asyncProps[e];n&&i>=n.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),n.resolvedValue=r,n.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let n=i.pendingLoadCount;r.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,n),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let n=i.pendingLoadCount,s=[],o=0;for await(let a of r){if(!this.component)return;let{dataTransform:A}=this.component.props;A?s=A(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,n)}this._onResolve(e,s)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let n=this.component&&this.component.props[Hi];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var af=class extends of{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,n=i?.props.fetch;return n?n(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let n=i.props.onDataLoad;e==="data"&&n&&n(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var uH="layer.changeFlag",fH="layer.initialize",hH="layer.update",dH="layer.finalize",pH="layer.matched",c4=2**24-1,gH=Object.freeze([]),mH=Gn(({oldViewport:t,viewport:e})=>t.equals(e)),Kn=new Uint8ClampedArray(0),_H={data:{type:"data",value:gH,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:i,loadOptions:n,signal:s})=>{let{resourceManager:o}=r.context;n=n||r.getLoadOptions(),i=i||r.props.loaders,s&&(n={...n,fetch:{...n?.fetch,signal:s}});let a=o.contains(t);return!a&&!n&&(o.add({resourceId:t,data:Cr(t,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:t,onChange:A=>r.internalState?.reloadAsyncProp(e,A),consumerId:r.id,requestId:e}):Cr(t,i,n)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:Oe.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ht=class extends sf{constructor(){super(...arguments),this.internalState=null,this.lifecycle=uo.NO_STATE,this.parent=null}static{this.defaultProps=_H}static{this.layerName="Layer"}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){Rt(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=P2(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,s,o]=Nc(i,r.pixelProjectionMatrix);return e.length===2?[n,s]:[n,s,o]}unproject(e){return Rt(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){Rt(this.internalState);let i=this.internalState.viewport||this.context.viewport;return Aw(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(let r of this.getModels())r.updateModuleSettings(e)}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===Oe.DEFAULT||e===Oe.LNGLAT||e===Oe.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){Rt(e instanceof Uint8Array);let[r,i,n]=e;return r+i*256+n*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:r4(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=qc(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=qc(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let n of i)r.invalidateAll(n);else r.invalidateAll();if(r){let{props:n}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(n.highlightedObjectIndex)||n.pickable||n.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:A}=r.attributes,h=a||A;h&&(o&&h.constant&&(h.constant=!1,r.invalidate(h.id)),!h.value&&!o&&(h.constant=!0,h.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:n}=e;return n>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[n]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!mH({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),n=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:n,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let n in r)Object.defineProperty(i,n,{value:r[n]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(Kn.length/4);if(this.internalState.usesPickingColorCache=!0,ic4&&me.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Kn=cn.allocate(Kn,r,{size:4,copy:!0,maxCount:Math.max(r,c4)});let n=Math.floor(Kn.length/4),s=[];for(let o=i;o(me.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new tf(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Zt(pH,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Zt(hH,this,e),!e)return;let r=this.props,i=this.context,n=this.internalState,s=i.viewport,o=this._updateUniformTransition();n.propsInTransition=o,i.viewport=n.viewport||s,this.props=o;try{let a=this._getUpdateParams(),A=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let g of this.props.extensions)g.updateState.call(this,a,g);let h=this.getModels()[0]!==A[0];this._postUpdate(a,h)}finally{i.viewport=s,this.props=r,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){Zt(dH,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:r=null,uniforms:i={},parameters:n={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;let a=this.props.opacity;i.opacity=Math.pow(a,1/2.2);try{if(r){let{isActive:g,isAttribute:_}=r.picking;this.setModuleParameters(r),this.setShaderModuleProps({picking:{isActive:g,isAttribute:_}})}let{getPolygonOffset:A}=this.props,h=A&&A(i)||[0,0];o.device.setParametersWebGL({polygonOffset:h});for(let g of this.getModels())g.setParameters(n);o.device.withParametersWebGL(n,()=>{let g={renderPass:e,moduleParameters:r,uniforms:i,parameters:n,context:o};for(let _ of this.props.extensions)_.draw.call(this,g,_);this.draw(g)})}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let n in e)if(e[n]){let s=!1;switch(n){case"dataChanged":let o=e[n],a=r[n];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:r[n]||(r[n]=e[n],s=!0)}s&&Zt(uH,this,n,e)}let i=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=t4(e,r);if(i.updateTriggersChanged)for(let n in i.updateTriggersChanged)i.updateTriggersChanged[n]&&this.invalidateAttribute(n);if(i.transitionsChanged)for(let n in i.transitionsChanged)this.internalState.uniformTransitions.add(n,r[n],e[n],e.transitions?.[n]);return this.setChangeFlags(i)}validateProps(){e4(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new qn(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:n}=e;this.setNeedsRedraw(),this._updateAttributes();let s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:A}=i;if(r||n.autoHighlight!==o||n.highlightedObjectIndex!==a||n.highlightColor!==A){let h={};o||(h.highlightedObjectColor=null),Array.isArray(A)&&(h.highlightColor=A),(r||a!==n.highlightedObjectIndex)&&(h.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:h})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),n=i?i.getNeedsRedraw(e):!1;if(r=r||n,r)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};var yH="compositeLayer.renderLayers",Gt=class extends ht{static{this.layerName="CompositeLayer"}get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,n)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,n)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:n,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:A,highlightColor:h,coordinateSystem:g,coordinateOrigin:_,wrapLongitude:x,positionFormat:T,modelMatrix:v,extensions:S,fetch:C,operation:M,_subLayerProps:R}=this.props,B={id:"",updateTriggers:{},opacity:r,pickable:i,visible:n,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:A,highlightColor:h,coordinateSystem:g,coordinateOrigin:_,wrapLongitude:x,positionFormat:T,modelMatrix:v,extensions:S,fetch:C,operation:M},k=R&&e.id&&R[e.id],Q=k&&k.updateTriggers,$=e.id||"sublayer";if(k){let re=this.props[Hi],Y=e.type?e.type._propTypes:{};for(let H in k){let L=Y[H]||re[H];L&&L.type==="accessor"&&(k[H]=this.getSubLayerAccessor(k[H]))}}Object.assign(B,e,k),B.id=`${this.props.id}-${$}`,B.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...Q};for(let re of S){let Y=re.getSubLayerProps.call(this,re);Y&&Object.assign(B,Y,{updateTriggers:Object.assign(B.updateTriggers,Y.updateTriggers)})}return B}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,n=!i||this.needsUpdate();if(n){let s=this.renderLayers();i=hi(s,Boolean),this.internalState.subLayers=i}Zt(yH,this,n,i);for(let s of i)s.parent=this}};var Gd=Math.PI/180,l4=180/Math.PI,Wd=6370972,Kc=256;function xH(){let t=Kc/Wd,e=Math.PI/180*Kc;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Jc=class extends _s{constructor(e={}){let{latitude:r=0,longitude:i=0,zoom:n=0,nearZMultiplier:s=.1,farZMultiplier:o=2,resolution:a=10}=e,{height:A,altitude:h=1.5}=e;A=A||1,h=Math.max(.75,h);let g=new Fe().lookAt({eye:[0,-h,0],up:[0,0,1]}),_=Math.pow(2,n);g.rotateX(r*Gd),g.rotateZ(-i*Gd),g.scale(_/A);let x=Math.atan(.5/h),T=Kc*2*_/A;super({...e,height:A,viewMatrix:g,longitude:i,latitude:r,zoom:n,distanceScales:xH(),fovyRadians:x*2,focalDistance:h,near:s,far:Math.min(2,1/T+1)*h*o}),this.latitude=r,this.longitude=i,this.resolution=a}get projectionMode(){return Wr.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,this.height/2],r),n=this.unproject([this.width/2,0],r),s=this.unproject([this.width,this.height/2],r),o=this.unproject([this.width/2,this.height],r);return s[0]this.longitude&&(i[0]-=360),[Math.min(i[0],s[0],n[0],o[0]),Math.min(i[1],s[1],n[1],o[1]),Math.max(i[0],s[0],n[0],o[0]),Math.max(i[1],s[1],n[1],o[1])]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[n,s,o]=e,a=r?s:this.height-s,{pixelUnprojectionMatrix:A}=this,h;if(Number.isFinite(o))h=ly(A,[n,a,o,1]);else{let T=ly(A,[n,a,-1,1]),v=ly(A,[n,a,1,1]),S=((i||0)/Wd+1)*Kc,C=Lr.sqrLen(Lr.sub([],T,v)),M=Lr.sqrLen(T),R=Lr.sqrLen(v),k=4*((4*M*R-(C-M-R)**2)/16)/C,Q=Math.sqrt(M-k),$=Math.sqrt(Math.max(0,S*S-k)),re=(Q-$)/Math.sqrt(C);h=Lr.lerp([],T,v,re)}let[g,_,x]=this.unprojectPosition(h);return Number.isFinite(o)?[g,_,x]:Number.isFinite(i)?[g,_,i]:[g,_]}projectPosition(e){let[r,i,n=0]=e,s=r*Gd,o=i*Gd,a=Math.cos(o),A=(n/Wd+1)*Kc;return[Math.sin(s)*a*A,-Math.cos(s)*a*A,Math.sin(o)*A]}unprojectPosition(e){let[r,i,n]=e,s=Lr.len(e),o=Math.asin(n/s),A=Math.atan2(r,-i)*l4,h=o*l4,g=(s/Kc-1)*Wd;return[A,h,g]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition(e,r){let i=this.unproject(r);return{longitude:e[0]-i[0]+this.longitude,latitude:e[1]-i[1]+this.latitude}}};function ly(t,e){let r=fi.transformMat4([],e,t);return fi.scale(r,r,1/r[3]),r}var Zc=class{static{this.defaultProps={}}static{this.extensionName="LayerExtension"}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&er(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,i={updateTriggers:{}};for(let n in r)if(n in this.props){let s=r[n],o=this.props[n];i[n]=o,s&&s.type==="accessor"&&(i.updateTriggers[n]=this.props.updateTriggers[n],typeof o=="function"&&(i[n]=this.getSubLayerAccessor(o)))}return i}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};var yo=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=cn,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:n,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:A=!0}=this.opts;if(this.data=r,this.getGeometry=n,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=A,s&&(Rt(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),A||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let h of a)this._rebuildGeometry(h);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Ld(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:n,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in n)o.release(i[a]),i[a]=null;else{let A=s[a];A.copy=r,i[a]=o.allocate(i[a],e,A)}}_forEachGeometry(e,r,i){let{data:n,getGeometry:s}=this,{iterable:o,objectInfo:a}=nr(n,r,i);for(let A of o){a.index++;let h=s?s(A,a):null;e(h,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:n}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:A=1/0}=e||{},h={};if(e||(r=[0],i=[0]),this.normalize||!o)this._forEachGeometry((_,x)=>{let T=_&&this.normalizeGeometry(_);h[x]=T,i[x+1]=i[x]+(T?this.getGeometrySize(T):0)},a,A),n=i[i.length-1];else if(i=s.startIndices,n=i[s.length]||0,ArrayBuffer.isView(o))n=n||o.length/this.positionSize;else if(o instanceof gt){let _=this.positionSize*4;n=n||o.byteLength/_}else if(o.buffer){let _=o.stride||this.positionSize*4;n=n||o.buffer.byteLength/_}else if(o.value){let _=o.value,x=o.stride/_.BYTES_PER_ELEMENT||this.positionSize;n=n||_.length/x}this._allocate(n,!!e),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=n;let g={};this._forEachGeometry((_,x)=>{let T=h[x]||_;g.vertexStart=i[x],g.indexStart=r[x];let v=x{t.triggerRepaint(),i?.("")}}),o;return(!r||r.props.gl===e)&&(Object.assign(s,{gl:e,width:null,height:null,touchAction:"unset",viewState:$c(t)}),r?.isInitialized?A4(r,t):s.onLoad=()=>{n?.(),A4(o,t)}),r?(o=r,r.setProps(s),r.userData.isExternal=!0):(o=new vs(s),t.on("remove",()=>{uy(t)})),o.userData.mapboxLayers=new Set,t.__deck=o,t.on("render",()=>{o.isInitialized&&EH(o,t)}),o}function A4(t,e){let r=()=>{t.isInitialized?vH(t,e):e.off("move",r)};e.on("move",r)}function uy(t){t.__deck?.finalize(),t.__deck=null}function fy(t){return{...t,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...t.parameters},views:t.views||[new ho({id:"mapbox"})]}}function u4(t,e){t.userData.mapboxLayers.add(e),hy(t)}function f4(t,e){t.userData.mapboxLayers.delete(e),hy(t)}function h4(t,e){hy(t)}function d4(t,e,r){let{currentViewport:i}=t.userData,n=!1;i||(i=p4(t,e,!0),t.userData.currentViewport=i,n=!0),t.isInitialized&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:({layer:s})=>r.id===s.id||s.props.operation.includes("terrain"),clearStack:n,clearCanvas:!1})}function $c(t){let{lng:e,lat:r}=t.getCenter(),i={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&TH(t,i),i}function TH(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let i=t.transform.height,{longitude:n,latitude:s,pitch:o}=e,a=r.x*Ay,A=(1-r.y)*Ay,h=r.z*Ay,g=gr([n,s]),_=a-g[0],x=A-g[1],T=Math.sqrt(_*_+x*x),v=o*bH,S=1.5*i,C=v<.001?S*Math.cos(v)/h:S*Math.sin(v)/T;e.zoom=Math.log2(C);let M=S*Math.cos(v)/C,R=h-M;e.position=[0,0,R/ga(s)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function p4(t,e,r=!0){return new wi({id:"mapbox",x:0,y:0,width:t.width,height:t.height,...$c(e),nearZMultiplier:r?.02:.1,nearZ:e.transform._nearZ/e.transform.height,farZ:e.transform._farZ/e.transform.height})}function EH(t,e){let{mapboxLayers:r,isExternal:i}=t.userData;if(i){let n=Array.from(r,g=>g.id),o=hi(t.props.layers,Boolean).some(g=>g&&!n.includes(g.id)),a=t.getViewports(),A=a.findIndex(g=>g.id==="mapbox"),h=a.length>1||A<0;(o||h)&&(A>=0&&(a=a.slice(),a[A]=p4(t,e,!1)),t._drawLayers("mapbox-repaint",{viewports:a,layerFilter:g=>(!t.props.layerFilter||t.props.layerFilter(g))&&(g.viewport.id!=="mapbox"||!n.includes(g.layer.id)),clearCanvas:!1}))}t.userData.currentViewport=null}function vH(t,e){t.setProps({viewState:$c(e)}),t.needsRedraw({clearRedrawFlags:!0})}function hy(t){if(t.userData.isExternal)return;let e=[];t.userData.mapboxLayers.forEach(r=>{let i=r.props.type,n=new i(r.props);e.push(n)}),t.setProps({layers:e})}var cf=class{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,r){this.map=e,this.deck=jd({map:e,gl:r,deck:this.props.deck}),u4(this.deck,this)}onRemove(){this.deck&&f4(this.deck,this)}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&h4(this.deck,this)}render(){d4(this.deck,this.map,this)}};var dy="__UNDEFINED__";function lf(t,e,r,i){if(!t||!e||!t.style||!t.style._loaded)return;let n=hi(i,Boolean);if(r!==i){let a=hi(r,Boolean),A=new Set(a.map(h=>h.id));for(let h of n)A.delete(h.id);for(let h of A)t.getLayer(h)&&t.removeLayer(h)}for(let a of n){let A=t.getLayer(a.id);A?A.implementation.setProps(a.props):t.addLayer(new cf({id:a.id,deck:e}),a.props.beforeId)}let s=t.style._order,o={};for(let a of n){let{beforeId:A}=a.props;(!A||!s.includes(A))&&(A=dy),o[A]=o[A]||[],o[A].push(a.id)}for(let a in o){let A=o[a],h=a===dy?s.length:s.indexOf(a),g=a===dy?void 0:a;for(let _=A.length-1;_>=0;_--){let x=A[_],T=s.indexOf(x);T!==h-1&&(t.moveLayer(x,g),T>h&&h++),h--,g=x}}}var el=class{constructor(e){this._handleStyleChange=()=>{lf(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:n,clientHeight:s}=this._map.getContainer();Object.assign(this._container.style,{width:`${n}px`,height:`${s}px`})}},this._updateViewState=()=>{let n=this._deck;n&&(n.setProps({viewState:$c(this._map)}),n.isInitialized&&n.redraw())},this._handleMouseEvent=n=>{let s=this._deck;if(!s||!s.isInitialized)return;let o={type:n.type,offsetCenter:n.point,srcEvent:n},a=this._lastMouseDownPoint;switch(!n.point&&a&&(o.deltaX=n.originalEvent.clientX-a.clientX,o.deltaY=n.originalEvent.clientY-a.clientY,o.offsetCenter={x:a.x+o.deltaX,y:a.y+o.deltaY}),o.type){case"mousedown":s._onPointerDown(o),this._lastMouseDownPoint={...n.point,clientX:n.originalEvent.clientX,clientY:n.originalEvent.clientY};break;case"dragstart":o.type="panstart",s._onEvent(o);break;case"drag":o.type="panmove",s._onEvent(o);break;case"dragend":o.type="panend",s._onEvent(o);break;case"click":o.tapCount=1,s._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,s._onEvent(o);break;case"mousemove":o.type="pointermove",s._onPointerMove(o);break;case"mouseout":o.type="pointerleave",s._onPointerMove(o);break;default:return}};let{interleaved:r=!1,...i}=e;this._interleaved=r,this._props=i}setProps(e){this._interleaved&&e.layers&&lf(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?fy(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new vs({...this._props,parent:r,viewState:$c(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&me.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=jd({map:e,gl:r,deck:new vs({...this._props,gl:r})}),e.on("styledata",this._handleStyleChange),lf(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),lf(e,this._deck,this._props.layers,[]),uy(e)}getDefaultPosition(){return"top-left"}pickObject(e){return Rt(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return Rt(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return Rt(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}};function tl(t,e=""){if(!t)throw new Error(`JSON conversion error ${e}`)}function m4(t,e){let r=wH(e),i=t;for(let n of r)i=SH(i)?i[n]:void 0;return i}function SH(t){return t!==null&&typeof t=="object"}var g4={};function wH(t){if(typeof t=="string"){let e=g4[t];return e||(e=t.split("."),g4[t]=e),e}return Array.isArray(t)?t:[t]}var gy={};dr(gy,{addBinaryOp:()=>RH,addUnaryOp:()=>IH,compile:()=>MH,compileAsync:()=>PH,eval:()=>Ir,evalAsync:()=>uf,parse:()=>T4.default});var rl=Ys(py()),T4=Ys(py()),uf=function t(e,r){try{var i,n=e;switch(n.type){case"ArrayExpression":return Promise.resolve(y4(n.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([t(n.left,r),t(n.right,r)])).then(function(T){return il[n.operator](T[0],T[1])});case"CallExpression":var s,o,a,A=function(){if(typeof o=="function"){var T=o,v=T.apply,S=s;return Promise.resolve(y4(n.arguments,r)).then(function(C){return Promise.resolve(v.call(T,S,C))})}},h=n.callee.type==="MemberExpression"?Promise.resolve(_4(n.callee,r)).then(function(T){s=(a=T)[0],o=a[1]}):Promise.resolve(t(n.callee,r)).then(function(T){o=T});return Promise.resolve(h&&h.then?h.then(A):A());case"ConditionalExpression":return Promise.resolve(t(n.test,r)).then(function(T){return Promise.resolve(t(T?n.consequent:n.alternate,r))});case"Identifier":return Promise.resolve(r[n.name]);case"Literal":return Promise.resolve(n.value);case"LogicalExpression":var g=function(T){return i?T:Promise.resolve(Promise.all([t(n.left,r),t(n.right,r)])).then(function(v){return il[n.operator](v[0],v[1])})},_=n.operator==="||"?(i=1,Promise.resolve(t(n.left,r)).then(function(T){return T||Promise.resolve(t(n.right,r))})):function(){if(n.operator==="&&")return i=1,Promise.resolve(t(n.left,r)).then(function(T){return T&&Promise.resolve(t(n.right,r))})}();return Promise.resolve(_&&_.then?_.then(g):g(_));case"MemberExpression":return Promise.resolve(_4(n,r)).then(function(T){return T[1]});case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var x=Yd[n.operator];return Promise.resolve(t(n.argument,r)).then(function(T){return x.call(Yd,T)});default:return Promise.resolve(void 0)}}catch(T){return Promise.reject(T)}},_4=function(t,e){try{return Promise.resolve(uf(t.object,e)).then(function(r){function i(){if(/^__proto__|prototype|constructor$/.test(n))throw Error('Access to member "'+n+'" disallowed.');return[r,r[n]]}var n,s=function(){if(t.computed)return Promise.resolve(uf(t.property,e)).then(function(o){n=o});n=t.property.name}();return s&&s.then?s.then(i):i()})}catch(r){return Promise.reject(r)}},y4=function(t,e){try{return Promise.resolve(Promise.all(t.map(function(r){return uf(r,e)})))}catch(r){return Promise.reject(r)}},CH={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},il={"||":function(t,e){return t||e},"&&":function(t,e){return t&&e},"|":function(t,e){return t|e},"^":function(t,e){return t^e},"&":function(t,e){return t&e},"==":function(t,e){return t==e},"!=":function(t,e){return t!=e},"===":function(t,e){return t===e},"!==":function(t,e){return t!==e},"<":function(t,e){return t":function(t,e){return t>e},"<=":function(t,e){return t<=e},">=":function(t,e){return t>=e},"<<":function(t,e){return t<>":function(t,e){return t>>e},">>>":function(t,e){return t>>>e},"+":function(t,e){return t+e},"-":function(t,e){return t-e},"*":function(t,e){return t*e},"/":function(t,e){return t/e},"%":function(t,e){return t%e}},Yd={"-":function(t){return-t},"+":function(t){return+t},"~":function(t){return~t},"!":function(t){return!t}};function x4(t,e){return t.map(function(r){return Ir(r,e)})}function b4(t,e){var r,i=Ir(t.object,e);if(r=t.computed?Ir(t.property,e):t.property.name,/^__proto__|prototype|constructor$/.test(r))throw Error('Access to member "'+r+'" disallowed.');return[i,i[r]]}function Ir(t,e){var r=t;switch(r.type){case"ArrayExpression":return x4(r.elements,e);case"BinaryExpression":return il[r.operator](Ir(r.left,e),Ir(r.right,e));case"CallExpression":var i,n,s;return r.callee.type==="MemberExpression"?(i=(s=b4(r.callee,e))[0],n=s[1]):n=Ir(r.callee,e),typeof n!="function"?void 0:n.apply(i,x4(r.arguments,e));case"ConditionalExpression":return Ir(r.test,e)?Ir(r.consequent,e):Ir(r.alternate,e);case"Identifier":return e[r.name];case"Literal":return r.value;case"LogicalExpression":return r.operator==="||"?Ir(r.left,e)||Ir(r.right,e):r.operator==="&&"?Ir(r.left,e)&&Ir(r.right,e):il[r.operator](Ir(r.left,e),Ir(r.right,e));case"MemberExpression":return b4(r,e)[1];case"ThisExpression":return e;case"UnaryExpression":return Yd[r.operator](Ir(r.argument,e));default:return}}function MH(t){return Ir.bind(null,(0,rl.default)(t))}function PH(t){return uf.bind(null,(0,rl.default)(t))}function IH(t,e){rl.default.addUnaryOp(t),Yd[t]=e}function RH(t,e,r){r?(rl.default.addBinaryOp(t,e),il[t]=r):(rl.default.addBinaryOp(t,CH[t]||1),il[t]=e)}var{parse:BH,eval:OH}=gy,my={"-":t=>t};function ff(t,e){if(t in my)return my[t];let r,i=BH(t);return i.type==="Identifier"?r=n=>m4(n,t):(_y(i,n=>{if(n.type==="CallExpression")throw new Error("Function calls not allowed in JSON expressions")}),r=n=>OH(i,n)),my[t]=r,r}function _y(t,e){if(Array.isArray(t))t.forEach(r=>_y(r,e));else if(t&&typeof t=="object"){t.type&&e(t);for(let r in t)_y(t[r],e)}}var nl="@@=",yy="@@#",E4="@@type",Qd="@@function";var v4=t=>t&&typeof t=="object",Jn=class{constructor(...e){this.typeKey=E4,this.functionKey=Qd,this.log=console,this.classes={},this.reactComponents={},this.enumerations={},this.constants={},this.functions={},this.React=null,this.convertFunction=ff,this.preProcessClassProps=(r,i)=>i,this.postProcessConvertedJson=r=>r;for(let r of e)this.merge(r)}merge(e){for(let r in e)switch(r){case"layers":case"views":Object.assign(this.classes,e[r]);break;default:if(r in this){let i=e[r];this[r]=v4(this[r])?Object.assign(this[r],i):i}}}validate(e){return tl(!this.typeKey||typeof this.typeKey=="string"),tl(v4(this.classes)),!0}};function FH(t){return typeof t=="string"&&t.startsWith(nl)}function LH(t){return t.replace(nl,"")}function qd(t,e){let r={};for(let i in t){let n=t[i];FH(n)&&(n=LH(n),n=ff(n,e)),r[i]=n}return r}function S4(t,e,r){let i=r.classes[t],n=r.reactComponents[t];if(!i&&!n){let{log:s}=r;if(s){let o=JSON.stringify(e,null,0).slice(0,40);s.warn(`JSON converter: No registered class of type ${t}(${o}...) `)}return null}return i?NH(i,e,r):DH(n,e,r)}function NH(t,e,r){return r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=qd(e,r),new t(e)}function DH(t,e,r){let{React:i}=r,{children:n=[]}=e;return delete e.children,r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=qd(e,r),i.createElement(t,e,n)}function w4(t,e,r){let i=r.functions[t];if(!i){let{log:n}=r;if(n){let s=JSON.stringify(e,null,0).slice(0,40);n.warn(`JSON converter: No registered function ${t}(${s}...) `)}return null}return i(e)}function xy(t){return typeof t=="string"?JSON.parse(t):t}var by=t=>t&&typeof t=="object",sl=class{constructor(e){this.log=console,this.onJSONChange=()=>{},this.json=null,this.convertedJson=null,this.setProps(e)}finalize(){}setProps(e){"configuration"in e&&(this.configuration=e.configuration instanceof Jn?e.configuration:new Jn(e.configuration)),"onJSONChange"in e&&(this.onJSONChange=e.onJSONChange)}mergeConfiguration(e){this.configuration.merge(e)}convert(e){if(!e||e===this.json)return this.convertedJson;this.json=e;let r=xy(e),i=UH(r,this.configuration);return i=this.configuration.postProcessConvertedJson(i),this.convertedJson=i,i}convertJson(e){return this.convert(e)}};function UH(t,e){return e=new Jn(e),Ty(t,"",e)}function Ty(t,e,r){return Array.isArray(t)?t.map((i,n)=>Ty(i,String(n),r)):kH(t,r)?VH(t,r):by(t)?Qd in t?zH(t,r):Ey(t,r):typeof t=="string"?HH(t,e,r):t}function kH(t,e){let{typeKey:r}=e;return by(t)&&!!t[r]}function VH(t,e){let{typeKey:r}=e,i=t[r],n={...t};return delete n[r],n=Ey(n,e),S4(i,n,e)}function zH(t,e){let{functionKey:r}=e,i=t[r],n={...t};return delete n[r],n=Ey(n,e),w4(i,n,e)}function Ey(t,e){tl(by(t));let r={};for(let i in t){let n=t[i];r[i]=Ty(n,i,e)}return r}function HH(t,e,r){if(t.startsWith(nl)&&r.convertFunction)return t=t.replace(nl,""),r.convertFunction(t,r);if(t.startsWith(yy)){if(t=t.replace(yy,""),r.constants[t])return r.constants[t];let[i,n]=t.split(".");return r.enumerations[i][n]}return t}var xb={};dr(xb,{AGGREGATION_OPERATION:()=>Lt,ArcLayer:()=>Ia,BitmapLayer:()=>Ra,CPUGridLayer:()=>So,ColumnLayer:()=>pn,ContourLayer:()=>kf,GPUGridLayer:()=>wo,GeoJsonLayer:()=>Zn,GeohashLayer:()=>Sh,GreatCircleLayer:()=>qf,GridCellLayer:()=>Da,GridLayer:()=>zf,H3ClusterLayer:()=>sh,H3HexagonLayer:()=>Ja,HeatmapLayer:()=>Gf,HexagonLayer:()=>Df,IconLayer:()=>Ss,LineLayer:()=>Ba,MVTLayer:()=>vh,PathLayer:()=>gn,PointCloudLayer:()=>Oa,PolygonLayer:()=>_n,QuadkeyLayer:()=>Zf,S2Layer:()=>Jf,ScatterplotLayer:()=>Fa,ScreenGridLayer:()=>Nf,SolidPolygonLayer:()=>mn,TerrainLayer:()=>Th,TextLayer:()=>Ha,Tile3DLayer:()=>_h,TileLayer:()=>rs,TripsLayer:()=>rh,_AggregationLayer:()=>Mi,_BinSorter:()=>ws,_CPUAggregator:()=>Ms,_GPUGridAggregator:()=>mr,_GeoCellLayer:()=>Pi,_MultiIconLayer:()=>ka,_TextBackgroundLayer:()=>za,_Tile2DHeader:()=>Ya,_Tileset2D:()=>Qa,_WMSLayer:()=>Pp,_getURLFromTemplate:()=>ts});var C4=`#version 300 es #define SHADER_NAME arc-layer-vertex-shader in vec3 positions; in vec4 instanceSourceColors; @@ -1096,7 +1403,7 @@ vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio); vColor = vec4(color.rgb, color.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } -`;var c2=`#version 300 es +`;var M4=`#version 300 es #define SHADER_NAME arc-layer-fragment-shader precision highp float; in vec4 vColor; @@ -1111,7 +1418,7 @@ fragColor = vColor; geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var Hl=[0,0,0,255],fP={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:Hl},getTargetColor:{type:"accessor",value:Hl},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},na=class extends ne{static{this.layerName="ArcLayer"}static{this.defaultProps=fP}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:a2,fs:c2,modules:[ae,ue]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:Hl},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:Hl},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e;(s.extensionsChanged||r.numSegments!==i.numSegments)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,greatCircle:o,wrapLongitude:a}=this.props,c=this.state.model;c.setUniforms(e),c.setUniforms({greatCircle:o,widthUnits:pe[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:a}),c.draw(this.context.renderPass)}_getModel(){let{numSegments:e}=this.props,r=[];for(let s=0;s0&&p>0&&(a[f++]=u-n,a[f++]=u-n-1,a[f++]=u-1,a[f++]=u-n,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function pP(t){let e=new Float64Array(12);for(let r=0;rt.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:Kd},getTargetColor:{type:"accessor",value:Kd},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},Ia=class extends ht{static{this.layerName="ArcLayer"}static{this.defaultProps=GH}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:C4,fs:M4,modules:[xt,Mt]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:Kd},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:Kd},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:n}=e;(n.extensionsChanged||r.numSegments!==i.numSegments)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:n,widthMaxPixels:s,greatCircle:o,wrapLongitude:a}=this.props,A=this.state.model;A.setUniforms(e),A.setUniforms({greatCircle:o,widthUnits:Yt[r],widthScale:i,widthMinPixels:n,widthMaxPixels:s,useShortestPath:a}),A.draw(this.context.renderPass)}_getModel(){let{numSegments:e}=this.props,r=[];for(let n=0;n0&&v>0&&(a[_++]=g-s,a[_++]=g-s-1,a[_++]=g-1,a[_++]=g-s,a[_++]=g-1,a[_++]=g),g++}}return{vertexCount:o,positions:h,indices:a,texCoords:A}}function XH(t){let e=new Float64Array(12);for(let r=0;ri.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:i}){let s=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll()),e.bounds!==r.bounds){let n=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)n&&n[a]!==o[a]&&s.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,i=e.info;if(!i.color||!r)return i.bitmap=null,i;let{width:s,height:n}=r;i.index=0;let o=xP(i.color);return i.bitmap={size:{width:s,height:n},uv:o,pixel:[Math.floor(o[0]*s),Math.floor(o[1]*n)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return f2(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),Jd(r,this.context.viewport.resolution)}_getModel(){return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{uniforms:r,moduleParameters:i}=e,{model:s,coordinateConversion:n,bounds:o,disablePicking:a}=this.state,{image:c,desaturate:l,transparentColor:u,tintColor:f}=this.props;i.picking.isActive&&a||c&&s&&(s.setUniforms(r),s.setBindings({bitmapTexture:c}),s.setUniforms({desaturate:l,transparentColor:u.map(h=>h/255),tintColor:f.slice(0,3).map(h=>h/255),coordinateConversion:n,bounds:o}),s.draw(this.context.renderPass))}_getCoordinateUniforms(){let{LNGLAT:e,CARTESIAN:r,DEFAULT:i}=q,{_imageCoordinateSystem:s}=this.props;if(s!==i){let{bounds:n}=this.props;if(!f2(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?e:r;if(s=s===e?e:r,s===e&&o===r)return{coordinateConversion:-1,bounds:n};if(s===r&&o===e){let a=Ze([n[0],n[1]]),c=Ze([n[2],n[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],c[0],c[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};function xP(t){let[e,r,i]=t,s=(i&240)/256,n=(i&15)/16;return[(e+n)/256,(r+s)/256]}function f2(t){return Number.isFinite(t[0])}var h2=`#version 300 es +`;var qH={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:Oe.DEFAULT,desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},Ra=class extends ht{static{this.layerName="BitmapLayer"}static{this.defaultProps=qH}getShaders(){return super.getShaders({vs:P4,fs:I4,modules:[xt,Mt]})}initializeState(){let e=this.getAttributeManager();e.remove(["instancePickingColors"]);let r=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:i}){let n=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll()),e.bounds!==r.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&n.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,i=e.info;if(!i.color||!r)return i.bitmap=null,i;let{width:n,height:s}=r;i.index=0;let o=KH(i.color);return i.bitmap={size:{width:n,height:s},uv:o,pixel:[Math.floor(o[0]*n),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return R4(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),vy(r,this.context.viewport.resolution)}_getModel(){return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{uniforms:r,moduleParameters:i}=e,{model:n,coordinateConversion:s,bounds:o,disablePicking:a}=this.state,{image:A,desaturate:h,transparentColor:g,tintColor:_}=this.props;i.picking.isActive&&a||A&&n&&(n.setUniforms(r),n.setBindings({bitmapTexture:A}),n.setUniforms({desaturate:h,transparentColor:g.map(x=>x/255),tintColor:_.slice(0,3).map(x=>x/255),coordinateConversion:s,bounds:o}),n.draw(this.context.renderPass))}_getCoordinateUniforms(){let{LNGLAT:e,CARTESIAN:r,DEFAULT:i}=Oe,{_imageCoordinateSystem:n}=this.props;if(n!==i){let{bounds:s}=this.props;if(!R4(s))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?e:r;if(n=n===e?e:r,n===e&&o===r)return{coordinateConversion:-1,bounds:s};if(n===r&&o===e){let a=gr([s[0],s[1]]),A=gr([s[2],s[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],A[0],A[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};function KH(t){let[e,r,i]=t,n=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(r+n)/256]}function R4(t){return Number.isFinite(t[0])}var B4=`#version 300 es #define SHADER_NAME icon-layer-vertex-shader in vec2 positions; in vec3 instancePositions; @@ -1324,7 +1631,7 @@ vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); vColorMode = instanceColorModes; } -`;var d2=`#version 300 es +`;var O4=`#version 300 es #define SHADER_NAME icon-layer-fragment-shader precision highp float; uniform float opacity; @@ -1346,7 +1653,7 @@ discard; fragColor = vec4(color, a); DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var yP=1024,bP=4,p2=()=>{},g2={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},vP={x:0,y:0,width:0,height:0};function TP(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function EP(t,e,r,i){let s=Math.min(r/e.width,i/e.height),n=Math.floor(e.width*s),o=Math.floor(e.height*s);return s===1?{data:e,width:n,height:o}:(t.canvas.height=o,t.canvas.width=n,t.clearRect(0,0,n,o),t.drawImage(e,0,0,e.width,e.height,0,0,n,o),{data:t.canvas,width:n,height:o})}function aa(t){return t&&(t.id||t.url)}function SP(t,e,r,i){let{width:s,height:n,device:o}=t,a=o.createTexture({format:"rgba8unorm",width:e,height:r,sampler:i}),c=o.createCommandEncoder();return c.copyTextureToTexture({source:t,destination:a,width:s,height:n}),c.finish(),t.destroy(),a}function m2(t,e,r){for(let i=0;io&&(m2(r,a,s),i=0,s=n+s+e,n=0,a=[]),a.push({icon:l,xOffset:i}),i=i+h+e,n=Math.max(n,f)}}return a.length>0&&m2(r,a,s),{mapping:r,rowHeight:n,xOffset:i,yOffset:s,canvasWidth:o,canvasHeight:TP(n+s+e)}}function wP(t,e,r){if(!t||!e)return null;r=r||{};let i={},{iterable:s,objectInfo:n}=$e(t);for(let o of s){n.index++;let a=e(o,n),c=aa(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[c]&&(!r[c]||a.url!==r[c].url)&&(i[c]={...a,source:o,sourceIndex:n.index})}return i}var ca=class{constructor(e,{onUpdate:r=p2,onError:i=p2}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._textureParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=bP,this._canvasWidth=yP,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?aa(e):e;return this._mapping[r]||vP}setProps({loadOptions:e,autoPacking:r,iconAtlas:i,iconMapping:s,textureParameters:n}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),s&&(this._mapping=s),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),n&&(this._textureParameters=n)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let i=Object.values(wP(e,r,this._mapping)||{});if(i.length>0){let{mapping:s,xOffset:n,yOffset:o,rowHeight:a,canvasHeight:c}=AP({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=s,this._xOffset=n,this._yOffset=o,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._textureParameters||g2})),this._texture.height!==this._canvasHeight&&(this._texture=SP(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||g2)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let i of e)this._pendingCount++,Lr(i.url,this._loadOptions).then(s=>{let n=aa(i),o=this._mapping[n],{x:a,y:c,width:l,height:u}=o,{data:f,width:h,height:d}=EP(r,s,l,u);this._texture.setSubImageData({data:f,x:a+(l-h)/2,y:c+(u-d)/2,width:h,height:d}),o.width=h,o.height=d,this._texture.generateMipmap(),this.onUpdate()}).catch(s=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:s})}).finally(()=>{this._pendingCount--})}};var _2=[0,0,0,255],PP={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:_2},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},Ar=class extends ne{static{this.defaultProps=PP}static{this.layerName="IconLayer"}getShaders(){return super.getShaders({vs:h2,fs:d2,modules:[ae,ue]})}initializeState(){this.state={iconManager:new ca(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:_2},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e,n=this.getAttributeManager(),{iconAtlas:o,iconMapping:a,data:c,getIcon:l,textureParameters:u}=r,{iconManager:f}=this.state;if(typeof o=="string")return;let h=o||this.internalState.isAsyncPropLoading("iconAtlas");f.setProps({loadOptions:r.loadOptions,autoPacking:!h,iconAtlas:o,iconMapping:h?a:null,textureParameters:u}),h?i.iconMapping!==r.iconMapping&&n.invalidate("getIcon"):(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getIcon))&&f.packIcons(c,l),s.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,sizeUnits:n,billboard:o,alphaCutoff:a}=this.props,{iconManager:c}=this.state,l=c.getTexture();if(l){let u=this.state.model;u.setBindings({iconsTexture:l}),u.setUniforms(e),u.setUniforms({iconsTextureDim:[l.width,l.height],sizeUnits:pe[n],sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,billboard:o,alphaCutoff:a}),u.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):U.error(e.error.message)()}getInstanceOffset(e){let{width:r,height:i,anchorX:s=r/2,anchorY:n=i/2}=this.state.iconManager.getIconMapping(e);return[r/2-s,i/2-n]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){let{x:r,y:i,width:s,height:n}=this.state.iconManager.getIconMapping(e);return[r,i,s,n]}};var x2=`#version 300 es +`;var JH=1024,ZH=4,F4=()=>{},L4={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},$H={x:0,y:0,width:0,height:0};function eG(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function tG(t,e,r,i){let n=Math.min(r/e.width,i/e.height),s=Math.floor(e.width*n),o=Math.floor(e.height*n);return n===1?{data:e,width:s,height:o}:(t.canvas.height=o,t.canvas.width=s,t.clearRect(0,0,s,o),t.drawImage(e,0,0,e.width,e.height,0,0,s,o),{data:t.canvas,width:s,height:o})}function hf(t){return t&&(t.id||t.url)}function rG(t,e,r,i){let{width:n,height:s,device:o}=t,a=o.createTexture({format:"rgba8unorm",width:e,height:r,sampler:i}),A=o.createCommandEncoder();return A.copyTextureToTexture({source:t,destination:a,width:n,height:s}),A.finish(),t.destroy(),a}function N4(t,e,r){for(let i=0;io&&(N4(r,a,n),i=0,n=s+n+e,s=0,a=[]),a.push({icon:h,xOffset:i}),i=i+x+e,s=Math.max(s,_)}}return a.length>0&&N4(r,a,n),{mapping:r,rowHeight:s,xOffset:i,yOffset:n,canvasWidth:o,canvasHeight:eG(s+n+e)}}function nG(t,e,r){if(!t||!e)return null;r=r||{};let i={},{iterable:n,objectInfo:s}=nr(t);for(let o of n){s.index++;let a=e(o,s),A=hf(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[A]&&(!r[A]||a.url!==r[A].url)&&(i[A]={...a,source:o,sourceIndex:s.index})}return i}var df=class{constructor(e,{onUpdate:r=F4,onError:i=F4}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._textureParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=ZH,this._canvasWidth=JH,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?hf(e):e;return this._mapping[r]||$H}setProps({loadOptions:e,autoPacking:r,iconAtlas:i,iconMapping:n,textureParameters:s}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),n&&(this._mapping=n),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),s&&(this._textureParameters=s)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let i=Object.values(nG(e,r,this._mapping)||{});if(i.length>0){let{mapping:n,xOffset:s,yOffset:o,rowHeight:a,canvasHeight:A}=iG({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=n,this._xOffset=s,this._yOffset=o,this._canvasHeight=A,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._textureParameters||L4})),this._texture.height!==this._canvasHeight&&(this._texture=rG(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||L4)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let i of e)this._pendingCount++,Cr(i.url,this._loadOptions).then(n=>{let s=hf(i),o=this._mapping[s],{x:a,y:A,width:h,height:g}=o,{data:_,width:x,height:T}=tG(r,n,h,g);this._texture.setSubImageData({data:_,x:a+(h-x)/2,y:A+(g-T)/2,width:x,height:T}),o.width=x,o.height=T,this._texture.generateMipmap(),this.onUpdate()}).catch(n=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:n})}).finally(()=>{this._pendingCount--})}};var D4=[0,0,0,255],sG={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:D4},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},Ss=class extends ht{static{this.defaultProps=sG}static{this.layerName="IconLayer"}getShaders(){return super.getShaders({vs:B4,fs:O4,modules:[xt,Mt]})}initializeState(){this.state={iconManager:new df(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:D4},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:n}=e,s=this.getAttributeManager(),{iconAtlas:o,iconMapping:a,data:A,getIcon:h,textureParameters:g}=r,{iconManager:_}=this.state;if(typeof o=="string")return;let x=o||this.internalState.isAsyncPropLoading("iconAtlas");_.setProps({loadOptions:r.loadOptions,autoPacking:!x,iconAtlas:o,iconMapping:x?a:null,textureParameters:g}),x?i.iconMapping!==r.iconMapping&&s.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&_.packIcons(A,h),n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeMinPixels:i,sizeMaxPixels:n,sizeUnits:s,billboard:o,alphaCutoff:a}=this.props,{iconManager:A}=this.state,h=A.getTexture();if(h){let g=this.state.model;g.setBindings({iconsTexture:h}),g.setUniforms(e),g.setUniforms({iconsTextureDim:[h.width,h.height],sizeUnits:Yt[s],sizeScale:r,sizeMinPixels:i,sizeMaxPixels:n,billboard:o,alphaCutoff:a}),g.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mt({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):me.error(e.error.message)()}getInstanceOffset(e){let{width:r,height:i,anchorX:n=r/2,anchorY:s=i/2}=this.state.iconManager.getIconMapping(e);return[r/2-n,i/2-s]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){let{x:r,y:i,width:n,height:s}=this.state.iconManager.getIconMapping(e);return[r,i,n,s]}};var U4=`#version 300 es #define SHADER_NAME line-layer-vertex-shader in vec3 positions; in vec3 instanceSourcePositions; @@ -1420,7 +1727,7 @@ gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vColor = vec4(instanceColors.rgb, instanceColors.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } -`;var y2=`#version 300 es +`;var k4=`#version 300 es #define SHADER_NAME line-layer-fragment-shader precision highp float; in vec4 vColor; @@ -1431,7 +1738,7 @@ geometry.uv = uv; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var CP=[0,0,0,255],RP={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:CP},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},Xi=class extends ne{static{this.layerName="LineLayer"}static{this.defaultProps=RP}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:x2,fs:y2,modules:[ae,ue]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,wrapLongitude:o}=this.props,a=this.state.model;a.setUniforms(e),a.setUniforms({widthUnits:pe[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:o?1:0}),a.draw(this.context.renderPass),o&&(a.setUniforms({useShortestPath:-1}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var b2=`#version 300 es +`;var oG=[0,0,0,255],aG={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:oG},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},Ba=class extends ht{static{this.layerName="LineLayer"}static{this.defaultProps=aG}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:U4,fs:k4,modules:[xt,Mt]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:n,widthMaxPixels:s,wrapLongitude:o}=this.props,a=this.state.model;a.setUniforms(e),a.setUniforms({widthUnits:Yt[r],widthScale:i,widthMinPixels:n,widthMaxPixels:s,useShortestPath:o?1:0}),a.draw(this.context.renderPass),o&&(a.setUniforms({useShortestPath:-1}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mt({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var V4=`#version 300 es #define SHADER_NAME point-cloud-layer-vertex-shader in vec3 positions; in vec3 instanceNormals; @@ -1459,7 +1766,7 @@ vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosi vColor = vec4(lightColor, instanceColors.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } -`;var v2=`#version 300 es +`;var z4=`#version 300 es #define SHADER_NAME point-cloud-layer-fragment-shader precision highp float; in vec4 vColor; @@ -1474,7 +1781,7 @@ discard; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var T2=[0,0,0,255],E2=[0,0,1],MP={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:E2},getColor:{type:"accessor",value:T2},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function IP(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:i,value:s}=r.COLOR_0;r.instanceColors={size:i,type:"unorm8",value:s}}}var la=class extends ne{static{this.layerName="PointCloudLayer"}static{this.defaultProps=MP}getShaders(){return super.getShaders({vs:b2,fs:v2,modules:[ae,Mt,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:E2},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:T2}})}updateState(e){let{changeFlags:r,props:i}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&IP(i.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:i}=this.props,s=this.state.model;s.setUniforms(e),s.setUniforms({sizeUnits:pe[i],radiusPixels:r}),s.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let i=r/3*Math.PI*2;e.push(Math.cos(i)*2,Math.sin(i)*2,0)}return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};var S2=`#version 300 es +`;var H4=[0,0,0,255],G4=[0,0,1],cG={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:G4},getColor:{type:"accessor",value:H4},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function lG(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:i,value:n}=r.COLOR_0;r.instanceColors={size:i,type:"unorm8",value:n}}}var Oa=class extends ht{static{this.layerName="PointCloudLayer"}static{this.defaultProps=cG}getShaders(){return super.getShaders({vs:V4,fs:z4,modules:[xt,sn,Mt]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:G4},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:H4}})}updateState(e){let{changeFlags:r,props:i}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&lG(i.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:i}=this.props,n=this.state.model;n.setUniforms(e),n.setUniforms({sizeUnits:Yt[i],radiusPixels:r}),n.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let i=r/3*Math.PI*2;e.push(Math.cos(i)*2,Math.sin(i)*2,0)}return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mt({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};var W4=`#version 300 es #define SHADER_NAME scatterplot-layer-vertex-shader in vec3 positions; in vec3 instancePositions; @@ -1535,7 +1842,7 @@ DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } -`;var A2=`#version 300 es +`;var j4=`#version 300 es #define SHADER_NAME scatterplot-layer-fragment-shader precision highp float; uniform bool filled; @@ -1576,7 +1883,7 @@ fragColor = vFillColor; fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var w2=[0,0,0,255],OP={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:w2},getLineColor:{type:"accessor",value:w2},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},$i=class extends ne{static{this.defaultProps=OP}static{this.layerName="ScatterplotLayer"}getShaders(){return super.getShaders({vs:S2,fs:A2,modules:[ae,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:i,radiusMinPixels:s,radiusMaxPixels:n,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props,p=this.state.model;p.setUniforms(e),p.setUniforms({stroked:o?1:0,filled:a,billboard:c,antialiasing:l,radiusUnits:pe[r],radiusScale:i,radiusMinPixels:s,radiusMaxPixels:n,lineWidthUnits:pe[u],lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}),p.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var Ws={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function Yi(t,e,r={}){return P2(t,r)!==e?(NP(t,r),!0):!1}function P2(t,e={}){return Math.sign(jl(t,e))}var Qd={x:0,y:1,z:2};function jl(t,e={}){let{start:r=0,end:i=t.length,plane:s="xy"}=e,n=e.size||2,o=0,a=Qd[s[0]],c=Qd[s[1]];for(let l=r,u=i-n;l0){let s=!0;for(let n=0;ne[2]&&(r|=2),t[1]e[3]&&(r|=8),r}function ha(t,e){let{size:r=2,broken:i=!1,gridResolution:s=10,gridOffset:n=[0,0],startIndex:o=0,endIndex:a=t.length}=e||{},c=(a-o)/r,l=[],u=[l],f=ti(t,0,r,o),h,d,p=M2(f,s,n,[]),g=[];tt(l,f);for(let _=1;_r&&(l=[],u.push(l),tt(l,f)),d=fa(h,p)}tt(l,h),ua(f,h)}return i?u:u[0]}var C2=0,DP=1;function da(t,e=null,r){if(!t.length)return[];let{size:i=2,gridResolution:s=10,gridOffset:n=[0,0],edgeTypes:o=!1}=r||{},a=[],c=[{pos:t,types:o?new Array(t.length/i).fill(DP):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:h,holes:d}=c.shift();kP(f,i,d[0]||f.length,l),u=M2(l[0],s,n,u);let p=fa(l[1],u);if(p){let g=R2(f,h,i,0,d[0]||f.length,u,p),_={pos:g[0].pos,types:g[0].types,holes:[]},y={pos:g[1].pos,types:g[1].types,holes:[]};c.push(_,y);for(let v=0;v=0?(tt(l,d)&&f.push(g),S+=p):f.length&&(f[f.length-1]=C2),ua(_,d),y=p,v=g;return[T?{pos:c,types:e&&u}:null,S?{pos:l,types:e&&f}:null]}function M2(t,e,r,i){let s=Math.floor((t[0]-r[0])/e)*e+r[0],n=Math.floor((t[1]-r[1])/e)*e+r[1];return i[0]=s,i[1]=n,i[2]=s+e,i[3]=n+e,i}function LP(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function kP(t,e,r,i){let s=1/0,n=-1/0,o=1/0,a=-1/0;for(let c=0;cn?l:n,o=ua?u:a}return i[0][0]=s,i[0][1]=o,i[1][0]=n,i[1][1]=a,i}function $l(t,e){for(let r=0;rs&&(s=a,n=o-1)}return n}function zP(t,e,r,i,s=BP){let n=t[r],o=t[i-e];if(Math.abs(n-o)>180){let a=ti(t,0,e,r);a[0]+=Math.round((o-n)/360)*360,tt(t,a),a[1]=Math.sign(a[1])*s,tt(t,a),a[0]=n,tt(t,a)}}function I2(t,e,r,i){let s=t[0],n;for(let o=r;o180||a<-180)&&(n-=Math.round(a/360)*360),t[o]=s=n}}function O2(t,e){let r,i=t.length/e;for(let n=0;n=i),s=s.flatMap(d=>[d[0],d[1]]),Yi(s,Ws.COUNTER_CLOCKWISE));let n=r>0,o=i+1,a=n?o*3+1:i,c=Math.PI*2/i,l=new Uint16Array(n?i*3*2:0),u=new Float32Array(a*3),f=new Float32Array(a*3),h=0;if(n){for(let d=0;dt.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:X4},getLineColor:{type:"accessor",value:X4},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},Fa=class extends ht{static{this.defaultProps=AG}static{this.layerName="ScatterplotLayer"}getShaders(){return super.getShaders({vs:W4,fs:j4,modules:[xt,Mt]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:i,radiusMinPixels:n,radiusMaxPixels:s,stroked:o,filled:a,billboard:A,antialiasing:h,lineWidthUnits:g,lineWidthScale:_,lineWidthMinPixels:x,lineWidthMaxPixels:T}=this.props,v=this.state.model;v.setUniforms(e),v.setUniforms({stroked:o?1:0,filled:a,billboard:A,antialiasing:h,radiusUnits:Yt[r],radiusScale:i,radiusMinPixels:n,radiusMaxPixels:s,lineWidthUnits:Yt[g],lineWidthScale:_,lineWidthMinPixels:x,lineWidthMaxPixels:T}),v.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mt({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var ol={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function La(t,e,r={}){return Y4(t,r)!==e?(uG(t,r),!0):!1}function Y4(t,e={}){return Math.sign(xo(t,e))}var pf={x:0,y:1,z:2};function xo(t,e={}){let{start:r=0,end:i=t.length,plane:n="xy"}=e,s=e.size||2,o=0,a=pf[n[0]],A=pf[n[1]];for(let h=r,g=i-s;h80*r){x=g=t[0],T=_=t[1];for(let C=r;Cg&&(g=v),S>_&&(_=S);h=Math.max(g-x,_-T),h=h!==0?32767/h:0}return gf(a,A,r,x,T,h,0),A}function q4(t,e,r,i,n,s,o){let a,A;s===void 0&&(s=xo(t,{start:e,end:r,size:i,plane:o}));let h=pf[o[0]],g=pf[o[1]];if(n===s<0)for(a=e;a=e;a-=i)A=Q4(a,t[a+h],t[a+g],A);return A&&$d(A,A.next)&&(_f(A),A=A.next),A}function Na(t,e){if(!t)return t;e||(e=t);let r=t,i;do if(i=!1,!r.steiner&&($d(r,r.next)||qt(r.prev,r,r.next)===0)){if(_f(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function gf(t,e,r,i,n,s,o){if(!t)return;!o&&s&&TG(t,i,n,s);let a=t,A,h;for(;t.prev!==t.next;){if(A=t.prev,h=t.next,s?dG(t,i,n,s):hG(t)){e.push(A.i/r|0),e.push(t.i/r|0),e.push(h.i/r|0),_f(t),t=h.next,a=h.next;continue}if(t=h,t===a){o?o===1?(t=pG(Na(t),e,r),gf(t,e,r,i,n,s,2)):o===2&&gG(t,e,r,i,n,s):gf(Na(t),e,r,i,n,s,1);break}}}function hG(t){let e=t.prev,r=t,i=t.next;if(qt(e,r,i)>=0)return!1;let n=e.x,s=r.x,o=i.x,a=e.y,A=r.y,h=i.y,g=ns?n>o?n:o:s>o?s:o,T=a>A?a>h?a:h:A>h?A:h,v=i.next;for(;v!==e;){if(v.x>=g&&v.x<=x&&v.y>=_&&v.y<=T&&al(n,a,s,A,o,h,v.x,v.y)&&qt(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function dG(t,e,r,i){let n=t.prev,s=t,o=t.next;if(qt(n,s,o)>=0)return!1;let a=n.x,A=s.x,h=o.x,g=n.y,_=s.y,x=o.y,T=aA?a>h?a:h:A>h?A:h,C=g>_?g>x?g:x:_>x?_:x,M=Sy(T,v,e,r,i),R=Sy(S,C,e,r,i),B=t.prevZ,k=t.nextZ;for(;B&&B.z>=M&&k&&k.z<=R;){if(B.x>=T&&B.x<=S&&B.y>=v&&B.y<=C&&B!==n&&B!==o&&al(a,g,A,_,h,x,B.x,B.y)&&qt(B.prev,B,B.next)>=0||(B=B.prevZ,k.x>=T&&k.x<=S&&k.y>=v&&k.y<=C&&k!==n&&k!==o&&al(a,g,A,_,h,x,k.x,k.y)&&qt(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;B&&B.z>=M;){if(B.x>=T&&B.x<=S&&B.y>=v&&B.y<=C&&B!==n&&B!==o&&al(a,g,A,_,h,x,B.x,B.y)&&qt(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;k&&k.z<=R;){if(k.x>=T&&k.x<=S&&k.y>=v&&k.y<=C&&k!==n&&k!==o&&al(a,g,A,_,h,x,k.x,k.y)&&qt(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function pG(t,e,r){let i=t;do{let n=i.prev,s=i.next.next;!$d(n,s)&&K4(n,i,i.next,s)&&mf(n,s)&&mf(s,n)&&(e.push(n.i/r|0),e.push(i.i/r|0),e.push(s.i/r|0),_f(i),_f(i.next),i=t=s),i=i.next}while(i!==t);return Na(i)}function gG(t,e,r,i,n,s){let o=t;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&SG(o,a)){let A=J4(o,a);o=Na(o,o.next),A=Na(A,A.next),gf(o,e,r,i,n,s,0),gf(A,e,r,i,n,s,0);return}a=a.next}o=o.next}while(o!==t)}function mG(t,e,r,i,n,s){let o=[],a,A,h,g,_;for(a=0,A=e.length;a=r.next.y&&r.next.y!==r.y){let x=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(x<=i&&x>s&&(s=x,o=r.x=r.x&&r.x>=A&&i!==r.x&&al(no.x||r.x===o.x&&bG(o,r)))&&(o=r,g=_)),r=r.next;while(r!==a);return o}function bG(t,e){return qt(t.prev,t,e.prev)<0&&qt(e.next,t,t.next)<0}function TG(t,e,r,i){let n=t;do n.z===0&&(n.z=Sy(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,EG(n)}function EG(t){let e,r,i=1,n,s,o,a,A,h;do{for(s=t,t=null,h=null,n=0;s;){for(n++,a=s,o=0,r=0;r0||A>0&&a;)o!==0&&(A===0||!a||s.z<=a.z)?(e=s,s=s.nextZ,o--):(e=a,a=a.nextZ,A--),h?h.nextZ=e:t=e,e.prevZ=h,h=e;s=a}h.nextZ=null,i*=2}while(n>1);return t}function Sy(t,e,r,i,n){return t=(t-r)*n|0,e=(e-i)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function vG(t){let e=t,r=t;do(e.x=(t-o)*(s-a)&&(t-o)*(i-a)>=(r-o)*(e-a)&&(r-o)*(s-a)>=(n-o)*(i-a)}function SG(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!wG(t,e)&&(mf(t,e)&&mf(e,t)&&CG(t,e)&&(qt(t.prev,t,e.prev)||qt(t,e.prev,e))||$d(t,e)&&qt(t.prev,t,t.next)>0&&qt(e.prev,e,e.next)>0)}function qt(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function $d(t,e){return t.x===e.x&&t.y===e.y}function K4(t,e,r,i){let n=Zd(qt(t,e,r)),s=Zd(qt(t,e,i)),o=Zd(qt(r,i,t)),a=Zd(qt(r,i,e));return!!(n!==s&&o!==a||n===0&&Jd(t,r,e)||s===0&&Jd(t,i,e)||o===0&&Jd(r,t,i)||a===0&&Jd(r,e,i))}function Jd(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Zd(t){return t>0?1:t<0?-1:0}function wG(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&K4(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function mf(t,e){return qt(t.prev,t,t.next)<0?qt(t,e,t.next)>=0&&qt(t,t.prev,e)>=0:qt(t,e,t.prev)<0||qt(t,t.next,e)<0}function CG(t,e){let r=t,i=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function J4(t,e){let r=new yf(t.i,t.x,t.y),i=new yf(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function Q4(t,e,r,i){let n=new yf(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function _f(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var yf=class{constructor(e,r,i){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=i}};function gi(t,e){let r=e.length,i=t.length;if(i>0){let n=!0;for(let s=0;se[2]&&(r|=2),t[1]e[3]&&(r|=8),r}function Tf(t,e){let{size:r=2,broken:i=!1,gridResolution:n=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=t.length}=e||{},A=(a-o)/r,h=[],g=[h],_=bo(t,0,r,o),x,T,v=eM(_,n,s,[]),S=[];gi(h,_);for(let C=1;Cr&&(h=[],g.push(h),gi(h,_)),T=bf(x,v)}gi(h,x),xf(_,x)}return i?g:g[0]}var Z4=0,MG=1;function Ef(t,e=null,r){if(!t.length)return[];let{size:i=2,gridResolution:n=10,gridOffset:s=[0,0],edgeTypes:o=!1}=r||{},a=[],A=[{pos:t,types:o?new Array(t.length/i).fill(MG):null,holes:e||[]}],h=[[],[]],g=[];for(;A.length;){let{pos:_,types:x,holes:T}=A.shift();IG(_,i,T[0]||_.length,h),g=eM(h[0],n,s,g);let v=bf(h[1],g);if(v){let S=$4(_,x,i,0,T[0]||_.length,g,v),C={pos:S[0].pos,types:S[0].types,holes:[]},M={pos:S[1].pos,types:S[1].types,holes:[]};A.push(C,M);for(let R=0;R=0?(gi(h,T)&&_.push(S),k+=v):_.length&&(_[_.length-1]=Z4),xf(C,T),M=v,R=S;return[B?{pos:A,types:e&&g}:null,k?{pos:h,types:e&&_}:null]}function eM(t,e,r,i){let n=Math.floor((t[0]-r[0])/e)*e+r[0],s=Math.floor((t[1]-r[1])/e)*e+r[1];return i[0]=n,i[1]=s,i[2]=n+e,i[3]=s+e,i}function PG(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function IG(t,e,r,i){let n=1/0,s=-1/0,o=1/0,a=-1/0;for(let A=0;As?h:s,o=ga?g:a}return i[0][0]=n,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function tp(t,e){for(let r=0;rn&&(n=a,s=o-1)}return s}function OG(t,e,r,i,n=RG){let s=t[r],o=t[i-e];if(Math.abs(s-o)>180){let a=bo(t,0,e,r);a[0]+=Math.round((o-s)/360)*360,gi(t,a),a[1]=Math.sign(a[1])*n,gi(t,a),a[0]=s,gi(t,a)}}function tM(t,e,r,i){let n=t[0],s;for(let o=r;o180||a<-180)&&(s-=Math.round(a/360)*360),t[o]=n=s}}function rM(t,e){let r,i=t.length/e;for(let s=0;s=i),n=n.flatMap(T=>[T[0],T[1]]),La(n,ol.COUNTER_CLOCKWISE));let s=r>0,o=i+1,a=s?o*3+1:i,A=Math.PI*2/i,h=new Uint16Array(s?i*3*2:0),g=new Float32Array(a*3),_=new Float32Array(a*3),x=0;if(s){for(let T=0;Tt.position},getFillColor:{type:"accessor",value:Yl},getLineColor:{type:"accessor",value:Yl},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},wr=class extends ne{static{this.layerName="ColumnLayer"}static{this.defaultProps=HP}getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:N2,fs:F2,defines:e,modules:[ae,r?eo:Mt,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:Yl},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:Yl},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e,n=s.extensionsChanged||r.flatShading!==i.flatShading;n&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(n||r.diskResolution!==i.diskResolution||r.vertices!==i.vertices||(r.extruded||r.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(r)}getGeometry(e,r,i){let s=new pa({radius:1,height:i?2:0,vertices:r,nradial:e}),n=0;if(r)for(let o=0;o=e.length&&(r+=1-e.length/s);let n=r*s;return i[0]=e[n],i[1]=e[n+1],i[2]=s===3&&e[n+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,i=e.length-r;return e[0]===e[i]&&e[1]===e[i+1]&&(r===2||e[2]===e[i+2])}};function L2(t){return Array.isArray(t[0])}var k2=`#version 300 es +`;var rp=[0,0,0,255],NG={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:rp},getLineColor:{type:"accessor",value:rp},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},pn=class extends ht{static{this.layerName="ColumnLayer"}static{this.defaultProps=NG}getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:iM,fs:nM,defines:e,modules:[xt,r?ha:sn,Mt]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:rp},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:rp},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:n}=e,s=n.extensionsChanged||r.flatShading!==i.flatShading;s&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(s||r.diskResolution!==i.diskResolution||r.vertices!==i.vertices||(r.extruded||r.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(r)}getGeometry(e,r,i){let n=new vf({radius:1,height:i?2:0,vertices:r,nradial:e}),s=0;if(r)for(let o=0;o=e.length&&(r+=1-e.length/n);let s=r*n;return i[0]=e[s],i[1]=e[s+1],i[2]=n===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,i=e.length-r;return e[0]===e[i]&&e[1]===e[i+1]&&(r===2||e[2]===e[i+2])}};function oM(t){return Array.isArray(t[0])}var aM=`#version 300 es #define SHADER_NAME path-layer-vertex-shader in vec2 positions; in float instanceTypes; @@ -1827,7 +2134,7 @@ DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } DECKGL_FILTER_COLOR(vColor, geometry); } -`;var B2=`#version 300 es +`;var cM=`#version 300 es #define SHADER_NAME path-layer-fragment-shader precision highp float; uniform float miterLimit; @@ -1851,7 +2158,7 @@ discard; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var U2=[0,0,0,255],YP={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:U2},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},ip={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},Pr=class extends ne{static{this.defaultProps=YP}static{this.layerName="PathLayer"}getShaders(){return super.getShaders({vs:k2,fs:B2,modules:[ae,ue]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:ip,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:ip,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:ip,defaultValue:U2},instancePickingColors:{size:4,type:"uint8",accessor:(i,{index:s,target:n})=>this.encodePickingColor(i&&i.__source?i.__source.index:s,n)}}),this.setState({pathTesselator:new ga({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:i}=e,s=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){let{pathTesselator:o}=this.state,a=r.data.attributes||{};o.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:o.instanceCount,startIndices:o.vertexStarts}),i.dataChanged||s.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;i=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function hC(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function dC(t,e,r,i){for(let s=0;sa/e));let n=js(t),o=i&&e===3;if(r){let a=n.length;n=n.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(r||(n=n.slice()),K2(n,0,2,1)):(r||(n=n.slice()),K2(n,2,0,1)))}return(0,q2.default)(n,s,e)}var ba=class extends ei{constructor(e){let{fp64:r,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=Ql(e,this.positionSize);return this.opts.resolution?da(js(r),ya(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?tp(js(r),ya(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(J2(e)){let r=0;for(let i of e)r+=this.getGeometrySize(i);return r}return js(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&J2(e))for(let i of e){let s=this.getGeometrySize(i);r.geometrySize=s,this.updateGeometryAttributes(i,r),r.vertexStart+=s,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let i=e;this._updateIndices(i,r),this._updatePositions(i,r),this._updateVertexValid(i,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:i,indexStart:s}){let{attributes:n,indexStarts:o,typedArrayManager:a}=this,c=n.indices;if(!c||!e)return;let l=s,u=G2(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,s+u.length,{copy:!0});for(let f=0;f2?o[c*n+2]:0;s[a*3]=l,s[a*3+1]=u,s[a*3+2]=f}}_updateVertexValid(e,{vertexStart:r,geometrySize:i}){let{positionSize:s}=this,n=this.attributes.vertexValid,o=e&&ya(e);if(e&&e.edgeTypes?n.set(e.edgeTypes,r):n.fill(1,r,r+i),o)for(let a=0;a0&&!Number.isFinite(t[0])}var eu=`uniform bool extruded; +`;var lM=[0,0,0,255],VG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:lM},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Iy={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},gn=class extends ht{static{this.defaultProps=VG}static{this.layerName="PathLayer"}getShaders(){return super.getShaders({vs:aM,fs:cM,modules:[xt,Mt]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Iy,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Iy,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Iy,defaultValue:lM},instancePickingColors:{size:4,type:"uint8",accessor:(i,{index:n,target:s})=>this.encodePickingColor(i&&i.__source?i.__source.index:n,s)}}),this.setState({pathTesselator:new Sf({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:i}=e,n=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){let{pathTesselator:o}=this.state,a=r.data.attributes||{};o.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:o.instanceCount,startIndices:o.vertexStarts}),i.dataChanged||n.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(s=>s.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;i=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function sW(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function oW(t,e,r,i){for(let n=0;na/e));let s=ll(t),o=i&&e===3;if(r){let a=s.length;s=s.slice();let A=[];for(let h=0;hA&&a>h||(A>h?(r||(s=s.slice()),_M(s,0,2,1)):(r||(s=s.slice()),_M(s,2,0,1)))}return(0,yM.default)(s,n,e)}var If=class extends yo{constructor(e){let{fp64:r,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=cp(e,this.positionSize);return this.opts.resolution?Ef(ll(r),Pf(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?My(ll(r),Pf(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(TM(e)){let r=0;for(let i of e)r+=this.getGeometrySize(i);return r}return ll(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&TM(e))for(let i of e){let n=this.getGeometrySize(i);r.geometrySize=n,this.updateGeometryAttributes(i,r),r.vertexStart+=n,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let i=e;this._updateIndices(i,r),this._updatePositions(i,r),this._updateVertexValid(i,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:i,indexStart:n}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,A=s.indices;if(!A||!e)return;let h=n,g=xM(e,this.positionSize,this.opts.preproject,this.opts.full3d);A=a.allocate(A,n+g.length,{copy:!0});for(let _=0;_2?o[A*s+2]:0;n[a*3]=h,n[a*3+1]=g,n[a*3+2]=_}}_updateVertexValid(e,{vertexStart:r,geometrySize:i}){let{positionSize:n}=this,s=this.attributes.vertexValid,o=e&&Pf(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,r):s.fill(1,r,r+i),o)for(let a=0;a0&&!Number.isFinite(t[0])}var lp=`uniform bool extruded; uniform bool isWireframe; uniform float elevationScale; uniform float opacity; @@ -1898,12 +2205,12 @@ vColor = vec4(colors.rgb, colors.a * opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } -`;var Q2=`#version 300 es +`;var EM=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader in vec3 vertexPositions; in vec3 vertexPositions64Low; in float elevations; -${eu} +${lp} void main(void) { PolygonProps props; props.positions = vertexPositions; @@ -1912,7 +2219,7 @@ props.elevations = elevations; props.normal = vec3(0.0, 0.0, 1.0); calculatePosition(props); } -`;var e3=`#version 300 es +`;var vM=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader-side #define IS_SIDE_VERTEX in vec2 positions; @@ -1922,7 +2229,7 @@ in vec3 vertexPositions64Low; in vec3 nextVertexPositions64Low; in float elevations; in float instanceVertexValid; -${eu} +${lp} void main(void) { if(instanceVertexValid < 0.5){ gl_Position = vec4(0.); @@ -1953,7 +2260,7 @@ nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), props.elevations = elevations * positions.y; calculatePosition(props); } -`;var t3=`#version 300 es +`;var SM=`#version 300 es #define SHADER_NAME solid-polygon-layer-fragment-shader precision highp float; in vec4 vColor; @@ -1963,7 +2270,7 @@ fragColor = vColor; geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var ru=[0,0,0,255],pC={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ru},getLineColor:{type:"accessor",value:ru},material:!0},tu={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},zt=class extends ne{static{this.defaultProps=pC}static{this.layerName="SolidPolygonLayer"}getShaders(e){return super.getShaders({vs:e==="top"?Q2:e3,fs:t3,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[ae,Mt,ue]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:i}=this.props;e.isGeospatial&&r===q.DEFAULT&&(r=q.LNGLAT);let s;r===q.LNGLAT&&(i?s=e.projectPosition.bind(e):s=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new ba({preproject:s,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let n=this.getAttributeManager(),o=!0;n.remove(["instancePickingColors"]),n.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:tu,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:tu,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:tu,accessor:"getFillColor",defaultValue:ru},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:tu,accessor:"getLineColor",defaultValue:ru},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),n.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:n}=this.state,o=e.data.attributes||{};n.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:n.instanceCount,startIndices:n.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:i}=this.props,s,n,o;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});s=new te(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});n=new te(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,uniforms:{isWireframe:!1},geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new te(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,uniforms:{isWireframe:!0},geometry:new fe({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[n,o,s].filter(Boolean),topModel:s,sideModel:n,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};function iu({data:t,getIndex:e,dataRange:r,replace:i}){let{startRow:s=0,endRow:n=1/0}=r,o=t.length,a=o,c=o;for(let h=0;hh&&d>=s&&(a=h),d>=n){c=h;break}}let l=a,f=c-a!==i.length?t.slice(c):void 0;for(let h=0;ht.polygon},getFillColor:{type:"accessor",value:gC},getLineColor:{type:"accessor",value:r3},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},va=class extends et{static{this.layerName="PolygonLayer"}static{this.defaultProps=mC}initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&U.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let i=this.state.paths.slice(),s=e.dataChanged.map(n=>iu({data:i,getIndex:o=>o.__source.index,dataRange:n,replace:this._getPaths(n)}));this.setState({paths:i,pathsDiff:s})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:i,positionFormat:s,_normalize:n}=this.props,o=[],a=s==="XY"?2:3,{startRow:c,endRow:l}=e,{iterable:u,objectInfo:f}=$e(r,c,l);for(let h of u){f.index++;let d=i(h,f);n&&(d=Ql(d,a));let{holeIndices:p}=d,g=d.positions||d;if(p)for(let _=0;_<=p.length;_++){let y=g.slice(p[_-1]||0,p[_]||g.length);o.push(this.getSubLayerRow({path:y},h,f.index))}else o.push(this.getSubLayerRow({path:g},h,f.index))}return o}renderLayers(){let{data:e,_dataDiff:r,stroked:i,filled:s,extruded:n,wireframe:o,_normalize:a,_windingOrder:c,elevationScale:l,transitions:u,positionFormat:f}=this.props,{lineWidthUnits:h,lineWidthScale:d,lineWidthMinPixels:p,lineWidthMaxPixels:g,lineJointRounded:_,lineMiterLimit:y,lineDashJustified:v}=this.props,{getFillColor:T,getLineColor:S,getLineWidth:R,getLineDashArray:M,getElevation:F,getPolygon:N,updateTriggers:D,material:L}=this.props,{paths:Y,pathsDiff:X}=this.state,$=this.getSubLayerClass("fill",zt),Z=this.getSubLayerClass("stroke",Pr),ge=this.shouldRenderSubLayer("fill",Y)&&new $({_dataDiff:r,extruded:n,elevationScale:l,filled:s,wireframe:o,_normalize:a,_windingOrder:c,getElevation:F,getFillColor:T,getLineColor:n&&o?S:r3,material:L,transitions:u},this.getSubLayerProps({id:"fill",updateTriggers:D&&{getPolygon:D.getPolygon,getElevation:D.getElevation,getFillColor:D.getFillColor,lineColors:n&&o,getLineColor:D.getLineColor}}),{data:e,positionFormat:f,getPolygon:N}),rt=!n&&i&&this.shouldRenderSubLayer("stroke",Y)&&new Z({_dataDiff:X&&(()=>X),widthUnits:h,widthScale:d,widthMinPixels:p,widthMaxPixels:g,jointRounded:_,miterLimit:y,dashJustified:v,_pathType:"loop",transitions:u&&{getWidth:u.getLineWidth,getColor:u.getLineColor,getPath:u.getPolygon},getColor:this.getSubLayerAccessor(S),getWidth:this.getSubLayerAccessor(R),getDashArray:this.getSubLayerAccessor(M)},this.getSubLayerProps({id:"stroke",updateTriggers:D&&{getWidth:D.getLineWidth,getColor:D.getLineColor,getDashArray:D.getLineDashArray}}),{data:Y,positionFormat:f,getPath:ot=>ot.path});return[!n&&ge,rt,n&&ge]}};function i3(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,i=t.featureIds.value[r];return r!==-1?_C(t,i,r):null}function _C(t,e,r){let i={properties:{...t.properties[e]}};for(let s in t.numericProps)i.properties[s]=t.numericProps[s].value[r];return i}function s3(t,e){let r={points:null,lines:null,polygons:null};for(let i in r){let s=t[i].globalFeatureIds.value;r[i]=new Uint8ClampedArray(s.length*3);let n=[];for(let o=0;ot.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:up},getLineColor:{type:"accessor",value:up},material:!0},Ap={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},mn=class extends ht{static{this.defaultProps=aW}static{this.layerName="SolidPolygonLayer"}getShaders(e){return super.getShaders({vs:e==="top"?EM:vM,fs:SM,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[xt,sn,Mt]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:i}=this.props;e.isGeospatial&&r===Oe.DEFAULT&&(r=Oe.LNGLAT);let n;r===Oe.LNGLAT&&(i?n=e.projectPosition.bind(e):n=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new If({preproject:n,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0;s.remove(["instancePickingColors"]),s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:Ap,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:Ap,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Ap,accessor:"getFillColor",defaultValue:up},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Ap,accessor:"getLineColor",defaultValue:up},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:A,target:h})=>this.encodePickingColor(a&&a.__source?a.__source.index:A,h)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(s=>s.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:i}=this.props,n,s,o;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let A=this.getAttributeManager().getBufferLayouts({isInstanced:!1});n=new Qe(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:A,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});s=new Qe(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,uniforms:{isWireframe:!1},geometry:new mt({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Qe(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,uniforms:{isWireframe:!0},geometry:new mt({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,n].filter(Boolean),topModel:n,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};function fp({data:t,getIndex:e,dataRange:r,replace:i}){let{startRow:n=0,endRow:s=1/0}=r,o=t.length,a=o,A=o;for(let x=0;xx&&T>=n&&(a=x),T>=s){A=x;break}}let h=a,_=A-a!==i.length?t.slice(A):void 0;for(let x=0;xt.polygon},getFillColor:{type:"accessor",value:cW},getLineColor:{type:"accessor",value:wM},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},_n=class extends Gt{static{this.layerName="PolygonLayer"}static{this.defaultProps=lW}initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&me.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let i=this.state.paths.slice(),n=e.dataChanged.map(s=>fp({data:i,getIndex:o=>o.__source.index,dataRange:s,replace:this._getPaths(s)}));this.setState({paths:i,pathsDiff:n})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:i,positionFormat:n,_normalize:s}=this.props,o=[],a=n==="XY"?2:3,{startRow:A,endRow:h}=e,{iterable:g,objectInfo:_}=nr(r,A,h);for(let x of g){_.index++;let T=i(x,_);s&&(T=cp(T,a));let{holeIndices:v}=T,S=T.positions||T;if(v)for(let C=0;C<=v.length;C++){let M=S.slice(v[C-1]||0,v[C]||S.length);o.push(this.getSubLayerRow({path:M},x,_.index))}else o.push(this.getSubLayerRow({path:S},x,_.index))}return o}renderLayers(){let{data:e,_dataDiff:r,stroked:i,filled:n,extruded:s,wireframe:o,_normalize:a,_windingOrder:A,elevationScale:h,transitions:g,positionFormat:_}=this.props,{lineWidthUnits:x,lineWidthScale:T,lineWidthMinPixels:v,lineWidthMaxPixels:S,lineJointRounded:C,lineMiterLimit:M,lineDashJustified:R}=this.props,{getFillColor:B,getLineColor:k,getLineWidth:Q,getLineDashArray:$,getElevation:re,getPolygon:Y,updateTriggers:H,material:L}=this.props,{paths:ae,pathsDiff:fe}=this.state,he=this.getSubLayerClass("fill",mn),ye=this.getSubLayerClass("stroke",gn),Ne=this.shouldRenderSubLayer("fill",ae)&&new he({_dataDiff:r,extruded:s,elevationScale:h,filled:n,wireframe:o,_normalize:a,_windingOrder:A,getElevation:re,getFillColor:B,getLineColor:s&&o?k:wM,material:L,transitions:g},this.getSubLayerProps({id:"fill",updateTriggers:H&&{getPolygon:H.getPolygon,getElevation:H.getElevation,getFillColor:H.getFillColor,lineColors:s&&o,getLineColor:H.getLineColor}}),{data:e,positionFormat:_,getPolygon:Y}),nt=!s&&i&&this.shouldRenderSubLayer("stroke",ae)&&new ye({_dataDiff:fe&&(()=>fe),widthUnits:x,widthScale:T,widthMinPixels:v,widthMaxPixels:S,jointRounded:C,miterLimit:M,dashJustified:R,_pathType:"loop",transitions:g&&{getWidth:g.getLineWidth,getColor:g.getLineColor,getPath:g.getPolygon},getColor:this.getSubLayerAccessor(k),getWidth:this.getSubLayerAccessor(Q),getDashArray:this.getSubLayerAccessor($)},this.getSubLayerProps({id:"stroke",updateTriggers:H&&{getWidth:H.getLineWidth,getColor:H.getLineColor,getDashArray:H.getLineDashArray}}),{data:ae,positionFormat:_,getPath:it=>it.path});return[!s&&Ne,nt,s&&Ne]}};function CM(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,i=t.featureIds.value[r];return r!==-1?AW(t,i,r):null}function AW(t,e,r){let i={properties:{...t.properties[e]}};for(let n in t.numericProps)i.properties[n]=t.numericProps[n].value[r];return i}function MM(t,e){let r={points:null,lines:null,polygons:null};for(let i in r){let n=t[i].globalFeatureIds.value;r[i]=new Uint8ClampedArray(n.length*3);let s=[];for(let o=0;ot.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},Gi=class extends Ar{static{this.defaultProps=xC}static{this.layerName="MultiIconLayer"}getShaders(){return{...super.getShaders(),fs:n3}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(r,{index:i,target:s})=>this.encodePickingColor(i,s)}})}updateState(e){super.updateState(e);let{props:r,oldProps:i}=e,{outlineColor:s}=r;s!==i.outlineColor&&(s=s.map(n=>n/255),s[3]=Number.isFinite(s[3])?s[3]:1,this.setState({outlineColor:s})),!r.sdf&&r.outlineWidth&&U.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:i,outlineWidth:s}=this.props,{outlineColor:n}=this.state,o=s?Math.max(i,lp*(1-s)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:lp,outlineBuffer:o,gamma:i,sdf:!!r,outlineColor:n},super.draw(e),r&&s){let{iconManager:a}=this.state,c=a.getTexture(),l=this.state.model;c&&(l.setUniforms({outlineBuffer:lp}),l.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(r=>super.getInstanceOffset(r)):o3}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(r=>super.getInstanceIconFrame(r)):o3}};var Ta=class{constructor({fontSize:e=24,buffer:r=3,radius:i=8,cutoff:s=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=s,this.radius=i;let c=this.size=e+r*4,l=this._createCanvas(c),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),c=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),u=Math.min(this.size-this.buffer,a+Math.ceil(s)),f=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(f*h,0),p=new Uint8ClampedArray(d),g={data:p,width:f,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:c,glyphAdvance:r};if(l===0||u===0)return g;let{ctx:_,buffer:y,gridInner:v,gridOuter:T}=this;_.clearRect(y,y,l,u),_.fillText(e,y,y+a);let S=_.getImageData(y,y,l,u);T.fill(1e20,0,d),v.fill(0,0,d);for(let R=0;R0?D*D:0,v[N]=D<0?D*D:0}}a3(T,0,0,f,h,f,this.f,this.v,this.z),a3(v,y,y,l,u,f,this.f,this.v,this.z);for(let R=0;R-1);c++,n[c]=a,o[c]=l,o[c+1]=1e20}for(let a=0,c=0;as&&(l=0,c++),n[f]={x:l+i,y:a+c*u+i,width:h,height:u,layoutWidth:h,layoutHeight:r},l+=h+i*2}return{mapping:n,xOffset:l,yOffset:a+c*u,canvasHeight:vC(a+(c+1)*u)}}function u3(t,e,r,i){let s=0;for(let n=e;ni&&(oa){let f=u3(t,a,c,s);l+f>i&&(oi&&(f=f3(t,a,c,i,s,n),o=n[n.length-1])),a=c,l+=f}return l}function EC(t,e,r,i,s=0,n){n===void 0&&(n=t.length);let o=[];return e==="break-all"?f3(t,s,n,r,i,o):TC(t,s,n,r,i,o),o}function SC(t,e,r,i,s,n){let o=0,a=0;for(let c=e;c0,f=[0,0],h=[0,0],d=0,p=0,g=0;for(let _=0;_<=o;_++){let y=n[_];if((y===` -`||_===o)&&(g=_),g>p){let v=u?EC(n,r,i,s,p,g):bC;for(let T=0;T<=v.length;T++){let S=T===0?p:v[T-1],R=T1||c>0){let d=t.constructor;h=new d(l);for(let p=0;p=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function AC(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Zi={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:AC(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},p3=1024,g3=.9,m3=1.2,x3=3,su=new Xs(x3);function wC(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let i=su.get(t);if(!i)return r;for(let s in i.mapping)r.has(s)&&r.delete(s);return r}function PC(t,e){for(let r=0;r=x3,"Invalid cache limit"),su=new Xs(t)}var Ea=class{constructor(){this.props={...Zi}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:e,buffer:r}=this.props;return(e*m3+r*2)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();let r=wC(this._key,this.props.characterSet),i=su.get(this._key);if(i&&r.size===0){this._atlas!==i&&(this._atlas=i);return}let s=this._generateFontAtlas(r,i);this._atlas=s,su.set(this._key,s)}_generateFontAtlas(e,r){let{fontFamily:i,fontWeight:s,fontSize:n,buffer:o,sdf:a,radius:c,cutoff:l}=this.props,u=r&&r.data;u||(u=document.createElement("canvas"),u.width=p3);let f=u.getContext("2d",{willReadFrequently:!0});_3(f,i,n,s);let{mapping:h,canvasHeight:d,xOffset:p,yOffset:g}=l3({getFontWidth:_=>f.measureText(_).width,fontHeight:n*m3,buffer:o,characterSet:e,maxCanvasWidth:p3,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffset:r.yOffset}});if(u.height!==d){let _=f.getImageData(0,0,u.width,u.height);u.height=d,f.putImageData(_,0,0)}if(_3(f,i,n,s),a){let _=new Ta({fontSize:n,buffer:o,radius:c,cutoff:l,fontFamily:i,fontWeight:`${s}`});for(let y of e){let{data:v,width:T,height:S,glyphTop:R}=_.draw(y);h[y].width=T,h[y].layoutOffsetY=n*g3-R;let M=f.createImageData(T,S);PC(v,M),f.putImageData(M,h[y].x,h[y].y)}}else for(let _ of e)f.fillText(_,h[_].x,h[_].y+o+n*g3);return{xOffset:p,yOffset:g,mapping:h,data:u,width:u.width,height:u.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:i,buffer:s,sdf:n,radius:o,cutoff:a}=this.props;return n?`${e} ${r} ${i} ${s} ${o} ${a}`:`${e} ${r} ${i} ${s}`}};var b3=`#version 300 es +`;var Ny=192/256,IM=[],uW={getIconOffsets:{type:"accessor",value:t=>t.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},ka=class extends Ss{static{this.defaultProps=uW}static{this.layerName="MultiIconLayer"}getShaders(){return{...super.getShaders(),fs:PM}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(r,{index:i,target:n})=>this.encodePickingColor(i,n)}})}updateState(e){super.updateState(e);let{props:r,oldProps:i}=e,{outlineColor:n}=r;n!==i.outlineColor&&(n=n.map(s=>s/255),n[3]=Number.isFinite(n[3])?n[3]:1,this.setState({outlineColor:n})),!r.sdf&&r.outlineWidth&&me.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:i,outlineWidth:n}=this.props,{outlineColor:s}=this.state,o=n?Math.max(i,Ny*(1-n)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:Ny,outlineBuffer:o,gamma:i,sdf:!!r,outlineColor:s},super.draw(e),r&&n){let{iconManager:a}=this.state,A=a.getTexture(),h=this.state.model;A&&(h.setUniforms({outlineBuffer:Ny}),h.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(r=>super.getInstanceOffset(r)):IM}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(r=>super.getInstanceIconFrame(r)):IM}};var Rf=class{constructor({fontSize:e=24,buffer:r=3,radius:i=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=n,this.radius=i;let A=this.size=e+r*4,h=this._createCanvas(A),g=this.ctx=h.getContext("2d",{willReadFrequently:!0});g.font=`${a} ${o} ${e}px ${s}`,g.textBaseline="alphabetic",g.textAlign="left",g.fillStyle="black",this.gridOuter=new Float64Array(A*A),this.gridInner=new Float64Array(A*A),this.f=new Float64Array(A),this.z=new Float64Array(A+1),this.v=new Uint16Array(A)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),A=0,h=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-s))),g=Math.min(this.size-this.buffer,a+Math.ceil(n)),_=h+2*this.buffer,x=g+2*this.buffer,T=Math.max(_*x,0),v=new Uint8ClampedArray(T),S={data:v,width:_,height:x,glyphWidth:h,glyphHeight:g,glyphTop:a,glyphLeft:A,glyphAdvance:r};if(h===0||g===0)return S;let{ctx:C,buffer:M,gridInner:R,gridOuter:B}=this;C.clearRect(M,M,h,g),C.fillText(e,M,M+a);let k=C.getImageData(M,M,h,g);B.fill(1e20,0,T),R.fill(0,0,T);for(let Q=0;Q0?H*H:0,R[Y]=H<0?H*H:0}}RM(B,0,0,_,x,_,this.f,this.v,this.z),RM(R,M,M,h,g,_,this.f,this.v,this.z);for(let Q=0;Q-1);A++,s[A]=a,o[A]=h,o[A+1]=1e20}for(let a=0,A=0;an&&(h=0,A++),s[_]={x:h+i,y:a+A*g+i,width:x,height:g,layoutWidth:x,layoutHeight:r},h+=x+i*2}return{mapping:s,xOffset:h,yOffset:a+A*g,canvasHeight:dW(a+(A+1)*g)}}function FM(t,e,r,i){let n=0;for(let s=e;si&&(oa){let _=FM(t,a,A,n);h+_>i&&(oi&&(_=LM(t,a,A,i,n,s),o=s[s.length-1])),a=A,h+=_}return h}function gW(t,e,r,i,n=0,s){s===void 0&&(s=t.length);let o=[];return e==="break-all"?LM(t,n,s,r,i,o):pW(t,n,s,r,i,o),o}function mW(t,e,r,i,n,s){let o=0,a=0;for(let A=e;A0,_=[0,0],x=[0,0],T=0,v=0,S=0;for(let C=0;C<=o;C++){let M=s[C];if((M===` +`||C===o)&&(S=C),S>v){let R=g?gW(s,r,i,n,v,S):hW;for(let B=0;B<=R.length;B++){let k=B===0?v:R[B-1],Q=B1||A>0){let T=t.constructor;x=new T(h);for(let v=0;v=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function _W(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Va={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:_W(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},UM=1024,kM=.9,VM=1.2,HM=3,hp=new Al(HM);function yW(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let i=hp.get(t);if(!i)return r;for(let n in i.mapping)r.has(n)&&r.delete(n);return r}function xW(t,e){for(let r=0;r=HM,"Invalid cache limit"),hp=new Al(t)}var Bf=class{constructor(){this.props={...Va}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:e,buffer:r}=this.props;return(e*VM+r*2)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();let r=yW(this._key,this.props.characterSet),i=hp.get(this._key);if(i&&r.size===0){this._atlas!==i&&(this._atlas=i);return}let n=this._generateFontAtlas(r,i);this._atlas=n,hp.set(this._key,n)}_generateFontAtlas(e,r){let{fontFamily:i,fontWeight:n,fontSize:s,buffer:o,sdf:a,radius:A,cutoff:h}=this.props,g=r&&r.data;g||(g=document.createElement("canvas"),g.width=UM);let _=g.getContext("2d",{willReadFrequently:!0});zM(_,i,s,n);let{mapping:x,canvasHeight:T,xOffset:v,yOffset:S}=OM({getFontWidth:C=>_.measureText(C).width,fontHeight:s*VM,buffer:o,characterSet:e,maxCanvasWidth:UM,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffset:r.yOffset}});if(g.height!==T){let C=_.getImageData(0,0,g.width,g.height);g.height=T,_.putImageData(C,0,0)}if(zM(_,i,s,n),a){let C=new Rf({fontSize:s,buffer:o,radius:A,cutoff:h,fontFamily:i,fontWeight:`${n}`});for(let M of e){let{data:R,width:B,height:k,glyphTop:Q}=C.draw(M);x[M].width=B,x[M].layoutOffsetY=s*kM-Q;let $=_.createImageData(B,k);xW(R,$),_.putImageData($,x[M].x,x[M].y)}}else for(let C of e)_.fillText(C,x[C].x,x[C].y+o+s*kM);return{xOffset:v,yOffset:S,mapping:x,data:g,width:g.width,height:g.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:i,buffer:n,sdf:s,radius:o,cutoff:a}=this.props;return s?`${e} ${r} ${i} ${n} ${o} ${a}`:`${e} ${r} ${i} ${n}`}};var WM=`#version 300 es #define SHADER_NAME text-background-layer-vertex-shader in vec2 positions; in vec3 instancePositions; @@ -2067,7 +2374,7 @@ DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } -`;var v3=`#version 300 es +`;var jM=`#version 300 es #define SHADER_NAME text-background-layer-fragment-shader precision highp float; uniform bool stroked; @@ -2092,7 +2399,7 @@ fragColor = vFillColor; } DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var CC={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Ji=class extends ne{static{this.defaultProps=CC}static{this.layerName="TextBackgroundLayer"}getShaders(){return super.getShaders({vs:b3,fs:v3,modules:[ae,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:i,sizeUnits:s,sizeMinPixels:n,sizeMaxPixels:o,getLineWidth:a}=this.props,{padding:c}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]);let l=this.state.model;l.setUniforms(e),l.setUniforms({billboard:r,stroked:!!a,padding:c,sizeUnits:pe[s],sizeScale:i,sizeMinPixels:n,sizeMaxPixels:o}),l.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,1,1,0,1];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};var T3={start:1,middle:0,end:-1},E3={top:1,center:0,bottom:-1},up=[0,0,0,255],RC=1,MC={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:up},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Zi.characterSet},fontFamily:Zi.fontFamily,fontWeight:Zi.fontWeight,lineHeight:RC,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:up},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:up},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Qi=class extends et{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[i,s]}=this.transformParagraph(e,r),{fontSize:n}=this.state.fontAtlasManager.props;i/=n,s/=n;let{getTextAnchor:o,getAlignmentBaseline:a}=this.props,c=T3[typeof o=="function"?o(e,r):o],l=E3[typeof a=="function"?a(e,r):a];return[(c-1)*i/2,(l-1)*s/2,i,s]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:i,getAlignmentBaseline:s}=this.props,{x:n,y:o,rowWidth:a,size:[c,l]}=this.transformParagraph(e,r),u=T3[typeof i=="function"?i(e,r):i],f=E3[typeof s=="function"?s(e,r):s],h=n.length,d=new Array(h*2),p=0;for(let g=0;g0&&U.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:i,changeFlags:s}=e;(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==i.lineHeight||r.wordBreak!==i.wordBreak||r.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:i}=this.props,{fontAtlasManager:s,characterSet:n}=this.state,o={...e,characterSet:n,fontFamily:r,fontWeight:i};if(!s.mapping)return s.setProps(o),!0;for(let a in o)if(o[a]!==s.props[a])return s.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,i=e.attributes?.getText,{getText:s}=this.props,n=e.startIndices,o,a=r==="auto"&&new Set;if(i&&n){let{texts:c,characterCount:l}=d3({...ArrayBuffer.isView(i)?{value:i}:i,length:e.length,startIndices:n,characterSet:a});o=l,s=(u,{index:f})=>c[f]}else{let{iterable:c,objectInfo:l}=$e(e);n=[0],o=0;for(let u of c){l.index++;let f=Array.from(s(u,l)||"");a&&f.forEach(a.add,a),o+=f.length,n.push(o)}}this.setState({getText:s,startIndices:n,numInstances:o,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:i}=this.state,s=i.mapping,n=this.state.getText,{wordBreak:o,lineHeight:a,maxWidth:c}=this.props,l=n(e,r)||"";return h3(l,a,o,c*i.props.fontSize,s)}renderLayers(){let{startIndices:e,numInstances:r,getText:i,fontAtlasManager:{scale:s,atlas:n,mapping:o},styleVersion:a}=this.state,{data:c,_dataDiff:l,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,getBackgroundColor:g,getBorderColor:_,getBorderWidth:y,backgroundPadding:v,background:T,billboard:S,fontSettings:R,outlineWidth:M,outlineColor:F,sizeScale:N,sizeUnits:D,sizeMinPixels:L,sizeMaxPixels:Y,transitions:X,updateTriggers:$}=this.props,Z=this.getSubLayerClass("characters",Gi),ge=this.getSubLayerClass("background",Ji);return[T&&new ge({getFillColor:g,getLineColor:_,getLineWidth:y,padding:v,getPosition:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:S,sizeScale:N,sizeUnits:D,sizeMinPixels:L,sizeMaxPixels:Y,transitions:X&&{getPosition:X.getPosition,getAngle:X.getAngle,getSize:X.getSize,getFillColor:X.getBackgroundColor,getLineColor:X.getBorderColor,getLineWidth:X.getBorderWidth,getPixelOffset:X.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:$.getPosition,getAngle:$.getAngle,getSize:$.getSize,getFillColor:$.getBackgroundColor,getLineColor:$.getBorderColor,getLineWidth:$.getBorderWidth,getPixelOffset:$.getPixelOffset,getBoundingRect:{getText:$.getText,getTextAnchor:$.getTextAnchor,getAlignmentBaseline:$.getAlignmentBaseline,styleVersion:a}}}),{data:c.attributes&&c.attributes.background?{length:c.length,attributes:c.attributes.background}:c,_dataDiff:l,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new Z({sdf:R.sdf,smoothing:Number.isFinite(R.smoothing)?R.smoothing:Zi.smoothing,outlineWidth:M/(R.radius||Zi.radius),outlineColor:F,iconAtlas:n,iconMapping:o,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,billboard:S,sizeScale:N*s,sizeUnits:D,sizeMinPixels:L*s,sizeMaxPixels:Y*s,transitions:X&&{getPosition:X.getPosition,getAngle:X.getAngle,getColor:X.getColor,getSize:X.getSize,getPixelOffset:X.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:$.getText,getPosition:$.getPosition,getAngle:$.getAngle,getColor:$.getColor,getSize:$.getSize,getPixelOffset:$.getPixelOffset,getIconOffsets:{getTextAnchor:$.getTextAnchor,getAlignmentBaseline:$.getAlignmentBaseline,styleVersion:a}}}),{data:c,_dataDiff:l,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(e){y3(e)}};var Sa={circle:{type:$i,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:Ar,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Qi,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Aa={type:Pr,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},nu={type:zt,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function $s({type:t,props:e}){let r={};for(let i in e)r[i]=t.defaultProps[e[i]];return r}function ou(t,e){let{transitions:r,updateTriggers:i}=t.props,s={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let n in e){let o=e[n],a=t.props[n];n.startsWith("get")&&(a=t.getSubLayerAccessor(a),s.updateTriggers[o]=i[n],r&&(s.transitions[o]=r[n])),s[o]=a}return s}function A3(t){if(Array.isArray(t))return t;switch(U.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return U.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function fp(t,e,r={}){let i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:n=t.length}=r;for(let o=s;o{a.push(r({geometry:{type:"Point",coordinates:f}},i,s))});break;case"LineString":c.push(r({geometry:t},i,s));break;case"MultiLineString":o.forEach(f=>{c.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"Polygon":l.push(r({geometry:t},i,s)),o.forEach(f=>{u.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"MultiPolygon":o.forEach(f=>{l.push(r({geometry:{type:"Polygon",coordinates:f}},i,s)),f.forEach(h=>{u.push(r({geometry:{type:"LineString",coordinates:h}},i,s))})});break;default:}}var IC={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function OC(t,e){let r=IC[t];for(U.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function w3(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function au(t){return t.geometry.coordinates}function P3(t,e){let r=w3(),{pointFeatures:i,lineFeatures:s,polygonFeatures:n,polygonOutlineFeatures:o}=t;return r.points.data=i,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=au,r.lines.data=s,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=au,r.polygons.data=n,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=au,r.polygonsOutline.data=o,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=au,r}function C3(t,e){let r=w3(),{points:i,lines:s,polygons:n}=t,o=s3(t,e);return r.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:3,value:o.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.lines.data={length:s.pathIndices.value.length-1,startIndices:s.pathIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:3,value:o.lines}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},r.lines._pathType="open",r.polygons.data={length:n.polygonIndices.value.length-1,startIndices:n.polygonIndices.value,attributes:{...n.attributes,getPolygon:n.positions,pickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygons._normalize=!1,n.triangles&&(r.polygons.data.attributes.indices=n.triangles.value),r.polygonsOutline.data={length:n.primitivePolygonIndices.value.length-1,startIndices:n.primitivePolygonIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygonsOutline._pathType="open",r}var NC=["points","linestrings","polygons"],FC={...$s(Sa.circle),...$s(Sa.icon),...$s(Sa.text),...$s(Aa),...$s(nu),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},wa=class extends et{static{this.layerName="GeoJsonLayer"}static{this.defaultProps=FC}initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:i}=this.props,s=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:s}),s?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let i=C3(e.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:e,changeFlags:r}){let i=A3(e.data),s=this.getSubLayerRow.bind(this),n={},o={};if(Array.isArray(r.dataChanged)){let c=this.state.features;for(let l in c)n[l]=c[l].slice(),o[l]=[];for(let l of r.dataChanged){let u=fp(i,s,l);for(let f in c)o[f].push(iu({data:n[f],getIndex:h=>h.__source.index,dataRange:l,replace:u[f]}))}}else n=fp(i,s);let a=P3(n,o);this.setState({features:n,featuresDiff:o,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i,sourceLayer:s}=r;return r.featureType=NC.find(n=>s.id.startsWith(`${this.id}-${n}-`)),i>=0&&s.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[i]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,i=e.featureType==="points";for(let s of this.getSubLayers())s.id.startsWith(r)===i&&s.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:i}=this.state,s="polygons-fill",n=this.shouldRenderSubLayer(s,i.polygons?.data)&&this.getSubLayerClass(s,nu.type);if(n){let o=ou(this,nu.props),a=e&&r;return a||delete o.getLineColor,o.updateTriggers.lineColors=a,new n(o,this.getSubLayerProps({id:s,updateTriggers:o.updateTriggers}),i.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:i}=this.state,s="polygons-stroke",n="linestrings",o=!e&&r&&this.shouldRenderSubLayer(s,i.polygonsOutline?.data)&&this.getSubLayerClass(s,Aa.type),a=this.shouldRenderSubLayer(n,i.lines?.data)&&this.getSubLayerClass(n,Aa.type);if(o||a){let c=ou(this,Aa.props);return[o&&new o(c,this.getSubLayerProps({id:s,updateTriggers:c.updateTriggers}),i.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),i.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:i}=this.state,{highlightedObjectIndex:s}=this.props;!i&&Number.isFinite(s)&&(s=r.points.data.findIndex(a=>a.__source.index===s));let n=new Set(e.split("+")),o=[];for(let a of n){let c=`points-${a}`,l=Sa[a],u=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(u){let f=ou(this,l.props),h=r.points;if(a==="text"&&i){let{instancePickingColors:d,...p}=h.data.attributes;h={...h,data:{...h.data,attributes:p}}}o.push(new u(f,this.getSubLayerProps({id:c,updateTriggers:f.updateTriggers,highlightedObjectIndex:s}),h))}}return o}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),i=this._renderLineLayers(),s=this._renderPointLayers();return[!e&&r,i,s,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(i,s)=>{let{data:n,index:o}=s,a=i3(n,o);return e(a,s)}}};var le={SUM:1,MEAN:2,MIN:3,MAX:4};function R3(t,e){return t+e}function DC(t,e){return e>t?e:t}function LC(t,e){return ezC(s,e);case le.SUM:return s=>BC(s,e);case le.MEAN:return s=>kC(s,e);case le.MAX:return s=>UC(s,e);default:return null}}function VC(t,e={}){return Number.isFinite(t)?t:r=>(e.index=r.index,t(r.source,e))}function M3(t,e={}){return r=>(e.indices=r.map(i=>i.index),t(r.map(i=>i.source),e))}var I3={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},ii=3402823466e29,hp=[32775,32774],dp=[32776,32774],O3=[32776,32775],pp={[le.SUM]:32774,[le.MEAN]:32774,[le.MIN]:hp,[le.MAX]:dp};var N3={size:1,operation:le.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},F3=4;var D3=`#version 300 es +`;var bW={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},za=class extends ht{static{this.defaultProps=bW}static{this.layerName="TextBackgroundLayer"}getShaders(){return super.getShaders({vs:WM,fs:jM,modules:[xt,Mt]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:i,sizeUnits:n,sizeMinPixels:s,sizeMaxPixels:o,getLineWidth:a}=this.props,{padding:A}=this.props;A.length<4&&(A=[A[0],A[1],A[0],A[1]]);let h=this.state.model;h.setUniforms(e),h.setUniforms({billboard:r,stroked:!!a,padding:A,sizeUnits:Yt[n],sizeScale:i,sizeMinPixels:s,sizeMaxPixels:o}),h.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,1,1,0,1];return new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mt({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};var XM={start:1,middle:0,end:-1},YM={top:1,center:0,bottom:-1},Dy=[0,0,0,255],TW=1,EW={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:Dy},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Va.characterSet},fontFamily:Va.fontFamily,fontWeight:Va.fontWeight,lineHeight:TW,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:Dy},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:Dy},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Ha=class extends Gt{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[i,n]}=this.transformParagraph(e,r),{fontSize:s}=this.state.fontAtlasManager.props;i/=s,n/=s;let{getTextAnchor:o,getAlignmentBaseline:a}=this.props,A=XM[typeof o=="function"?o(e,r):o],h=YM[typeof a=="function"?a(e,r):a];return[(A-1)*i/2,(h-1)*n/2,i,n]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:i,getAlignmentBaseline:n}=this.props,{x:s,y:o,rowWidth:a,size:[A,h]}=this.transformParagraph(e,r),g=XM[typeof i=="function"?i(e,r):i],_=YM[typeof n=="function"?n(e,r):n],x=s.length,T=new Array(x*2),v=0;for(let S=0;S0&&me.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:i,changeFlags:n}=e;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==i.lineHeight||r.wordBreak!==i.wordBreak||r.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:i}=this.props,{fontAtlasManager:n,characterSet:s}=this.state,o={...e,characterSet:s,fontFamily:r,fontWeight:i};if(!n.mapping)return n.setProps(o),!0;for(let a in o)if(o[a]!==n.props[a])return n.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,i=e.attributes?.getText,{getText:n}=this.props,s=e.startIndices,o,a=r==="auto"&&new Set;if(i&&s){let{texts:A,characterCount:h}=DM({...ArrayBuffer.isView(i)?{value:i}:i,length:e.length,startIndices:s,characterSet:a});o=h,n=(g,{index:_})=>A[_]}else{let{iterable:A,objectInfo:h}=nr(e);s=[0],o=0;for(let g of A){h.index++;let _=Array.from(n(g,h)||"");a&&_.forEach(a.add,a),o+=_.length,s.push(o)}}this.setState({getText:n,startIndices:s,numInstances:o,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:i}=this.state,n=i.mapping,s=this.state.getText,{wordBreak:o,lineHeight:a,maxWidth:A}=this.props,h=s(e,r)||"";return NM(h,a,o,A*i.props.fontSize,n)}renderLayers(){let{startIndices:e,numInstances:r,getText:i,fontAtlasManager:{scale:n,atlas:s,mapping:o},styleVersion:a}=this.state,{data:A,_dataDiff:h,getPosition:g,getColor:_,getSize:x,getAngle:T,getPixelOffset:v,getBackgroundColor:S,getBorderColor:C,getBorderWidth:M,backgroundPadding:R,background:B,billboard:k,fontSettings:Q,outlineWidth:$,outlineColor:re,sizeScale:Y,sizeUnits:H,sizeMinPixels:L,sizeMaxPixels:ae,transitions:fe,updateTriggers:he}=this.props,ye=this.getSubLayerClass("characters",ka),Ne=this.getSubLayerClass("background",za);return[B&&new Ne({getFillColor:S,getLineColor:C,getLineWidth:M,padding:R,getPosition:g,getSize:x,getAngle:T,getPixelOffset:v,billboard:k,sizeScale:Y,sizeUnits:H,sizeMinPixels:L,sizeMaxPixels:ae,transitions:fe&&{getPosition:fe.getPosition,getAngle:fe.getAngle,getSize:fe.getSize,getFillColor:fe.getBackgroundColor,getLineColor:fe.getBorderColor,getLineWidth:fe.getBorderWidth,getPixelOffset:fe.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:he.getPosition,getAngle:he.getAngle,getSize:he.getSize,getFillColor:he.getBackgroundColor,getLineColor:he.getBorderColor,getLineWidth:he.getBorderWidth,getPixelOffset:he.getPixelOffset,getBoundingRect:{getText:he.getText,getTextAnchor:he.getTextAnchor,getAlignmentBaseline:he.getAlignmentBaseline,styleVersion:a}}}),{data:A.attributes&&A.attributes.background?{length:A.length,attributes:A.attributes.background}:A,_dataDiff:h,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new ye({sdf:Q.sdf,smoothing:Number.isFinite(Q.smoothing)?Q.smoothing:Va.smoothing,outlineWidth:$/(Q.radius||Va.radius),outlineColor:re,iconAtlas:s,iconMapping:o,getPosition:g,getColor:_,getSize:x,getAngle:T,getPixelOffset:v,billboard:k,sizeScale:Y*n,sizeUnits:H,sizeMinPixels:L*n,sizeMaxPixels:ae*n,transitions:fe&&{getPosition:fe.getPosition,getAngle:fe.getAngle,getColor:fe.getColor,getSize:fe.getSize,getPixelOffset:fe.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:he.getText,getPosition:he.getPosition,getAngle:he.getAngle,getColor:he.getColor,getSize:he.getSize,getPixelOffset:he.getPixelOffset,getIconOffsets:{getTextAnchor:he.getTextAnchor,getAlignmentBaseline:he.getAlignmentBaseline,styleVersion:a}}}),{data:A,_dataDiff:h,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(e){GM(e)}};var Of={circle:{type:Fa,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:Ss,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Ha,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Ff={type:gn,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},dp={type:mn,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function ul({type:t,props:e}){let r={};for(let i in e)r[i]=t.defaultProps[e[i]];return r}function pp(t,e){let{transitions:r,updateTriggers:i}=t.props,n={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let s in e){let o=e[s],a=t.props[s];s.startsWith("get")&&(a=t.getSubLayerAccessor(a),n.updateTriggers[o]=i[s],r&&(n.transitions[o]=r[s])),n[o]=a}return n}function qM(t){if(Array.isArray(t))return t;switch(me.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return me.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function Uy(t,e,r={}){let i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:n=0,endRow:s=t.length}=r;for(let o=n;o{a.push(r({geometry:{type:"Point",coordinates:_}},i,n))});break;case"LineString":A.push(r({geometry:t},i,n));break;case"MultiLineString":o.forEach(_=>{A.push(r({geometry:{type:"LineString",coordinates:_}},i,n))});break;case"Polygon":h.push(r({geometry:t},i,n)),o.forEach(_=>{g.push(r({geometry:{type:"LineString",coordinates:_}},i,n))});break;case"MultiPolygon":o.forEach(_=>{h.push(r({geometry:{type:"Polygon",coordinates:_}},i,n)),_.forEach(x=>{g.push(r({geometry:{type:"LineString",coordinates:x}},i,n))})});break;default:}}var vW={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function SW(t,e){let r=vW[t];for(me.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function KM(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function gp(t){return t.geometry.coordinates}function JM(t,e){let r=KM(),{pointFeatures:i,lineFeatures:n,polygonFeatures:s,polygonOutlineFeatures:o}=t;return r.points.data=i,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=gp,r.lines.data=n,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=gp,r.polygons.data=s,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=gp,r.polygonsOutline.data=o,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=gp,r}function ZM(t,e){let r=KM(),{points:i,lines:n,polygons:s}=t,o=MM(t,e);return r.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:3,value:o.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.lines.data={length:n.pathIndices.value.length-1,startIndices:n.pathIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:3,value:o.lines}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.lines._pathType="open",r.polygons.data={length:s.polygonIndices.value.length-1,startIndices:s.polygonIndices.value,attributes:{...s.attributes,getPolygon:s.positions,pickingColors:{size:3,value:o.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},r.polygons._normalize=!1,s.triangles&&(r.polygons.data.attributes.indices=s.triangles.value),r.polygonsOutline.data={length:s.primitivePolygonIndices.value.length-1,startIndices:s.primitivePolygonIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:3,value:o.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},r.polygonsOutline._pathType="open",r}var wW=["points","linestrings","polygons"],CW={...ul(Of.circle),...ul(Of.icon),...ul(Of.text),...ul(Ff),...ul(dp),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},Zn=class extends Gt{static{this.layerName="GeoJsonLayer"}static{this.defaultProps=CW}initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:i}=this.props,n=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:n}),n?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let i=ZM(e.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:e,changeFlags:r}){let i=qM(e.data),n=this.getSubLayerRow.bind(this),s={},o={};if(Array.isArray(r.dataChanged)){let A=this.state.features;for(let h in A)s[h]=A[h].slice(),o[h]=[];for(let h of r.dataChanged){let g=Uy(i,n,h);for(let _ in A)o[_].push(fp({data:s[_],getIndex:x=>x.__source.index,dataRange:h,replace:g[_]}))}}else s=Uy(i,n);let a=JM(s,o);this.setState({features:s,featuresDiff:o,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i,sourceLayer:n}=r;return r.featureType=wW.find(s=>n.id.startsWith(`${this.id}-${s}-`)),i>=0&&n.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[i]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,i=e.featureType==="points";for(let n of this.getSubLayers())n.id.startsWith(r)===i&&n.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:i}=this.state,n="polygons-fill",s=this.shouldRenderSubLayer(n,i.polygons?.data)&&this.getSubLayerClass(n,dp.type);if(s){let o=pp(this,dp.props),a=e&&r;return a||delete o.getLineColor,o.updateTriggers.lineColors=a,new s(o,this.getSubLayerProps({id:n,updateTriggers:o.updateTriggers}),i.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:i}=this.state,n="polygons-stroke",s="linestrings",o=!e&&r&&this.shouldRenderSubLayer(n,i.polygonsOutline?.data)&&this.getSubLayerClass(n,Ff.type),a=this.shouldRenderSubLayer(s,i.lines?.data)&&this.getSubLayerClass(s,Ff.type);if(o||a){let A=pp(this,Ff.props);return[o&&new o(A,this.getSubLayerProps({id:n,updateTriggers:A.updateTriggers}),i.polygonsOutline),a&&new a(A,this.getSubLayerProps({id:s,updateTriggers:A.updateTriggers}),i.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:i}=this.state,{highlightedObjectIndex:n}=this.props;!i&&Number.isFinite(n)&&(n=r.points.data.findIndex(a=>a.__source.index===n));let s=new Set(e.split("+")),o=[];for(let a of s){let A=`points-${a}`,h=Of[a],g=h&&this.shouldRenderSubLayer(A,r.points?.data)&&this.getSubLayerClass(A,h.type);if(g){let _=pp(this,h.props),x=r.points;if(a==="text"&&i){let{instancePickingColors:T,...v}=x.data.attributes;x={...x,data:{...x.data,attributes:v}}}o.push(new g(_,this.getSubLayerProps({id:A,updateTriggers:_.updateTriggers,highlightedObjectIndex:n}),x))}}return o}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),i=this._renderLineLayers(),n=this._renderPointLayers();return[!e&&r,i,n,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(i,n)=>{let{data:s,index:o}=n,a=CM(s,o);return e(a,n)}}};var Lt={SUM:1,MEAN:2,MIN:3,MAX:4};function $M(t,e){return t+e}function MW(t,e){return e>t?e:t}function PW(t,e){return eOW(n,e);case Lt.SUM:return n=>RW(n,e);case Lt.MEAN:return n=>IW(n,e);case Lt.MAX:return n=>BW(n,e);default:return null}}function FW(t,e={}){return Number.isFinite(t)?t:r=>(e.index=r.index,t(r.source,e))}function eP(t,e={}){return r=>(e.indices=r.map(i=>i.index),t(r.map(i=>i.source),e))}var tP={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},Eo=3402823466e29,ky=[32775,32774],Vy=[32776,32774],rP=[32776,32775],zy={[Lt.SUM]:32774,[Lt.MEAN]:32774,[Lt.MIN]:ky,[Lt.MAX]:Vy};var iP={size:1,operation:Lt.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},nP=4;var sP=`#version 300 es #define SHADER_NAME gpu-aggregation-to-grid-vs in vec3 positions; in vec3 positions64Low; @@ -2132,7 +2439,7 @@ pos = pos + offset; gl_Position = vec4(pos, 0.0, 1.0); gl_PointSize = 1.0; } -`;var L3=`#version 300 es +`;var oP=`#version 300 es #define SHADER_NAME gpu-aggregation-to-grid-fs precision highp float; in vec3 vWeights; @@ -2141,7 +2448,7 @@ void main(void) { fragColor = vec4(vWeights, 1.0); DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var k3=`#version 300 es +`;var aP=`#version 300 es #define SHADER_NAME gpu-aggregation-all-vs-64 in vec2 position; uniform ivec2 gridSize; @@ -2162,7 +2469,7 @@ vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64); vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x); gl_PointSize = 1.0; } -`;var B3=`#version 300 es +`;var cP=`#version 300 es #define SHADER_NAME gpu-aggregation-all-fs precision highp float; in vec2 vTextureCoord; @@ -2177,7 +2484,7 @@ discard; fragColor.rgb = textureColor.rgb; fragColor.a = combineMaxMin ? textureColor.r : textureColor.a; } -`;var U3=`#version 300 es +`;var lP=`#version 300 es #define SHADER_NAME gpu-aggregation-transform-mean-vs in vec4 aggregationValues; out vec4 meanValues; @@ -2188,7 +2495,7 @@ meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3( meanValues.w = aggregationValues.w; gl_PointSize = 1.0; } -`;var WC={minFilter:"nearest",magFilter:"nearest"};function Ks(t,e){let{width:r=1,height:i=1,data:s=null,parameters:n=WC}=e;return t.createTexture({data:s,format:"rgba32float",mipmaps:!1,sampler:n,width:r,height:i})}function Pa(t,e){let{id:r,width:i=1,height:s=1,texture:n}=e;return t.createFramebuffer({id:r,width:i,height:s,colorAttachments:[n]})}var HC=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],z3={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},jC=["float32-renderable-webgl","texture-blend-float-webgl"],Ce=class{static getAggregationData({aggregationData:e,maxData:r,minData:i,maxMinData:s,pixelIndex:n}){let o=n*F3,a={};return e&&(a.cellCount=e[o+3],a.cellWeight=e[o]),s?(a.maxCellWieght=s[0],a.minCellWeight=s[3]):(r&&(a.maxCellWieght=r[0],a.totalCount=r[3]),i&&(a.minCellWeight=i[0],a.totalCount=i[3])),a}static getCellData({countsData:e,size:r=1}){let i=e.length/4,s=new Float32Array(i*r),n=new Uint32Array(i);for(let o=0;oe.features.has(r))}constructor(e,r={}){this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=r.id||"gpu-grid-aggregator",this.device=e;let i=["float32-renderable-webgl"];this._hasGPUSupport=i.every(s=>e.features.has(s)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:e,allAggregationModel:r,meanTransform:i}=this,{textures:s,framebuffers:n,maxMinFramebuffers:o,minFramebuffers:a,maxFramebuffers:c,meanTextures:l,resources:u}=this.state;e?.destroy(),r?.destroy(),i?.destroy(),$C([n,s,o,a,c,l,u])}run(e={}){this.setState({results:{}});let r=this._normalizeAggregationParams(e);return this._runAggregation(r)}getData(e){let r={},i=this.state.results;i[e].aggregationData||(i[e].aggregationData=i[e].aggregationBuffer.getData()),r.aggregationData=i[e].aggregationData;for(let s in z3){let n=z3[s];(i[e][s]||i[e][n])&&(i[e][s]=i[e][s]||i[e][n].getData(),r[s]=i[e][s])}return r}updateShaders(e={}){this.setState({shaderOptions:e,modelDirty:!0})}_normalizeAggregationParams(e){let r={...I3,...e},{weights:i}=r;return i&&(r.weights=XC(i)),r}setState(e){Object.assign(this.state,e)}_getAggregateData(e){let r={},{textures:i,framebuffers:s,maxMinFramebuffers:n,minFramebuffers:o,maxFramebuffers:a,resources:c}=this.state,{weights:l}=e;for(let u in l){r[u]={};let{needMin:f,needMax:h,combineMaxMin:d}=l[u];r[u].aggregationTexture=i[u],r[u].aggregationBuffer=this.device.readPixelsToBufferWebGL(s[u],{target:l[u].aggregationBuffer,sourceType:5126}),f&&h&&d?(r[u].maxMinBuffer=this.device.readPixelsToBufferWebGL(n[u],{target:l[u].maxMinBuffer,sourceType:5126}),r[u].maxMinTexture=c[`${u}-maxMinTexture`]):(f&&(r[u].minBuffer=this.device.readPixelsToBufferWebGL(o[u],{target:l[u].minBuffer,sourceType:5126}),r[u].minTexture=c[`${u}-minTexture`]),h&&(r[u].maxBuffer=this.device.readPixelsToBufferWebGL(a[u],{target:l[u].maxBuffer,sourceType:5126}),r[u].maxTexture=c[`${u}-maxTexture`]))}return this._trackGPUResultBuffers(r,l),r}_renderAggregateData(e){let{cellSize:r,projectPoints:i,attributes:s,moduleSettings:n,numCol:o,numRow:a,weights:c,translation:l,scaling:u}=e,{maxMinFramebuffers:f,minFramebuffers:h,maxFramebuffers:d}=this.state,p=[o,a],g={blend:!0,depthTest:!1,blendFunc:[1,1]},_={cellSize:r,gridSize:p,projectPoints:i,translation:l,scaling:u};for(let y in c){let{needMin:v,needMax:T}=c[y],S=v&&T&&c[y].combineMaxMin;this._renderToWeightsTexture({id:y,parameters:g,moduleSettings:n,uniforms:_,gridSize:p,attributes:s,weights:c}),S?this._renderToMaxMinTexture({id:y,parameters:{...g,blendEquation:O3},gridSize:p,minOrMaxFb:f[y],clearParams:{clearColor:[0,0,0,ii]},combineMaxMin:S}):(v&&this._renderToMaxMinTexture({id:y,parameters:{...g,blendEquation:hp},gridSize:p,minOrMaxFb:h[y],clearParams:{clearColor:[ii,ii,ii,0]},combineMaxMin:S}),T&&this._renderToMaxMinTexture({id:y,parameters:{...g,blendEquation:dp},gridSize:p,minOrMaxFb:d[y],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:S}))}}_renderToMaxMinTexture(e){let{id:r,gridSize:i,minOrMaxFb:s,combineMaxMin:n,clearParams:o={}}=e,{framebuffers:a}=this.state,{allAggregationModel:c}=this;this.device.withParametersWebGL({...o,framebuffer:s,viewport:[0,0,i[0],i[1]]},()=>{this.device.clearWebGL({color:!0}),c.setUniforms({gridSize:i,combineMaxMin:n}),c.setBindings({uSampler:a[r].texture}),c.draw()})}_renderToWeightsTexture(e){let{id:r,parameters:i,moduleSettings:s,uniforms:n,gridSize:o,weights:a}=e,{framebuffers:c,equations:l,weightAttributes:u}=this.state,{gridAggregationModel:f}=this,{operation:h}=a[r],d=h===le.MIN?[ii,ii,ii,0]:[0,0,0,0];if(this.device.withParametersWebGL({framebuffer:c[r],viewport:[0,0,o[0],o[1]],clearColor:d},()=>{this.device.clearWebGL({color:!0});let p={weights:u[r]};f.draw({parameters:{...i,blendEquation:l[r]},moduleSettings:s,uniforms:n,attributes:p})}),h===le.MEAN){let{meanTextures:p,textures:g}=this.state,_={_sourceTextures:{aggregationValues:p[r]},_targetTexture:g[r],elementCount:g[r].width*g[r].height};this.meanTransform?this.meanTransform.update(_):this.meanTransform=qC(this.device,_),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),c[r].attach({36064:g[r]})}}_runAggregation(e){this._updateModels(e),this._setupFramebuffers(e),this._renderAggregateData(e);let r=this._getAggregateData(e);return this.setState({results:r}),r}_setupFramebuffers(e){let{textures:r,framebuffers:i,maxMinFramebuffers:s,minFramebuffers:n,maxFramebuffers:o,meanTextures:a,equations:c}=this.state,{weights:l}=e,{numCol:u,numRow:f}=e,h={width:u,height:f};for(let d in l){let{needMin:p,needMax:g,combineMaxMin:_,operation:y}=l[d];r[d]=l[d].aggregationTexture||r[d]||Ks(this.device,{id:`${d}-texture`,width:u,height:f}),r[d].resize(h);let v=r[d];y===le.MEAN&&(a[d]=a[d]||Ks(this.device,{id:`${d}-mean-texture`,width:u,height:f}),a[d].resize(h),v=a[d]),i[d]?i[d].attach({36064:v}):i[d]=Pa(this.device,{id:`${d}-fb`,width:u,height:f,texture:v}),i[d].resize(h),c[d]=pp[y]||pp[le.SUM],(p||g)&&(p&&g&&_?s[d]||(v=l[d].maxMinTexture||this._getMinMaxTexture(`${d}-maxMinTexture`),s[d]=Pa(this.device,{id:`${d}-maxMinFb`,texture:v})):(p&&(n[d]||(v=l[d].minTexture||this._getMinMaxTexture(`${d}-minTexture`),n[d]=Pa(this.device,{id:`${d}-minFb`,texture:v}))),g&&(o[d]||(v=l[d].maxTexture||this._getMinMaxTexture(`${d}-maxTexture`),o[d]=Pa(this.device,{id:`${d}-maxFb`,texture:v})))))}}_getMinMaxTexture(e){let{resources:r}=this.state;return r[e]||(r[e]=Ks(this.device,{id:"resourceName"})),r[e]}_setupModels({numCol:e=0,numRow:r=0}={}){let{shaderOptions:i}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=YC(this.device,i),!this.allAggregationModel){let s=e*r;this.allAggregationModel=KC(this.device,s)}}_setupWeightAttributes(e){let{weightAttributes:r}=this.state,{weights:i}=e;for(let s in i)r[s]=e.attributes[s]}_trackGPUResultBuffers(e,r){let{resources:i}=this.state;for(let s in e)if(e[s]){for(let n of HC)if(e[s][n]&&r[s][n]!==e[s][n]){let o=`gpu-result-${s}-${n}`;i[o]&&i[o].delete(),i[o]=e[s][n]}}}_updateModels(e){let{vertexCount:r,attributes:i,numCol:s,numRow:n}=e,{modelDirty:o}=this.state;o&&(this._setupModels(e),this.setState({modelDirty:!1})),this._setupWeightAttributes(e),this.gridAggregationModel.setVertexCount(r),this.gridAggregationModel.setAttributes(i),this.allAggregationModel.setInstanceCount(s*n)}};function XC(t){let e={};for(let r in t)e[r]={...N3,...t[r]};return e}function $C(t){t=Array.isArray(t)?t:[t],t.forEach(e=>{for(let r in e)e[r].delete()})}function YC(t,e){let r=Fs({vs:D3,fs:L3,modules:[Wr,ae]},e);return new te(t,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:no(),...r})}function KC(t,e){return new te(t,{id:"All-Aggregation-Model",vs:k3,fs:B3,modules:[Wr],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:e,attributes:{position:[0,0]}})}function qC(t,e){return new $r(t,{vs:U3,_targetTextureVarying:"meanValues",...e})}var At=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function si(t,e=!1,r=Float32Array){let i;if(Number.isFinite(t[0]))i=new r(t);else{i=new r(t.length*4);let s=0;for(let n=0;ne.features.has(r))}constructor(e,r={}){this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=r.id||"gpu-grid-aggregator",this.device=e;let i=["float32-renderable-webgl"];this._hasGPUSupport=i.every(n=>e.features.has(n)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:e,allAggregationModel:r,meanTransform:i}=this,{textures:n,framebuffers:s,maxMinFramebuffers:o,minFramebuffers:a,maxFramebuffers:A,meanTextures:h,resources:g}=this.state;e?.destroy(),r?.destroy(),i?.destroy(),kW([s,n,o,a,A,h,g])}run(e={}){this.setState({results:{}});let r=this._normalizeAggregationParams(e);return this._runAggregation(r)}getData(e){let r={},i=this.state.results;i[e].aggregationData||(i[e].aggregationData=i[e].aggregationBuffer.getData()),r.aggregationData=i[e].aggregationData;for(let n in AP){let s=AP[n];(i[e][n]||i[e][s])&&(i[e][n]=i[e][n]||i[e][s].getData(),r[n]=i[e][n])}return r}updateShaders(e={}){this.setState({shaderOptions:e,modelDirty:!0})}_normalizeAggregationParams(e){let r={...tP,...e},{weights:i}=r;return i&&(r.weights=UW(i)),r}setState(e){Object.assign(this.state,e)}_getAggregateData(e){let r={},{textures:i,framebuffers:n,maxMinFramebuffers:s,minFramebuffers:o,maxFramebuffers:a,resources:A}=this.state,{weights:h}=e;for(let g in h){r[g]={};let{needMin:_,needMax:x,combineMaxMin:T}=h[g];r[g].aggregationTexture=i[g],r[g].aggregationBuffer=this.device.readPixelsToBufferWebGL(n[g],{target:h[g].aggregationBuffer,sourceType:5126}),_&&x&&T?(r[g].maxMinBuffer=this.device.readPixelsToBufferWebGL(s[g],{target:h[g].maxMinBuffer,sourceType:5126}),r[g].maxMinTexture=A[`${g}-maxMinTexture`]):(_&&(r[g].minBuffer=this.device.readPixelsToBufferWebGL(o[g],{target:h[g].minBuffer,sourceType:5126}),r[g].minTexture=A[`${g}-minTexture`]),x&&(r[g].maxBuffer=this.device.readPixelsToBufferWebGL(a[g],{target:h[g].maxBuffer,sourceType:5126}),r[g].maxTexture=A[`${g}-maxTexture`]))}return this._trackGPUResultBuffers(r,h),r}_renderAggregateData(e){let{cellSize:r,projectPoints:i,attributes:n,moduleSettings:s,numCol:o,numRow:a,weights:A,translation:h,scaling:g}=e,{maxMinFramebuffers:_,minFramebuffers:x,maxFramebuffers:T}=this.state,v=[o,a],S={blend:!0,depthTest:!1,blendFunc:[1,1]},C={cellSize:r,gridSize:v,projectPoints:i,translation:h,scaling:g};for(let M in A){let{needMin:R,needMax:B}=A[M],k=R&&B&&A[M].combineMaxMin;this._renderToWeightsTexture({id:M,parameters:S,moduleSettings:s,uniforms:C,gridSize:v,attributes:n,weights:A}),k?this._renderToMaxMinTexture({id:M,parameters:{...S,blendEquation:rP},gridSize:v,minOrMaxFb:_[M],clearParams:{clearColor:[0,0,0,Eo]},combineMaxMin:k}):(R&&this._renderToMaxMinTexture({id:M,parameters:{...S,blendEquation:ky},gridSize:v,minOrMaxFb:x[M],clearParams:{clearColor:[Eo,Eo,Eo,0]},combineMaxMin:k}),B&&this._renderToMaxMinTexture({id:M,parameters:{...S,blendEquation:Vy},gridSize:v,minOrMaxFb:T[M],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:k}))}}_renderToMaxMinTexture(e){let{id:r,gridSize:i,minOrMaxFb:n,combineMaxMin:s,clearParams:o={}}=e,{framebuffers:a}=this.state,{allAggregationModel:A}=this;this.device.withParametersWebGL({...o,framebuffer:n,viewport:[0,0,i[0],i[1]]},()=>{this.device.clearWebGL({color:!0}),A.setUniforms({gridSize:i,combineMaxMin:s}),A.setBindings({uSampler:a[r].texture}),A.draw()})}_renderToWeightsTexture(e){let{id:r,parameters:i,moduleSettings:n,uniforms:s,gridSize:o,weights:a}=e,{framebuffers:A,equations:h,weightAttributes:g}=this.state,{gridAggregationModel:_}=this,{operation:x}=a[r],T=x===Lt.MIN?[Eo,Eo,Eo,0]:[0,0,0,0];if(this.device.withParametersWebGL({framebuffer:A[r],viewport:[0,0,o[0],o[1]],clearColor:T},()=>{this.device.clearWebGL({color:!0});let v={weights:g[r]};_.draw({parameters:{...i,blendEquation:h[r]},moduleSettings:n,uniforms:s,attributes:v})}),x===Lt.MEAN){let{meanTextures:v,textures:S}=this.state,C={_sourceTextures:{aggregationValues:v[r]},_targetTexture:S[r],elementCount:S[r].width*S[r].height};this.meanTransform?this.meanTransform.update(C):this.meanTransform=HW(this.device,C),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),A[r].attach({36064:S[r]})}}_runAggregation(e){this._updateModels(e),this._setupFramebuffers(e),this._renderAggregateData(e);let r=this._getAggregateData(e);return this.setState({results:r}),r}_setupFramebuffers(e){let{textures:r,framebuffers:i,maxMinFramebuffers:n,minFramebuffers:s,maxFramebuffers:o,meanTextures:a,equations:A}=this.state,{weights:h}=e,{numCol:g,numRow:_}=e,x={width:g,height:_};for(let T in h){let{needMin:v,needMax:S,combineMaxMin:C,operation:M}=h[T];r[T]=h[T].aggregationTexture||r[T]||hl(this.device,{id:`${T}-texture`,width:g,height:_}),r[T].resize(x);let R=r[T];M===Lt.MEAN&&(a[T]=a[T]||hl(this.device,{id:`${T}-mean-texture`,width:g,height:_}),a[T].resize(x),R=a[T]),i[T]?i[T].attach({36064:R}):i[T]=Lf(this.device,{id:`${T}-fb`,width:g,height:_,texture:R}),i[T].resize(x),A[T]=zy[M]||zy[Lt.SUM],(v||S)&&(v&&S&&C?n[T]||(R=h[T].maxMinTexture||this._getMinMaxTexture(`${T}-maxMinTexture`),n[T]=Lf(this.device,{id:`${T}-maxMinFb`,texture:R})):(v&&(s[T]||(R=h[T].minTexture||this._getMinMaxTexture(`${T}-minTexture`),s[T]=Lf(this.device,{id:`${T}-minFb`,texture:R}))),S&&(o[T]||(R=h[T].maxTexture||this._getMinMaxTexture(`${T}-maxTexture`),o[T]=Lf(this.device,{id:`${T}-maxFb`,texture:R})))))}}_getMinMaxTexture(e){let{resources:r}=this.state;return r[e]||(r[e]=hl(this.device,{id:"resourceName"})),r[e]}_setupModels({numCol:e=0,numRow:r=0}={}){let{shaderOptions:i}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=VW(this.device,i),!this.allAggregationModel){let n=e*r;this.allAggregationModel=zW(this.device,n)}}_setupWeightAttributes(e){let{weightAttributes:r}=this.state,{weights:i}=e;for(let n in i)r[n]=e.attributes[n]}_trackGPUResultBuffers(e,r){let{resources:i}=this.state;for(let n in e)if(e[n]){for(let s of NW)if(e[n][s]&&r[n][s]!==e[n][s]){let o=`gpu-result-${n}-${s}`;i[o]&&i[o].delete(),i[o]=e[n][s]}}}_updateModels(e){let{vertexCount:r,attributes:i,numCol:n,numRow:s}=e,{modelDirty:o}=this.state;o&&(this._setupModels(e),this.setState({modelDirty:!1})),this._setupWeightAttributes(e),this.gridAggregationModel.setVertexCount(r),this.gridAggregationModel.setAttributes(i),this.allAggregationModel.setInstanceCount(n*s)}};function UW(t){let e={};for(let r in t)e[r]={...iP,...t[r]};return e}function kW(t){t=Array.isArray(t)?t:[t],t.forEach(e=>{for(let r in e)e[r].delete()})}function VW(t,e){let r=qc({vs:sP,fs:oP,modules:[ro,xt]},e);return new Qe(t,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:hu(),...r})}function zW(t,e){return new Qe(t,{id:"All-Aggregation-Model",vs:aP,fs:cP,modules:[ro],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:e,attributes:{position:[0,0]}})}function HW(t,e){return new lo(t,{vs:lP,_targetTextureVarying:"meanValues",...e})}var ji=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function vo(t,e=!1,r=Float32Array){let i;if(Number.isFinite(t[0]))i=new r(t);else{i=new r(t.length*4);let n=0;for(let s=0;se[n]!==r[n])&&s.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),e.colorRange!==r.colorRange&&s.setUniforms({colorRange:si(r.colorRange)}),e.cellMarginPixels!==r.cellMarginPixels||e.cellSizePixels!==r.cellSizePixels||i.viewportChanged){let{width:n,height:o}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:c}=this.props,l=a>c?c:0,u=new Float32Array([(a-l)/n*2,-(a-l)/o*2,1]);s.setUniforms({cellScale:u})}}};function H3(t,e){let r={};for(let i in t)e.includes(i)||(r[i]=t[i]);return r}var nt=class extends et{static{this.layerName="AggregationLayer"}initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:H3(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let i=this.getShaders({});i&&i.defines&&(i.defines.NON_INSTANCED_MODEL=1),this.updateShaders(i)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:i}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:i.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:i,oldProps:s,changeFlags:n}=e,{compareAll:o=!1,dimension:a}=r,{ignoreProps:c}=this.state,{props:l,accessors:u=[]}=a,{updateTriggersChanged:f}=n;if(n.dataChanged)return!0;if(f){if(f.all)return!0;for(let h of u)if(f[h])return!0}if(o)return n.extensionsChanged?!0:qo({oldProps:s,newProps:i,ignoreProps:c,propTypes:this.constructor._propTypes});for(let h of l)if(i[h]!==s[h])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!eR(r)}_getAttributeManager(){return new nr(this.context.device,{id:this.props.id,stats:this.context.stats})}};function eR(t){let e=!0;for(let r in t){e=!1;break}return e}function cu(t,e,r){let i=r;return i.domain=()=>t,i.range=()=>e,i}function j3(t,e){return cu(t,e,i=>cR(t,e,i))}function tR(t,e){return cu(t,e,i=>lR(t,e,i))}function rR(t,e){let r=t.sort(X3),i=0,s=Math.max(1,e.length),n=new Array(s-1);for(;++inR(n,e,a);return o.thresholds=()=>n,cu(t,e,o)}function X3(t,e){return t-e}function iR(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let i=(r-1)*e,s=Math.floor(i),n=t[s],o=t[s+1];return n+(o-n)*(i-s)}function sR(t,e){let r=0,i=t.length;for(;r>>1;X3(t[s],e)>0?i=s:r=s+1}return r}function nR(t,e,r){return e[sR(t,r)]}function oR(t,e,r,i){let s=`${i}`,n=e.get(s);return n===void 0&&(n=t.push(i),e.set(s,n)),r[(n-1)%r.length]}function aR(t,e){let r=new Map,i=[];for(let n of t){let o=`${n}`;r.has(o)||r.set(o,i.push(n))}return cu(t,e,n=>oR(i,r,e,n))}function cR(t,e,r){let i=t[1]-t[0];if(i<=0)return U.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];let s=i/e.length,n=Math.floor((r-t[0])/s),o=Math.max(Math.min(n,e.length-1),0);return e[o]}function lR(t,e,r){return(r-t[0])/(t[1]-t[0])*(e[1]-e[0])+e[0]}function $3(t){return t!=null}function uR(t){let e=[];return t.forEach(r=>{!e.includes(r)&&$3(r)&&e.push(r)}),e}function Y3(t,e){return(typeof e=="function"?t.map(e):t).filter($3)}function K3(t,e){return Y3(t,e)}function q3(t,e){return uR(Y3(t,e))}function G3(t,e,r){return Math.max(e,Math.min(r,t))}function Z3(t){switch(t){case"quantize":return j3;case"linear":return tR;case"quantile":return rR;case"ordinal":return aR;default:return j3}}var Q3=t=>t.length,fR=3402823466e29,ex=t=>t.points,tx=t=>t.index,J3=(t,e)=>te?1:t>=e?0:NaN,hR={getValue:Q3,getPoints:ex,getIndex:tx,filterData:null},Cr=class{constructor(e=[],r=hR){this.aggregatedBins=this.getAggregatedBins(e,r),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(e,r){let{getValue:i=Q3,getPoints:s=ex,getIndex:n=tx,filterData:o}=r,a=typeof o=="function",c=e.length,l=[],u=0;for(let f=0;fG3(a,0,100)),n=Math.ceil(i/100*(r-1)),o=Math.floor(s/100*(r-1));return[n,o]}getBinMap(){let e={};for(let r of this.aggregatedBins)e[r.i]=r;return e}_updateMinMaxValues(){let e=0,r=0,i=fR,s=0;for(let n of this.aggregatedBins)e=e>n.counts?e:n.counts,r=r>n.value?r:n.value,i=iJ3(s.value,n.value))),!this.sortedBins.length)return[];let r=0,i=this.sortedBins.length-1;if(Array.isArray(e)){let s=this._percentileToIndex(e);r=s[0],i=s[1]}return[this.sortedBins[r].value,this.sortedBins[i].value]}getValueDomainByScale(e,[r=0,i=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((n,o)=>J3(n.value,o.value))),!this.sortedBins.length)return[];let s=this._percentileToIndex([r,i]);return this._getScaleDomain(e,s)}_getScaleDomain(e,[r,i]){let s=this.sortedBins;switch(e){case"quantize":case"linear":return[s[r].value,s[i].value];case"quantile":return K3(s.slice(r,i+1),n=>n.value);case"ordinal":return q3(s,n=>n.value);default:return[s[r].value,s[i].value]}}};var ix=6378e3;function lu(t){return Number.isFinite(t)?t:0}function uu(t,e){let r=t.positions.value,i=1/0,s=-1/0,n=1/0,o=-1/0,a,c;for(let u=0;us?a:s,n=co?c:o;return{xMin:lu(n),xMax:lu(o),yMin:lu(i),yMax:lu(s)}}function dR(t,e,r,i){let{width:s,height:n}=i,o=r===q.CARTESIAN?[-s/2,-n/2]:[-180,-90];U.assert(r===q.CARTESIAN||r===q.LNGLAT||r===q.DEFAULT);let{xMin:a,yMin:c}=t;return[-1*(rx(a-o[0],e.xOffset)+o[0]),-1*(rx(c-o[1],e.yOffset)+o[1])]}function rx(t,e){let r=t<0?-1:1,i=r<0?Math.abs(t)+e:Math.abs(t);return i=Math.floor(i/e)*e,i*r}function gp(t,e,r=!0){if(!r)return{xOffset:e,yOffset:e};let{yMin:i,yMax:s}=t,n=(i+s)/2;return pR(e,n)}function fu(t,e,r,i){let s=gp(t,e,i!==q.CARTESIAN),n=dR(t,s,i,r),{xMin:o,yMin:a,xMax:c,yMax:l}=t,u=c-o+s.xOffset,f=l-a+s.yOffset,h=Math.ceil(u/s.xOffset),d=Math.ceil(f/s.yOffset);return{gridOffset:s,translation:n,width:u,height:f,numCol:h,numRow:d}}function pR(t,e){let r=gR(t),i=mR(e,t);return{yOffset:r,xOffset:i}}function gR(t){return t/ix*(180/Math.PI)}function mR(t,e){return e/ix*(180/Math.PI)/Math.cos(t*Math.PI/180)}function Gs(t,e){let r=_R(t,e),i=xR(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:i}}function _R(t,e){let{data:r=[],cellSize:i}=t,{attributes:s,viewport:n,projectPoints:o,numInstances:a}=e,c=s.positions.value,{size:l}=s.positions.getAccessor(),u=e.boundingBox||yR(s.positions,a),f=e.posOffset||[180,90],h=e.gridOffset||gp(u,i);if(h.xOffset<=0||h.yOffset<=0)return{gridHash:{},gridOffset:h,offsets:[0,0]};let{width:d,height:p}=n,g=Math.ceil(d/h.xOffset),_=Math.ceil(p/h.yOffset),y={},{iterable:v,objectInfo:T}=$e(r),S=new Array(3);for(let R of v){T.index++,S[0]=c[T.index*l],S[1]=c[T.index*l+1],S[2]=l>=3?c[T.index*l+2]:0;let[M,F]=o?n.project(S):S;if(Number.isFinite(M)&&Number.isFinite(F)){let N=Math.floor((F+f[1])/h.yOffset),D=Math.floor((M+f[0])/h.xOffset);if(!o||D>=0&&D=0&&N<_){let L=`${N}-${D}`;y[L]=y[L]||{count:0,points:[],lonIdx:D,latIdx:N},y[L].count+=1,y[L].points.push({source:R,index:T.index})}}}return{gridHash:y,gridOffset:h,offsets:[f[0]*-1,f[1]*-1]}}function xR({gridHash:t,gridOffset:e,offsets:r}){let i=new Array(Object.keys(t).length),s=0;for(let n in t){let o=n.split("-"),a=parseInt(o[0],10),c=parseInt(o[1],10),l=s++;i[l]={index:l,position:[r[0]+e.xOffset*c,r[1]+e.yOffset*a],...t[n]}}return i}function yR(t,e){let r=t.value,{size:i}=t.getAccessor(),s=1/0,n=-1/0,o=1/0,a=-1/0,c,l;for(let u=0;un?c:n,o=la?l:a);return{xMin:o,xMax:a,yMin:s,yMax:n}}var Rr=class extends nt{static{this.layerName="GridAggregationLayer"}initializeAggregationLayer({dimensions:e}){super.initializeAggregationLayer(e),this.setState({layerData:{},gpuGridAggregator:new Ce(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:Gs})}updateState(e){super.updateState(e),this.updateAggregationState(e);let{aggregationDataDirty:r,aggregationWeightsDirty:i,gpuAggregation:s}=this.state;if(this.getNumInstances()<=0)return;let n=!1;(r||s&&i)&&(this._updateAggregation(e),n=!0),!s&&(r||i)&&(this._updateWeightBins(),this._uploadAggregationResults(),n=!0),this.setState({aggregationDirty:n})}finalizeState(e){let{count:r}=this.state.weights;r&&r.aggregationBuffer&&r.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(e)}updateShaders(e){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(e)}updateAggregationState(e){U.assert(!1)}allocateResources(e,r){if(this.state.numRow!==e||this.state.numCol!==r){let i=r*e*4*4,{weights:s}=this.state;for(let n in s){let o=s[n];o.aggregationBuffer&&o.aggregationBuffer.delete(),o.aggregationBuffer=this.context.device.createBuffer({byteLength:i,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:e,maxMinData:r,maxData:i,minData:s}){let{count:n}=this.state.weights;n&&(n.aggregationData=e,n.maxMinData=r,n.maxData=i,n.minData=s)}_updateAggregation(e){let{cpuGridAggregator:r,gpuGridAggregator:i,gridOffset:s,posOffset:n,translation:o=[0,0],scaling:a=[0,0,0],boundingBox:c,projectPoints:l,gpuAggregation:u,numCol:f,numRow:h}=this.state,{props:d}=e,{viewport:p}=this.context,g=this.getAttributes(),_=this.getNumInstances();if(u){let{weights:y}=this.state;i.run({weights:y,cellSize:[s.xOffset,s.yOffset],numCol:f,numRow:h,translation:o,scaling:a,vertexCount:_,projectPoints:l,attributes:g,moduleSettings:this.getModuleSettings()})}else{let y=r(d,{gridOffset:s,projectPoints:l,attributes:g,viewport:p,posOffset:n,boundingBox:c});this.setState({layerData:y})}}_updateWeightBins(){let{getValue:e}=this.state,r=new Cr(this.state.layerData.data||[],{getValue:e});this.setState({sortedBins:r})}_uploadAggregationResults(){let{numCol:e,numRow:r}=this.state,{data:i}=this.state.layerData,{aggregatedBins:s,minValue:n,maxValue:o,totalCount:a}=this.state.sortedBins,c=4,l=e*r*c,u=new Float32Array(l).fill(0);for(let p of s){let{lonIdx:g,latIdx:_}=i[p.i],{value:y,counts:v}=p,T=(g+_*e)*c;u[T]=y,u[T+c-1]=v}let f=new Float32Array([o,0,0,n]),h=new Float32Array([o,0,0,a]),d=new Float32Array([n,0,0,a]);this.updateResults({aggregationData:u,maxMinData:f,maxData:h,minData:d})}};var bR={...qs.defaultProps,getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},sx="positions",vR={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Ca=class extends Rr{static{this.layerName="ScreenGridLayer"}static{this.defaultProps=bR}initializeState(){super.initializeAggregationLayer({dimensions:vR,getCellSize:i=>i.cellSizePixels});let e={count:{size:1,operation:le.SUM,needMax:!0,maxTexture:Ks(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:e,subLayerData:{attributes:{}},maxTexture:e.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[sx]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return this.state.supported&&e.somethingChanged}updateState(e){super.updateState(e)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:e,numRow:r,numCol:i,weights:s}=this.state,{updateTriggers:n}=this.props,{aggregationBuffer:o}=s.count,a=this.getSubLayerClass("cells",qs);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:n}),{data:{attributes:{instanceCounts:o}},maxTexture:e,numInstances:r*i})}finalizeState(e){super.finalizeState(e);let{aggregationBuffer:r,maxBuffer:i,maxTexture:s}=this.state;r?.delete(),i?.delete(),s?.delete()}getPickingInfo({info:e}){let{index:r}=e;if(r>=0){let{gpuGridAggregator:i,gpuAggregation:s,weights:n}=this.state,o=s?i.getData("count"):n.count;e.object=Ce.getAggregationData({pixelIndex:r,...o})}return e}updateResults({aggregationData:e,maxData:r}){let{count:i}=this.state.weights;i.aggregationData=e,i.aggregationBuffer.write(e),i.maxData=r,i.maxTexture.setImageData({data:r})}updateAggregationState(e){let r=e.props.cellSizePixels,i=e.oldProps.cellSizePixels!==r,{viewportChanged:s}=e.changeFlags,n=e.props.gpuAggregation;this.state.gpuAggregation!==e.props.gpuAggregation&&n&&!Ce.isSupported(this.context.device)&&(U.warn("GPU Grid Aggregation not supported, falling back to CPU")(),n=!1);let o=n!==this.state.gpuAggregation;this.setState({gpuAggregation:n});let a=this.isAttributeChanged(sx),{dimensions:c}=this.state,{data:l,weights:u}=c,f=a||o||s||this.isAggregationDirty(e,{compareAll:n,dimension:l}),h=this.isAggregationDirty(e,{dimension:u});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:h});let{viewport:d}=this.context;if(s||i){let{width:p,height:g}=d,_=Math.ceil(p/r),y=Math.ceil(g/r);this.allocateResources(y,_),this.setState({scaling:[p/2,-g/2,1],gridOffset:{xOffset:r,yOffset:r},width:p,height:g,numCol:_,numRow:y})}h&&this._updateAccessors(e),(f||h)&&this._resetResults()}_updateAccessors(e){let{getWeight:r,aggregation:i,data:s}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=le[i]),this.setState({getValue:Ys(i,r,{data:s})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}};function nx(){}var ox=["getBins","getDomain","getScaleFunc"],ax=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],TR=t=>t.cellSize,Mr=class{constructor(e){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=e.getCellSize||TR,this._getAggregator=e.getAggregator,this._addDimension(e.dimensions||ax)}static defaultDimensions(){return ax}updateState(e,r){let{oldProps:i,props:s,changeFlags:n}=e;this.updateGetValueFuncs(i,s,n);let o=this.needsReProjectPoints(i,s,n),a=!1;return n.dataChanged||o?(this.getAggregatedData(s,r),a=!0):((this.getDimensionChanges(i,s,n)||[]).forEach(l=>typeof l=="function"&&l()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(e){this.state={...this.state,...e}}setDimensionState(e,r){this.setState({dimensions:{...this.state.dimensions,[e]:{...this.state.dimensions[e],...r}}})}normalizeResult(e={}){return e.hexagons?{data:e.hexagons,...e}:e.layerData?{data:e.layerData,...e}:e}getAggregatedData(e,r){let s=this._getAggregator(e)(e,r);this.setState({layerData:this.normalizeResult(s)}),this.changeFlags={layerData:!0},this.getSortedBins(e)}updateGetValueFuncs(e,r,i){for(let s in this.dimensionUpdaters){let{value:n,weight:o,aggregation:a}=this.dimensionUpdaters[s].getBins.triggers,c=r[n.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[s].getBins,e,r,i)&&(c?c=M3(c,{data:r.data}):c=Ys(r[a.prop],r[o.prop],{data:r.data})),c&&this.setDimensionState(s,{getValue:c})}}needsReProjectPoints(e,r,i){return this._getCellSize(e)!==this._getCellSize(r)||this._getAggregator(e)!==this._getAggregator(r)||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPosition)}addDimension(e){this._addDimension(e)}_addDimension(e=[]){e.forEach(r=>{let{key:i}=r;this.dimensionUpdaters[i]=this.getDimensionUpdaters(r),this.state.dimensions[i]={getValue:null,domain:null,sortedBins:null,scaleFunc:nx}})}getDimensionUpdaters({key:e,accessor:r,pickingInfo:i,getBins:s,getDomain:n,getScaleFunc:o,nullValue:a}){return{key:e,accessor:r,pickingInfo:i,getBins:{updater:this.getDimensionSortedBins.bind(this),...s},getDomain:{updater:this.getDimensionValueDomain.bind(this),...n},getScaleFunc:{updater:this.getDimensionScale.bind(this),...o},attributeAccessor:this.getSubLayerDimensionAttribute(e,a)}}needUpdateDimensionStep(e,r,i,s){return Object.values(e.triggers).some(n=>n.updateTrigger?s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged[n.updateTrigger]):r[n.prop]!==i[n.prop])}getDimensionChanges(e,r,i){let s=[];for(let n in this.dimensionUpdaters){let o=ox.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[n][a],e,r,i));o&&s.push(this.dimensionUpdaters[n][o].updater.bind(this,r,this.dimensionUpdaters[n]))}return s.length?s:null}getUpdateTriggers(e){let r=e.updateTriggers||{},i={};for(let s in this.dimensionUpdaters){let{accessor:n}=this.dimensionUpdaters[s];i[n]={},ox.forEach(o=>{Object.values(this.dimensionUpdaters[s][o].triggers).forEach(({prop:a,updateTrigger:c})=>{if(c){let l=r[c];typeof l=="object"&&!Array.isArray(l)?Object.assign(i[n],l):l!==void 0&&(i[n][a]=l)}else i[n][a]=e[a]})})}return i}getSortedBins(e){for(let r in this.dimensionUpdaters)this.getDimensionSortedBins(e,this.dimensionUpdaters[r])}getDimensionSortedBins(e,r){let{key:i}=r,{getValue:s}=this.state.dimensions[i],n=new Cr(this.state.layerData.data||[],{getValue:s,filterData:e._filterData});this.setDimensionState(i,{sortedBins:n}),this.getDimensionValueDomain(e,r)}getDimensionValueDomain(e,r){let{getDomain:i,key:s}=r,{triggers:{lowerPercentile:n,upperPercentile:o,scaleType:a}}=i,c=this.state.dimensions[s].sortedBins.getValueDomainByScale(e[a.prop],[e[n.prop],e[o.prop]]);this.setDimensionState(s,{valueDomain:c}),this.getDimensionScale(e,r)}getDimensionScale(e,r){let{key:i,getScaleFunc:s,getDomain:n}=r,{domain:o,range:a}=s.triggers,{scaleType:c}=n.triggers,{onSet:l}=s,u=e[a.prop],f=e[o.prop]||this.state.dimensions[i].valueDomain,d=Z3(c&&e[c.prop])(f,u);typeof l=="object"&&typeof e[l.props]=="function"&&e[l.props](d.domain()),this.setDimensionState(i,{scaleFunc:d})}getSubLayerDimensionAttribute(e,r){return i=>{let{sortedBins:s,scaleFunc:n}=this.state.dimensions[e],o=s.binMap[i.index];if(o&&o.counts===0)return r;let a=o&&o.value,c=n.domain();return a>=c[0]&&a<=c[c.length-1]?n(a):r}}getSubLayerAccessors(e){let r={};for(let i in this.dimensionUpdaters){let{accessor:s}=this.dimensionUpdaters[i];r[s]=this.getSubLayerDimensionAttribute(e,i)}return r}getPickingInfo({info:e}){let r=e.picked&&e.index>-1,i=null;if(r){let s=this.state.layerData.data[e.index],n={};for(let o in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[o],{sortedBins:c}=this.state.dimensions[o],l=c.binMap[s.index]&&c.binMap[s.index].value;n[a]=l}i=Object.assign(n,s,{points:s.filteredPoints||s.points})}return e.picked=!!i,e.object=i,e}getAccessor(e){return this.dimensionUpdaters.hasOwnProperty(e)?this.dimensionUpdaters[e].attributeAccessor:nx}};function cx(){}var ER={colorDomain:null,colorRange:At,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:cx,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:cx,gridAggregator:Gs,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},ni=class extends nt{static{this.layerName="CPUGridLayer"}static{this.defaultProps=ER}initializeState(){let e=new Mr({getAggregator:i=>i.gridAggregator,getCellSize:i=>i.cellSize});this.state={cpuAggregator:e,aggregatorState:e.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){super.updateState(e),this.setState({aggregatorState:this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,cellSize:i,coverage:s,material:n,transitions:o}=this.props,{cpuAggregator:a}=this.state,c=this.getSubLayerClass("grid-cell",Ki),l=this._getSublayerUpdateTriggers();return new c({cellSize:i,coverage:s,material:n,elevationScale:e,extruded:r,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:o&&{getFillColor:o.getColorValue||o.getColorWeight,getElevation:o.getElevationValue||o.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:l}),{data:a.state.layerData.data})}};var Zs=Math.PI/3,SR=[0,Zs,2*Zs,3*Zs,4*Zs,5*Zs];function AR(t){return t[0]}function wR(t){return t[1]}function mp(){var t=0,e=0,r=1,i=1,s=AR,n=wR,o,a,c;function l(f){var h={},d=[],p,g=f.length;for(p=0;p1){var M=y-S,F=S+(yD*D+L*L&&(S=F+(T&1?1:-1)/2,T=N)}var Y=S+"-"+T,X=h[Y];X?X.push(_):(d.push(X=h[Y]=[_]),X.x=(S+(T&1)/2)*a,X.y=T*c)}return d}function u(f){var h=0,d=0;return SR.map(function(p){var g=Math.sin(p)*f,_=-Math.cos(p)*f,y=g-h,v=_-d;return h=g,d=_,[y,v]})}return l.hexagon=function(f){return"m"+u(f==null?o:+f).join("l")+"z"},l.centers=function(){for(var f=[],h=Math.round(e/c),d=Math.round(t/a),p=h*c;pg.screenCoord[0]).y(g=>g.screenCoord[1])(c).map((g,_)=>({position:s.unprojectFlat([g.x,g.y]),points:g,index:_})),radiusCommon:a}}function PR(t,e){let{attributes:r}=e,i=r.positions.value,{size:s}=r.positions.getAccessor(),n=1/0,o=1/0,a=-1/0,c=-1/0,l;for(l=0;lt.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},Ra=class extends nt{static{this.layerName="HexagonLayer"}static{this.defaultProps=RR}initializeState(){let e=new Mr({getAggregator:i=>i.hexagonAggregator,getCellSize:i=>i.radius});this.state={cpuAggregator:e,aggregatorState:e.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){if(super.updateState(e),e.changeFlags.propsOrDataChanged){let r=this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==r.layerData){let{hexagonVertices:i}=r.layerData||{};this.setState({vertices:i&&this.convertLatLngToMeterOffset(i)})}this.setState({aggregatorState:r})}}convertLatLngToMeterOffset(e){let{viewport:r}=this.context;if(Array.isArray(e)&&e.length===6){let i=e[0],s=e[3],n=[(i[0]+s[0])/2,(i[1]+s[1])/2],o=r.projectFlat(n),{metersPerUnit:a}=r.getDistanceScales(n);return e.map(l=>{let u=r.projectFlat(l);return[(u[0]-o[0])*a[0],(u[1]-o[1])*a[1]]})}return U.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,coverage:i,material:s,transitions:n}=this.props,{aggregatorState:o,vertices:a}=this.state,c=this.getSubLayerClass("hexagon-cell",wr),l=this._getSublayerUpdateTriggers(),u=a?{vertices:a,radius:1}:{radius:o.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new c({...u,diskResolution:6,elevationScale:e,extruded:r,coverage:i,material:s,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:n&&{getFillColor:n.getColorValue||n.getColorWeight,getElevation:n.getElevationValue||n.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:l}),{data:o.layerData.data})}};var W=.16666666666666666,P={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},Js=[P.W,P.SW,P.S],Qs=[P.S,P.SE,P.E],en=[P.E,P.NE,P.N],tn=[P.NW,P.W,P.N],rn=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5]],sn=[[-W,-.5],[W,-.5],[.5,-W],[.5,W]],nn=[[.5,-W],[.5,W],[W,.5],[-W,.5]],on=[[-.5,W],[-.5,-W],[W,.5],[-W,.5]],fx=[P.W,P.SW,P.SE,P.E],hx=[P.S,P.SE,P.NE,P.N],dx=[P.NW,P.W,P.E,P.NE],px=[P.NW,P.SW,P.S,P.N],gx=[[-.5,W],[-.5,-W],[.5,-W],[.5,W]],mx=[[-W,-.5],[W,-.5],[W,.5],[-W,.5]],MR=[P.NW,P.SW,P.SE,P.NE],_x=[P.NW,P.SW,P.SE,P.E,P.N],xx=[P.W,P.SW,P.SE,P.NE,P.N],yx=[P.NW,P.W,P.S,P.SE,P.NE],bx=[P.NW,P.SW,P.S,P.E,P.NE],vx=[P.NW,P.W,[.5,-W],[.5,W],P.N],Tx=[[-W,-.5],[W,-.5],P.E,P.NE,P.N],Ex=[[-.5,W],[-.5,-W],P.S,P.SE,P.E],Sx=[P.W,P.SW,P.S,[W,.5],[-W,.5]],Ax=[P.NW,P.W,[-W,-.5],[W,-.5],P.N],wx=[[-.5,W],[-.5,-W],P.E,P.NE,P.N],Px=[P.S,P.SE,P.E,[W,.5],[-W,.5]],Cx=[P.W,P.SW,P.S,[.5,-W],[.5,W]],Rx=[P.W,P.SW,P.SE,P.E,[W,.5],[-W,.5]],Mx=[[-.5,W],[-.5,-W],P.S,P.SE,P.NE,P.N],Ix=[P.NW,P.W,[-W,-.5],[W,-.5],P.E,P.NE],Ox=[P.NW,P.SW,P.S,[.5,-W],[.5,W],P.N],an=[P.W,P.SW,P.S,P.E,P.NE,P.N],cn=[P.NW,P.W,P.S,P.SE,P.E,P.N],hu=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],P.E,P.NE,P.N],du=[P.W,P.SW,P.S,[.5,-W],[.5,W],[W,.5],[-W,.5]],pu=[P.NW,P.W,[-W,-.5],[W,-.5],[.5,-W],[.5,W],P.N],gu=[[-.5,W],[-.5,-W],P.S,P.SE,P.E,[W,.5],[-W,.5]],Nx=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],[.5,-W],[.5,W],[W,.5],[-W,.5]],Fx={0:[],1:[[P.W,P.S]],2:[[P.S,P.E]],3:[[P.W,P.E]],4:[[P.N,P.E]],5:{0:[[P.W,P.S],[P.N,P.E]],1:[[P.W,P.N],[P.S,P.E]]},6:[[P.N,P.S]],7:[[P.W,P.N]],8:[[P.W,P.N]],9:[[P.N,P.S]],10:{0:[[P.W,P.N],[P.S,P.E]],1:[[P.W,P.S],[P.N,P.E]]},11:[[P.N,P.E]],12:[[P.W,P.E]],13:[[P.S,P.E]],14:[[P.W,P.S]],15:[]};function z(t){return parseInt(t,4)}var Dx={[z("0000")]:[],[z("2222")]:[],[z("2221")]:[Js],[z("2212")]:[Qs],[z("2122")]:[en],[z("1222")]:[tn],[z("0001")]:[Js],[z("0010")]:[Qs],[z("0100")]:[en],[z("1000")]:[tn],[z("2220")]:[rn],[z("2202")]:[sn],[z("2022")]:[nn],[z("0222")]:[on],[z("0002")]:[rn],[z("0020")]:[sn],[z("0200")]:[nn],[z("2000")]:[on],[z("0011")]:[fx],[z("0110")]:[hx],[z("1100")]:[dx],[z("1001")]:[px],[z("2211")]:[fx],[z("2112")]:[hx],[z("1122")]:[dx],[z("1221")]:[px],[z("2200")]:[gx],[z("2002")]:[mx],[z("0022")]:[gx],[z("0220")]:[mx],[z("1111")]:[MR],[z("1211")]:[_x],[z("2111")]:[xx],[z("1112")]:[yx],[z("1121")]:[bx],[z("1011")]:[_x],[z("0111")]:[xx],[z("1110")]:[yx],[z("1101")]:[bx],[z("1200")]:[vx],[z("0120")]:[Tx],[z("0012")]:[Ex],[z("2001")]:[Sx],[z("1022")]:[vx],[z("2102")]:[Tx],[z("2210")]:[Ex],[z("0221")]:[Sx],[z("1002")]:[Ax],[z("2100")]:[wx],[z("0210")]:[Px],[z("0021")]:[Cx],[z("1220")]:[Ax],[z("0122")]:[wx],[z("2012")]:[Px],[z("2201")]:[Cx],[z("0211")]:[Rx],[z("2110")]:[Mx],[z("1102")]:[Ix],[z("1021")]:[Ox],[z("2011")]:[Rx],[z("0112")]:[Mx],[z("1120")]:[Ix],[z("1201")]:[Ox],[z("2101")]:[an],[z("0121")]:[an],[z("1012")]:[cn],[z("1210")]:[cn],[z("0101")]:{0:[Js,en],1:[an],2:[an]},[z("1010")]:{0:[tn,Qs],1:[cn],2:[cn]},[z("2121")]:{0:[an],1:[an],2:[Js,en]},[z("1212")]:{0:[cn],1:[cn],2:[tn,Qs]},[z("2120")]:{0:[hu],1:[hu],2:[rn,en]},[z("2021")]:{0:[du],1:[du],2:[Js,nn]},[z("1202")]:{0:[pu],1:[pu],2:[tn,sn]},[z("0212")]:{0:[gu],1:[gu],2:[Qs,on]},[z("0102")]:{0:[rn,en],1:[hu],2:[hu]},[z("0201")]:{0:[Js,nn],1:[du],2:[du]},[z("1020")]:{0:[tn,sn],1:[pu],2:[pu]},[z("2010")]:{0:[Qs,on],1:[gu],2:[gu]},[z("2020")]:{0:[on,sn],1:[Nx],2:[rn,nn]},[z("0202")]:{0:[nn,rn],1:[Nx],2:[on,sn]}};var es={ISO_LINES:1,ISO_BANDS:2},IR={zIndex:0,zOffset:.005};function Ma(t,e){return Array.isArray(e)?t=e?1:0}function Lx(t){let{cellWeights:e,x:r,y:i,width:s,height:n}=t,o=t.threshold;t.thresholdValue&&(U.deprecated("thresholdValue","threshold")(),o=t.thresholdValue);let a=r<0,c=r>=s-1,l=i<0,u=i>=n-1,f=a||c||l||u,h={},d={};a||u?d.top=0:(h.top=e[(i+1)*s+r],d.top=Ma(h.top,o)),c||u?d.topRight=0:(h.topRight=e[(i+1)*s+r+1],d.topRight=Ma(h.topRight,o)),c||l?d.right=0:(h.right=e[i*s+r+1],d.right=Ma(h.right,o)),a||l?d.current=0:(h.current=e[i*s+r],d.current=Ma(h.current,o));let{top:p,topRight:g,right:_,current:y}=d,v=-1;Number.isFinite(o)&&(v=p<<3|g<<2|_<<1|y),Array.isArray(o)&&(v=p<<6|g<<4|_<<2|y);let T=0;return f||(T=Ma((h.top+h.topRight+h.right+h.current)/4,o)),{code:v,meanCode:T}}function _p(t){let{gridOrigin:e,cellSize:r,x:i,y:s,code:n,meanCode:o,type:a=es.ISO_LINES}=t,c={...IR,...t.thresholdData},l=a===es.ISO_BANDS?Dx[n]:Fx[n];Array.isArray(l)||(l=l[o]);let u=c.zIndex*c.zOffset,f=(i+1)*r[0],h=(s+1)*r[1],d=e[0]+f,p=e[1]+h;if(a===es.ISO_BANDS){let _=[];return l.forEach(y=>{let v=[];y.forEach(T=>{let S=d+T[0]*r[0],R=p+T[1]*r[1];v.push([S,R,u])}),_.push(v)}),_}let g=[];return l.forEach(_=>{_.forEach(y=>{let v=d+y[0]*r[0],T=p+y[1]*r[1];g.push([v,T,u])})}),g}function kx({thresholdData:t,cellWeights:e,gridSize:r,gridOrigin:i,cellSize:s}){let n=[],o=[],a=r[0],c=r[1],l=0,u=0;for(let f of t){let{contour:h}=f,{threshold:d}=h;for(let p=-1;pt.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:NR}],optional:!0,compare:3},zOffset:.005},Ux="positions",DR={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Ia=class extends Rr{static{this.layerName="ContourLayer"}static{this.defaultProps=FR}initializeState(){super.initializeAggregationLayer({dimensions:DR}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:le.SUM}}}),this.getAttributeManager().add({[Ux]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(e){super.updateState(e);let r=!1,{oldProps:i,props:s}=e,{aggregationDirty:n}=this.state;(i.contours!==s.contours||i.zOffset!==s.zOffset)&&(r=!0,this._updateThresholdData(e.props)),this.getNumInstances()>0&&(n||r)&&this._generateContours()}renderLayers(){let{contourSegments:e,contourPolygons:r}=this.state.contourData,i=this.getSubLayerClass("lines",Xi),s=this.getSubLayerClass("bands",zt),n=e&&e.length>0&&new i(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||Bx,getWidth:a=>a.contour.strokeWidth||OR}),o=r&&r.length>0&&new s(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||Bx});return[n,o]}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,c=r.gpuAggregation;this.state.gpuAggregation!==r.gpuAggregation&&c&&!Ce.isSupported(this.context.device)&&(U.warn("GPU Grid Aggregation not supported, falling back to CPU")(),c=!1);let l=c!==this.state.gpuAggregation;this.setState({gpuAggregation:c});let{dimensions:u}=this.state,f=this.isAttributeChanged(Ux),{data:h,weights:d}=u,{boundingBox:p}=this.state;if(f&&(p=uu(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:p})),f||a){let{gridOffset:y,translation:v,width:T,height:S,numCol:R,numRow:M}=fu(p,s,o,n);this.allocateResources(M,R),this.setState({gridOffset:y,boundingBox:p,translation:v,posOffset:v.slice(),gridOrigin:[-1*v[0],-1*v[1]],width:T,height:S,numCol:R,numRow:M})}let g=f||l||this.isAggregationDirty(e,{dimension:h,compareAll:c}),_=this.isAggregationDirty(e,{dimension:d});_&&this._updateAccessors(e),(g||_)&&this._resetResults(),this.setState({aggregationDataDirty:g,aggregationWeightsDirty:_})}_updateAccessors(e){let{getWeight:r,aggregation:i,data:s}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=le[i]),this.setState({getValue:Ys(i,r,{data:s})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}_generateContours(){let{numCol:e,numRow:r,gridOrigin:i,gridOffset:s,thresholdData:n}=this.state,{count:o}=this.state.weights,{aggregationData:a}=o;a||(a=o.aggregationBuffer.readSyncWebGL(),o.aggregationData=a);let{cellWeights:c}=Ce.getCellData({countsData:a}),l=kx({thresholdData:n,cellWeights:c,gridSize:[e,r],gridOrigin:i,cellSize:[s.xOffset,s.yOffset]});this.setState({contourData:l})}_updateThresholdData(e){let{contours:r,zOffset:i}=e,s=r.length,n=new Array(s);for(let o=0;oe[s]!==r[s])&&n.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),e.colorRange!==r.colorRange&&n.setUniforms({colorRange:vo(r.colorRange)}),e.cellMarginPixels!==r.cellMarginPixels||e.cellSizePixels!==r.cellSizePixels||i.viewportChanged){let{width:s,height:o}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:A}=this.props,h=a>A?A:0,g=new Float32Array([(a-h)/s*2,-(a-h)/o*2,1]);n.setUniforms({cellScale:g})}}};function hP(t,e){let r={};for(let i in t)e.includes(i)||(r[i]=t[i]);return r}var Mi=class extends Gt{static{this.layerName="AggregationLayer"}initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:hP(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let i=this.getShaders({});i&&i.defines&&(i.defines.NON_INSTANCED_MODEL=1),this.updateShaders(i)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:i}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:i.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:i,oldProps:n,changeFlags:s}=e,{compareAll:o=!1,dimension:a}=r,{ignoreProps:A}=this.state,{props:h,accessors:g=[]}=a,{updateTriggersChanged:_}=s;if(s.dataChanged)return!0;if(_){if(_.all)return!0;for(let x of g)if(_[x])return!0}if(o)return s.extensionsChanged?!0:rf({oldProps:n,newProps:i,ignoreProps:A,propTypes:this.constructor._propTypes});for(let x of h)if(i[x]!==n[x])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!YW(r)}_getAttributeManager(){return new qn(this.context.device,{id:this.props.id,stats:this.context.stats})}};function YW(t){let e=!0;for(let r in t){e=!1;break}return e}function mp(t,e,r){let i=r;return i.domain=()=>t,i.range=()=>e,i}function dP(t,e){return mp(t,e,i=>tj(t,e,i))}function QW(t,e){return mp(t,e,i=>rj(t,e,i))}function qW(t,e){let r=t.sort(pP),i=0,n=Math.max(1,e.length),s=new Array(n-1);for(;++iZW(s,e,a);return o.thresholds=()=>s,mp(t,e,o)}function pP(t,e){return t-e}function KW(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let i=(r-1)*e,n=Math.floor(i),s=t[n],o=t[n+1];return s+(o-s)*(i-n)}function JW(t,e){let r=0,i=t.length;for(;r>>1;pP(t[n],e)>0?i=n:r=n+1}return r}function ZW(t,e,r){return e[JW(t,r)]}function $W(t,e,r,i){let n=`${i}`,s=e.get(n);return s===void 0&&(s=t.push(i),e.set(n,s)),r[(s-1)%r.length]}function ej(t,e){let r=new Map,i=[];for(let s of t){let o=`${s}`;r.has(o)||r.set(o,i.push(s))}return mp(t,e,s=>$W(i,r,e,s))}function tj(t,e,r){let i=t[1]-t[0];if(i<=0)return me.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];let n=i/e.length,s=Math.floor((r-t[0])/n),o=Math.max(Math.min(s,e.length-1),0);return e[o]}function rj(t,e,r){return(r-t[0])/(t[1]-t[0])*(e[1]-e[0])+e[0]}function gP(t){return t!=null}function ij(t){let e=[];return t.forEach(r=>{!e.includes(r)&&gP(r)&&e.push(r)}),e}function mP(t,e){return(typeof e=="function"?t.map(e):t).filter(gP)}function _P(t,e){return mP(t,e)}function yP(t,e){return ij(mP(t,e))}function xP(t,e,r){return Math.max(e,Math.min(r,t))}function bP(t){switch(t){case"quantize":return dP;case"linear":return QW;case"quantile":return qW;case"ordinal":return ej;default:return dP}}var EP=t=>t.length,nj=3402823466e29,vP=t=>t.points,SP=t=>t.index,TP=(t,e)=>te?1:t>=e?0:NaN,sj={getValue:EP,getPoints:vP,getIndex:SP,filterData:null},ws=class{constructor(e=[],r=sj){this.aggregatedBins=this.getAggregatedBins(e,r),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(e,r){let{getValue:i=EP,getPoints:n=vP,getIndex:s=SP,filterData:o}=r,a=typeof o=="function",A=e.length,h=[],g=0;for(let _=0;_xP(a,0,100)),s=Math.ceil(i/100*(r-1)),o=Math.floor(n/100*(r-1));return[s,o]}getBinMap(){let e={};for(let r of this.aggregatedBins)e[r.i]=r;return e}_updateMinMaxValues(){let e=0,r=0,i=nj,n=0;for(let s of this.aggregatedBins)e=e>s.counts?e:s.counts,r=r>s.value?r:s.value,i=iTP(n.value,s.value))),!this.sortedBins.length)return[];let r=0,i=this.sortedBins.length-1;if(Array.isArray(e)){let n=this._percentileToIndex(e);r=n[0],i=n[1]}return[this.sortedBins[r].value,this.sortedBins[i].value]}getValueDomainByScale(e,[r=0,i=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((s,o)=>TP(s.value,o.value))),!this.sortedBins.length)return[];let n=this._percentileToIndex([r,i]);return this._getScaleDomain(e,n)}_getScaleDomain(e,[r,i]){let n=this.sortedBins;switch(e){case"quantize":case"linear":return[n[r].value,n[i].value];case"quantile":return _P(n.slice(r,i+1),s=>s.value);case"ordinal":return yP(n,s=>s.value);default:return[n[r].value,n[i].value]}}};var CP=6378e3;function _p(t){return Number.isFinite(t)?t:0}function yp(t,e){let r=t.positions.value,i=1/0,n=-1/0,s=1/0,o=-1/0,a,A;for(let g=0;gn?a:n,s=Ao?A:o;return{xMin:_p(s),xMax:_p(o),yMin:_p(i),yMax:_p(n)}}function oj(t,e,r,i){let{width:n,height:s}=i,o=r===Oe.CARTESIAN?[-n/2,-s/2]:[-180,-90];me.assert(r===Oe.CARTESIAN||r===Oe.LNGLAT||r===Oe.DEFAULT);let{xMin:a,yMin:A}=t;return[-1*(wP(a-o[0],e.xOffset)+o[0]),-1*(wP(A-o[1],e.yOffset)+o[1])]}function wP(t,e){let r=t<0?-1:1,i=r<0?Math.abs(t)+e:Math.abs(t);return i=Math.floor(i/e)*e,i*r}function Hy(t,e,r=!0){if(!r)return{xOffset:e,yOffset:e};let{yMin:i,yMax:n}=t,s=(i+n)/2;return aj(e,s)}function xp(t,e,r,i){let n=Hy(t,e,i!==Oe.CARTESIAN),s=oj(t,n,i,r),{xMin:o,yMin:a,xMax:A,yMax:h}=t,g=A-o+n.xOffset,_=h-a+n.yOffset,x=Math.ceil(g/n.xOffset),T=Math.ceil(_/n.yOffset);return{gridOffset:n,translation:s,width:g,height:_,numCol:x,numRow:T}}function aj(t,e){let r=cj(t),i=lj(e,t);return{yOffset:r,xOffset:i}}function cj(t){return t/CP*(180/Math.PI)}function lj(t,e){return e/CP*(180/Math.PI)/Math.cos(t*Math.PI/180)}function pl(t,e){let r=Aj(t,e),i=uj(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:i}}function Aj(t,e){let{data:r=[],cellSize:i}=t,{attributes:n,viewport:s,projectPoints:o,numInstances:a}=e,A=n.positions.value,{size:h}=n.positions.getAccessor(),g=e.boundingBox||fj(n.positions,a),_=e.posOffset||[180,90],x=e.gridOffset||Hy(g,i);if(x.xOffset<=0||x.yOffset<=0)return{gridHash:{},gridOffset:x,offsets:[0,0]};let{width:T,height:v}=s,S=Math.ceil(T/x.xOffset),C=Math.ceil(v/x.yOffset),M={},{iterable:R,objectInfo:B}=nr(r),k=new Array(3);for(let Q of R){B.index++,k[0]=A[B.index*h],k[1]=A[B.index*h+1],k[2]=h>=3?A[B.index*h+2]:0;let[$,re]=o?s.project(k):k;if(Number.isFinite($)&&Number.isFinite(re)){let Y=Math.floor((re+_[1])/x.yOffset),H=Math.floor(($+_[0])/x.xOffset);if(!o||H>=0&&H=0&&Ys?A:s,o=ha?h:a);return{xMin:o,xMax:a,yMin:n,yMax:s}}var Cs=class extends Mi{static{this.layerName="GridAggregationLayer"}initializeAggregationLayer({dimensions:e}){super.initializeAggregationLayer(e),this.setState({layerData:{},gpuGridAggregator:new mr(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:pl})}updateState(e){super.updateState(e),this.updateAggregationState(e);let{aggregationDataDirty:r,aggregationWeightsDirty:i,gpuAggregation:n}=this.state;if(this.getNumInstances()<=0)return;let s=!1;(r||n&&i)&&(this._updateAggregation(e),s=!0),!n&&(r||i)&&(this._updateWeightBins(),this._uploadAggregationResults(),s=!0),this.setState({aggregationDirty:s})}finalizeState(e){let{count:r}=this.state.weights;r&&r.aggregationBuffer&&r.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(e)}updateShaders(e){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(e)}updateAggregationState(e){me.assert(!1)}allocateResources(e,r){if(this.state.numRow!==e||this.state.numCol!==r){let i=r*e*4*4,{weights:n}=this.state;for(let s in n){let o=n[s];o.aggregationBuffer&&o.aggregationBuffer.delete(),o.aggregationBuffer=this.context.device.createBuffer({byteLength:i,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:e,maxMinData:r,maxData:i,minData:n}){let{count:s}=this.state.weights;s&&(s.aggregationData=e,s.maxMinData=r,s.maxData=i,s.minData=n)}_updateAggregation(e){let{cpuGridAggregator:r,gpuGridAggregator:i,gridOffset:n,posOffset:s,translation:o=[0,0],scaling:a=[0,0,0],boundingBox:A,projectPoints:h,gpuAggregation:g,numCol:_,numRow:x}=this.state,{props:T}=e,{viewport:v}=this.context,S=this.getAttributes(),C=this.getNumInstances();if(g){let{weights:M}=this.state;i.run({weights:M,cellSize:[n.xOffset,n.yOffset],numCol:_,numRow:x,translation:o,scaling:a,vertexCount:C,projectPoints:h,attributes:S,moduleSettings:this.getModuleSettings()})}else{let M=r(T,{gridOffset:n,projectPoints:h,attributes:S,viewport:v,posOffset:s,boundingBox:A});this.setState({layerData:M})}}_updateWeightBins(){let{getValue:e}=this.state,r=new ws(this.state.layerData.data||[],{getValue:e});this.setState({sortedBins:r})}_uploadAggregationResults(){let{numCol:e,numRow:r}=this.state,{data:i}=this.state.layerData,{aggregatedBins:n,minValue:s,maxValue:o,totalCount:a}=this.state.sortedBins,A=4,h=e*r*A,g=new Float32Array(h).fill(0);for(let v of n){let{lonIdx:S,latIdx:C}=i[v.i],{value:M,counts:R}=v,B=(S+C*e)*A;g[B]=M,g[B+A-1]=R}let _=new Float32Array([o,0,0,s]),x=new Float32Array([o,0,0,a]),T=new Float32Array([s,0,0,a]);this.updateResults({aggregationData:g,maxMinData:_,maxData:x,minData:T})}};var hj={...dl.defaultProps,getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},MP="positions",dj={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Nf=class extends Cs{static{this.layerName="ScreenGridLayer"}static{this.defaultProps=hj}initializeState(){super.initializeAggregationLayer({dimensions:dj,getCellSize:i=>i.cellSizePixels});let e={count:{size:1,operation:Lt.SUM,needMax:!0,maxTexture:hl(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:e,subLayerData:{attributes:{}},maxTexture:e.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[MP]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return this.state.supported&&e.somethingChanged}updateState(e){super.updateState(e)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:e,numRow:r,numCol:i,weights:n}=this.state,{updateTriggers:s}=this.props,{aggregationBuffer:o}=n.count,a=this.getSubLayerClass("cells",dl);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:s}),{data:{attributes:{instanceCounts:o}},maxTexture:e,numInstances:r*i})}finalizeState(e){super.finalizeState(e);let{aggregationBuffer:r,maxBuffer:i,maxTexture:n}=this.state;r?.delete(),i?.delete(),n?.delete()}getPickingInfo({info:e}){let{index:r}=e;if(r>=0){let{gpuGridAggregator:i,gpuAggregation:n,weights:s}=this.state,o=n?i.getData("count"):s.count;e.object=mr.getAggregationData({pixelIndex:r,...o})}return e}updateResults({aggregationData:e,maxData:r}){let{count:i}=this.state.weights;i.aggregationData=e,i.aggregationBuffer.write(e),i.maxData=r,i.maxTexture.setImageData({data:r})}updateAggregationState(e){let r=e.props.cellSizePixels,i=e.oldProps.cellSizePixels!==r,{viewportChanged:n}=e.changeFlags,s=e.props.gpuAggregation;this.state.gpuAggregation!==e.props.gpuAggregation&&s&&!mr.isSupported(this.context.device)&&(me.warn("GPU Grid Aggregation not supported, falling back to CPU")(),s=!1);let o=s!==this.state.gpuAggregation;this.setState({gpuAggregation:s});let a=this.isAttributeChanged(MP),{dimensions:A}=this.state,{data:h,weights:g}=A,_=a||o||n||this.isAggregationDirty(e,{compareAll:s,dimension:h}),x=this.isAggregationDirty(e,{dimension:g});this.setState({aggregationDataDirty:_,aggregationWeightsDirty:x});let{viewport:T}=this.context;if(n||i){let{width:v,height:S}=T,C=Math.ceil(v/r),M=Math.ceil(S/r);this.allocateResources(M,C),this.setState({scaling:[v/2,-S/2,1],gridOffset:{xOffset:r,yOffset:r},width:v,height:S,numCol:C,numRow:M})}x&&this._updateAccessors(e),(_||x)&&this._resetResults()}_updateAccessors(e){let{getWeight:r,aggregation:i,data:n}=e.props,{count:s}=this.state.weights;s&&(s.getWeight=r,s.operation=Lt[i]),this.setState({getValue:fl(i,r,{data:n})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}};function PP(){}var IP=["getBins","getDomain","getScaleFunc"],RP=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],pj=t=>t.cellSize,Ms=class{constructor(e){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=e.getCellSize||pj,this._getAggregator=e.getAggregator,this._addDimension(e.dimensions||RP)}static defaultDimensions(){return RP}updateState(e,r){let{oldProps:i,props:n,changeFlags:s}=e;this.updateGetValueFuncs(i,n,s);let o=this.needsReProjectPoints(i,n,s),a=!1;return s.dataChanged||o?(this.getAggregatedData(n,r),a=!0):((this.getDimensionChanges(i,n,s)||[]).forEach(h=>typeof h=="function"&&h()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(e){this.state={...this.state,...e}}setDimensionState(e,r){this.setState({dimensions:{...this.state.dimensions,[e]:{...this.state.dimensions[e],...r}}})}normalizeResult(e={}){return e.hexagons?{data:e.hexagons,...e}:e.layerData?{data:e.layerData,...e}:e}getAggregatedData(e,r){let n=this._getAggregator(e)(e,r);this.setState({layerData:this.normalizeResult(n)}),this.changeFlags={layerData:!0},this.getSortedBins(e)}updateGetValueFuncs(e,r,i){for(let n in this.dimensionUpdaters){let{value:s,weight:o,aggregation:a}=this.dimensionUpdaters[n].getBins.triggers,A=r[s.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[n].getBins,e,r,i)&&(A?A=eP(A,{data:r.data}):A=fl(r[a.prop],r[o.prop],{data:r.data})),A&&this.setDimensionState(n,{getValue:A})}}needsReProjectPoints(e,r,i){return this._getCellSize(e)!==this._getCellSize(r)||this._getAggregator(e)!==this._getAggregator(r)||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPosition)}addDimension(e){this._addDimension(e)}_addDimension(e=[]){e.forEach(r=>{let{key:i}=r;this.dimensionUpdaters[i]=this.getDimensionUpdaters(r),this.state.dimensions[i]={getValue:null,domain:null,sortedBins:null,scaleFunc:PP}})}getDimensionUpdaters({key:e,accessor:r,pickingInfo:i,getBins:n,getDomain:s,getScaleFunc:o,nullValue:a}){return{key:e,accessor:r,pickingInfo:i,getBins:{updater:this.getDimensionSortedBins.bind(this),...n},getDomain:{updater:this.getDimensionValueDomain.bind(this),...s},getScaleFunc:{updater:this.getDimensionScale.bind(this),...o},attributeAccessor:this.getSubLayerDimensionAttribute(e,a)}}needUpdateDimensionStep(e,r,i,n){return Object.values(e.triggers).some(s=>s.updateTrigger?n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged[s.updateTrigger]):r[s.prop]!==i[s.prop])}getDimensionChanges(e,r,i){let n=[];for(let s in this.dimensionUpdaters){let o=IP.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[s][a],e,r,i));o&&n.push(this.dimensionUpdaters[s][o].updater.bind(this,r,this.dimensionUpdaters[s]))}return n.length?n:null}getUpdateTriggers(e){let r=e.updateTriggers||{},i={};for(let n in this.dimensionUpdaters){let{accessor:s}=this.dimensionUpdaters[n];i[s]={},IP.forEach(o=>{Object.values(this.dimensionUpdaters[n][o].triggers).forEach(({prop:a,updateTrigger:A})=>{if(A){let h=r[A];typeof h=="object"&&!Array.isArray(h)?Object.assign(i[s],h):h!==void 0&&(i[s][a]=h)}else i[s][a]=e[a]})})}return i}getSortedBins(e){for(let r in this.dimensionUpdaters)this.getDimensionSortedBins(e,this.dimensionUpdaters[r])}getDimensionSortedBins(e,r){let{key:i}=r,{getValue:n}=this.state.dimensions[i],s=new ws(this.state.layerData.data||[],{getValue:n,filterData:e._filterData});this.setDimensionState(i,{sortedBins:s}),this.getDimensionValueDomain(e,r)}getDimensionValueDomain(e,r){let{getDomain:i,key:n}=r,{triggers:{lowerPercentile:s,upperPercentile:o,scaleType:a}}=i,A=this.state.dimensions[n].sortedBins.getValueDomainByScale(e[a.prop],[e[s.prop],e[o.prop]]);this.setDimensionState(n,{valueDomain:A}),this.getDimensionScale(e,r)}getDimensionScale(e,r){let{key:i,getScaleFunc:n,getDomain:s}=r,{domain:o,range:a}=n.triggers,{scaleType:A}=s.triggers,{onSet:h}=n,g=e[a.prop],_=e[o.prop]||this.state.dimensions[i].valueDomain,T=bP(A&&e[A.prop])(_,g);typeof h=="object"&&typeof e[h.props]=="function"&&e[h.props](T.domain()),this.setDimensionState(i,{scaleFunc:T})}getSubLayerDimensionAttribute(e,r){return i=>{let{sortedBins:n,scaleFunc:s}=this.state.dimensions[e],o=n.binMap[i.index];if(o&&o.counts===0)return r;let a=o&&o.value,A=s.domain();return a>=A[0]&&a<=A[A.length-1]?s(a):r}}getSubLayerAccessors(e){let r={};for(let i in this.dimensionUpdaters){let{accessor:n}=this.dimensionUpdaters[i];r[n]=this.getSubLayerDimensionAttribute(e,i)}return r}getPickingInfo({info:e}){let r=e.picked&&e.index>-1,i=null;if(r){let n=this.state.layerData.data[e.index],s={};for(let o in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[o],{sortedBins:A}=this.state.dimensions[o],h=A.binMap[n.index]&&A.binMap[n.index].value;s[a]=h}i=Object.assign(s,n,{points:n.filteredPoints||n.points})}return e.picked=!!i,e.object=i,e}getAccessor(e){return this.dimensionUpdaters.hasOwnProperty(e)?this.dimensionUpdaters[e].attributeAccessor:PP}};function BP(){}var gj={colorDomain:null,colorRange:ji,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:BP,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:BP,gridAggregator:pl,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},So=class extends Mi{static{this.layerName="CPUGridLayer"}static{this.defaultProps=gj}initializeState(){let e=new Ms({getAggregator:i=>i.gridAggregator,getCellSize:i=>i.cellSize});this.state={cpuAggregator:e,aggregatorState:e.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){super.updateState(e),this.setState({aggregatorState:this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,cellSize:i,coverage:n,material:s,transitions:o}=this.props,{cpuAggregator:a}=this.state,A=this.getSubLayerClass("grid-cell",Da),h=this._getSublayerUpdateTriggers();return new A({cellSize:i,coverage:n,material:s,elevationScale:e,extruded:r,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:o&&{getFillColor:o.getColorValue||o.getColorWeight,getElevation:o.getElevationValue||o.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:h}),{data:a.state.layerData.data})}};var gl=Math.PI/3,mj=[0,gl,2*gl,3*gl,4*gl,5*gl];function _j(t){return t[0]}function yj(t){return t[1]}function Gy(){var t=0,e=0,r=1,i=1,n=_j,s=yj,o,a,A;function h(_){var x={},T=[],v,S=_.length;for(v=0;v1){var $=M-k,re=k+(MH*H+L*L&&(k=re+(B&1?1:-1)/2,B=Y)}var ae=k+"-"+B,fe=x[ae];fe?fe.push(C):(T.push(fe=x[ae]=[C]),fe.x=(k+(B&1)/2)*a,fe.y=B*A)}return T}function g(_){var x=0,T=0;return mj.map(function(v){var S=Math.sin(v)*_,C=-Math.cos(v)*_,M=S-x,R=C-T;return x=S,T=C,[M,R]})}return h.hexagon=function(_){return"m"+g(_==null?o:+_).join("l")+"z"},h.centers=function(){for(var _=[],x=Math.round(e/A),T=Math.round(t/a),v=x*A;vS.screenCoord[0]).y(S=>S.screenCoord[1])(A).map((S,C)=>({position:n.unprojectFlat([S.x,S.y]),points:S,index:C})),radiusCommon:a}}function xj(t,e){let{attributes:r}=e,i=r.positions.value,{size:n}=r.positions.getAccessor(),s=1/0,o=1/0,a=-1/0,A=-1/0,h;for(h=0;ht.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},Df=class extends Mi{static{this.layerName="HexagonLayer"}static{this.defaultProps=Tj}initializeState(){let e=new Ms({getAggregator:i=>i.hexagonAggregator,getCellSize:i=>i.radius});this.state={cpuAggregator:e,aggregatorState:e.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){if(super.updateState(e),e.changeFlags.propsOrDataChanged){let r=this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==r.layerData){let{hexagonVertices:i}=r.layerData||{};this.setState({vertices:i&&this.convertLatLngToMeterOffset(i)})}this.setState({aggregatorState:r})}}convertLatLngToMeterOffset(e){let{viewport:r}=this.context;if(Array.isArray(e)&&e.length===6){let i=e[0],n=e[3],s=[(i[0]+n[0])/2,(i[1]+n[1])/2],o=r.projectFlat(s),{metersPerUnit:a}=r.getDistanceScales(s);return e.map(h=>{let g=r.projectFlat(h);return[(g[0]-o[0])*a[0],(g[1]-o[1])*a[1]]})}return me.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,coverage:i,material:n,transitions:s}=this.props,{aggregatorState:o,vertices:a}=this.state,A=this.getSubLayerClass("hexagon-cell",pn),h=this._getSublayerUpdateTriggers(),g=a?{vertices:a,radius:1}:{radius:o.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new A({...g,diskResolution:6,elevationScale:e,extruded:r,coverage:i,material:n,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:s&&{getFillColor:s.getColorValue||s.getColorWeight,getElevation:s.getElevationValue||s.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:h}),{data:o.layerData.data})}};var Me=.16666666666666666,ie={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},ml=[ie.W,ie.SW,ie.S],_l=[ie.S,ie.SE,ie.E],yl=[ie.E,ie.NE,ie.N],xl=[ie.NW,ie.W,ie.N],bl=[[-.5,Me],[-.5,-Me],[-Me,-.5],[Me,-.5]],Tl=[[-Me,-.5],[Me,-.5],[.5,-Me],[.5,Me]],El=[[.5,-Me],[.5,Me],[Me,.5],[-Me,.5]],vl=[[-.5,Me],[-.5,-Me],[Me,.5],[-Me,.5]],LP=[ie.W,ie.SW,ie.SE,ie.E],NP=[ie.S,ie.SE,ie.NE,ie.N],DP=[ie.NW,ie.W,ie.E,ie.NE],UP=[ie.NW,ie.SW,ie.S,ie.N],kP=[[-.5,Me],[-.5,-Me],[.5,-Me],[.5,Me]],VP=[[-Me,-.5],[Me,-.5],[Me,.5],[-Me,.5]],Ej=[ie.NW,ie.SW,ie.SE,ie.NE],zP=[ie.NW,ie.SW,ie.SE,ie.E,ie.N],HP=[ie.W,ie.SW,ie.SE,ie.NE,ie.N],GP=[ie.NW,ie.W,ie.S,ie.SE,ie.NE],WP=[ie.NW,ie.SW,ie.S,ie.E,ie.NE],jP=[ie.NW,ie.W,[.5,-Me],[.5,Me],ie.N],XP=[[-Me,-.5],[Me,-.5],ie.E,ie.NE,ie.N],YP=[[-.5,Me],[-.5,-Me],ie.S,ie.SE,ie.E],QP=[ie.W,ie.SW,ie.S,[Me,.5],[-Me,.5]],qP=[ie.NW,ie.W,[-Me,-.5],[Me,-.5],ie.N],KP=[[-.5,Me],[-.5,-Me],ie.E,ie.NE,ie.N],JP=[ie.S,ie.SE,ie.E,[Me,.5],[-Me,.5]],ZP=[ie.W,ie.SW,ie.S,[.5,-Me],[.5,Me]],$P=[ie.W,ie.SW,ie.SE,ie.E,[Me,.5],[-Me,.5]],e5=[[-.5,Me],[-.5,-Me],ie.S,ie.SE,ie.NE,ie.N],t5=[ie.NW,ie.W,[-Me,-.5],[Me,-.5],ie.E,ie.NE],r5=[ie.NW,ie.SW,ie.S,[.5,-Me],[.5,Me],ie.N],Sl=[ie.W,ie.SW,ie.S,ie.E,ie.NE,ie.N],wl=[ie.NW,ie.W,ie.S,ie.SE,ie.E,ie.N],bp=[[-.5,Me],[-.5,-Me],[-Me,-.5],[Me,-.5],ie.E,ie.NE,ie.N],Tp=[ie.W,ie.SW,ie.S,[.5,-Me],[.5,Me],[Me,.5],[-Me,.5]],Ep=[ie.NW,ie.W,[-Me,-.5],[Me,-.5],[.5,-Me],[.5,Me],ie.N],vp=[[-.5,Me],[-.5,-Me],ie.S,ie.SE,ie.E,[Me,.5],[-Me,.5]],i5=[[-.5,Me],[-.5,-Me],[-Me,-.5],[Me,-.5],[.5,-Me],[.5,Me],[Me,.5],[-Me,.5]],n5={0:[],1:[[ie.W,ie.S]],2:[[ie.S,ie.E]],3:[[ie.W,ie.E]],4:[[ie.N,ie.E]],5:{0:[[ie.W,ie.S],[ie.N,ie.E]],1:[[ie.W,ie.N],[ie.S,ie.E]]},6:[[ie.N,ie.S]],7:[[ie.W,ie.N]],8:[[ie.W,ie.N]],9:[[ie.N,ie.S]],10:{0:[[ie.W,ie.N],[ie.S,ie.E]],1:[[ie.W,ie.S],[ie.N,ie.E]]},11:[[ie.N,ie.E]],12:[[ie.W,ie.E]],13:[[ie.S,ie.E]],14:[[ie.W,ie.S]],15:[]};function ve(t){return parseInt(t,4)}var s5={[ve("0000")]:[],[ve("2222")]:[],[ve("2221")]:[ml],[ve("2212")]:[_l],[ve("2122")]:[yl],[ve("1222")]:[xl],[ve("0001")]:[ml],[ve("0010")]:[_l],[ve("0100")]:[yl],[ve("1000")]:[xl],[ve("2220")]:[bl],[ve("2202")]:[Tl],[ve("2022")]:[El],[ve("0222")]:[vl],[ve("0002")]:[bl],[ve("0020")]:[Tl],[ve("0200")]:[El],[ve("2000")]:[vl],[ve("0011")]:[LP],[ve("0110")]:[NP],[ve("1100")]:[DP],[ve("1001")]:[UP],[ve("2211")]:[LP],[ve("2112")]:[NP],[ve("1122")]:[DP],[ve("1221")]:[UP],[ve("2200")]:[kP],[ve("2002")]:[VP],[ve("0022")]:[kP],[ve("0220")]:[VP],[ve("1111")]:[Ej],[ve("1211")]:[zP],[ve("2111")]:[HP],[ve("1112")]:[GP],[ve("1121")]:[WP],[ve("1011")]:[zP],[ve("0111")]:[HP],[ve("1110")]:[GP],[ve("1101")]:[WP],[ve("1200")]:[jP],[ve("0120")]:[XP],[ve("0012")]:[YP],[ve("2001")]:[QP],[ve("1022")]:[jP],[ve("2102")]:[XP],[ve("2210")]:[YP],[ve("0221")]:[QP],[ve("1002")]:[qP],[ve("2100")]:[KP],[ve("0210")]:[JP],[ve("0021")]:[ZP],[ve("1220")]:[qP],[ve("0122")]:[KP],[ve("2012")]:[JP],[ve("2201")]:[ZP],[ve("0211")]:[$P],[ve("2110")]:[e5],[ve("1102")]:[t5],[ve("1021")]:[r5],[ve("2011")]:[$P],[ve("0112")]:[e5],[ve("1120")]:[t5],[ve("1201")]:[r5],[ve("2101")]:[Sl],[ve("0121")]:[Sl],[ve("1012")]:[wl],[ve("1210")]:[wl],[ve("0101")]:{0:[ml,yl],1:[Sl],2:[Sl]},[ve("1010")]:{0:[xl,_l],1:[wl],2:[wl]},[ve("2121")]:{0:[Sl],1:[Sl],2:[ml,yl]},[ve("1212")]:{0:[wl],1:[wl],2:[xl,_l]},[ve("2120")]:{0:[bp],1:[bp],2:[bl,yl]},[ve("2021")]:{0:[Tp],1:[Tp],2:[ml,El]},[ve("1202")]:{0:[Ep],1:[Ep],2:[xl,Tl]},[ve("0212")]:{0:[vp],1:[vp],2:[_l,vl]},[ve("0102")]:{0:[bl,yl],1:[bp],2:[bp]},[ve("0201")]:{0:[ml,El],1:[Tp],2:[Tp]},[ve("1020")]:{0:[xl,Tl],1:[Ep],2:[Ep]},[ve("2010")]:{0:[_l,vl],1:[vp],2:[vp]},[ve("2020")]:{0:[vl,Tl],1:[i5],2:[bl,El]},[ve("0202")]:{0:[El,bl],1:[i5],2:[vl,Tl]}};var Ga={ISO_LINES:1,ISO_BANDS:2},vj={zIndex:0,zOffset:.005};function Uf(t,e){return Array.isArray(e)?t=e?1:0}function o5(t){let{cellWeights:e,x:r,y:i,width:n,height:s}=t,o=t.threshold;t.thresholdValue&&(me.deprecated("thresholdValue","threshold")(),o=t.thresholdValue);let a=r<0,A=r>=n-1,h=i<0,g=i>=s-1,_=a||A||h||g,x={},T={};a||g?T.top=0:(x.top=e[(i+1)*n+r],T.top=Uf(x.top,o)),A||g?T.topRight=0:(x.topRight=e[(i+1)*n+r+1],T.topRight=Uf(x.topRight,o)),A||h?T.right=0:(x.right=e[i*n+r+1],T.right=Uf(x.right,o)),a||h?T.current=0:(x.current=e[i*n+r],T.current=Uf(x.current,o));let{top:v,topRight:S,right:C,current:M}=T,R=-1;Number.isFinite(o)&&(R=v<<3|S<<2|C<<1|M),Array.isArray(o)&&(R=v<<6|S<<4|C<<2|M);let B=0;return _||(B=Uf((x.top+x.topRight+x.right+x.current)/4,o)),{code:R,meanCode:B}}function Wy(t){let{gridOrigin:e,cellSize:r,x:i,y:n,code:s,meanCode:o,type:a=Ga.ISO_LINES}=t,A={...vj,...t.thresholdData},h=a===Ga.ISO_BANDS?s5[s]:n5[s];Array.isArray(h)||(h=h[o]);let g=A.zIndex*A.zOffset,_=(i+1)*r[0],x=(n+1)*r[1],T=e[0]+_,v=e[1]+x;if(a===Ga.ISO_BANDS){let C=[];return h.forEach(M=>{let R=[];M.forEach(B=>{let k=T+B[0]*r[0],Q=v+B[1]*r[1];R.push([k,Q,g])}),C.push(R)}),C}let S=[];return h.forEach(C=>{C.forEach(M=>{let R=T+M[0]*r[0],B=v+M[1]*r[1];S.push([R,B,g])})}),S}function a5({thresholdData:t,cellWeights:e,gridSize:r,gridOrigin:i,cellSize:n}){let s=[],o=[],a=r[0],A=r[1],h=0,g=0;for(let _ of t){let{contour:x}=_,{threshold:T}=x;for(let v=-1;vt.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:wj}],optional:!0,compare:3},zOffset:.005},l5="positions",Mj={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},kf=class extends Cs{static{this.layerName="ContourLayer"}static{this.defaultProps=Cj}initializeState(){super.initializeAggregationLayer({dimensions:Mj}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:Lt.SUM}}}),this.getAttributeManager().add({[l5]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(e){super.updateState(e);let r=!1,{oldProps:i,props:n}=e,{aggregationDirty:s}=this.state;(i.contours!==n.contours||i.zOffset!==n.zOffset)&&(r=!0,this._updateThresholdData(e.props)),this.getNumInstances()>0&&(s||r)&&this._generateContours()}renderLayers(){let{contourSegments:e,contourPolygons:r}=this.state.contourData,i=this.getSubLayerClass("lines",Ba),n=this.getSubLayerClass("bands",mn),s=e&&e.length>0&&new i(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||c5,getWidth:a=>a.contour.strokeWidth||Sj}),o=r&&r.length>0&&new n(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||c5});return[s,o]}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:n,coordinateSystem:s}=r,{viewport:o}=this.context,a=i.cellSize!==n,A=r.gpuAggregation;this.state.gpuAggregation!==r.gpuAggregation&&A&&!mr.isSupported(this.context.device)&&(me.warn("GPU Grid Aggregation not supported, falling back to CPU")(),A=!1);let h=A!==this.state.gpuAggregation;this.setState({gpuAggregation:A});let{dimensions:g}=this.state,_=this.isAttributeChanged(l5),{data:x,weights:T}=g,{boundingBox:v}=this.state;if(_&&(v=yp(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:v})),_||a){let{gridOffset:M,translation:R,width:B,height:k,numCol:Q,numRow:$}=xp(v,n,o,s);this.allocateResources($,Q),this.setState({gridOffset:M,boundingBox:v,translation:R,posOffset:R.slice(),gridOrigin:[-1*R[0],-1*R[1]],width:B,height:k,numCol:Q,numRow:$})}let S=_||h||this.isAggregationDirty(e,{dimension:x,compareAll:A}),C=this.isAggregationDirty(e,{dimension:T});C&&this._updateAccessors(e),(S||C)&&this._resetResults(),this.setState({aggregationDataDirty:S,aggregationWeightsDirty:C})}_updateAccessors(e){let{getWeight:r,aggregation:i,data:n}=e.props,{count:s}=this.state.weights;s&&(s.getWeight=r,s.operation=Lt[i]),this.setState({getValue:fl(i,r,{data:n})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}_generateContours(){let{numCol:e,numRow:r,gridOrigin:i,gridOffset:n,thresholdData:s}=this.state,{count:o}=this.state.weights,{aggregationData:a}=o;a||(a=o.aggregationBuffer.readSyncWebGL(),o.aggregationData=a);let{cellWeights:A}=mr.getCellData({countsData:a}),h=a5({thresholdData:s,cellWeights:A,gridSize:[e,r],gridOrigin:i,cellSize:[n.xOffset,n.yOffset]});this.setState({contourData:h})}_updateThresholdData(e){let{contours:r,zOffset:i}=e,n=r.length,s=new Array(n);for(let o=0;ot.position},extruded:!1,material:!0},BR={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},Wx="positions",oi=class extends Rr{static{this.layerName="GPUGridLayer"}static{this.defaultProps=kR}initializeState({device:e}){let r=Ce.isSupported(e);r||U.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:BR}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:r,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[Wx]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(e){if(this.state.isSupported===!1)return;super.updateState(e);let{aggregationDirty:r}=this.state;r&&this.setState({gridHash:null})}getHashKeyForIndex(e){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=Math.floor((l*c[1]+a[1]+90+c[1]/2)/c[1]),h=Math.floor((u*c[0]+a[0]+180+c[0]/2)/c[0]);return`${f}-${h}`}getPositionForIndex(e){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=l*c[1]+a[1];return[u*c[0]+a[0],f]}getPickingInfo({info:e,mode:r}){let{index:i}=e,s=null;if(i>=0){let n=this.state.gpuGridAggregator,o=this.getPositionForIndex(i),a=Ce.getAggregationData({pixelIndex:i,...n.getData("color")}),c=Ce.getAggregationData({pixelIndex:i,...n.getData("elevation")});if(s={colorValue:a.cellWeight,elevationValue:c.cellWeight,count:a.cellCount||c.cellCount,position:o,totalCount:a.totalCount||c.totalCount},r!=="hover"){let{props:l}=this,{gridHash:u}=this.state;if(!u){let{gridOffset:d,translation:p,boundingBox:g}=this.state,{viewport:_}=this.context,y=this.getAttributes();u=Gs(l,{gridOffset:d,attributes:y,viewport:_,translation:p,boundingBox:g}).gridHash,this.setState({gridHash:u})}let f=this.getHashKeyForIndex(i),h=u[f];Object.assign(s,h)}}return e.picked=!!s,e.object=s,e}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:e,extruded:r,cellSize:i,coverage:s,material:n,elevationRange:o,colorDomain:a,elevationDomain:c}=this.props,{weights:l,numRow:u,numCol:f,gridOrigin:h,gridOffset:d}=this.state,{color:p,elevation:g}=l,_=si(this.props.colorRange),y=this.getSubLayerClass("gpu-grid-cell",Oa);return new y({gridSize:[f,u],gridOrigin:h,gridOffset:[d.xOffset,d.yOffset],colorRange:_,elevationRange:o,colorDomain:a,elevationDomain:c,cellSize:i,coverage:s,material:n,elevationScale:e,extruded:r},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:p.aggregationBuffer,elevations:g.aggregationBuffer}},colorMaxMinBuffer:p.maxMinBuffer,elevationMaxMinBuffer:g.maxMinBuffer,numInstances:f*u})}finalizeState(e){let{color:r,elevation:i}=this.state.weights;[r,i].forEach(s=>{let{aggregationBuffer:n,maxMinBuffer:o}=s;o?.destroy(),n?.destroy()}),super.finalizeState(e)}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,{dimensions:c}=this.state,l=this.isAttributeChanged(Wx),u=l||this.isAttributeChanged(),{boundingBox:f}=this.state;if(l&&(f=uu(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:f})),l||a){let{gridOffset:d,translation:p,width:g,height:_,numCol:y,numRow:v}=fu(f,s,o,n);this.allocateResources(v,y),this.setState({gridOffset:d,translation:p,gridOrigin:[-1*p[0],-1*p[1]],width:g,height:_,numCol:y,numRow:v})}let h=u||this.isAggregationDirty(e,{dimension:c.data,compareAll:!0});h&&this._updateAccessors(e),this.setState({aggregationDataDirty:h})}_updateAccessors(e){let{colorAggregation:r,elevationAggregation:i}=e.props,{color:s,elevation:n}=this.state.weights;s.operation=le[r],n.operation=le[i]}};var UR={...oi.defaultProps,...ni.defaultProps,gpuAggregation:!1},Na=class extends et{static{this.layerName="GridLayer"}static{this.defaultProps=UR}initializeState(){this.state={useGPUAggregation:!1}}updateState({props:e}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:e,updateTriggers:r}=this.props,i=this.state.useGPUAggregation?"GPU":"CPU",s=this.state.useGPUAggregation?this.getSubLayerClass("GPU",oi):this.getSubLayerClass("CPU",ni);return new s(this.props,this.getSubLayerProps({id:i,updateTriggers:r}),{data:e})}canUseGPUAggregation(e){let{gpuAggregation:r,lowerPercentile:i,upperPercentile:s,getColorValue:n,getElevationValue:o,colorScaleType:a}=e;return!(!r||!Ce.isSupported(this.context.device)||i!==0||s!==100||n!==null||o!==null||a==="quantile"||a==="ordinal")}};function jx(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),i=Math.min.apply(null,e),s=Math.max.apply(null,e),n=Math.min.apply(null,r),o=Math.max.apply(null,r);return[i,n,s,o]}function Xx(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var Hx=new Float32Array(12);function bp(t,e=2){let r=0;for(let i of t)for(let s=0;st.position},extruded:!1,material:!0},Rj={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},f5="positions",wo=class extends Cs{static{this.layerName="GPUGridLayer"}static{this.defaultProps=Ij}initializeState({device:e}){let r=mr.isSupported(e);r||me.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:Rj}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:r,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[f5]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(e){if(this.state.isSupported===!1)return;super.updateState(e);let{aggregationDirty:r}=this.state;r&&this.setState({gridHash:null})}getHashKeyForIndex(e){let{numRow:r,numCol:i,boundingBox:n,gridOffset:s}=this.state,o=[i,r],a=[n.xMin,n.yMin],A=[s.xOffset,s.yOffset],h=Math.floor(e/o[0]),g=e-h*o[0],_=Math.floor((h*A[1]+a[1]+90+A[1]/2)/A[1]),x=Math.floor((g*A[0]+a[0]+180+A[0]/2)/A[0]);return`${_}-${x}`}getPositionForIndex(e){let{numRow:r,numCol:i,boundingBox:n,gridOffset:s}=this.state,o=[i,r],a=[n.xMin,n.yMin],A=[s.xOffset,s.yOffset],h=Math.floor(e/o[0]),g=e-h*o[0],_=h*A[1]+a[1];return[g*A[0]+a[0],_]}getPickingInfo({info:e,mode:r}){let{index:i}=e,n=null;if(i>=0){let s=this.state.gpuGridAggregator,o=this.getPositionForIndex(i),a=mr.getAggregationData({pixelIndex:i,...s.getData("color")}),A=mr.getAggregationData({pixelIndex:i,...s.getData("elevation")});if(n={colorValue:a.cellWeight,elevationValue:A.cellWeight,count:a.cellCount||A.cellCount,position:o,totalCount:a.totalCount||A.totalCount},r!=="hover"){let{props:h}=this,{gridHash:g}=this.state;if(!g){let{gridOffset:T,translation:v,boundingBox:S}=this.state,{viewport:C}=this.context,M=this.getAttributes();g=pl(h,{gridOffset:T,attributes:M,viewport:C,translation:v,boundingBox:S}).gridHash,this.setState({gridHash:g})}let _=this.getHashKeyForIndex(i),x=g[_];Object.assign(n,x)}}return e.picked=!!n,e.object=n,e}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:e,extruded:r,cellSize:i,coverage:n,material:s,elevationRange:o,colorDomain:a,elevationDomain:A}=this.props,{weights:h,numRow:g,numCol:_,gridOrigin:x,gridOffset:T}=this.state,{color:v,elevation:S}=h,C=vo(this.props.colorRange),M=this.getSubLayerClass("gpu-grid-cell",Vf);return new M({gridSize:[_,g],gridOrigin:x,gridOffset:[T.xOffset,T.yOffset],colorRange:C,elevationRange:o,colorDomain:a,elevationDomain:A,cellSize:i,coverage:n,material:s,elevationScale:e,extruded:r},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:v.aggregationBuffer,elevations:S.aggregationBuffer}},colorMaxMinBuffer:v.maxMinBuffer,elevationMaxMinBuffer:S.maxMinBuffer,numInstances:_*g})}finalizeState(e){let{color:r,elevation:i}=this.state.weights;[r,i].forEach(n=>{let{aggregationBuffer:s,maxMinBuffer:o}=n;o?.destroy(),s?.destroy()}),super.finalizeState(e)}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:n,coordinateSystem:s}=r,{viewport:o}=this.context,a=i.cellSize!==n,{dimensions:A}=this.state,h=this.isAttributeChanged(f5),g=h||this.isAttributeChanged(),{boundingBox:_}=this.state;if(h&&(_=yp(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:_})),h||a){let{gridOffset:T,translation:v,width:S,height:C,numCol:M,numRow:R}=xp(_,n,o,s);this.allocateResources(R,M),this.setState({gridOffset:T,translation:v,gridOrigin:[-1*v[0],-1*v[1]],width:S,height:C,numCol:M,numRow:R})}let x=g||this.isAggregationDirty(e,{dimension:A.data,compareAll:!0});x&&this._updateAccessors(e),this.setState({aggregationDataDirty:x})}_updateAccessors(e){let{colorAggregation:r,elevationAggregation:i}=e.props,{color:n,elevation:s}=this.state.weights;n.operation=Lt[r],s.operation=Lt[i]}};var Bj={...wo.defaultProps,...So.defaultProps,gpuAggregation:!1},zf=class extends Gt{static{this.layerName="GridLayer"}static{this.defaultProps=Bj}initializeState(){this.state={useGPUAggregation:!1}}updateState({props:e}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:e,updateTriggers:r}=this.props,i=this.state.useGPUAggregation?"GPU":"CPU",n=this.state.useGPUAggregation?this.getSubLayerClass("GPU",wo):this.getSubLayerClass("CPU",So);return new n(this.props,this.getSubLayerProps({id:i,updateTriggers:r}),{data:e})}canUseGPUAggregation(e){let{gpuAggregation:r,lowerPercentile:i,upperPercentile:n,getColorValue:s,getElevationValue:o,colorScaleType:a}=e;return!(!r||!mr.isSupported(this.context.device)||i!==0||n!==100||s!==null||o!==null||a==="quantile"||a==="ordinal")}};function d5(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),i=Math.min.apply(null,e),n=Math.max.apply(null,e),s=Math.min.apply(null,r),o=Math.max.apply(null,r);return[i,s,n,o]}function p5(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var h5=new Float32Array(12);function Yy(t,e=2){let r=0;for(let i of t)for(let n=0;nt.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:At,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},HR=["float32-renderable-webgl","texture-blend-float-webgl"],jR={data:{props:["radiusPixels"]}},Da=class extends nt{static{this.layerName="HeatmapLayer"}static{this.defaultProps=WR}initializeState(){super.initializeAggregationLayer(jR),this.setState({colorDomain:Jx}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:i}=e,s=this._getChangeFlags(e);(s.dataChanged||s.viewportChanged)&&(s.boundsChanged=this._updateBounds(s.dataChanged),this._updateTextureRenderingBounds()),s.dataChanged||s.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):s.viewportZoomChanged&&this._debouncedUpdateWeightmap(),r.colorRange!==i.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:i,maxWeightsTexture:s,colorTexture:n,colorDomain:o}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:u}=this.props,f=this.getSubLayerClass("triangle",Fa);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:q.DEFAULT,data:{attributes:{positions:r,texCoords:i}},vertexCount:4,maxTexture:s,colorTexture:n,aggregationMode:VR[u]||0,weightsTexture:e,intensity:c,threshold:l,colorDomain:o})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:i,maxWeightTransform:s,maxWeightsTexture:n,triPositionBuffer:o,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),i?.destroy(),s?.destroy(),n?.destroy(),o?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new nr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:i}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:i.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:s}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==s)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...Ep,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...Ep,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,i=Math.min(r,e.limits.maxTextureDimension2D),s=HR.every(a=>e.features.has(a)),n=s?"rgba32float":"rgba8unorm",o=s?1:1/255;this.setState({textureSize:i,format:n,weightsScale:o}),s||U.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:i}=this.state,s=this.getAttributeManager();r?.destroy(),r=new $r(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:s.getBufferLayouts(),vertexCount:1,targetTexture:i,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...e}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:i,maxWeightsTexture:s}=this.state,n=this.getShaders({vs:vp,fs:Tp});this._createWeightsTransform(n);let o=this.getShaders({vs:Gx,fs:Zx}),a=new $r(e,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:i},uniforms:{textureSize:r},targetTexture:s,...o,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:i,maxWeightsTexture:s,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:vp,fs:Tp,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,i=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([r.width,r.height]),r.unproject([0,r.height])].map(a=>a.map(Math.fround)),s=jx(i),n={visibleWorldBounds:s,viewportCorners:i},o=!1;if(e||!this.state.worldBounds||!Xx(this.state.worldBounds,s)){let a=this._worldToCommonBounds(s),c=this._commonToWorldBounds(a);this.props.coordinateSystem===q.LNGLAT&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let l=this._worldToCommonBounds(c);n.worldBounds=c,n.normalizedCommonBounds=l,o=!0}return this.setState(n),o}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:i,viewportCorners:s}=this.state,{viewport:n}=this.context;e.write(bp(s,3));let o=s.map(a=>Yx(n.projectPosition(a),i));r.write(bp(o,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:i}=this.state,s=si(r,!1,Uint8Array);i&&i?.width===r.length?i.setSubImageData({data:s}):(i?.destroy(),i=this.context.device.createTexture({...Ep,data:s,width:r.length,height:1})),this.setState({colorTexture:i})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:i}=this.props,{worldBounds:s,textureSize:n,weightsScale:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let c=this._worldToCommonBounds(s,{useLayerCoordinateSystem:!0});if(r&&i==="SUM"){let{viewport:g}=this.context,_=g.distanceScales.metersPerUnit[2]*(c[2]-c[0])/n;this.state.colorDomain=r.map(y=>y*_*o)}else this.state.colorDomain=r||Jx;let u=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),h=u.positions.buffer,d={radiusPixels:e,commonBounds:c,textureWidth:n,weightsScale:o},p=u.weights.buffer;a.model.setAttributes({positions:h,weights:p}),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(d),a.model.updateModuleSettings(f),a.run({parameters:{viewport:[0,0,n,n]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:i}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),i)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:i=!1}=r,[s,n,o,a]=e,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:u}=this.props,f=i&&(u===q.LNGLAT_OFFSETS||u===q.METER_OFFSETS),h=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=l*zR/c.scale,p,g;return i&&!f?(p=this.projectPosition([s,n,0]),g=this.projectPosition([o,a,0])):(p=c.projectPosition([s,n,0]),g=c.projectPosition([o,a,0])),$x([p[0]-h[0],p[1]-h[1],g[0]-h[0],g[1]-h[1]],d,d)}_commonToWorldBounds(e){let[r,i,s,n]=e,{viewport:o}=this.context,a=o.unprojectPosition([r,i]),c=o.unprojectPosition([s,n]);return a.slice(0,2).concat(c.slice(0,2))}};import mu from"https://esm.sh/@mapbox/mapbox-gl-draw@1.4.3";mu.constants.classes.CONTROL_BASE="maplibregl-ctrl";mu.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-";mu.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var Qx=mu;var XR=Object.prototype.toString,un=Array.isArray||function(e){return XR.call(e)==="[object Array]"};function wp(t){return typeof t=="function"}function $R(t){return un(t)?"array":typeof t}function Ap(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function ey(t,e){return t!=null&&typeof t=="object"&&e in t}function YR(t,e){return t!=null&&typeof t!="object"&&t.hasOwnProperty&&t.hasOwnProperty(e)}var KR=RegExp.prototype.test;function qR(t,e){return KR.call(t,e)}var GR=/\S/;function ZR(t){return!qR(GR,t)}var JR={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function QR(t){return String(t).replace(/[&<>"'`=\/]/g,function(r){return JR[r]})}var e6=/\s*/,t6=/\s+/,ty=/\s*=/,r6=/\s*\}/,i6=/#|\^|\/|>|\{|&|=|!/;function s6(t,e){if(!t)return[];var r=!1,i=[],s=[],n=[],o=!1,a=!1,c="",l=0;function u(){if(o&&!a)for(;n.length;)delete s[n.pop()];else n=[];o=!1,a=!1}var f,h,d;function p(N){if(typeof N=="string"&&(N=N.split(t6,2)),!un(N)||N.length!==2)throw new Error("Invalid tags: "+N);f=new RegExp(Ap(N[0])+"\\s*"),h=new RegExp("\\s*"+Ap(N[1])),d=new RegExp("\\s*"+Ap("}"+N[1]))}p(e||wt.tags);for(var g=new ka(t),_,y,v,T,S,R;!g.eos();){if(_=g.pos,v=g.scanUntil(f),v)for(var M=0,F=v.length;M"?S=[y,v,_,g.pos,c,l,r]:S=[y,v,_,g.pos],l++,s.push(S),y==="#"||y==="^")i.push(S);else if(y==="/"){if(R=i.pop(),!R)throw new Error('Unopened section "'+v+'" at '+_);if(R[1]!==v)throw new Error('Unclosed section "'+R[1]+'" at '+_)}else y==="name"||y==="{"||y==="&"?a=!0:y==="="&&p(v)}if(u(),R=i.pop(),R)throw new Error('Unclosed section "'+R[1]+'" at '+g.pos);return o6(n6(s))}function n6(t){for(var e=[],r,i,s=0,n=t.length;s0?i[i.length-1][4]:e;break;default:r.push(s)}return e}function ka(t){this.string=t,this.tail=t,this.pos=0}ka.prototype.eos=function(){return this.tail===""};ka.prototype.scan=function(e){var r=this.tail.match(e);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};ka.prototype.scanUntil=function(e){var r=this.tail.search(e),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function ln(t,e){this.view=t,this.cache={".":this.view},this.parent=e}ln.prototype.push=function(e){return new ln(e,this)};ln.prototype.lookup=function(e){var r=this.cache,i;if(r.hasOwnProperty(e))i=r[e];else{for(var s=this,n,o,a,c=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),a=0;n!=null&&a"?l=this.renderPartial(a,r,i,n):c==="&"?l=this.unescapedValue(a,r):c==="name"?l=this.escapedValue(a,r,n):c==="text"&&(l=this.rawValue(a)),l!==void 0&&(o+=l);return o};Ye.prototype.renderSection=function(e,r,i,s,n){var o=this,a="",c=r.lookup(e[1]);function l(h){return o.render(h,r,i,n)}if(c){if(un(c))for(var u=0,f=c.length;u0||!i)&&(n[o]=s+n[o]);return n.join(` -`)};Ye.prototype.renderPartial=function(e,r,i,s){if(i){var n=this.getConfigTags(s),o=wp(i)?i(e[1]):i[e[1]];if(o!=null){var a=e[6],c=e[5],l=e[4],u=o;c==0&&l&&(u=this.indentPartial(o,l,a));var f=this.parse(u,n);return this.renderTokens(f,r,i,u,s)}}};Ye.prototype.unescapedValue=function(e,r){var i=r.lookup(e[1]);if(i!=null)return i};Ye.prototype.escapedValue=function(e,r,i){var s=this.getConfigEscape(i)||wt.escape,n=r.lookup(e[1]);if(n!=null)return typeof n=="number"&&s===wt.escape?String(n):s(n)};Ye.prototype.rawValue=function(e){return e[1]};Ye.prototype.getConfigTags=function(e){return un(e)?e:e&&typeof e=="object"?e.tags:void 0};Ye.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!un(e))return e.escape};var wt={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(t){La.templateCache=t},get templateCache(){return La.templateCache}},La=new Ye;wt.clearCache=function(){return La.clearCache()};wt.parse=function(e,r){return La.parse(e,r)};wt.render=function(e,r,i,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+$R(e)+'" was given as the first argument for mustache#render(template, view, partials)');return La.render(e,r,i,s)};wt.escape=QR;wt.Scanner=ka;wt.Context=ln;wt.Writer=Ye;var Pp=wt;function Cp(t,e,r){return r!==null?Pp.render(r,t.properties):e===null?Object.keys(t.properties).map(s=>`${s}: ${t.properties[s]}`).join("
"):t.properties[e]}function Rp(t){let e={background:"white",color:"black","border-radius":"3px"};return({layer:r,object:i})=>{if(i){let s=typeof t=="object"?t[r.id]:t;return s&&{html:Pp.render(s,i),style:e}}return null}}var a6=new Vs({configuration:new ar({layers:Sp})});function iy(t,e){let[r,i]=e;console.log(r,i),t[r](...i)}function ry(t){return t.map(e=>a6.convert(Object.assign(e,{onHover:({object:r})=>console.log(r)})))}function sy(t,e){let r=null,i=null;return{addTooltip:function(s,n=null,o=null){let a={closeButton:!1,closeOnClick:!1},c=new t.Popup(a);e.on("mousemove",s,l=>{let u=l.features[0],f=Cp(u,n,o);c.setLngLat(l.lngLat).setHTML(f).addTo(e)}),e.on("mouseleave",s,()=>{c.remove()})},addControl:function(s,n,o){e.addControl(new t[s](n),o)},addPopup:function(s,n=null,o=null){let a={closeButton:!1},c=new t.Popup(a);e.on("click",s,l=>{let u=l.features[0],f=Cp(u,n,o);c.setLngLat(l.lngLat).setHTML(f).addTo(e)})},addMarker:function({lngLat:s,popup:n,options:o}){let a=new t.Marker(o).setLngLat(s);if(n){let c=new t.Popup(n.options).setHTML(n.text);a.setPopup(c)}a.addTo(e)},setSourceData:function(s,n){e.getSource(s).setData(n)},addDeckOverlay:function(s,n=null){let o=ry(s);r=new Ls({interleaved:!0,layers:o,getTooltip:n?Rp(n):null}),e.addControl(r)},setDeckLayers:function(s,n=null){console.log("Updating Deck.GL layers");let o=ry(s);r.setProps({layers:o,getTooltip:n?Rp(n):null})},addMapboxDraw(s,n,o=null){i=new Qx(s),e.addControl(i,n),o&&i.add(o)},getMapboxDraw:function(){return i}}}var l6=new c6;fn.addProtocol("pmtiles",l6.tile);fn.LayerSwitcherControl=bn;fn.InfoBoxControl=yn;function u6(t){let e="pymaplibregl",r=document.createElement("div");return r.id=e,r.style.height=t.get("height"),r}function Mp(t,e){let r={center:e.getCenter(),zoom:e.getZoom(),bounds:e.getBounds(),bearing:e.getBearing(),pitch:e.getPitch()};t.set("view_state",r),t.save_changes()}function f6(t,e){let r=new fn.Map(t);return r.on("mouseover",()=>{r.getCanvas().style.cursor="pointer"}),r.on("mouseout",()=>{r.getCanvas().style.cursor=""}),r.on("click",i=>{e.set("clicked",i.lngLat),e.save_changes()}),r.on("zoomend",i=>{Mp(e,r)}),r.on("moveend",i=>{Mp(e,r)}),r.once("load",()=>{r.resize(),Mp(e,r)}),r.on("draw.selectionchange",i=>{let s=i.features;console.log("selection changed",s),e.set("draw_features_selected",s),e.save_changes()}),r}function h6({model:t,el:e}){console.log("maplibregl",fn.version);let r=u6(t),i=Object.assign({container:r},t.get("map_options"));console.log(i);let s=f6(i,t),n=sy(fn,s),o=["draw.create","draw.update","draw.delete","draw.render"];for(let l in o)s.on(o[l],u=>{let f=n.getMapboxDraw();console.log("features",f.getAll()),t.set("draw_feature_collection_all",f.getAll()),t.save_changes()});let a=l=>{l.forEach(u=>{if(Object.keys(n).includes(u[0])){console.log("internal call",u);let[f,h]=u;n[f](...h);return}iy(s,u)})},c=t.get("calls");s.on("load",()=>{console.log("init calls",c),a(c),t.set("_rendered",!0),t.save_changes()}),t.on("msg:custom",l=>{console.log("custom msg",l),a(l.calls)}),e.appendChild(r)}var mQ={render:h6};export{mQ as default}; +`;var Oj=2,Ky={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},T5=[0,0],Fj={SUM:0,MEAN:1},Lj={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:ji,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Nj=["float32-renderable-webgl","texture-blend-float-webgl"],Dj={data:{props:["radiusPixels"]}},Gf=class extends Mi{static{this.layerName="HeatmapLayer"}static{this.defaultProps=Lj}initializeState(){super.initializeAggregationLayer(Dj),this.setState({colorDomain:T5}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:i}=e,n=this._getChangeFlags(e);(n.dataChanged||n.viewportChanged)&&(n.boundsChanged=this._updateBounds(n.dataChanged),this._updateTextureRenderingBounds()),n.dataChanged||n.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):n.viewportZoomChanged&&this._debouncedUpdateWeightmap(),r.colorRange!==i.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:i,maxWeightsTexture:n,colorTexture:s,colorDomain:o}=this.state,{updateTriggers:a,intensity:A,threshold:h,aggregation:g}=this.props,_=this.getSubLayerClass("triangle",Hf);return new _(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:Oe.DEFAULT,data:{attributes:{positions:r,texCoords:i}},vertexCount:4,maxTexture:n,colorTexture:s,aggregationMode:Fj[g]||0,weightsTexture:e,intensity:A,threshold:h,colorDomain:o})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:i,maxWeightTransform:n,maxWeightsTexture:s,triPositionBuffer:o,triTexCoordBuffer:a,colorTexture:A,updateTimer:h}=this.state;r?.destroy(),i?.destroy(),n?.destroy(),s?.destroy(),o?.destroy(),a?.destroy(),A?.destroy(),h&&clearTimeout(h)}_getAttributeManager(){return new qn(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:i}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:i.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:n}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==n)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...Ky,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...Ky,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,i=Math.min(r,e.limits.maxTextureDimension2D),n=Nj.every(a=>e.features.has(a)),s=n?"rgba32float":"rgba8unorm",o=n?1:1/255;this.setState({textureSize:i,format:s,weightsScale:o}),n||me.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:i}=this.state,n=this.getAttributeManager();r?.destroy(),r=new lo(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:n.getBufferLayouts(),vertexCount:1,targetTexture:i,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...e}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:i,maxWeightsTexture:n}=this.state,s=this.getShaders({vs:Qy,fs:qy});this._createWeightsTransform(s);let o=this.getShaders({vs:x5,fs:b5}),a=new lo(e,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:i},uniforms:{textureSize:r},targetTexture:n,...o,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:i,maxWeightsTexture:n,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:Qy,fs:qy,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,i=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([r.width,r.height]),r.unproject([0,r.height])].map(a=>a.map(Math.fround)),n=d5(i),s={visibleWorldBounds:n,viewportCorners:i},o=!1;if(e||!this.state.worldBounds||!p5(this.state.worldBounds,n)){let a=this._worldToCommonBounds(n),A=this._commonToWorldBounds(a);this.props.coordinateSystem===Oe.LNGLAT&&(A[1]=Math.max(A[1],-85.051129),A[3]=Math.min(A[3],85.051129),A[0]=Math.max(A[0],-360),A[2]=Math.min(A[2],360));let h=this._worldToCommonBounds(A);s.worldBounds=A,s.normalizedCommonBounds=h,o=!0}return this.setState(s),o}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:i,viewportCorners:n}=this.state,{viewport:s}=this.context;e.write(Yy(n,3));let o=n.map(a=>m5(s.projectPosition(a),i));r.write(Yy(o,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:i}=this.state,n=vo(r,!1,Uint8Array);i&&i?.width===r.length?i.setSubImageData({data:n}):(i?.destroy(),i=this.context.device.createTexture({...Ky,data:n,width:r.length,height:1})),this.setState({colorTexture:i})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:i}=this.props,{worldBounds:n,textureSize:s,weightsScale:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let A=this._worldToCommonBounds(n,{useLayerCoordinateSystem:!0});if(r&&i==="SUM"){let{viewport:S}=this.context,C=S.distanceScales.metersPerUnit[2]*(A[2]-A[0])/s;this.state.colorDomain=r.map(M=>M*C*o)}else this.state.colorDomain=r||T5;let g=this.getAttributeManager().getAttributes(),_=this.getModuleSettings(),x=g.positions.buffer,T={radiusPixels:e,commonBounds:A,textureWidth:s,weightsScale:o},v=g.weights.buffer;a.model.setAttributes({positions:x,weights:v}),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(T),a.model.updateModuleSettings(_),a.run({parameters:{viewport:[0,0,s,s]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:i}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),i)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:i=!1}=r,[n,s,o,a]=e,{viewport:A}=this.context,{textureSize:h}=this.state,{coordinateSystem:g}=this.props,_=i&&(g===Oe.LNGLAT_OFFSETS||g===Oe.METER_OFFSETS),x=_?A.projectPosition(this.props.coordinateOrigin):[0,0],T=h*Oj/A.scale,v,S;return i&&!_?(v=this.projectPosition([n,s,0]),S=this.projectPosition([o,a,0])):(v=A.projectPosition([n,s,0]),S=A.projectPosition([o,a,0])),g5([v[0]-x[0],v[1]-x[1],S[0]-x[0],S[1]-x[1]],T,T)}_commonToWorldBounds(e){let[r,i,n,s]=e,{viewport:o}=this.context,a=o.unprojectPosition([r,i]),A=o.unprojectPosition([n,s]);return a.slice(0,2).concat(A.slice(0,2))}};function Uj(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function Sp(t){if(Array.isArray(t))return t.map(e=>Sp(e));if(t&&typeof t=="object"){let e={};for(let[r,i]of Object.entries(t))e[Uj(r)]=Sp(i);return e}return t}var tI=Ys(eI(),1);function s3(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(n,s,o,a)=>!!e?.arrayPaths?.some(h=>s===h),...e?._fastXML},i=YX(t,r);return e?.uncapitalizeKeys?Sp(i):i}function YX(t,e){return new tI.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var QX="4.2.1",yn={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:QX,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:qX,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>s3(new TextDecoder().decode(t),{...yn.options.xml,...e?.xml}),parseTextSync:(t,e)=>s3(t,{...yn.options.xml,...e?.xml})};function qX(t){return t.startsWith("o3(new TextDecoder().decode(t),e),parseSync:(t,e)=>o3(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>o3(t,e)};function JX(t){return t.startsWith("0&&e.every(r=>typeof r=="string")?e:[]}function Qf(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function Cp(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function Xa(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function a3(t,e){let r=yn.parseTextSync?.(t,e),i=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,n=ZX(i);if(e?.inheritedLayerProps)for(let s of n.layers)nI(s,null);return e?.includeRawJSON&&(n.json=i),e?.includeXMLText&&(n.xml=t),n}function ZX(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Yf(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:Cp(t.Service?.LayerLimit),maxWidth:Cp(t.Service?.maxWidth),maxHeight:Cp(t.Service?.maxHeight),layers:[],requests:$X(t.Capability?.Request),exceptions:eY(t.Exception)},r=ja(t.Capability?.Layer);for(let i of r)e.layers.push(iI(i));for(let[i,n]of Object.entries(e))n===void 0&&delete e[i];return e}function $X(t){let e={};for(let[r,i]of Object.entries(t||{})){let n=Yf(i?.Format);e[r]={mimeTypes:n}}return e}function eY(t){if(ja(t?.Format).length>0)return{mimeTypes:Yf(t)}}function iI(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Yf(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(h=>typeof h=="string")&&(e.crs=r);let i=t?.EX_GeographicBoundingBox&&tY(t?.EX_GeographicBoundingBox);i&&(e.geographicBoundingBox=i),i=t?.LatLonBoundingBox&&rY(t?.LatLonBoundingBox),i&&(e.geographicBoundingBox=i);let n=t?.BoundingBox&&iY(t?.BoundingBox);n&&n.length>0&&(e.boundingBoxes=n);let o=ja(t?.Dimension).map(h=>sY(h));o.length&&(e.dimensions=o),t?.opaque&&(e.opaque=Xa(t?.opaque)),t?.cascaded&&(e.cascaded=Xa(t?.cascaded)),t?.queryable&&(e.queryable=Xa(t?.queryable));let a=ja(t?.Layer),A=[];for(let h of a)A.push(iI(h));A.length>0&&(e.layers=A);for(let[h,g]of Object.entries(e))g===void 0&&delete e[h];return e}function tY(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:i,southBoundLatitude:n}=t;return[[e,n],[i,r]]}function rY(t){let{minx:e,miny:r,maxx:i,maxy:n}=t;return[[e,r],[i,n]]}function iY(t){return ja(t).map(r=>nY(r))}function nY(t){let{CRS:e,SRS:r,minx:i,miny:n,maxx:s,maxy:o,resx:a,resy:A}=t,h={crs:e||r,boundingBox:[[Qf(i),Qf(n)],[Qf(s),Qf(o)]]};return a&&(h.xResolution=a),A&&(h.yResolution=A),h}function sY(t){let{name:e,units:r,value:i}=t,n={name:e,units:r,extent:i};return t.unitSymbol&&(n.unitSymbol=t.unitSymbol),t.default&&(n.defaultValue=t.default),t.multipleValues&&(n.multipleValues=Xa(t.multipleValues)),t.nearestValue&&(n.nearestValue=Xa(t.nearestValue)),t.current&&(n.current=Xa(t.current)),n}function nI(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])nI(r,t)}var oY="4.2.1",Cl={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:oY,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:aY,options:{wms:{}},parse:async(t,e)=>a3(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>a3(t,e?.wms)};function aY(t){return t.startsWith("cY(s))}}function cY(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var sI={...Cl,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>c3(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>c3(t,e)};function l3(t,e){return yn.parseTextSync?.(t,e)}var oI={...Cl,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>l3(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>l3(t,e)};function aI(t,e){let{type:r="auto"}=t,i=r==="auto"?AY(t.url,e):lY(r,e);if(!i)throw new Error("Not a valid image source type");return i.create(t)}function lY(t,e){for(let r of e)if(r.type===t)return r;return null}function AY(t,e){for(let r of e)if(r.testURL&&r.testURL(t))return r;return null}var cI={type:"wms",testURL:t=>t.toLowerCase().includes("wms"),create:t=>new A3(t)},A3=class extends Nn{url;data;substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e){super(e),this.url=e.url,this.data=e.url,this.substituteCRS84=e.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...e.wmsParameters},this.vendorParameters=e.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:i,...n}=e,s={bbox:r?[...r[0],...r[1]]:i,...n};return await this.getMap(s)}normalizeMetadata(e){return e}async getCapabilities(e,r){let i=this.getCapabilitiesURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();this._checkResponse(n,s);let o=await Cl.parse(s,this.loadOptions);return this.capabilities=o,o}async getMap(e,r){let i=this.getMapURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();this._checkResponse(n,s);try{return await Un.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}async getFeatureInfo(e,r){let i=this.getFeatureInfoURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();return this._checkResponse(n,s),await sI.parse(s,this.loadOptions)}async getFeatureInfoText(e,r){let i=this.getFeatureInfoURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();return this._checkResponse(n,s),new TextDecoder().decode(s)}async describeLayer(e,r){let i=this.describeLayerURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();return this._checkResponse(n,s),await oI.parse(s,this.loadOptions)}async getLegendGraphic(e,r){let i=this.getLegendGraphicURL(e,r),n=await this.fetch(i),s=await n.arrayBuffer();this._checkResponse(n,s);try{return await Un.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}getCapabilitiesURL(e,r){let i={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",i,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let i={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",i,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:i,bbox:n}=e;e.bbox=i?[...i[0],...i[1]]:n;let s={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",s,r)}describeLayerURL(e,r){let i={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",i,r)}getLegendGraphicURL(e,r){let i={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",i,r)}_parseWMSUrl(e){let[r,i]=e.split("?"),n=i.split("&"),s={};for(let o of n){let[a,A]=o.split("=");s[a]=A}return{url:r,parameters:s}}_getWMSUrl(e,r,i){let n=this.url,s=!0,o={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...i},a=["transparent","time","elevation"];for(let[A,h]of Object.entries(o))(!a.includes(A)||h)&&(n+=s?"?":"&",s=!1,n+=this._getURLParameter(A,h,r));return encodeURI(n)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,i){switch(e){case"crs":i.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":i.version==="1.3.0"&&(e="crs");break;case"bbox":let n=this._flipBoundingBox(r,i);n&&(r=n);break;case"x":i.version==="1.3.0"&&(e="i");break;case"y":i.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let i=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),n=e;return i?[n[1],n[0],n[3],n[2]]:n}async _fetchArrayBuffer(e){let r=await this.fetch(e),i=await r.arrayBuffer();return this._checkResponse(r,i),i}_checkResponse(e,r){let i=e.headers["content-type"];if(!e.ok||Xf.mimeTypes.includes(i)){let n=xA(this.loadOptions,{wms:{throwOnError:!0}}),s=Xf.parseSync?.(r,n);throw new Error(s)}}_parseError(e){let r=Xf.parseSync?.(e,this.loadOptions);return new Error(r)}};var Mp=class extends Nn{static type="template";static testURL=e=>e.toLowerCase().includes("{");constructor(e){super(e)}async getMetadata(){throw new Error("ImageSource.getMetadata not implemented")}async getImage(e){let r=this.getGranularParameters(e),i=this.getURLFromTemplate(r),s=await(await this.fetch(i)).arrayBuffer();return await Un.parse(s)}getGranularParameters(e){let[[r,i],[n,s]]=e.boundingBox;return{...e,east:r,north:i,south:s,west:n}}getURLFromTemplate(e){let r=this.props.url;for(let[i,n]of Object.entries(e))r=r.replace(`\${${i}}`,String(n)),r=r.replace(`{${i}}`,String(n));return r}};var u3=class extends Mp{data;constructor(e){super(e),this.data=e.url}async getMetadata(){return await this.metadata()}async getImage(e){throw new Error("not implemented")}async metadata(){throw new Error("not implemented")}exportImage(e){throw new Error("not implemented")}metadataURL(e){return`${this.props.url}?f=pjson`}exportImageURL(e){let r=`bbox=${e.bbox[0]},${e.bbox[1]},${e.bbox[2]},${e.bbox[3]}`,i=`size=${e.width},${e.height}`,n={...e,bbox:r,size:i};return delete n.width,delete n.height,this.getUrl("exportImage",n)}getUrl(e,r,i){let n=`${this.props.url}/${e}`,s=!0;for(let[o,a]of Object.entries(r))n+=s?"?":"&",s=!1,Array.isArray(a)?n+=`${o.toUpperCase()}=${a.join(",")}`:n+=`${o.toUpperCase()}=${a?String(a):""}`;return n}async checkResponse(e){if(!e.ok)throw new Error("error")}},lI={type:"arcgis-image-server",testURL:t=>t.toLowerCase().includes("ImageServer"),create:t=>new u3(t)};var uY=[cI,lI];function f3(t){return aI(t,uY)}var AI=6378137*Math.PI;function h3(t){let e=gr(t);return e[0]=(e[0]/256-1)*AI,e[1]=(e[1]/256-1)*AI,e}var fY={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Pp=class extends Gt{static{this.layerName="WMSLayer"}static{this.defaultProps=fY}get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:i}){let{viewport:n}=this.context;e.dataChanged||r.serviceType!==i.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(n,"image source changed"),0)):er(r.layers,i.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(n,"viewport changed")):this.debounce(()=>this.loadImage(n,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:i}=this.state;return r&&new Ra({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:i.srs==="EPSG:4326"?Oe.LNGLAT:Oe.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:i}=this.state;return i?await this.state.imageSource.getFeatureInfoText?.({...i,query_layers:i.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof Nn)return e.data;if(typeof e.data=="string")return f3({url:e.data,loadOptions:e.loadOptions,type:e.serviceType});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:i,serviceType:n}=this.props;if(n==="wms"&&i.length===0)return;let s=e.getBounds(),{width:o,height:a}=e,A=this.getRequestId(),{srs:h}=this.props;h==="auto"&&(h=e.resolution?"EPSG:4326":"EPSG:3857");let g={width:o,height:a,boundingBox:[[s[0],s[1]],[s[2],s[3]]],layers:i,crs:h};if(h==="EPSG:3857"){let _=h3([s[0],s[1]]),x=h3([s[2],s[3]]);g.boundingBox=[_,x]}try{this.state.loadCounter++,this.props.onImageLoadStart(A);let _=await this.state.imageSource.getImage(g);this.state.lastRequestIde(),r)}};var hY={getHeight:{type:"accessor",value:0},greatCircle:!0},qf=class extends Ia{static{this.layerName="GreatCircleLayer"}static{this.defaultProps=hY}};var dY={..._n.defaultProps},Pi=class extends Gt{static{this.layerName="GeoCellLayer"}static{this.defaultProps=dY}indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:i,filled:n,stroked:s,lineWidthUnits:o,lineWidthScale:a,lineWidthMinPixels:A,lineWidthMaxPixels:h,lineJointRounded:g,lineMiterLimit:_,lineDashJustified:x,getElevation:T,getFillColor:v,getLineColor:S,getLineWidth:C}=this.props,{updateTriggers:M,material:R,transitions:B}=this.props,k=this.getSubLayerClass("cell",_n),{updateTriggers:Q,...$}=this.indexToBounds()||{};return new k({filled:n,wireframe:i,extruded:r,elevationScale:e,stroked:s,lineWidthUnits:o,lineWidthScale:a,lineWidthMinPixels:A,lineWidthMaxPixels:h,lineJointRounded:g,lineMiterLimit:_,lineDashJustified:x,material:R,transitions:B,getElevation:T,getFillColor:v,getLineColor:S,getLineWidth:C},this.getSubLayerProps({id:"cell",updateTriggers:M&&{...Q,getElevation:M.getElevation,getFillColor:M.getFillColor,getLineColor:M.getLineColor,getLineWidth:M.getLineWidth}}),$)}};var Ip=Ys(d3(),1),pY=3,gY=30,mY=2*gY+1,fI=180/Math.PI;function dI(t,e,r){let i=1<=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function pI(t){return[hI(t[0]),hI(t[1])]}function gI(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function mI([t,e,r]){let i=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*fI,i*fI]}function _I(t){let e=Ip.default.fromString(t,!0,10).toString(2);for(;e.length=0;a--){o=n-a;let A=i[a],h=0,g=0;A==="1"?g=1:A==="2"?(h=1,g=1):A==="3"&&(h=1);let _=Math.pow(2,o-1);_Y(_,s,h,g),s[0]+=_*h,s[1]+=_*g}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:o}}var xI=Ys(d3(),1);function yY(t){let e=t.padEnd(16,"0");return xI.default.fromString(e,16)}var xY=100;function bY({face:t,ij:e,level:r}){let i=[[0,0],[0,1],[1,1],[1,0],[0,0]],n=Math.max(1,Math.ceil(xY*Math.pow(2,-r))),s=new Float64Array(4*n*2+2),o=0,a=0;for(let A=0;A<4;A++){let h=i[A].slice(0),g=i[A+1],_=(g[0]-h[0])/n,x=(g[1]-h[1])/n;for(let T=0;T89.999&&(M[0]=a);let R=M[0]-a;M[0]+=R>180?-360:R<-180?360:0,s[o++]=M[0],s[o++]=M[1],a=M[0]}}return s[o++]=s[0],s[o++]=s[1],s}function TY(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=yY(t)}return _I(t.toString())}function bI(t){let e=TY(t),r=yI(e);return bY(r)}var EY={getS2Token:{type:"accessor",value:t=>t.token}},Jf=class extends Pi{static{this.layerName="S2Layer"}static{this.defaultProps=EY}indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(i,n)=>bI(r(i,n))}}};var p3=512;function vY(t,e){let r=0,i=0,n=1<>=1;let a=parseInt(t[o]);a%2&&(r|=n),a>1&&(i|=n)}return[[r/s,p3-i/s],[(r+e)/s,p3-(i+e)/s]]}function TI(t,e=1){let[r,i]=vY(t,e),[n,s]=jr(r),[o,a]=jr(i);return[o,s,o,a,n,a,n,s,o,s]}var SY={getQuadkey:{type:"accessor",value:t=>t.quadkey}},Zf=class extends Pi{static{this.layerName="QuadkeyLayer"}static{this.defaultProps=SY}indexToBounds(){let{data:e,extruded:r,getQuadkey:i}=this.props,n=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,o)=>TI(i(s,o),n),updateTriggers:{getPolygon:n}}}};var Ya=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:i,onError:n}){let{index:s,id:o,bbox:a,userData:A,zoom:h}=this,g=this._loaderId;this._abortController=new AbortController;let{signal:_}=this._abortController,x=await r.scheduleRequest(this,S=>S.isSelected?1:-1);if(!x){this._isCancelled=!0;return}if(this._isCancelled){x.done();return}let T=null,v;try{T=await e({index:s,id:o,bbox:a,userData:A,zoom:h,signal:_})}catch(S){v=S||!0}finally{x.done()}if(g===this._loaderId){if(this._loader=void 0,this.content=T,this._isCancelled&&!T){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,v?n(v,this):i(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var or={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var EI=new X,wY=new X,Ml=class t{constructor(e=[0,0,0],r=[0,0,0],i){i=i||EI.copy(e).add(r).scale(.5),this.center=new X(i),this.halfDiagonal=new X(r).subtract(this.center),this.minimum=new X(e),this.maximum=new X(r)}clone(){return new t(this.minimum,this.maximum,this.center)}equals(e){return this===e||!!e&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,i=wY.from(e.normal),n=r.x*Math.abs(i.x)+r.y*Math.abs(i.y)+r.z*Math.abs(i.z),s=this.center.dot(i)+e.distance;return s-n>0?or.INSIDE:s+n<0?or.OUTSIDE:or.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=EI.from(e).subtract(this.center),{halfDiagonal:i}=this,n=0,s;return s=Math.abs(r.x)-i.x,s>0&&(n+=s*s),s=Math.abs(r.y)-i.y,s>0&&(n+=s*s),s=Math.abs(r.z)-i.z,s>0&&(n+=s*s),n}};var $f=new X,vI=new X,$n=class t{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new X,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=$f.from(r),this.center=new X().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new t(this.center,this.radius)}union(e){let r=this.center,i=this.radius,n=e.center,s=e.radius,o=$f.copy(n).subtract(r),a=o.magnitude();if(i>=a+s)return this.clone();if(s>=a+i)return e.clone();let A=(i+a+s)*.5;return vI.copy(o).scale((-i+A)/a).add(r),this.center.copy(vI),this.radius=A,this}expand(e){let i=$f.from(e).subtract(this.center).magnitude();return i>this.radius&&(this.radius=i),this}transform(e){this.center.transform(e);let r=ir.getScaling($f,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let i=$f.from(e).subtract(this.center);return Math.max(0,i.len()-this.radius)}intersectPlane(e){let r=this.center,i=this.radius,s=e.normal.dot(r)+e.distance;return s<-i?or.OUTSIDE:s=A?or.INSIDE:or.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=MY.from(e).subtract(this.center),i=this.halfAxes,n=i.getColumn(0,Rp),s=i.getColumn(1,Bp),o=i.getColumn(2,Op),a=n.magnitude(),A=s.magnitude(),h=o.magnitude();n.normalize(),s.normalize(),o.normalize();let g=0,_;return _=Math.abs(r.dot(n))-a,_>0&&(g+=_*_),_=Math.abs(r.dot(s))-A,_>0&&(g+=_*_),_=Math.abs(r.dot(o))-h,_>0&&(g+=_*_),g}computePlaneDistances(e,r,i=[-0,-0]){let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,A=a.getColumn(0,Rp),h=a.getColumn(1,Bp),g=a.getColumn(2,Op),_=PY.copy(A).add(h).add(g).add(o),x=IY.copy(_).subtract(e),T=r.dot(x);return n=Math.min(T,n),s=Math.max(T,s),_.copy(o).add(A).add(h).subtract(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),_.copy(o).add(A).subtract(h).add(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),_.copy(o).add(A).subtract(h).subtract(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),o.copy(_).subtract(A).add(h).add(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),o.copy(_).subtract(A).add(h).subtract(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),o.copy(_).subtract(A).subtract(h).add(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),o.copy(_).subtract(A).subtract(h).subtract(g),x.copy(_).subtract(e),T=r.dot(x),n=Math.min(T,n),s=Math.max(T,s),i[0]=n,i[1]=s,i}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,Rp);r.transformAsPoint(e);let i=this.halfAxes.getColumn(1,Bp);i.transformAsPoint(e);let n=this.halfAxes.getColumn(2,Op);return n.transformAsPoint(e),this.halfAxes=new wt([...r,...i,...n]),this}getTransform(){throw new Error("not implemented")}};var SI=new X,wI=new X,Yr=class t{constructor(e=[0,0,1],r=0){this.normal=new X,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return Mr(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=SI.from(e),this.normal.from(r).normalize();let i=-this.normal.dot(e);return this.distance=i,this}fromCoefficients(e,r,i,n){return this.normal.set(e,r,i),Mr(lr(this.normal.len(),1)),this.distance=n,this}clone(){return new t(this.normal,this.distance)}equals(e){return lr(this.distance,e.distance)&&lr(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=wI.copy(this.normal).transformAsVector(e).normalize(),i=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(i,r)}projectPointOntoPlane(e,r=[0,0,0]){let i=SI.from(e),n=this.getPointDistance(i),s=wI.copy(this.normal).scale(n);return i.subtract(s).to(r)}};var CI=[new X([1,0,0]),new X([0,1,0]),new X([0,0,1])],MI=new X,RY=new X,ii=class t{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*CI.length;let r=e.center,i=e.radius,n=0;for(let s of CI){let o=this.planes[n],a=this.planes[n+1];o||(o=this.planes[n]=new Yr),a||(a=this.planes[n+1]=new Yr);let A=MI.copy(s).scale(-i).add(r);o.fromPointNormal(A,s);let h=MI.copy(s).scale(i).add(r),g=RY.copy(s).negate();a.fromPointNormal(h,g),n+=2}return this}computeVisibility(e){let r=or.INSIDE;for(let i of this.planes)switch(e.intersectPlane(i)){case or.OUTSIDE:return or.OUTSIDE;case or.INTERSECTING:r=or.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(Mr(Number.isFinite(r),"parentPlaneMask is required."),r===t.MASK_OUTSIDE||r===t.MASK_INSIDE)return r;let i=t.MASK_INSIDE,n=this.planes;for(let s=0;sA;)DY(a,Fp),PI.copy(Fp).transpose(),a.multiplyRight(Fp),a.multiplyLeft(PI),o.multiplyRight(Fp),++n>2&&(++s,n=0);return e.unitary=o.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function LY(t){let e=0;for(let r=0;r<9;++r){let i=t[r];e+=i*i}return Math.sqrt(e)}var g3=[1,0,0],m3=[2,2,1];function NY(t){let e=0;for(let r=0;r<3;++r){let i=t[es.getElementIndex(m3[r],g3[r])];e+=2*i*i}return Math.sqrt(e)}function DY(t,e){let r=nn.EPSILON15,i=0,n=1;for(let h=0;h<3;++h){let g=Math.abs(t[es.getElementIndex(m3[h],g3[h])]);g>i&&(n=h,i=g)}let s=g3[n],o=m3[n],a=1,A=0;if(Math.abs(t[es.getElementIndex(o,s)])>r){let h=t[es.getElementIndex(o,o)],g=t[es.getElementIndex(s,s)],_=t[es.getElementIndex(o,s)],x=(h-g)/2/_,T;x<0?T=-1/(-x+Math.sqrt(1+x*x)):T=1/(x+Math.sqrt(1+x*x)),a=1/Math.sqrt(1+T*T),A=T*a}return wt.IDENTITY.to(e),e[es.getElementIndex(s,s)]=e[es.getElementIndex(o,o)]=a,e[es.getElementIndex(o,s)]=A,e[es.getElementIndex(s,o)]=-A,e}var Mo=new X,UY=new X,kY=new X,VY=new X,zY=new X,HY=new wt,GY={diagonal:new wt,unitary:new wt};function eh(t,e=new Rs){if(!t||t.length===0)return e.halfAxes=new wt([0,0,0,0,0,0,0,0,0]),e.center=new X,e;let r=t.length,i=new X(0,0,0);for(let H of t)i.add(H);let n=1/r;i.multiplyByScalar(n);let s=0,o=0,a=0,A=0,h=0,g=0;for(let H of t){let L=Mo.copy(H).subtract(i);s+=L.x*L.x,o+=L.x*L.y,a+=L.x*L.z,A+=L.y*L.y,h+=L.y*L.z,g+=L.z*L.z}s*=n,o*=n,a*=n,A*=n,h*=n,g*=n;let _=HY;_[0]=s,_[1]=o,_[2]=a,_[3]=o,_[4]=A,_[5]=h,_[6]=a,_[7]=h,_[8]=g;let{unitary:x}=_3(_,GY),T=e.halfAxes.copy(x),v=T.getColumn(0,kY),S=T.getColumn(1,VY),C=T.getColumn(2,zY),M=-Number.MAX_VALUE,R=-Number.MAX_VALUE,B=-Number.MAX_VALUE,k=Number.MAX_VALUE,Q=Number.MAX_VALUE,$=Number.MAX_VALUE;for(let H of t)Mo.copy(H),M=Math.max(Mo.dot(v),M),R=Math.max(Mo.dot(S),R),B=Math.max(Mo.dot(C),B),k=Math.min(Mo.dot(v),k),Q=Math.min(Mo.dot(S),Q),$=Math.min(Mo.dot(C),$);v=v.multiplyByScalar(.5*(k+M)),S=S.multiplyByScalar(.5*(Q+R)),C=C.multiplyByScalar(.5*($+B)),e.center.copy(v).add(S).add(C);let re=UY.set(M-k,R-Q,B-$).multiplyByScalar(.5),Y=new wt([re[0],0,0,0,re[1],0,0,0,re[2]]);return e.halfAxes.multiplyRight(Y),e}var Pl=512,II=3,RI=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],BI=RI.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),WY=BI.concat([[.25,.5],[.75,.5]]),y3=class t{constructor(e,r,i){this.x=e,this.y=r,this.z=i}get children(){if(!this._children){let e=this.x*2,r=this.y*2,i=this.z+1;this._children=[new t(e,r,i),new t(e,r+1,i),new t(e+1,r,i),new t(e+1,r+1,i)]}return this._children}update(e){let{viewport:r,cullingVolume:i,elevationBounds:n,minZ:s,maxZ:o,bounds:a,offset:A,project:h}=e,g=this.getBoundingVolume(n,A,h);if(a&&!this.insideBounds(a)||i.computeVisibility(g)<0)return!1;if(!this.childVisible){let{z:x}=this;if(x=s){let T=g.distanceTo(r.cameraPosition)*r.scale/r.height;x+=Math.floor(Math.log2(T))}if(x>=o)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let x of this.children)x.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,i,n]){let s=Math.pow(2,this.z),o=Pl/s;return this.x*oe&&(this.y+1)*o>r}getBoundingVolume(e,r,i){if(i){let A=this.z<1?WY:this.z<2?BI:RI,h=[];for(let g of A){let _=Lp(this.x+g[0],this.y+g[1],this.z);_[2]=e[0],h.push(i(_)),e[0]!==e[1]&&(_[2]=e[1],h.push(i(_)))}return eh(h)}let n=Math.pow(2,this.z),s=Pl/n,o=this.x*s+r*Pl,a=Pl-(this.y+1)*s;return new Ml([o,a,e[0]],[o+s,a+s,e[1]])}};function OI(t,e,r,i){let n=t instanceof Jc&&t.resolution?t.projectPosition:null,s=Object.values(t.getFrustumPlanes()).map(({normal:T,distance:v})=>new Yr(T.clone().negate(),v)),o=new ii(s),a=t.distanceScales.unitsPerMeter[2],A=r&&r[0]*a||0,h=r&&r[1]*a||0,g=t instanceof wi&&t.pitch<=60?e:0;if(i){let[T,v,S,C]=i,M=gr([T,C]),R=gr([S,v]);i=[M[0],Pl-M[1],R[0],Pl-R[1]]}let _=new y3(0,0,0),x={viewport:t,project:n,cullingVolume:o,elevationBounds:[A,h],minZ:g,maxZ:e,bounds:i,offset:0};if(_.update(x),t instanceof wi&&t.subViewports&&t.subViewports.length>1){for(x.offset=-1;_.update(x)&&!(--x.offset<-II););for(x.offset=1;_.update(x)&&!(++x.offset>II););}return _.getSelected()}var Bs=512,jY=[-1/0,-1/0,1/0,1/0],Po={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let i=0;in[0])),Math.min(...r.map(n=>n[1])),Math.max(...r.map(n=>n[0])),Math.max(...r.map(n=>n[1]))]}function XY(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function ts(t,e){if(!t||!t.length)return null;let{index:r,id:i}=e;if(Array.isArray(t)){let s=XY(i)%t.length;t=t[s]}let n=t;for(let s of Object.keys(r)){let o=new RegExp(`{${s}}`,"g");n=n.replace(o,String(r[s]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(n=n.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),n}function YY(t,e,r){let i;if(e&&e.length===2){let[n,s]=e,o=t.getBounds({z:n}),a=t.getBounds({z:s});i=[Math.min(o[0],a[0]),Math.min(o[1],a[1]),Math.max(o[2],a[2]),Math.max(o[3],a[3])]}else i=t.getBounds();return t.isGeospatial?[Math.max(i[0],r[0]),Math.max(i[1],r[1]),Math.min(i[2],r[2]),Math.min(i[3],r[3])]:[Math.max(Math.min(i[0],r[2]),r[0]),Math.max(Math.min(i[1],r[3]),r[1]),Math.min(Math.max(i[2],r[0]),r[2]),Math.min(Math.max(i[3],r[1]),r[3])]}function NI({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(n=>x3(n,e||0,r))}function x3(t,e,r){if(!Array.isArray(e)){let s=r.x-t.x,o=r.y-t.y,{width:a,height:A}=r,h={targetZ:e},g=t.unproject([s,o],h),_=t.unproject([s+a,o],h),x=t.unproject([s,o+A],h),T=t.unproject([s+a,o+A],h);return[Math.min(g[0],_[0],x[0],T[0]),Math.min(g[1],_[1],x[1],T[1]),Math.max(g[0],_[0],x[0],T[0]),Math.max(g[1],_[1],x[1],T[1])]}let i=x3(t,e[0],r),n=x3(t,e[1],r);return[Math.min(i[0],n[0]),Math.min(i[1],n[1]),Math.max(i[2],n[2]),Math.max(i[3],n[3])]}function QY(t,e,r){return r?LI(t,r).map(n=>n*e/Bs):t.map(i=>i*e/Bs)}function b3(t,e){return Math.pow(2,t)*Bs/e}function Lp(t,e,r){let i=b3(r,Bs),n=t/i*360-180,s=Math.PI-2*Math.PI*e/i,o=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[n,o]}function FI(t,e,r,i){let n=b3(r,i);return[t/n*Bs,e/n*Bs]}function T3(t,e,r,i,n=Bs){if(t.isGeospatial){let[h,g]=Lp(e,r,i),[_,x]=Lp(e+1,r+1,i);return{west:h,north:g,east:_,south:x}}let[s,o]=FI(e,r,i,n),[a,A]=FI(e+1,r+1,i,n);return{left:s,top:o,right:a,bottom:A}}function qY(t,e,r,i,n){let s=YY(t,null,i),o=b3(e,r),[a,A,h,g]=QY(s,o,n),_=[];for(let x=Math.floor(a);xe&&(h=e);let g=n;return o&&a&&n&&!t.isGeospatial&&(g=LI(n,o)),t.isGeospatial?OI(t,h,i,n):qY(t,h,s,g||jY,a)}function v3(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function S3(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function DI(t){let e={},r;return i=>{for(let n in i)if(!KY(i[n],e[n])){r=t(i),e=i;break}return r}}function KY(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i{}},tQ={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},Qa=class{constructor(e){this._getCullBounds=DI(NI),this.opts={...tQ,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new Ks({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new Fe,this._modelMatrixInverse=new Fe}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:i}={zRange:null,modelMatrix:null}){let n=i?new Fe(i):new Fe,s=!n.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!lr(this._zRange,r)||s){s&&(this._modelMatrixInverse=n.clone().invert(),this._modelMatrix=n),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(A=>this._getTile(A,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let o=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),o&&this._frameNumber++,this._frameNumber}isTileVisible(e,r){if(!e.isVisible)return!1;if(r&&this._viewport){let i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:n}=e;for(let[s,o,a,A]of i){let h;if("west"in n)h=n.wests&&n.southo;else{let g=Math.min(n.top,n.bottom),_=Math.max(n.top,n.bottom);h=n.lefts&&go}if(h)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:i,zRange:n,modelMatrix:s,modelMatrixInverse:o}){let{tileSize:a,extent:A,zoomOffset:h}=this.opts;return E3({viewport:e,maxZoom:r,minZoom:i,zRange:n,tileSize:a,extent:A,modelMatrix:s,modelMatrixInverse:o,zoomOffset:h})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:T3(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),i=Math.floor(e.y/2),n=e.z-1;return{x:r,y:i,z:n}}updateTileStates(){let e=this.opts.refinementStrategy||th,r=new Array(this._cache.size),i=0;for(let n of this._cache.values())r[i++]=n.isVisible,n.isSelected=!1,n.isVisible=!1;for(let n of this._selectedTiles)n.isSelected=!0,n.isVisible=!0;(typeof e=="function"?e:eQ[e])(Array.from(this._cache.values())),i=0;for(let n of this._cache.values())if(r[i++]!==n.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],i=0;for(let n of this._cache.values())n.isLoading&&(i++,!n.isSelected&&!n.isVisible&&r.push(n));for(;e>0&&i>e&&r.length>0;)r.shift().abort(),i--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let i=this._getNearestAncestor(r);r.parent=i,i?.children&&i.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,i=r.maxCacheSize||(r.maxCacheByteSize?1/0:$Y*this.selectedTiles.length),n=r.maxCacheByteSize||1/0;if(e.size>i||this._cacheByteSize>n){for(let[o,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize?a.byteLength:0,e.delete(o),this.opts.onTileUnload?.(a)),e.size<=i&&this._cacheByteSize<=n)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((o,a)=>o.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let i=this.getTileId(e),n=this._cache.get(i),s=!1;return!n&&r?(n=new Ya(e),Object.assign(n,this.getTileMetadata(n.index)),Object.assign(n,{id:i,zoom:this.getTileZoom(n.index)}),s=!0,this._cache.set(i,n),this._dirty=!0):n&&n.needsReload&&(s=!0),n&&s&&n.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),n}_getNearestAncestor(e){let{_minZoom:r=0}=this,i=e.index;for(;this.getTileZoom(i)>r;){i=this.getParentIndex(i);let n=this._getTile(i);if(n)return n}return null}};function rQ(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!kI(e)&&w3(e);for(let e of t)e.isVisible=!!(e.state&Np)}function iQ(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&kI(r);let e=Array.from(t).sort((r,i)=>r.zoom-i.zoom);for(let r of e)if(r.isVisible=!!(r.state&Np),r.children&&(r.isVisible||r.state&UI))for(let i of r.children)i.state=UI;else r.isSelected&&w3(r)}function kI(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=Np,!0;e=e.parent}return!1}function w3(t){for(let e of t.children)e.isLoaded||e.content?e.state|=Np:w3(e)}var nQ={TilesetClass:Qa,data:{type:"data",value:[]},dataComparator:Po.equal,renderSubLayers:{type:"function",value:t=>new Zn(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:th,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},rs=class extends Gt{static{this.defaultProps=nQ}static{this.layerName="TileLayer"}initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return!!this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&e.layers&&e.layers.every(r=>r.isLoaded))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,i=e.propsOrDataChanged||e.updateTriggersChanged,n=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?i&&(r.setOptions(this._getTilesetOptions()),n?r.reloadAll():r.tiles.forEach(s=>{s.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:i,refinementStrategy:n,extent:s,maxZoom:o,minZoom:a,maxRequests:A,debounceTime:h,zoomOffset:g}=this.props;return{maxCacheSize:r,maxCacheByteSize:i,maxZoom:o,minZoom:a,tileSize:e,refinementStrategy:n,extent:s,maxRequests:A,debounceTime:h,zoomOffset:g,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:i}=this.props,n=e.update(this.context.viewport,{zRange:r,modelMatrix:i}),{isLoaded:s}=e,o=this.state.isLoaded!==s,a=this.state.frameNumber!==n;s&&(o||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:n}),this.state.isLoaded=s}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:i,fetch:n}=this.props,{signal:s}=e;return e.url=typeof r=="string"||Array.isArray(r)?ts(r,e):null,i?i(e):n&&e.url?n(e.url,{propName:"data",layer:this,signal:s}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,i=r.props.tile,n=e.info;return n.picked&&(n.tile=i),n.sourceTile=i,n.sourceTileSubLayer=r,n}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){return this.state.tileset.tiles.map(e=>{let r=this.getSubLayerPropsByTile(e);if(!(!e.isLoaded&&!e.content))if(e.layers)r&&e.layers[0]&&Object.keys(r).some(i=>e.layers[0].props[i]!==r[i])&&(e.layers=e.layers.map(i=>i.clone(r)));else{let i=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=hi(i,Boolean).map(n=>n.clone({tile:e,...r}))}return e.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:i}=e.props;return this.state.tileset.isTileVisible(i,r)}};var sQ={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},rh=class extends gn{static{this.layerName="TripsLayer"}static{this.defaultProps=sQ}getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`uniform float trailLength; +in float instanceTimestamps; +in float instanceNextTimestamps; +out float vTime; +`,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength; +`,"fs:#decl":`uniform bool fadeTrail; +uniform float trailLength; +uniform float currentTime; +in float vTime; +`,"fs:#main-start":`if(vTime > currentTime || (fadeTrail && (vTime < currentTime - trailLength))) { + discard; +} +`,"fs:DECKGL_FILTER_COLOR":`if(fadeTrail) { + color.a *= 1.0 - (currentTime - vTime) / trailLength; +} +`},e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:i,currentTime:n}=this.props;e.uniforms={...e.uniforms,fadeTrail:r,trailLength:i,currentTime:n},super.draw(e)}};var bt=function(t){t=t||{};var e=typeof t<"u"?t:{},r={},i;for(i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);var n=[],s="";function o(ee){return e.locateFile?e.locateFile(ee,s):s+ee}var a;typeof document<"u"&&document.currentScript&&(s=document.currentScript.src),s.indexOf("blob:")!==0?s=s.substr(0,s.lastIndexOf("/")+1):s="",a=function(Ae,Ee,ke){var u=new XMLHttpRequest;u.open("GET",Ae,!0),u.responseType="arraybuffer",u.onload=function(){if(u.status==200||u.status==0&&u.response){Ee(u.response);return}var Et=iA(Ae);if(Et){Ee(Et.buffer);return}ke()},u.onerror=ke,u.send(null)};var A=e.print||console.log.bind(console),h=e.printErr||console.warn.bind(console);for(i in r)r.hasOwnProperty(i)&&(e[i]=r[i]);r=null,e.arguments&&(n=e.arguments);var g=0,_=function(ee){g=ee},x=function(){return g},T=8;function v(ee,Ae,Ee,ke){switch(Ee=Ee||"i8",Ee.charAt(Ee.length-1)==="*"&&(Ee="i32"),Ee){case"i1":ye[ee>>0]=Ae;break;case"i8":ye[ee>>0]=Ae;break;case"i16":nt[ee>>1]=Ae;break;case"i32":et[ee>>2]=Ae;break;case"i64":fr=[Ae>>>0,(Vt=Ae,+Fo(Vt)>=1?Vt>0?(Dr(+zs(Vt/4294967296),4294967295)|0)>>>0:~~+Lo((Vt-+(~~Vt>>>0))/4294967296)>>>0:0)],et[ee>>2]=fr[0],et[ee+4>>2]=fr[1];break;case"float":At[ee>>2]=Ae;break;case"double":De[ee>>3]=Ae;break;default:ko("invalid type for setValue: "+Ee)}}function S(ee,Ae,Ee){switch(Ae=Ae||"i8",Ae.charAt(Ae.length-1)==="*"&&(Ae="i32"),Ae){case"i1":return ye[ee>>0];case"i8":return ye[ee>>0];case"i16":return nt[ee>>1];case"i32":return et[ee>>2];case"i64":return et[ee>>2];case"float":return At[ee>>2];case"double":return De[ee>>3];default:ko("invalid type for getValue: "+Ae)}return null}var C=!1;function M(ee,Ae){ee||ko("Assertion failed: "+Ae)}function R(ee){var Ae=e["_"+ee];return M(Ae,"Cannot call unknown function "+ee+", make sure it is exported"),Ae}function B(ee,Ae,Ee,ke,u){var Bt={string:function(Er){var _t=0;if(Er!=null&&Er!==0){var yt=(Er.length<<2)+1;_t=Db(yt),H(Er,_t,yt)}return _t},array:function(Er){var _t=Db(Er.length);return ae(Er,_t),_t}};function Et(Er){return Ae==="string"?re(Er):Ae==="boolean"?!!Er:Er}var F=R(ee),br=[],li=0;if(ke)for(var Tr=0;Tr=ke);)++u;if(u-Ae>16&&ee.subarray&&Q)return Q.decode(ee.subarray(Ae,u));for(var Bt="";Ae>10,56320|li&1023)}}return Bt}function re(ee,Ae){return ee?$(Ne,ee,Ae):""}function Y(ee,Ae,Ee,ke){if(!(ke>0))return 0;for(var u=Ee,Bt=Ee+ke-1,Et=0;Et=55296&&F<=57343){var br=ee.charCodeAt(++Et);F=65536+((F&1023)<<10)|br&1023}if(F<=127){if(Ee>=Bt)break;Ae[Ee++]=F}else if(F<=2047){if(Ee+1>=Bt)break;Ae[Ee++]=192|F>>6,Ae[Ee++]=128|F&63}else if(F<=65535){if(Ee+2>=Bt)break;Ae[Ee++]=224|F>>12,Ae[Ee++]=128|F>>6&63,Ae[Ee++]=128|F&63}else{if(Ee+3>=Bt)break;Ae[Ee++]=240|F>>18,Ae[Ee++]=128|F>>12&63,Ae[Ee++]=128|F>>6&63,Ae[Ee++]=128|F&63}}return Ae[Ee]=0,Ee-u}function H(ee,Ae,Ee){return Y(ee,Ne,Ae,Ee)}var L=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function ae(ee,Ae){ye.set(ee,Ae)}function fe(ee,Ae){return ee%Ae>0&&(ee+=Ae-ee%Ae),ee}var he,ye,Ne,nt,it,et,st,At,De;function rr(ee){he=ee,e.HEAP8=ye=new Int8Array(ee),e.HEAP16=nt=new Int16Array(ee),e.HEAP32=et=new Int32Array(ee),e.HEAPU8=Ne=new Uint8Array(ee),e.HEAPU16=it=new Uint16Array(ee),e.HEAPU32=st=new Uint32Array(ee),e.HEAPF32=At=new Float32Array(ee),e.HEAPF64=De=new Float64Array(ee)}var Re=5267040,de=24128,Br=e.TOTAL_MEMORY||33554432;e.buffer?he=e.buffer:he=new ArrayBuffer(Br),Br=he.byteLength,rr(he),et[de>>2]=Re;function Nt(ee){for(;ee.length>0;){var Ae=ee.shift();if(typeof Ae=="function"){Ae();continue}var Ee=Ae.func;typeof Ee=="number"?Ae.arg===void 0?e.dynCall_v(Ee):e.dynCall_vi(Ee,Ae.arg):Ee(Ae.arg===void 0?null:Ae.arg)}}var kt=[],Ge=[],Jt=[],yr=[];function oi(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)ai(e.preRun.shift());Nt(kt)}function Sn(){Nt(Ge)}function ss(){Nt(Jt)}function Ri(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Ji(e.postRun.shift());Nt(yr)}function ai(ee){kt.unshift(ee)}function Ji(ee){yr.unshift(ee)}var Fo=Math.abs,Lo=Math.ceil,zs=Math.floor,Dr=Math.min,Zi=0,wn=null,$i=null;function Ac(ee){Zi++,e.monitorRunDependencies&&e.monitorRunDependencies(Zi)}function Ce(ee){if(Zi--,e.monitorRunDependencies&&e.monitorRunDependencies(Zi),Zi==0&&(wn!==null&&(clearInterval(wn),wn=null),$i)){var Ae=$i;$i=null,Ae()}}e.preloadedImages={},e.preloadedAudios={};var Pe=null,Ue="data:application/octet-stream;base64,";function Qt(ee){return String.prototype.startsWith?ee.startsWith(Ue):ee.indexOf(Ue)===0}var Vt,fr;Pe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP7KBdLHZTpFAqKYk69AqekDbeGY41MdjQD8AZzHK501A1vcrrjubNkD5LnquvBYhQCbiRRD71QlAqt72EbOH8z8Eu+jL1YbdP4uaox/xUcY/abedg1XfsD+BsUdzJ4KZP5wE9YFySIM/rW1kAKMpbT+rZFthVRhWPy4PKlXIs0A/qMZLlwDnMEHByqEF0I0ZQQYSFD8lUQNBPpY+dFs07UAH8BZImBPWQN9RY0I0sMBA2T7kLfc6qUByFYvfhBKTQMq+0Mis1XxA0XQbeQXMZUBJJ5aEGXpQQP7/SY0a6ThAaMD92b/UIkAs8s8yqXoMQNIegOvCk/U/aOi7NZJP4D8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAAGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjb29yZGlqay5jAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAbGF0TG5nVG9DZWxsAGNlbGxUb0NoaWxkUG9zAHZhbGlkYXRlQ2hpbGRQb3MAbGF0TG5nLmMAY2VsbEFyZWFSYWRzMgBwb2x5Z29uLT5uZXh0ID09IE5VTEwAbGlua2VkR2VvLmMAYWRkTmV3TGlua2VkUG9seWdvbgBuZXh0ICE9IE5VTEwAbG9vcCAhPSBOVUxMAGFkZE5ld0xpbmtlZExvb3AAcG9seWdvbi0+Zmlyc3QgPT0gTlVMTABhZGRMaW5rZWRMb29wAGNvb3JkICE9IE5VTEwAYWRkTGlua2VkQ29vcmQAbG9vcC0+Zmlyc3QgPT0gTlVMTABpbm5lckxvb3BzICE9IE5VTEwAbm9ybWFsaXplTXVsdGlQb2x5Z29uAGJib3hlcyAhPSBOVUxMAGNhbmRpZGF0ZXMgIT0gTlVMTABmaW5kUG9seWdvbkZvckhvbGUAY2FuZGlkYXRlQkJveGVzICE9IE5VTEwAcmV2RGlyICE9IElOVkFMSURfRElHSVQAbG9jYWxpai5jAGNlbGxUb0xvY2FsSWprAGJhc2VDZWxsICE9IG9yaWdpbkJhc2VDZWxsACEob3JpZ2luT25QZW50ICYmIGluZGV4T25QZW50KQBiYXNlQ2VsbCA9PSBvcmlnaW5CYXNlQ2VsbABiYXNlQ2VsbCAhPSBJTlZBTElEX0JBU0VfQ0VMTABsb2NhbElqa1RvQ2VsbAAhX2lzQmFzZUNlbGxQZW50YWdvbihiYXNlQ2VsbCkAYmFzZUNlbGxSb3RhdGlvbnMgPj0gMABncmlkUGF0aENlbGxzADAAdmVydGV4LmMAY2VsbFRvVmVydGV4AGdyYXBoLT5idWNrZXRzICE9IE5VTEwAdmVydGV4R3JhcGguYwBpbml0VmVydGV4R3JhcGgAbm9kZSAhPSBOVUxMAGFkZFZlcnRleE5vZGU=";var ci=24144;function os(ee){return ee}function en(ee){var Ae=/\b__Z[\w\d_]+/g;return ee.replace(Ae,function(Ee){var ke=Ee;return Ee===ke?Ee:ke+" ["+Ee+"]"})}function No(){var ee=new Error;if(!ee.stack){try{throw new Error(0)}catch(Ae){ee=Ae}if(!ee.stack)return"(no stack trace available)"}return ee.stack.toString()}function Jg(){var ee=No();return e.extraStackTrace&&(ee+=` +`+e.extraStackTrace()),en(ee)}function Zg(ee,Ae,Ee,ke){ko("Assertion failed: "+re(ee)+", at: "+[Ae?re(Ae):"unknown filename",Ee,ke?re(ke):"unknown function"])}function Do(){return ye.length}function $g(ee,Ae,Ee){Ne.set(Ne.subarray(Ae,Ae+Ee),ee)}function em(ee){return e.___errno_location&&(et[e.___errno_location()>>2]=ee),ee}function Mh(ee){ko("OOM")}function tA(ee){try{var Ae=new ArrayBuffer(ee);return Ae.byteLength!=ee?void 0:(new Int8Array(Ae).set(ye),bi(Ae),rr(Ae),1)}catch{}}function rA(ee){var Ae=Do(),Ee=16777216,ke=2147483648-Ee;if(ee>ke)return!1;for(var u=16777216,Bt=Math.max(Ae,u);Bt>4,u=(F&15)<<4|br>>2,Bt=(br&3)<<6|li,Ee=Ee+String.fromCharCode(ke),br!==64&&(Ee=Ee+String.fromCharCode(u)),li!==64&&(Ee=Ee+String.fromCharCode(Bt));while(Tr13780509?(c=Bm(15,c)|0,c|0):(f=((l|0)<0)<<31>>31,p=zr(l|0,f|0,3,0)|0,d=U()|0,f=ot(l|0,f|0,1,0)|0,f=zr(p|0,d|0,f|0,U()|0)|0,f=ot(f|0,U()|0,1,0)|0,l=U()|0,u[c>>2]=f,u[c+4>>2]=l,c=0,c|0)}function Hb(l,c,f,d){return l=l|0,c=c|0,f=f|0,d=d|0,Gb(l,c,f,d,0)|0}function Gb(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0;if(E=O,O=O+16|0,y=E,!(Wb(l,c,f,d,p)|0))return d=0,O=E,d|0;do if((f|0)>=0){if((f|0)>13780509){if(m=Bm(15,y)|0,m|0)break;b=y,y=u[b>>2]|0,b=u[b+4>>2]|0}else m=((f|0)<0)<<31>>31,w=zr(f|0,m|0,3,0)|0,b=U()|0,m=ot(f|0,m|0,1,0)|0,m=zr(w|0,b|0,m|0,U()|0)|0,m=ot(m|0,U()|0,1,0)|0,b=U()|0,u[y>>2]=m,u[y+4>>2]=b,y=m;if(Xo(d|0,0,y<<3|0)|0,p|0){Xo(p|0,0,y<<2|0)|0,m=cs(l,c,f,d,p,y,b,0)|0;break}m=Bn(y,4)|0,m?(w=cs(l,c,f,d,m,y,b,0)|0,We(m),m=w):m=13}else m=2;while(!1);return w=m,O=E,w|0}function Wb(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0;if(Z=O,O=O+16|0,j=Z,z=Z+8|0,G=j,u[G>>2]=l,u[G+4>>2]=c,(f|0)<0)return z=2,O=Z,z|0;if(m=d,u[m>>2]=l,u[m+4>>2]=c,m=(p|0)!=0,m&&(u[p>>2]=0),Ht(l,c)|0)return z=9,O=Z,z|0;u[z>>2]=0;e:do if((f|0)>=1)if(m)for(P=1,w=0,N=0,G=1,m=l;;){if(!(w|N)){if(m=vr(m,c,4,z,j)|0,m|0)break e;if(c=j,m=u[c>>2]|0,c=u[c+4>>2]|0,Ht(m,c)|0){m=9;break e}}if(m=vr(m,c,u[22384+(N<<2)>>2]|0,z,j)|0,m|0)break e;if(c=j,m=u[c>>2]|0,c=u[c+4>>2]|0,l=d+(P<<3)|0,u[l>>2]=m,u[l+4>>2]=c,u[p+(P<<2)>>2]=G,l=w+1|0,y=(l|0)==(G|0),b=N+1|0,E=(b|0)==6,Ht(m,c)|0){m=9;break e}if(G=G+(E&y&1)|0,(G|0)>(f|0)){m=0;break}else P=P+1|0,w=y?0:l,N=y?E?0:b:N}else for(P=1,w=0,N=0,G=1,m=l;;){if(!(w|N)){if(m=vr(m,c,4,z,j)|0,m|0)break e;if(c=j,m=u[c>>2]|0,c=u[c+4>>2]|0,Ht(m,c)|0){m=9;break e}}if(m=vr(m,c,u[22384+(N<<2)>>2]|0,z,j)|0,m|0)break e;if(c=j,m=u[c>>2]|0,c=u[c+4>>2]|0,l=d+(P<<3)|0,u[l>>2]=m,u[l+4>>2]=c,l=w+1|0,y=(l|0)==(G|0),b=N+1|0,E=(b|0)==6,Ht(m,c)|0){m=9;break e}if(G=G+(E&y&1)|0,(G|0)>(f|0)){m=0;break}else P=P+1|0,w=y?0:l,N=y?E?0:b:N}else m=0;while(!1);return z=m,O=Z,z|0}function cs(l,c,f,d,p,m,y,b){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,m=m|0,y=y|0,b=b|0;var E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0;if(Z=O,O=O+16|0,j=Z+8|0,z=Z,E=_c(l|0,c|0,m|0,y|0)|0,P=U()|0,N=d+(E<<3)|0,ce=N,oe=u[ce>>2]|0,ce=u[ce+4>>2]|0,w=(oe|0)==(l|0)&(ce|0)==(c|0),!((oe|0)==0&(ce|0)==0|w))do E=ot(E|0,P|0,1,0)|0,E=Wh(E|0,U()|0,m|0,y|0)|0,P=U()|0,N=d+(E<<3)|0,oe=N,ce=u[oe>>2]|0,oe=u[oe+4>>2]|0,w=(ce|0)==(l|0)&(oe|0)==(c|0);while(!((ce|0)==0&(oe|0)==0|w));if(E=p+(E<<2)|0,w&&(u[E>>2]|0)<=(b|0)||(oe=N,u[oe>>2]=l,u[oe+4>>2]=c,u[E>>2]=b,(b|0)>=(f|0)))return oe=0,O=Z,oe|0;switch(w=b+1|0,u[j>>2]=0,E=vr(l,c,2,j,z)|0,E|0){case 9:{G=9;break}case 0:{E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E||(G=9);break}default:}e:do if((G|0)==9){switch(u[j>>2]=0,E=vr(l,c,3,j,z)|0,E|0){case 9:break;case 0:{if(E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E|0)break e;break}default:break e}switch(u[j>>2]=0,E=vr(l,c,1,j,z)|0,E|0){case 9:break;case 0:{if(E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E|0)break e;break}default:break e}switch(u[j>>2]=0,E=vr(l,c,5,j,z)|0,E|0){case 9:break;case 0:{if(E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E|0)break e;break}default:break e}switch(u[j>>2]=0,E=vr(l,c,4,j,z)|0,E|0){case 9:break;case 0:{if(E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E|0)break e;break}default:break e}switch(u[j>>2]=0,E=vr(l,c,6,j,z)|0,E|0){case 9:break;case 0:{if(E=z,E=cs(u[E>>2]|0,u[E+4>>2]|0,f,d,p,m,y,w)|0,E|0)break e;break}default:break e}return oe=0,O=Z,oe|0}while(!1);return oe=E,O=Z,oe|0}function vr(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0;if(f>>>0>6)return p=1,p|0;if(N=(u[d>>2]|0)%6|0,u[d>>2]=N,(N|0)>0){m=0;do f=Go(f)|0,m=m+1|0;while((m|0)<(u[d>>2]|0))}if(N=pe(l|0,c|0,45)|0,U()|0,P=N&127,P>>>0>121)return p=5,p|0;E=Ai(l,c)|0,m=pe(l|0,c|0,52)|0,U()|0,m=m&15;e:do if(!m)w=8;else{for(;;){if(y=(15-m|0)*3|0,b=pe(l|0,c|0,y|0)|0,U()|0,b=b&7,(b|0)==7){c=5;break}if(z=(Oi(m)|0)==0,m=m+-1|0,G=Te(7,0,y|0)|0,c=c&~(U()|0),j=Te(u[(z?432:16)+(b*28|0)+(f<<2)>>2]|0,0,y|0)|0,y=U()|0,f=u[(z?640:224)+(b*28|0)+(f<<2)>>2]|0,l=j|l&~G,c=y|c,!f){f=0;break e}if(!m){w=8;break e}}return c|0}while(!1);(w|0)==8&&(z=u[848+(P*28|0)+(f<<2)>>2]|0,j=Te(z|0,0,45)|0,l=j|l,c=U()|0|c&-1040385,f=u[4272+(P*28|0)+(f<<2)>>2]|0,(z&127|0)==127&&(z=Te(u[848+(P*28|0)+20>>2]|0,0,45)|0,c=U()|0|c&-1040385,f=u[4272+(P*28|0)+20>>2]|0,l=Wo(z|l,c)|0,c=U()|0,u[d>>2]=(u[d>>2]|0)+1)),b=pe(l|0,c|0,45)|0,U()|0,b=b&127;e:do if(zt(b)|0){t:do if((Ai(l,c)|0)==1){if((P|0)!=(b|0))if(Yb(b,u[7696+(P*28|0)>>2]|0)|0){l=Pm(l,c)|0,y=1,c=U()|0;break}else Ve(23313,22416,436,22424);switch(E|0){case 3:{l=Wo(l,c)|0,c=U()|0,u[d>>2]=(u[d>>2]|0)+1,y=0;break t}case 5:{l=Pm(l,c)|0,c=U()|0,u[d>>2]=(u[d>>2]|0)+5,y=0;break t}case 0:return z=9,z|0;default:return z=1,z|0}}else y=0;while(!1);if((f|0)>0){m=0;do l=Mm(l,c)|0,c=U()|0,m=m+1|0;while((m|0)!=(f|0))}if((P|0)!=(b|0)){if(!(ym(b)|0)){if((y|0)!=0|(Ai(l,c)|0)!=5)break;u[d>>2]=(u[d>>2]|0)+1;break}switch(N&127){case 8:case 118:break e;default:}(Ai(l,c)|0)!=3&&(u[d>>2]=(u[d>>2]|0)+1)}}else if((f|0)>0){m=0;do l=Wo(l,c)|0,c=U()|0,m=m+1|0;while((m|0)!=(f|0))}while(!1);return u[d>>2]=((u[d>>2]|0)+f|0)%6|0,z=p,u[z>>2]=l,u[z+4>>2]=c,z=0,z|0}function _m(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0;for(b=O,O=O+16|0,m=b,y=b+8|0,p=(Ht(l,c)|0)==0,p=p?1:2;;){if(u[y>>2]=0,w=(vr(l,c,p,y,m)|0)==0,E=m,w&((u[E>>2]|0)==(f|0)?(u[E+4>>2]|0)==(d|0):0)){l=4;break}if(p=p+1|0,p>>>0>=7){p=7,l=4;break}}return(l|0)==4?(O=b,p|0):0}function Y8(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0;if(z=O,O=O+16|0,G=z,j=z+8|0,N=G,u[N>>2]=l,u[N+4>>2]=c,!f)return j=d,u[j>>2]=l,u[j+4>>2]=c,j=0,O=z,j|0;u[j>>2]=0;e:do if(Ht(l,c)|0)l=9;else{if(m=(f|0)>0,m){p=0,N=l;do{if(l=vr(N,c,4,j,G)|0,l|0)break e;if(c=G,N=u[c>>2]|0,c=u[c+4>>2]|0,p=p+1|0,Ht(N,c)|0){l=9;break e}}while((p|0)<(f|0));if(P=d,u[P>>2]=N,u[P+4>>2]=c,P=f+-1|0,m){w=0,l=1;do{if(p=22384+(w<<2)|0,(w|0)==5)for(y=u[p>>2]|0,m=0,p=l;;){if(l=G,l=vr(u[l>>2]|0,u[l+4>>2]|0,y,j,G)|0,l|0)break e;if((m|0)!=(P|0))if(E=G,b=u[E>>2]|0,E=u[E+4>>2]|0,l=d+(p<<3)|0,u[l>>2]=b,u[l+4>>2]=E,!(Ht(b,E)|0))l=p+1|0;else{l=9;break e}else l=p;if(m=m+1|0,(m|0)>=(f|0))break;p=l}else for(y=G,E=u[p>>2]|0,b=0,p=l,m=u[y>>2]|0,y=u[y+4>>2]|0;;){if(l=vr(m,y,E,j,G)|0,l|0)break e;if(y=G,m=u[y>>2]|0,y=u[y+4>>2]|0,l=d+(p<<3)|0,u[l>>2]=m,u[l+4>>2]=y,l=p+1|0,Ht(m,y)|0){l=9;break e}if(b=b+1|0,(b|0)>=(f|0))break;p=l}w=w+1|0}while(w>>>0<6);l=G,y=N,p=u[l>>2]|0,m=c,l=u[l+4>>2]|0}else y=N,p=N,m=c,l=c}else y=d,u[y>>2]=l,u[y+4>>2]=c,y=l,p=l,m=c,l=c;l=(y|0)==(p|0)&(m|0)==(l|0)?0:9}while(!1);return j=l,O=z,j|0}function Q8(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0;if(b=O,O=O+48|0,p=b+16|0,m=b+8|0,y=b,f|0)return y=15,O=b,y|0;if(w=l,E=u[w+4>>2]|0,f=m,u[f>>2]=u[w>>2],u[f+4>>2]=E,gT(m,p),c=Kb(p,c,y)|0,!c){if(f=u[m>>2]|0,m=u[l+8>>2]|0,(m|0)>0){p=u[l+12>>2]|0,c=0;do f=(u[p+(c<<3)>>2]|0)+f|0,c=c+1|0;while((c|0)<(m|0))}c=y,p=u[c>>2]|0,c=u[c+4>>2]|0,m=((f|0)<0)<<31>>31,(c|0)<(m|0)|(c|0)==(m|0)&p>>>0>>0?(c=y,u[c>>2]=f,u[c+4>>2]=m,c=m):f=p,E=ot(f|0,c|0,12,0)|0,w=U()|0,c=y,u[c>>2]=E,u[c+4>>2]=w,c=d,u[c>>2]=E,u[c+4>>2]=w,c=0}return w=c,O=b,w|0}function jb(l,c,f,d,p,m,y){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,m=m|0,y=y|0;var b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0,St=0,dt=0,pt=0,Je=0,qe=0,Ze=0,It=0,je=0,Dt=0,$r=0,CT=0;if(It=O,O=O+64|0,pt=It+48|0,Je=It+32|0,qe=It+24|0,Se=It+8|0,Ie=It,E=u[l>>2]|0,(E|0)<=0)return Ze=0,O=It,Ze|0;for(be=l+4|0,we=pt+8|0,St=Je+8|0,dt=Se+8|0,b=0,ne=0;;){w=u[be>>2]|0,te=w+(ne<<4)|0,u[pt>>2]=u[te>>2],u[pt+4>>2]=u[te+4>>2],u[pt+8>>2]=u[te+8>>2],u[pt+12>>2]=u[te+12>>2],(ne|0)==(E+-1|0)?(u[Je>>2]=u[w>>2],u[Je+4>>2]=u[w+4>>2],u[Je+8>>2]=u[w+8>>2],u[Je+12>>2]=u[w+12>>2]):(te=w+(ne+1<<4)|0,u[Je>>2]=u[te>>2],u[Je+4>>2]=u[te+4>>2],u[Je+8>>2]=u[te+8>>2],u[Je+12>>2]=u[te+12>>2]),E=iO(pt,Je,d,qe)|0;e:do if(E)w=0,b=E;else if(w=qe,E=u[w>>2]|0,w=u[w+4>>2]|0,(w|0)>0|(w|0)==0&E>>>0>0){oe=0,te=0;t:for(;;){if(CT=+F[pt>>3],ce=Vr(E|0,w|0,oe|0,te|0)|0,$r=+(ce>>>0)+4294967296*+(U()|0),je=+(E>>>0)+4294967296*+(w|0),Dt=+(oe>>>0)+4294967296*+(te|0),F[Se>>3]=CT*$r/je+ +F[Je>>3]*Dt/je,F[dt>>3]=+F[we>>3]*$r/je+ +F[St>>3]*Dt/je,E=aT(Se,d,Ie)|0,E|0){b=E;break}ce=Ie,Z=u[ce>>2]|0,ce=u[ce+4>>2]|0,G=_c(Z|0,ce|0,c|0,f|0)|0,P=U()|0,E=y+(G<<3)|0,N=E,w=u[N>>2]|0,N=u[N+4>>2]|0;r:do if((w|0)==0&(N|0)==0)J=E,Ze=16;else for(j=0,z=0;;){if((j|0)>(f|0)|(j|0)==(f|0)&z>>>0>c>>>0){b=1;break t}if((w|0)==(Z|0)&(N|0)==(ce|0))break r;if(E=ot(G|0,P|0,1,0)|0,G=Wh(E|0,U()|0,c|0,f|0)|0,P=U()|0,z=ot(z|0,j|0,1,0)|0,j=U()|0,E=y+(G<<3)|0,N=E,w=u[N>>2]|0,N=u[N+4>>2]|0,(w|0)==0&(N|0)==0){J=E,Ze=16;break}}while(!1);if((Ze|0)==16&&(Ze=0,!((Z|0)==0&(ce|0)==0))&&(z=J,u[z>>2]=Z,u[z+4>>2]=ce,z=m+(u[p>>2]<<3)|0,u[z>>2]=Z,u[z+4>>2]=ce,z=p,z=ot(u[z>>2]|0,u[z+4>>2]|0,1,0)|0,Z=U()|0,ce=p,u[ce>>2]=z,u[ce+4>>2]=Z),oe=ot(oe|0,te|0,1,0)|0,te=U()|0,w=qe,E=u[w>>2]|0,w=u[w+4>>2]|0,!((w|0)>(te|0)|(w|0)==(te|0)&E>>>0>oe>>>0)){w=1;break e}}w=0}else w=1;while(!1);if(ne=ne+1|0,!w){Ze=21;break}if(E=u[l>>2]|0,(ne|0)>=(E|0)){b=0,Ze=21;break}}return(Ze|0)==21?(O=It,b|0):0}function q8(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0,St=0,dt=0,pt=0,Je=0,qe=0,Ze=0,It=0,je=0,Dt=0,$r=0;if($r=O,O=O+112|0,Ze=$r+80|0,E=$r+72|0,It=$r,je=$r+56|0,f|0)return Dt=15,O=$r,Dt|0;if(w=l+8|0,Dt=Rn((u[w>>2]<<5)+32|0)|0,!Dt)return Dt=13,O=$r,Dt|0;if(sF(l,Dt),Je=l,qe=u[Je+4>>2]|0,f=E,u[f>>2]=u[Je>>2],u[f+4>>2]=qe,gT(E,Ze),f=Kb(Ze,c,It)|0,f)Je=0,qe=0;else{if(f=u[E>>2]|0,m=u[w>>2]|0,(m|0)>0){y=u[l+12>>2]|0,p=0;do f=(u[y+(p<<3)>>2]|0)+f|0,p=p+1|0;while((p|0)!=(m|0));p=f}else p=f;f=It,m=u[f>>2]|0,f=u[f+4>>2]|0,y=((p|0)<0)<<31>>31,(f|0)<(y|0)|(f|0)==(y|0)&m>>>0

>>0?(f=It,u[f>>2]=p,u[f+4>>2]=y,f=y):p=m,Je=ot(p|0,f|0,12,0)|0,qe=U()|0,f=It,u[f>>2]=Je,u[f+4>>2]=qe,f=0}if(f|0)return We(Dt),Dt=f,O=$r,Dt|0;if(p=Bn(Je,8)|0,!p)return We(Dt),Dt=13,O=$r,Dt|0;if(b=Bn(Je,8)|0,!b)return We(Dt),We(p),Dt=13,O=$r,Dt|0;dt=Ze,u[dt>>2]=0,u[dt+4>>2]=0,dt=l,pt=u[dt+4>>2]|0,f=E,u[f>>2]=u[dt>>2],u[f+4>>2]=pt,f=jb(E,Je,qe,c,Ze,p,b)|0;e:do if(f)We(p),We(b),We(Dt);else{t:do if((u[w>>2]|0)>0){for(y=l+12|0,m=0;f=jb((u[y>>2]|0)+(m<<3)|0,Je,qe,c,Ze,p,b)|0,m=m+1|0,!(f|0);)if((m|0)>=(u[w>>2]|0))break t;We(p),We(b),We(Dt);break e}while(!1);(qe|0)>0|(qe|0)==0&Je>>>0>0&&Xo(b|0,0,Je<<3|0)|0,pt=Ze,dt=u[pt+4>>2]|0;t:do if((dt|0)>0|(dt|0)==0&(u[pt>>2]|0)>>>0>0){be=p,we=b,St=p,dt=b,pt=p,f=p,J=p,Se=b,Ie=b,p=b;r:for(;;){for(ce=0,oe=0,te=0,ne=0,m=0,y=0;;){b=It,E=b+56|0;do u[b>>2]=0,b=b+4|0;while((b|0)<(E|0));if(c=be+(ce<<3)|0,w=u[c>>2]|0,c=u[c+4>>2]|0,Wb(w,c,1,It,0)|0){b=It,E=b+56|0;do u[b>>2]=0,b=b+4|0;while((b|0)<(E|0));b=Bn(7,4)|0,b|0&&(cs(w,c,1,It,b,7,0,0)|0,We(b))}for(Z=0;;){z=It+(Z<<3)|0,j=u[z>>2]|0,z=u[z+4>>2]|0;i:do if((j|0)==0&(z|0)==0)b=m,E=y;else{if(P=_c(j|0,z|0,Je|0,qe|0)|0,w=U()|0,b=d+(P<<3)|0,c=b,E=u[c>>2]|0,c=u[c+4>>2]|0,!((E|0)==0&(c|0)==0)){N=0,G=0;do{if((N|0)>(qe|0)|(N|0)==(qe|0)&G>>>0>Je>>>0)break r;if((E|0)==(j|0)&(c|0)==(z|0)){b=m,E=y;break i}b=ot(P|0,w|0,1,0)|0,P=Wh(b|0,U()|0,Je|0,qe|0)|0,w=U()|0,G=ot(G|0,N|0,1,0)|0,N=U()|0,b=d+(P<<3)|0,c=b,E=u[c>>2]|0,c=u[c+4>>2]|0}while(!((E|0)==0&(c|0)==0))}(j|0)==0&(z|0)==0?(b=m,E=y):(fA(j,z,je)|0,oF(l,Dt,je)|0&&(G=ot(m|0,y|0,1,0)|0,y=U()|0,N=b,u[N>>2]=j,u[N+4>>2]=z,m=we+(m<<3)|0,u[m>>2]=j,u[m+4>>2]=z,m=G),b=m,E=y)}while(!1);if(Z=Z+1|0,Z>>>0>=7)break;m=b,y=E}if(ce=ot(ce|0,oe|0,1,0)|0,oe=U()|0,te=ot(te|0,ne|0,1,0)|0,ne=U()|0,y=Ze,m=u[y>>2]|0,y=u[y+4>>2]|0,(ne|0)<(y|0)|(ne|0)==(y|0)&te>>>0>>0)m=b,y=E;else break}if((y|0)>0|(y|0)==0&m>>>0>0){m=0,y=0;do ne=be+(m<<3)|0,u[ne>>2]=0,u[ne+4>>2]=0,m=ot(m|0,y|0,1,0)|0,y=U()|0,ne=Ze,te=u[ne+4>>2]|0;while((y|0)<(te|0)|((y|0)==(te|0)?m>>>0<(u[ne>>2]|0)>>>0:0))}if(ne=Ze,u[ne>>2]=b,u[ne+4>>2]=E,(E|0)>0|(E|0)==0&b>>>0>0)Z=p,ce=Ie,oe=pt,te=Se,ne=we,p=J,Ie=f,Se=St,J=Z,f=ce,pt=dt,dt=oe,St=te,we=be,be=ne;else break t}We(St),We(dt),We(Dt),f=1;break e}else f=b;while(!1);We(Dt),We(p),We(f),f=0}while(!1);return Dt=f,O=$r,Dt|0}function K8(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(P=O,O=O+176|0,E=P,(c|0)<1)return yT(f,0,0),w=0,O=P,w|0;for(b=l,b=pe(u[b>>2]|0,u[b+4>>2]|0,52)|0,U()|0,yT(f,(c|0)>6?c:6,b&15),b=0;d=l+(b<<3)|0,d=hA(u[d>>2]|0,u[d+4>>2]|0,E)|0,!(d|0);){if(d=u[E>>2]|0,(d|0)>0){y=0;do m=E+8+(y<<4)|0,y=y+1|0,d=E+8+(((y|0)%(d|0)|0)<<4)|0,p=TF(f,d,m)|0,p?TT(f,p)|0:bF(f,m,d)|0,d=u[E>>2]|0;while((y|0)<(d|0))}if(b=b+1|0,(b|0)>=(c|0)){d=0,w=13;break}}return(w|0)==13?(O=P,d|0):(xT(f),w=d,O=P,w|0)}function J8(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;if(m=O,O=O+32|0,d=m,p=m+16|0,l=K8(l,c,p)|0,l|0)return f=l,O=m,f|0;if(u[f>>2]=0,u[f+4>>2]=0,u[f+8>>2]=0,l=bT(p)|0,l|0)do{c=JO(f)|0;do ZO(c,l)|0,y=l+16|0,u[d>>2]=u[y>>2],u[d+4>>2]=u[y+4>>2],u[d+8>>2]=u[y+8>>2],u[d+12>>2]=u[y+12>>2],TT(p,l)|0,l=EF(p,d)|0;while(l|0);l=bT(p)|0}while(l|0);return xT(p),l=$O(f)|0,l?(fT(f),y=l,O=m,y|0):(y=0,O=m,y|0)}function zt(l){return l=l|0,l>>>0>121?(l=0,l|0):(l=u[7696+(l*28|0)+16>>2]|0,l|0)}function ym(l){return l=l|0,(l|0)==4|(l|0)==117|0}function Xb(l){return l=l|0,u[11120+((u[l>>2]|0)*216|0)+((u[l+4>>2]|0)*72|0)+((u[l+8>>2]|0)*24|0)+(u[l+12>>2]<<3)>>2]|0}function Z8(l){return l=l|0,u[11120+((u[l>>2]|0)*216|0)+((u[l+4>>2]|0)*72|0)+((u[l+8>>2]|0)*24|0)+(u[l+12>>2]<<3)+4>>2]|0}function $8(l,c){l=l|0,c=c|0,l=7696+(l*28|0)|0,u[c>>2]=u[l>>2],u[c+4>>2]=u[l+4>>2],u[c+8>>2]=u[l+8>>2],u[c+12>>2]=u[l+12>>2]}function eO(l,c){l=l|0,c=c|0;var f=0,d=0;if(c>>>0>20)return c=-1,c|0;do if((u[11120+(c*216|0)>>2]|0)!=(l|0))if((u[11120+(c*216|0)+8>>2]|0)!=(l|0))if((u[11120+(c*216|0)+16>>2]|0)!=(l|0))if((u[11120+(c*216|0)+24>>2]|0)!=(l|0))if((u[11120+(c*216|0)+32>>2]|0)!=(l|0))if((u[11120+(c*216|0)+40>>2]|0)!=(l|0))if((u[11120+(c*216|0)+48>>2]|0)!=(l|0))if((u[11120+(c*216|0)+56>>2]|0)!=(l|0))if((u[11120+(c*216|0)+64>>2]|0)!=(l|0))if((u[11120+(c*216|0)+72>>2]|0)!=(l|0))if((u[11120+(c*216|0)+80>>2]|0)!=(l|0))if((u[11120+(c*216|0)+88>>2]|0)!=(l|0))if((u[11120+(c*216|0)+96>>2]|0)!=(l|0))if((u[11120+(c*216|0)+104>>2]|0)!=(l|0))if((u[11120+(c*216|0)+112>>2]|0)!=(l|0))if((u[11120+(c*216|0)+120>>2]|0)!=(l|0))if((u[11120+(c*216|0)+128>>2]|0)!=(l|0))if((u[11120+(c*216|0)+136>>2]|0)==(l|0))l=2,f=1,d=2;else{if((u[11120+(c*216|0)+144>>2]|0)==(l|0)){l=0,f=2,d=0;break}if((u[11120+(c*216|0)+152>>2]|0)==(l|0)){l=0,f=2,d=1;break}if((u[11120+(c*216|0)+160>>2]|0)==(l|0)){l=0,f=2,d=2;break}if((u[11120+(c*216|0)+168>>2]|0)==(l|0)){l=1,f=2,d=0;break}if((u[11120+(c*216|0)+176>>2]|0)==(l|0)){l=1,f=2,d=1;break}if((u[11120+(c*216|0)+184>>2]|0)==(l|0)){l=1,f=2,d=2;break}if((u[11120+(c*216|0)+192>>2]|0)==(l|0)){l=2,f=2,d=0;break}if((u[11120+(c*216|0)+200>>2]|0)==(l|0)){l=2,f=2,d=1;break}if((u[11120+(c*216|0)+208>>2]|0)==(l|0)){l=2,f=2,d=2;break}else l=-1;return l|0}else l=2,f=1,d=1;else l=2,f=1,d=0;else l=1,f=1,d=2;else l=1,f=1,d=1;else l=1,f=1,d=0;else l=0,f=1,d=2;else l=0,f=1,d=1;else l=0,f=1,d=0;else l=2,f=0,d=2;else l=2,f=0,d=1;else l=2,f=0,d=0;else l=1,f=0,d=2;else l=1,f=0,d=1;else l=1,f=0,d=0;else l=0,f=0,d=2;else l=0,f=0,d=1;else l=0,f=0,d=0;while(!1);return c=u[11120+(c*216|0)+(f*72|0)+(l*24|0)+(d<<3)+4>>2]|0,c|0}function Yb(l,c){return l=l|0,c=c|0,(u[7696+(l*28|0)+20>>2]|0)==(c|0)?(c=1,c|0):(c=(u[7696+(l*28|0)+24>>2]|0)==(c|0),c|0)}function xm(l,c){return l=l|0,c=c|0,u[848+(l*28|0)+(c<<2)>>2]|0}function bm(l,c){return l=l|0,c=c|0,(u[848+(l*28|0)>>2]|0)==(c|0)?(c=0,c|0):(u[848+(l*28|0)+4>>2]|0)==(c|0)?(c=1,c|0):(u[848+(l*28|0)+8>>2]|0)==(c|0)?(c=2,c|0):(u[848+(l*28|0)+12>>2]|0)==(c|0)?(c=3,c|0):(u[848+(l*28|0)+16>>2]|0)==(c|0)?(c=4,c|0):(u[848+(l*28|0)+20>>2]|0)==(c|0)?(c=5,c|0):((u[848+(l*28|0)+24>>2]|0)==(c|0)?6:7)|0}function tO(){return 122}function rO(l){l=l|0;var c=0,f=0,d=0;c=0;do Te(c|0,0,45)|0,d=U()|0|134225919,f=l+(c<<3)|0,u[f>>2]=-1,u[f+4>>2]=d,c=c+1|0;while((c|0)!=122);return 0}function Qb(l){return l=l|0,+F[l+16>>3]<+F[l+24>>3]|0}function qb(l,c){l=l|0,c=c|0;var f=0,d=0,p=0;return f=+F[c>>3],!(f>=+F[l+8>>3])||!(f<=+F[l>>3])?(c=0,c|0):(d=+F[l+16>>3],f=+F[l+24>>3],p=+F[c+8>>3],c=p>=f,l=p<=d&1,d>2]=0,b=b+4|0;while((b|0)<(E|0));return c=Rm(c,w)|0,c|0?(j=c,O=z,j|0):(E=w,w=u[E>>2]|0,E=u[E+4>>2]|0,fA(w,E,P)|0,hA(w,E,N)|0,y=+pA(P,N+8|0),F[P>>3]=+F[l>>3],E=P+8|0,F[E>>3]=+F[l+16>>3],F[N>>3]=+F[l+8>>3],w=N+8|0,F[w>>3]=+F[l+24>>3],p=+pA(P,N),ce=+F[E>>3]-+F[w>>3],m=+vt(+ce),Z=+F[P>>3]-+F[N>>3],d=+vt(+Z),!(ce==0|Z==0)&&(ce=+ST(+m,+d),ce=+dc(+(p*p/+Lm(+(ce/+Lm(+m,+d)),3)/(y*(y*2.59807621135)*.8))),F[br>>3]=ce,G=~~ce>>>0,j=+vt(ce)>=1?ce>0?~~+mm(+Tr(ce/4294967296),4294967295)>>>0:~~+dc((ce-+(~~ce>>>0))/4294967296)>>>0:0,(u[br+4>>2]&2146435072|0)!=2146435072)?(N=(G|0)==0&(j|0)==0,c=f,u[c>>2]=N?1:G,u[c+4>>2]=N?0:j,c=0):c=1,j=c,O=z,j|0)}function iO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0;w=O,O=O+288|0,y=w+264|0,b=w+96|0,E=w,p=E,m=p+96|0;do u[p>>2]=0,p=p+4|0;while((p|0)<(m|0));return f=Rm(f,E)|0,f|0?(d=f,O=w,d|0):(f=E,p=u[f>>2]|0,f=u[f+4>>2]|0,fA(p,f,y)|0,hA(p,f,b)|0,P=+pA(y,b+8|0),P=+dc(+(+pA(l,c)/(P*2))),F[br>>3]=P,f=~~P>>>0,p=+vt(P)>=1?P>0?~~+mm(+Tr(P/4294967296),4294967295)>>>0:~~+dc((P-+(~~P>>>0))/4294967296)>>>0:0,(u[br+4>>2]&2146435072|0)==2146435072?(d=1,O=w,d|0):(E=(f|0)==0&(p|0)==0,u[d>>2]=E?1:f,u[d+4>>2]=E?0:p,d=0,O=w,d|0))}function nO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0,u[l>>2]=c,u[l+4>>2]=f,u[l+8>>2]=d}function sO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0;N=c+8|0,u[N>>2]=0,E=+F[l>>3],y=+vt(+E),w=+F[l+8>>3],b=+vt(+w)/.8660254037844386,y=y+b*.5,f=~~y,l=~~b,y=y-+(f|0),b=b-+(l|0);do if(y<.5)if(y<.3333333333333333)if(u[c>>2]=f,b<(y+1)*.5){u[c+4>>2]=l;break}else{l=l+1|0,u[c+4>>2]=l;break}else if(G=1-y,l=(!(b>2]=l,G<=b&b>2]=f;break}else{u[c>>2]=f;break}else{if(!(y<.6666666666666666))if(f=f+1|0,u[c>>2]=f,b>2]=l;break}else{l=l+1|0,u[c+4>>2]=l;break}if(b<1-y){if(u[c+4>>2]=l,y*2+-1>2]=f;break}}else l=l+1|0,u[c+4>>2]=l;f=f+1|0,u[c>>2]=f}while(!1);do if(E<0)if(l&1){P=(l+1|0)/2|0,P=Vr(f|0,((f|0)<0)<<31>>31|0,P|0,((P|0)<0)<<31>>31|0)|0,f=~~(+(f|0)-((+(P>>>0)+4294967296*+(U()|0))*2+1)),u[c>>2]=f;break}else{P=(l|0)/2|0,P=Vr(f|0,((f|0)<0)<<31>>31|0,P|0,((P|0)<0)<<31>>31|0)|0,f=~~(+(f|0)-(+(P>>>0)+4294967296*+(U()|0))*2),u[c>>2]=f;break}while(!1);P=c+4|0,w<0&&(f=f-((l<<1|1|0)/2|0)|0,u[c>>2]=f,l=0-l|0,u[P>>2]=l),d=l-f|0,(f|0)<0?(p=0-f|0,u[P>>2]=d,u[N>>2]=p,u[c>>2]=0,l=d,f=0):p=0,(l|0)<0&&(f=f-l|0,u[c>>2]=f,p=p-l|0,u[N>>2]=p,u[P>>2]=0,l=0),m=f-p|0,d=l-p|0,(p|0)<0&&(u[c>>2]=m,u[P>>2]=d,u[N>>2]=0,l=d,f=m,p=0),d=(l|0)<(f|0)?l:f,d=(p|0)<(d|0)?p:d,!((d|0)<=0)&&(u[c>>2]=f-d,u[P>>2]=l-d,u[N>>2]=p-d)}function kr(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0;c=u[l>>2]|0,y=l+4|0,f=u[y>>2]|0,(c|0)<0&&(f=f-c|0,u[y>>2]=f,m=l+8|0,u[m>>2]=(u[m>>2]|0)-c,u[l>>2]=0,c=0),(f|0)<0?(c=c-f|0,u[l>>2]=c,m=l+8|0,p=(u[m>>2]|0)-f|0,u[m>>2]=p,u[y>>2]=0,f=0):(p=l+8|0,m=p,p=u[p>>2]|0),(p|0)<0&&(c=c-p|0,u[l>>2]=c,f=f-p|0,u[y>>2]=f,u[m>>2]=0,p=0),d=(f|0)<(c|0)?f:c,d=(p|0)<(d|0)?p:d,!((d|0)<=0)&&(u[l>>2]=c-d,u[y>>2]=f-d,u[m>>2]=p-d)}function zo(l,c){l=l|0,c=c|0;var f=0,d=0;d=u[l+8>>2]|0,f=+((u[l+4>>2]|0)-d|0),F[c>>3]=+((u[l>>2]|0)-d|0)-f*.5,F[c+8>>3]=f*.8660254037844386}function Zr(l,c,f){l=l|0,c=c|0,f=f|0,u[f>>2]=(u[c>>2]|0)+(u[l>>2]|0),u[f+4>>2]=(u[c+4>>2]|0)+(u[l+4>>2]|0),u[f+8>>2]=(u[c+8>>2]|0)+(u[l+8>>2]|0)}function Tm(l,c,f){l=l|0,c=c|0,f=f|0,u[f>>2]=(u[l>>2]|0)-(u[c>>2]|0),u[f+4>>2]=(u[l+4>>2]|0)-(u[c+4>>2]|0),u[f+8>>2]=(u[l+8>>2]|0)-(u[c+8>>2]|0)}function Jb(l,c){l=l|0,c=c|0;var f=0,d=0;f=In(u[l>>2]|0,c)|0,u[l>>2]=f,f=l+4|0,d=In(u[f>>2]|0,c)|0,u[f>>2]=d,l=l+8|0,c=In(u[l>>2]|0,c)|0,u[l>>2]=c}function kh(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;y=u[l>>2]|0,b=(y|0)<0,d=(u[l+4>>2]|0)-(b?y:0)|0,m=(d|0)<0,p=(m?0-d|0:0)+((u[l+8>>2]|0)-(b?y:0))|0,f=(p|0)<0,l=f?0:p,c=(m?0:d)-(f?p:0)|0,p=(b?0:y)-(m?d:0)-(f?p:0)|0,f=(c|0)<(p|0)?c:p,f=(l|0)<(f|0)?l:f,d=(f|0)>0,l=l-(d?f:0)|0,c=c-(d?f:0)|0;e:do switch(p-(d?f:0)|0){case 0:switch(c|0){case 0:return b=l|0?(l|0)==1?1:7:0,b|0;case 1:return b=l|0?(l|0)==1?3:7:2,b|0;default:break e}case 1:switch(c|0){case 0:return b=l|0?(l|0)==1?5:7:4,b|0;case 1:{if(!l)l=6;else break e;return l|0}default:break e}default:}while(!1);return b=7,b|0}function oO(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;y=l+8|0,p=u[y>>2]|0,m=(u[l>>2]|0)-p|0,b=l+4|0,p=(u[b>>2]|0)-p|0;do if(m>>>0>715827881|p>>>0>715827881){if(f=(m|0)>0,f){if((2147483647-m|0)<(m|0)||(2147483647-(m<<1)|0)<(m|0))return b=1,b|0}else if((-2147483648-m|0)>(m|0)||(-2147483648-(m<<1)|0)>(m|0))return b=1,b|0;if(c=m*3|0,(p|0)>0){if((2147483647-p|0)<(p|0))return b=1,b|0}else if((-2147483648-p|0)>(p|0))return b=1,b|0;if(d=p<<1,(m|0)>-1){if((c|-2147483648|0)>=(p|0))return b=1,b|0}else if((c^-2147483648|0)<(p|0))return b=1,b|0;if(f){if((2147483647-m|0)<(d|0))c=1;else{f=d;break}return c|0}else{if((-2147483648-m|0)>(d|0))c=1;else{f=d;break}return c|0}}else f=p<<1,c=m*3|0;while(!1);d=js(+(c-p|0)/7)|0,u[l>>2]=d,p=js(+(f+m|0)/7)|0,u[b>>2]=p,u[y>>2]=0,f=(p|0)<(d|0),c=f?d:p,f=f?p:d;do if((f|0)<0){if((c|0)>0){if((c|-2147483648|0)<(f|0)&((f|0)!=-2147483648&(2147483647-c|0)>=(f|0)))break;Ve(23313,22444,355,22455)}if((f|0)==-2147483648|(-2147483648-c|0)>(f|0)&&Ve(23313,22444,355,22455),(c|0)>-1){if((c|-2147483648|0)<(f|0))break;Ve(23313,22444,355,22455)}else{if((c^-2147483648|0)>=(f|0))break;Ve(23313,22444,355,22455)}}while(!1);return c=p-d|0,(d|0)<0?(f=0-d|0,u[b>>2]=c,u[y>>2]=f,u[l>>2]=0,d=0):(c=p,f=0),(c|0)<0&&(d=d-c|0,u[l>>2]=d,f=f-c|0,u[y>>2]=f,u[b>>2]=0,c=0),m=d-f|0,p=c-f|0,(f|0)<0?(u[l>>2]=m,u[b>>2]=p,u[y>>2]=0,c=p,p=m,f=0):p=d,d=(c|0)<(p|0)?c:p,d=(f|0)<(d|0)?f:d,(d|0)<=0?(b=0,b|0):(u[l>>2]=p-d,u[b>>2]=c-d,u[y>>2]=f-d,b=0,b|0)}function aO(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;y=l+8|0,p=u[y>>2]|0,m=(u[l>>2]|0)-p|0,b=l+4|0,p=(u[b>>2]|0)-p|0;do if(m>>>0>715827881|p>>>0>715827881){if(f=(m|0)>0,f){if((2147483647-m|0)<(m|0))return b=1,b|0}else if((-2147483648-m|0)>(m|0))return b=1,b|0;if(c=m<<1,(p|0)>0){if((2147483647-p|0)<(p|0)||(2147483647-(p<<1)|0)<(p|0))return b=1,b|0}else if((-2147483648-p|0)>(p|0)||(-2147483648-(p<<1)|0)>(p|0))return b=1,b|0;if(d=p*3|0,f){if((2147483647-c|0)<(p|0))return b=1,b|0}else if((-2147483648-c|0)>(p|0))return b=1,b|0;if((p|0)>-1){if((d|-2147483648|0)<(m|0)){f=d;break}else c=1;return c|0}else{if((d^-2147483648|0)<(m|0))c=1;else{f=d;break}return c|0}}else f=p*3|0,c=m<<1;while(!1);d=js(+(c+p|0)/7)|0,u[l>>2]=d,p=js(+(f-m|0)/7)|0,u[b>>2]=p,u[y>>2]=0,f=(p|0)<(d|0),c=f?d:p,f=f?p:d;do if((f|0)<0){if((c|0)>0){if((c|-2147483648|0)<(f|0)&((f|0)!=-2147483648&(2147483647-c|0)>=(f|0)))break;Ve(23313,22444,404,22469)}if((f|0)==-2147483648|(-2147483648-c|0)>(f|0)&&Ve(23313,22444,404,22469),(c|0)>-1){if((c|-2147483648|0)<(f|0))break;Ve(23313,22444,404,22469)}else{if((c^-2147483648|0)>=(f|0))break;Ve(23313,22444,404,22469)}}while(!1);return c=p-d|0,(d|0)<0?(f=0-d|0,u[b>>2]=c,u[y>>2]=f,u[l>>2]=0,d=0):(c=p,f=0),(c|0)<0&&(d=d-c|0,u[l>>2]=d,f=f-c|0,u[y>>2]=f,u[b>>2]=0,c=0),m=d-f|0,p=c-f|0,(f|0)<0?(u[l>>2]=m,u[b>>2]=p,u[y>>2]=0,c=p,p=m,f=0):p=d,d=(c|0)<(p|0)?c:p,d=(f|0)<(d|0)?f:d,(d|0)<=0?(b=0,b|0):(u[l>>2]=p-d,u[b>>2]=c-d,u[y>>2]=f-d,b=0,b|0)}function cO(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;y=l+8|0,f=u[y>>2]|0,c=(u[l>>2]|0)-f|0,b=l+4|0,f=(u[b>>2]|0)-f|0,d=js(+((c*3|0)-f|0)/7)|0,u[l>>2]=d,c=js(+((f<<1)+c|0)/7)|0,u[b>>2]=c,u[y>>2]=0,f=c-d|0,(d|0)<0?(m=0-d|0,u[b>>2]=f,u[y>>2]=m,u[l>>2]=0,c=f,d=0,f=m):f=0,(c|0)<0&&(d=d-c|0,u[l>>2]=d,f=f-c|0,u[y>>2]=f,u[b>>2]=0,c=0),m=d-f|0,p=c-f|0,(f|0)<0?(u[l>>2]=m,u[b>>2]=p,u[y>>2]=0,c=p,p=m,f=0):p=d,d=(c|0)<(p|0)?c:p,d=(f|0)<(d|0)?f:d,!((d|0)<=0)&&(u[l>>2]=p-d,u[b>>2]=c-d,u[y>>2]=f-d)}function Zb(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;y=l+8|0,f=u[y>>2]|0,c=(u[l>>2]|0)-f|0,b=l+4|0,f=(u[b>>2]|0)-f|0,d=js(+((c<<1)+f|0)/7)|0,u[l>>2]=d,c=js(+((f*3|0)-c|0)/7)|0,u[b>>2]=c,u[y>>2]=0,f=c-d|0,(d|0)<0?(m=0-d|0,u[b>>2]=f,u[y>>2]=m,u[l>>2]=0,c=f,d=0,f=m):f=0,(c|0)<0&&(d=d-c|0,u[l>>2]=d,f=f-c|0,u[y>>2]=f,u[b>>2]=0,c=0),m=d-f|0,p=c-f|0,(f|0)<0?(u[l>>2]=m,u[b>>2]=p,u[y>>2]=0,c=p,p=m,f=0):p=d,d=(c|0)<(p|0)?c:p,d=(f|0)<(d|0)?f:d,!((d|0)<=0)&&(u[l>>2]=p-d,u[b>>2]=c-d,u[y>>2]=f-d)}function Vh(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;c=u[l>>2]|0,y=l+4|0,f=u[y>>2]|0,b=l+8|0,d=u[b>>2]|0,p=f+(c*3|0)|0,u[l>>2]=p,f=d+(f*3|0)|0,u[y>>2]=f,c=(d*3|0)+c|0,u[b>>2]=c,d=f-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=d,u[b>>2]=c,u[l>>2]=0,f=d,d=0):d=p,(f|0)<0&&(d=d-f|0,u[l>>2]=d,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=d-c|0,p=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=p,u[b>>2]=0,d=m,c=0):p=f,f=(p|0)<(d|0)?p:d,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=d-f,u[y>>2]=p-f,u[b>>2]=c-f)}function Ho(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;p=u[l>>2]|0,y=l+4|0,c=u[y>>2]|0,b=l+8|0,f=u[b>>2]|0,d=(c*3|0)+p|0,p=f+(p*3|0)|0,u[l>>2]=p,u[y>>2]=d,c=(f*3|0)+c|0,u[b>>2]=c,f=d-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=f,u[b>>2]=c,u[l>>2]=0,p=0):f=d,(f|0)<0&&(p=p-f|0,u[l>>2]=p,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=p-c|0,d=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=d,u[b>>2]=0,p=m,c=0):d=f,f=(d|0)<(p|0)?d:p,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=p-f,u[y>>2]=d-f,u[b>>2]=c-f)}function $b(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0;(c+-1|0)>>>0>=6||(p=(u[15440+(c*12|0)>>2]|0)+(u[l>>2]|0)|0,u[l>>2]=p,b=l+4|0,d=(u[15440+(c*12|0)+4>>2]|0)+(u[b>>2]|0)|0,u[b>>2]=d,y=l+8|0,c=(u[15440+(c*12|0)+8>>2]|0)+(u[y>>2]|0)|0,u[y>>2]=c,f=d-p|0,(p|0)<0?(c=c-p|0,u[b>>2]=f,u[y>>2]=c,u[l>>2]=0,d=0):(f=d,d=p),(f|0)<0&&(d=d-f|0,u[l>>2]=d,c=c-f|0,u[y>>2]=c,u[b>>2]=0,f=0),m=d-c|0,p=f-c|0,(c|0)<0?(u[l>>2]=m,u[b>>2]=p,u[y>>2]=0,d=m,c=0):p=f,f=(p|0)<(d|0)?p:d,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=d-f,u[b>>2]=p-f,u[y>>2]=c-f))}function eT(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;p=u[l>>2]|0,y=l+4|0,c=u[y>>2]|0,b=l+8|0,f=u[b>>2]|0,d=c+p|0,p=f+p|0,u[l>>2]=p,u[y>>2]=d,c=f+c|0,u[b>>2]=c,f=d-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=f,u[b>>2]=c,u[l>>2]=0,d=0):(f=d,d=p),(f|0)<0&&(d=d-f|0,u[l>>2]=d,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=d-c|0,p=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=p,u[b>>2]=0,d=m,c=0):p=f,f=(p|0)<(d|0)?p:d,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=d-f,u[y>>2]=p-f,u[b>>2]=c-f)}function zh(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;c=u[l>>2]|0,y=l+4|0,d=u[y>>2]|0,b=l+8|0,f=u[b>>2]|0,p=d+c|0,u[l>>2]=p,d=f+d|0,u[y>>2]=d,c=f+c|0,u[b>>2]=c,f=d-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=f,u[b>>2]=c,u[l>>2]=0,d=0):(f=d,d=p),(f|0)<0&&(d=d-f|0,u[l>>2]=d,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=d-c|0,p=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=p,u[b>>2]=0,d=m,c=0):p=f,f=(p|0)<(d|0)?p:d,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=d-f,u[y>>2]=p-f,u[b>>2]=c-f)}function Go(l){switch(l=l|0,l|0){case 1:{l=5;break}case 5:{l=4;break}case 4:{l=6;break}case 6:{l=2;break}case 2:{l=3;break}case 3:{l=1;break}default:}return l|0}function Gs(l){switch(l=l|0,l|0){case 1:{l=3;break}case 3:{l=2;break}case 2:{l=6;break}case 6:{l=4;break}case 4:{l=5;break}case 5:{l=1;break}default:}return l|0}function tT(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;c=u[l>>2]|0,y=l+4|0,f=u[y>>2]|0,b=l+8|0,d=u[b>>2]|0,p=f+(c<<1)|0,u[l>>2]=p,f=d+(f<<1)|0,u[y>>2]=f,c=(d<<1)+c|0,u[b>>2]=c,d=f-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=d,u[b>>2]=c,u[l>>2]=0,f=d,d=0):d=p,(f|0)<0&&(d=d-f|0,u[l>>2]=d,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=d-c|0,p=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=p,u[b>>2]=0,d=m,c=0):p=f,f=(p|0)<(d|0)?p:d,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=d-f,u[y>>2]=p-f,u[b>>2]=c-f)}function rT(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;p=u[l>>2]|0,y=l+4|0,c=u[y>>2]|0,b=l+8|0,f=u[b>>2]|0,d=(c<<1)+p|0,p=f+(p<<1)|0,u[l>>2]=p,u[y>>2]=d,c=(f<<1)+c|0,u[b>>2]=c,f=d-p|0,(p|0)<0?(c=c-p|0,u[y>>2]=f,u[b>>2]=c,u[l>>2]=0,p=0):f=d,(f|0)<0&&(p=p-f|0,u[l>>2]=p,c=c-f|0,u[b>>2]=c,u[y>>2]=0,f=0),m=p-c|0,d=f-c|0,(c|0)<0?(u[l>>2]=m,u[y>>2]=d,u[b>>2]=0,p=m,c=0):d=f,f=(d|0)<(p|0)?d:p,f=(c|0)<(f|0)?c:f,!((f|0)<=0)&&(u[l>>2]=p-f,u[y>>2]=d-f,u[b>>2]=c-f)}function Em(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0;return y=(u[l>>2]|0)-(u[c>>2]|0)|0,b=(y|0)<0,d=(u[l+4>>2]|0)-(u[c+4>>2]|0)-(b?y:0)|0,m=(d|0)<0,p=(b?0-y|0:0)+(u[l+8>>2]|0)-(u[c+8>>2]|0)+(m?0-d|0:0)|0,l=(p|0)<0,c=l?0:p,f=(m?0:d)-(l?p:0)|0,p=(b?0:y)-(m?d:0)-(l?p:0)|0,l=(f|0)<(p|0)?f:p,l=(c|0)<(l|0)?c:l,d=(l|0)>0,c=c-(d?l:0)|0,f=f-(d?l:0)|0,l=p-(d?l:0)|0,l=(l|0)>-1?l:0-l|0,f=(f|0)>-1?f:0-f|0,c=(c|0)>-1?c:0-c|0,c=(f|0)>(c|0)?f:c,((l|0)>(c|0)?l:c)|0}function lO(l,c){l=l|0,c=c|0;var f=0;f=u[l+8>>2]|0,u[c>>2]=(u[l>>2]|0)-f,u[c+4>>2]=(u[l+4>>2]|0)-f}function AO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0;d=u[l>>2]|0,u[c>>2]=d,p=u[l+4>>2]|0,y=c+4|0,u[y>>2]=p,b=c+8|0,u[b>>2]=0,f=(p|0)<(d|0),l=f?d:p,f=f?p:d;do if((f|0)<0){if((l|0)>0){if((l|-2147483648|0)<(f|0)&((f|0)!=-2147483648&(2147483647-l|0)>=(f|0)))break;return l=1,l|0}if((f|0)==-2147483648|(-2147483648-l|0)>(f|0))return c=1,c|0;if((l|0)>-1){if((l|-2147483648|0)<(f|0))break;return l=1,l|0}else{if((l^-2147483648|0)<(f|0))l=1;else break;return l|0}}while(!1);return l=p-d|0,(d|0)<0?(f=0-d|0,u[y>>2]=l,u[b>>2]=f,u[c>>2]=0,d=0):(l=p,f=0),(l|0)<0&&(d=d-l|0,u[c>>2]=d,f=f-l|0,u[b>>2]=f,u[y>>2]=0,l=0),m=d-f|0,p=l-f|0,(f|0)<0?(u[c>>2]=m,u[y>>2]=p,u[b>>2]=0,l=p,p=m,f=0):p=d,d=(l|0)<(p|0)?l:p,d=(f|0)<(d|0)?f:d,(d|0)<=0?(c=0,c|0):(u[c>>2]=p-d,u[y>>2]=l-d,u[b>>2]=f-d,c=0,c|0)}function iT(l){l=l|0;var c=0,f=0,d=0,p=0;c=l+8|0,p=u[c>>2]|0,f=p-(u[l>>2]|0)|0,u[l>>2]=f,d=l+4|0,l=(u[d>>2]|0)-p|0,u[d>>2]=l,u[c>>2]=0-(l+f)}function uO(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;f=u[l>>2]|0,c=0-f|0,u[l>>2]=c,y=l+8|0,u[y>>2]=0,b=l+4|0,d=u[b>>2]|0,p=d+f|0,(f|0)>0?(u[b>>2]=p,u[y>>2]=f,u[l>>2]=0,c=0,d=p):f=0,(d|0)<0?(m=c-d|0,u[l>>2]=m,f=f-d|0,u[y>>2]=f,u[b>>2]=0,p=m-f|0,c=0-f|0,(f|0)<0?(u[l>>2]=p,u[b>>2]=c,u[y>>2]=0,d=c,f=0):(d=0,p=m)):p=c,c=(d|0)<(p|0)?d:p,c=(f|0)<(c|0)?f:c,!((c|0)<=0)&&(u[l>>2]=p-c,u[b>>2]=d-c,u[y>>2]=f-c)}function fO(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0;if(N=O,O=O+64|0,P=N,b=N+56|0,!(!0&(c&2013265920|0)==134217728&(!0&(d&2013265920|0)==134217728)))return p=5,O=N,p|0;if((l|0)==(f|0)&(c|0)==(d|0))return u[p>>2]=0,p=0,O=N,p|0;if(y=pe(l|0,c|0,52)|0,U()|0,y=y&15,w=pe(f|0,d|0,52)|0,U()|0,(y|0)!=(w&15|0))return p=12,O=N,p|0;if(m=y+-1|0,y>>>0>1){Cm(l,c,m,P)|0,Cm(f,d,m,b)|0,w=P,E=u[w>>2]|0,w=u[w+4>>2]|0;e:do if((E|0)==(u[b>>2]|0)&&(w|0)==(u[b+4>>2]|0)){y=(y^15)*3|0,m=pe(l|0,c|0,y|0)|0,U()|0,m=m&7,y=pe(f|0,d|0,y|0)|0,U()|0,y=y&7;do if((m|0)==0|(y|0)==0)u[p>>2]=1,m=0;else if((m|0)==7)m=5;else{if((m|0)==1|(y|0)==1&&Ht(E,w)|0){m=5;break}if((u[15536+(m<<2)>>2]|0)!=(y|0)&&(u[15568+(m<<2)>>2]|0)!=(y|0))break e;u[p>>2]=1,m=0}while(!1);return p=m,O=N,p|0}while(!1)}m=P,y=m+56|0;do u[m>>2]=0,m=m+4|0;while((m|0)<(y|0));return Hb(l,c,1,P)|0,c=P,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0))&&(c=P+8|0,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0)))&&(c=P+16|0,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0)))&&(c=P+24|0,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0)))&&(c=P+32|0,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0)))&&(c=P+40|0,!((u[c>>2]|0)==(f|0)&&(u[c+4>>2]|0)==(d|0)))?(m=P+48|0,m=((u[m>>2]|0)==(f|0)?(u[m+4>>2]|0)==(d|0):0)&1):m=1,u[p>>2]=m,p=0,O=N,p|0}function hO(l,c,f,d,p){return l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,f=_m(l,c,f,d)|0,(f|0)==7?(p=11,p|0):(d=Te(f|0,0,56)|0,c=c&-2130706433|(U()|0)|268435456,u[p>>2]=l|d,u[p+4>>2]=c,p=0,p|0)}function dO(l,c,f){return l=l|0,c=c|0,f=f|0,!0&(c&2013265920|0)==268435456?(u[f>>2]=l,u[f+4>>2]=c&-2130706433|134217728,f=0,f|0):(f=6,f|0)}function pO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;return p=O,O=O+16|0,d=p,u[d>>2]=0,!0&(c&2013265920|0)==268435456?(m=pe(l|0,c|0,56)|0,U()|0,d=vr(l,c&-2130706433|134217728,m&7,d,f)|0,O=p,d|0):(d=6,O=p,d|0)}function gO(l,c){l=l|0,c=c|0;var f=0;switch(f=pe(l|0,c|0,56)|0,U()|0,f&7){case 0:case 7:return f=0,f|0;default:}return f=c&-2130706433|134217728,!(!0&(c&2013265920|0)==268435456)||!0&(c&117440512|0)==16777216&(Ht(l,f)|0)!=0?(f=0,f|0):(f=wm(l,f)|0,f|0)}function mO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;return p=O,O=O+16|0,d=p,!0&(c&2013265920|0)==268435456?(m=c&-2130706433|134217728,y=f,u[y>>2]=l,u[y+4>>2]=m,u[d>>2]=0,c=pe(l|0,c|0,56)|0,U()|0,d=vr(l,m,c&7,d,f+8|0)|0,O=p,d|0):(d=6,O=p,d|0)}function _O(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0;return p=(Ht(l,c)|0)==0,c=c&-2130706433,d=f,u[d>>2]=p?l:0,u[d+4>>2]=p?c|285212672:0,d=f+8|0,u[d>>2]=l,u[d+4>>2]=c|301989888,d=f+16|0,u[d>>2]=l,u[d+4>>2]=c|318767104,d=f+24|0,u[d>>2]=l,u[d+4>>2]=c|335544320,d=f+32|0,u[d>>2]=l,u[d+4>>2]=c|352321536,f=f+40|0,u[f>>2]=l,u[f+4>>2]=c|369098752,0}function Hh(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;return y=O,O=O+16|0,p=y,m=c&-2130706433|134217728,!0&(c&2013265920|0)==268435456?(d=pe(l|0,c|0,56)|0,U()|0,d=mF(l,m,d&7)|0,(d|0)==-1?(u[f>>2]=0,m=6,O=y,m|0):(gc(l,m,p)|0&&Ve(23313,22484,282,22499),c=pe(l|0,c|0,52)|0,U()|0,c=c&15,Ht(l,m)|0?vm(p,c,d,2,f):Sm(p,c,d,2,f),m=0,O=y,m|0)):(m=6,O=y,m|0)}function yO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0;d=O,O=O+16|0,p=d,xO(l,c,f,p),sO(p,f+4|0),O=d}function xO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0;if(b=O,O=O+16|0,E=b,bO(l,f,E),m=+F8(+(1-+F[E>>3]*.5)),m<1e-16){u[d>>2]=0,u[d+4>>2]=0,u[d+8>>2]=0,u[d+12>>2]=0,O=b;return}if(E=u[f>>2]|0,p=+F[15920+(E*24|0)>>3],p=+dA(p-+dA(+VO(15600+(E<<4)|0,l))),Oi(c)|0?y=+dA(p+-.3334731722518321):y=p,p=+AA(+m)/.381966011250105,(c|0)>0){l=0;do p=p*2.6457513110645907,l=l+1|0;while((l|0)!=(c|0))}m=+_t(+y)*p,F[d>>3]=m,y=+yt(+y)*p,F[d+8>>3]=y,O=b}function bO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;if(m=O,O=O+32|0,p=m,gF(l,p),u[c>>2]=0,F[f>>3]=5,d=+cr(16400,p),d<+F[f>>3]&&(u[c>>2]=0,F[f>>3]=d),d=+cr(16424,p),d<+F[f>>3]&&(u[c>>2]=1,F[f>>3]=d),d=+cr(16448,p),d<+F[f>>3]&&(u[c>>2]=2,F[f>>3]=d),d=+cr(16472,p),d<+F[f>>3]&&(u[c>>2]=3,F[f>>3]=d),d=+cr(16496,p),d<+F[f>>3]&&(u[c>>2]=4,F[f>>3]=d),d=+cr(16520,p),d<+F[f>>3]&&(u[c>>2]=5,F[f>>3]=d),d=+cr(16544,p),d<+F[f>>3]&&(u[c>>2]=6,F[f>>3]=d),d=+cr(16568,p),d<+F[f>>3]&&(u[c>>2]=7,F[f>>3]=d),d=+cr(16592,p),d<+F[f>>3]&&(u[c>>2]=8,F[f>>3]=d),d=+cr(16616,p),d<+F[f>>3]&&(u[c>>2]=9,F[f>>3]=d),d=+cr(16640,p),d<+F[f>>3]&&(u[c>>2]=10,F[f>>3]=d),d=+cr(16664,p),d<+F[f>>3]&&(u[c>>2]=11,F[f>>3]=d),d=+cr(16688,p),d<+F[f>>3]&&(u[c>>2]=12,F[f>>3]=d),d=+cr(16712,p),d<+F[f>>3]&&(u[c>>2]=13,F[f>>3]=d),d=+cr(16736,p),d<+F[f>>3]&&(u[c>>2]=14,F[f>>3]=d),d=+cr(16760,p),d<+F[f>>3]&&(u[c>>2]=15,F[f>>3]=d),d=+cr(16784,p),d<+F[f>>3]&&(u[c>>2]=16,F[f>>3]=d),d=+cr(16808,p),d<+F[f>>3]&&(u[c>>2]=17,F[f>>3]=d),d=+cr(16832,p),d<+F[f>>3]&&(u[c>>2]=18,F[f>>3]=d),d=+cr(16856,p),!(d<+F[f>>3])){O=m;return}u[c>>2]=19,F[f>>3]=d,O=m}function uA(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0;if(m=+pF(l),m<1e-16){c=15600+(c<<4)|0,u[p>>2]=u[c>>2],u[p+4>>2]=u[c+4>>2],u[p+8>>2]=u[c+8>>2],u[p+12>>2]=u[c+12>>2];return}if(y=+Bi(+ +F[l+8>>3],+ +F[l>>3]),(f|0)>0){l=0;do m=m/2.6457513110645907,l=l+1|0;while((l|0)!=(f|0))}d?(m=m/3,f=(Oi(f)|0)==0,m=+gm(+((f?m:m/2.6457513110645907)*.381966011250105))):(m=+gm(+(m*.381966011250105)),Oi(f)|0&&(y=+dA(y+.3334731722518321))),zO(15600+(c<<4)|0,+dA(+F[15920+(c*24|0)>>3]-y),m,p)}function TO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0;d=O,O=O+16|0,p=d,zo(l+4|0,p),uA(p,u[l>>2]|0,c,0,f),O=d}function vm(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0,St=0,dt=0,pt=0,Je=0,qe=0,Ze=0,It=0,je=0;if(Ze=O,O=O+272|0,m=Ze+256|0,te=Ze+240|0,pt=Ze,Je=Ze+224|0,qe=Ze+208|0,ne=Ze+176|0,J=Ze+160|0,Se=Ze+192|0,Ie=Ze+144|0,be=Ze+128|0,we=Ze+112|0,St=Ze+96|0,dt=Ze+80|0,u[m>>2]=c,u[te>>2]=u[l>>2],u[te+4>>2]=u[l+4>>2],u[te+8>>2]=u[l+8>>2],u[te+12>>2]=u[l+12>>2],nT(te,m,pt),u[p>>2]=0,te=d+f+((d|0)==5&1)|0,(te|0)<=(f|0)){O=Ze;return}E=u[m>>2]|0,w=Je+4|0,P=ne+4|0,N=f+5|0,G=16880+(E<<2)|0,j=16960+(E<<2)|0,z=be+8|0,Z=we+8|0,ce=St+8|0,oe=qe+4|0,b=f;e:for(;;){y=pt+(((b|0)%5|0)<<4)|0,u[qe>>2]=u[y>>2],u[qe+4>>2]=u[y+4>>2],u[qe+8>>2]=u[y+8>>2],u[qe+12>>2]=u[y+12>>2];do;while((pc(qe,E,0,1)|0)==2);if((b|0)>(f|0)&(Oi(c)|0)!=0){if(u[ne>>2]=u[qe>>2],u[ne+4>>2]=u[qe+4>>2],u[ne+8>>2]=u[qe+8>>2],u[ne+12>>2]=u[qe+12>>2],zo(w,J),d=u[ne>>2]|0,m=u[17040+(d*80|0)+(u[Je>>2]<<2)>>2]|0,u[ne>>2]=u[18640+(d*80|0)+(m*20|0)>>2],y=u[18640+(d*80|0)+(m*20|0)+16>>2]|0,(y|0)>0){l=0;do eT(P),l=l+1|0;while((l|0)<(y|0))}switch(y=18640+(d*80|0)+(m*20|0)+4|0,u[Se>>2]=u[y>>2],u[Se+4>>2]=u[y+4>>2],u[Se+8>>2]=u[y+8>>2],Jb(Se,(u[G>>2]|0)*3|0),Zr(P,Se,P),kr(P),zo(P,Ie),It=+(u[j>>2]|0),F[be>>3]=It*3,F[z>>3]=0,je=It*-1.5,F[we>>3]=je,F[Z>>3]=It*2.598076211353316,F[St>>3]=je,F[ce>>3]=It*-2.598076211353316,u[17040+((u[ne>>2]|0)*80|0)+(u[qe>>2]<<2)>>2]|0){case 1:{l=we,d=be;break}case 3:{l=St,d=we;break}case 2:{l=be,d=St;break}default:{l=12;break e}}mT(J,Ie,d,l,dt),uA(dt,u[ne>>2]|0,E,1,p+8+(u[p>>2]<<4)|0),u[p>>2]=(u[p>>2]|0)+1}if((b|0)<(N|0)&&(zo(oe,ne),uA(ne,u[qe>>2]|0,E,1,p+8+(u[p>>2]<<4)|0),u[p>>2]=(u[p>>2]|0)+1),u[Je>>2]=u[qe>>2],u[Je+4>>2]=u[qe+4>>2],u[Je+8>>2]=u[qe+8>>2],u[Je+12>>2]=u[qe+12>>2],b=b+1|0,(b|0)>=(te|0)){l=3;break}}if((l|0)==3){O=Ze;return}else(l|0)==12&&Ve(22522,22569,571,22579)}function nT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0;E=O,O=O+128|0,d=E+64|0,p=E,m=d,y=20240,b=m+60|0;do u[m>>2]=u[y>>2],m=m+4|0,y=y+4|0;while((m|0)<(b|0));m=p,y=20304,b=m+60|0;do u[m>>2]=u[y>>2],m=m+4|0,y=y+4|0;while((m|0)<(b|0));b=(Oi(u[c>>2]|0)|0)==0,d=b?d:p,p=l+4|0,tT(p),rT(p),Oi(u[c>>2]|0)|0&&(Ho(p),u[c>>2]=(u[c>>2]|0)+1),u[f>>2]=u[l>>2],c=f+4|0,Zr(p,d,c),kr(c),u[f+16>>2]=u[l>>2],c=f+20|0,Zr(p,d+12|0,c),kr(c),u[f+32>>2]=u[l>>2],c=f+36|0,Zr(p,d+24|0,c),kr(c),u[f+48>>2]=u[l>>2],c=f+52|0,Zr(p,d+36|0,c),kr(c),u[f+64>>2]=u[l>>2],f=f+68|0,Zr(p,d+48|0,f),kr(f),O=E}function pc(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0;if(z=O,O=O+32|0,G=z+12|0,b=z,j=l+4|0,N=u[16960+(c<<2)>>2]|0,P=(d|0)!=0,N=P?N*3|0:N,p=u[j>>2]|0,w=l+8|0,y=u[w>>2]|0,P){if(m=l+12|0,d=u[m>>2]|0,p=y+p+d|0,(p|0)==(N|0))return j=1,O=z,j|0;E=m}else E=l+12|0,d=u[E>>2]|0,p=y+p+d|0;if((p|0)<=(N|0))return j=0,O=z,j|0;do if((d|0)>0){if(d=u[l>>2]|0,(y|0)>0){m=18640+(d*80|0)+60|0,d=l;break}d=18640+(d*80|0)+40|0,f?(nO(G,N,0,0),Tm(j,G,b),zh(b),Zr(b,G,j),m=d,d=l):(m=d,d=l)}else m=18640+((u[l>>2]|0)*80|0)+20|0,d=l;while(!1);if(u[d>>2]=u[m>>2],p=m+16|0,(u[p>>2]|0)>0){d=0;do eT(j),d=d+1|0;while((d|0)<(u[p>>2]|0))}return l=m+4|0,u[G>>2]=u[l>>2],u[G+4>>2]=u[l+4>>2],u[G+8>>2]=u[l+8>>2],c=u[16880+(c<<2)>>2]|0,Jb(G,P?c*3|0:c),Zr(j,G,j),kr(j),P?d=((u[w>>2]|0)+(u[j>>2]|0)+(u[E>>2]|0)|0)==(N|0)?1:2:d=2,j=d,O=z,j|0}function EO(l,c){l=l|0,c=c|0;var f=0;do f=pc(l,c,0,1)|0;while((f|0)==2);return f|0}function Sm(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0,St=0,dt=0,pt=0;if(St=O,O=O+240|0,m=St+224|0,Se=St+208|0,Ie=St,be=St+192|0,we=St+176|0,ce=St+160|0,oe=St+144|0,te=St+128|0,ne=St+112|0,J=St+96|0,u[m>>2]=c,u[Se>>2]=u[l>>2],u[Se+4>>2]=u[l+4>>2],u[Se+8>>2]=u[l+8>>2],u[Se+12>>2]=u[l+12>>2],sT(Se,m,Ie),u[p>>2]=0,Z=d+f+((d|0)==6&1)|0,(Z|0)<=(f|0)){O=St;return}E=u[m>>2]|0,w=f+6|0,P=16960+(E<<2)|0,N=oe+8|0,G=te+8|0,j=ne+8|0,z=be+4|0,y=0,b=f,d=-1;e:for(;;){if(m=(b|0)%6|0,l=Ie+(m<<4)|0,u[be>>2]=u[l>>2],u[be+4>>2]=u[l+4>>2],u[be+8>>2]=u[l+8>>2],u[be+12>>2]=u[l+12>>2],l=y,y=pc(be,E,0,1)|0,(b|0)>(f|0)&(Oi(c)|0)!=0&&(l|0)!=1&&(u[be>>2]|0)!=(d|0)){switch(zo(Ie+(((m+5|0)%6|0)<<4)+4|0,we),zo(Ie+(m<<4)+4|0,ce),dt=+(u[P>>2]|0),F[oe>>3]=dt*3,F[N>>3]=0,pt=dt*-1.5,F[te>>3]=pt,F[G>>3]=dt*2.598076211353316,F[ne>>3]=pt,F[j>>3]=dt*-2.598076211353316,m=u[Se>>2]|0,u[17040+(m*80|0)+(((d|0)==(m|0)?u[be>>2]|0:d)<<2)>>2]|0){case 1:{l=te,d=oe;break}case 3:{l=ne,d=te;break}case 2:{l=oe,d=ne;break}default:{l=8;break e}}mT(we,ce,d,l,J),!(_T(we,J)|0)&&!(_T(ce,J)|0)&&(uA(J,u[Se>>2]|0,E,1,p+8+(u[p>>2]<<4)|0),u[p>>2]=(u[p>>2]|0)+1)}if((b|0)<(w|0)&&(zo(z,we),uA(we,u[be>>2]|0,E,1,p+8+(u[p>>2]<<4)|0),u[p>>2]=(u[p>>2]|0)+1),b=b+1|0,(b|0)>=(Z|0)){l=3;break}else d=u[be>>2]|0}if((l|0)==3){O=St;return}else(l|0)==8&&Ve(22606,22569,736,22651)}function sT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0;E=O,O=O+160|0,d=E+80|0,p=E,m=d,y=20368,b=m+72|0;do u[m>>2]=u[y>>2],m=m+4|0,y=y+4|0;while((m|0)<(b|0));m=p,y=20448,b=m+72|0;do u[m>>2]=u[y>>2],m=m+4|0,y=y+4|0;while((m|0)<(b|0));b=(Oi(u[c>>2]|0)|0)==0,d=b?d:p,p=l+4|0,tT(p),rT(p),Oi(u[c>>2]|0)|0&&(Ho(p),u[c>>2]=(u[c>>2]|0)+1),u[f>>2]=u[l>>2],c=f+4|0,Zr(p,d,c),kr(c),u[f+16>>2]=u[l>>2],c=f+20|0,Zr(p,d+12|0,c),kr(c),u[f+32>>2]=u[l>>2],c=f+36|0,Zr(p,d+24|0,c),kr(c),u[f+48>>2]=u[l>>2],c=f+52|0,Zr(p,d+36|0,c),kr(c),u[f+64>>2]=u[l>>2],c=f+68|0,Zr(p,d+48|0,c),kr(c),u[f+80>>2]=u[l>>2],f=f+84|0,Zr(p,d+60|0,f),kr(f),O=E}function vO(l,c){return l=l|0,c=c|0,c=pe(l|0,c|0,52)|0,U()|0,c&15|0}function oT(l,c){return l=l|0,c=c|0,c=pe(l|0,c|0,45)|0,U()|0,c&127|0}function wm(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0;if(!(!0&(c&-16777216|0)==134217728)||(y=pe(l|0,c|0,45)|0,U()|0,y=y&127,y>>>0>121))return c=0,c|0;f=pe(l|0,c|0,52)|0,U()|0,f=f&15;do if(f|0){for(p=1,d=0;;){if(m=pe(l|0,c|0,(15-p|0)*3|0)|0,U()|0,m=m&7,(m|0)!=0&(d^1))if((m|0)==1&(zt(y)|0)!=0){b=0,d=13;break}else d=1;if((m|0)==7){b=0,d=13;break}if(p>>>0>>0)p=p+1|0;else{d=9;break}}if((d|0)==9){if((f|0)==15)b=1;else break;return b|0}else if((d|0)==13)return b|0}while(!1);for(;;){if(b=pe(l|0,c|0,(14-f|0)*3|0)|0,U()|0,!((b&7|0)==7&!0)){b=0,d=13;break}if(f>>>0<14)f=f+1|0;else{b=1,d=13;break}}return(d|0)==13?b|0:0}function Cm(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0;if(m=pe(l|0,c|0,52)|0,U()|0,m=m&15,f>>>0>15)return d=4,d|0;if((m|0)<(f|0))return d=12,d|0;if((m|0)==(f|0))return u[d>>2]=l,u[d+4>>2]=c,d=0,d|0;if(p=Te(f|0,0,52)|0,p=p|l,l=U()|0|c&-15728641,(m|0)>(f|0))do c=Te(7,0,(14-f|0)*3|0)|0,f=f+1|0,p=c|p,l=U()|0|l;while((f|0)<(m|0));return u[d>>2]=p,u[d+4>>2]=l,d=0,d|0}function Gh(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0;if(m=pe(l|0,c|0,52)|0,U()|0,m=m&15,!((f|0)<16&(m|0)<=(f|0)))return d=4,d|0;p=f-m|0,f=pe(l|0,c|0,45)|0,U()|0;e:do if(!(zt(f&127)|0))f=Ws(7,0,p,((p|0)<0)<<31>>31)|0,p=U()|0;else{t:do if(m|0){for(f=1;y=Te(7,0,(15-f|0)*3|0)|0,!!((y&l|0)==0&((U()|0)&c|0)==0);)if(f>>>0>>0)f=f+1|0;else break t;f=Ws(7,0,p,((p|0)<0)<<31>>31)|0,p=U()|0;break e}while(!1);f=Ws(7,0,p,((p|0)<0)<<31>>31)|0,f=zr(f|0,U()|0,5,0)|0,f=ot(f|0,U()|0,-5,-1)|0,f=jo(f|0,U()|0,6,0)|0,f=ot(f|0,U()|0,1,0)|0,p=U()|0}while(!1);return y=d,u[y>>2]=f,u[y+4>>2]=p,y=0,y|0}function Ht(l,c){l=l|0,c=c|0;var f=0,d=0,p=0;if(p=pe(l|0,c|0,45)|0,U()|0,!(zt(p&127)|0))return p=0,p|0;p=pe(l|0,c|0,52)|0,U()|0,p=p&15;e:do if(!p)f=0;else for(d=1;;){if(f=pe(l|0,c|0,(15-d|0)*3|0)|0,U()|0,f=f&7,f|0)break e;if(d>>>0

>>0)d=d+1|0;else{f=0;break}}while(!1);return p=(f|0)==0&1,p|0}function SO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0;if(y=O,O=O+16|0,m=y,lT(m,l,c,f),c=m,l=u[c>>2]|0,c=u[c+4>>2]|0,(l|0)==0&(c|0)==0)return O=y,0;p=0,f=0;do b=d+(p<<3)|0,u[b>>2]=l,u[b+4>>2]=c,p=ot(p|0,f|0,1,0)|0,f=U()|0,AT(m),b=m,l=u[b>>2]|0,c=u[b+4>>2]|0;while(!((l|0)==0&(c|0)==0));return O=y,0}function wO(l,c,f,d){return l=l|0,c=c|0,f=f|0,d=d|0,(d|0)<(f|0)?(f=c,d=l,tt(f|0),d|0):(f=Te(-1,-1,((d-f|0)*3|0)+3|0)|0,d=Te(~f|0,~(U()|0)|0,(15-d|0)*3|0)|0,f=~(U()|0)&c,d=~d&l,tt(f|0),d|0)}function CO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0;return p=pe(l|0,c|0,52)|0,U()|0,p=p&15,(f|0)<16&(p|0)<=(f|0)?((p|0)<(f|0)&&(p=Te(-1,-1,((f+-1-p|0)*3|0)+3|0)|0,p=Te(~p|0,~(U()|0)|0,(15-f|0)*3|0)|0,c=~(U()|0)&c,l=~p&l),p=Te(f|0,0,52)|0,f=c&-15728641|(U()|0),u[d>>2]=l|p,u[d+4>>2]=f,d=0,d|0):(d=4,d|0)}function MO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0;if((f|0)==0&(d|0)==0)return be=0,be|0;if(p=l,m=u[p>>2]|0,p=u[p+4>>2]|0,!0&(p&15728640|0)==0){if(!((d|0)>0|(d|0)==0&f>>>0>0)||(be=c,u[be>>2]=m,u[be+4>>2]=p,(f|0)==1&(d|0)==0))return be=0,be|0;p=1;do Se=l+(p<<3)|0,Ie=u[Se+4>>2]|0,be=c+(p<<3)|0,u[be>>2]=u[Se>>2],u[be+4>>2]=Ie,p=p+1|0;while(0<(d|0)|(d|0)==0&p>>>0>>0);return p=0,p|0}if(J=f<<3,Ie=Rn(J)|0,!Ie)return be=13,be|0;if(Xh(Ie|0,l|0,J|0)|0,Se=Bn(f,8)|0,!Se)return We(Ie),be=13,be|0;e:do if(f|0){t:for(;;){p=Ie,oe=u[p>>2]|0,p=u[p+4>>2]|0,te=pe(oe|0,p|0,52)|0,U()|0,te=te&15,ne=te+-1|0,ce=(f|0)>0;r:do if((te|0)!=0&ce){if(j=((f|0)<0)<<31>>31,z=Te(ne|0,0,52)|0,Z=U()|0,ne>>>0>15){if(!((oe|0)==0&(p|0)==0)){be=17;break t}for(m=0;;){if(m=m+1|0,(m|0)>=(f|0))break r;if(d=Ie+(m<<3)|0,Z=u[d>>2]|0,d=u[d+4>>2]|0,!((Z|0)==0&(d|0)==0)){p=d,be=17;break t}}}for(m=0,l=oe,d=p;;){if(!((l|0)==0&(d|0)==0)){if(!(!0&(d&117440512|0)==0)){be=22;break t}if(b=pe(l|0,d|0,52)|0,U()|0,b=b&15,(b|0)<(ne|0)){p=12,be=28;break t}if((b|0)!=(ne|0)&&(l=l|z,d=d&-15728641|Z,b>>>0>=te>>>0)){y=ne;do G=Te(7,0,(14-y|0)*3|0)|0,y=y+1|0,l=G|l,d=U()|0|d;while(y>>>0>>0)}if(y=_c(l|0,d|0,f|0,j|0)|0,U()|0,w=Se+(y<<3)|0,b=w,E=u[b>>2]|0,b=u[b+4>>2]|0,(E|0)==0&(b|0)==0)y=w;else for(G=0;;){if((G|0)>(f|0)){be=32;break t}if((E|0)==(l|0)&(b&-117440513|0)==(d|0)){P=pe(E|0,b|0,56)|0,U()|0,P=P&7,N=P+1|0,we=pe(E|0,b|0,45)|0,U()|0;i:do if(!(zt(we&127)|0))b=7;else{if(E=pe(E|0,b|0,52)|0,U()|0,E=E&15,!E){b=6;break}for(b=1;;){if(we=Te(7,0,(15-b|0)*3|0)|0,!((we&l|0)==0&((U()|0)&d|0)==0)){b=7;break i}if(b>>>0>>0)b=b+1|0;else{b=6;break}}}while(!1);if((P+2|0)>>>0>b>>>0){be=42;break t}we=Te(N|0,0,56)|0,d=U()|0|d&-117440513,N=w,u[N>>2]=0,u[N+4>>2]=0,l=we|l}else y=(y+1|0)%(f|0)|0;if(w=Se+(y<<3)|0,b=w,E=u[b>>2]|0,b=u[b+4>>2]|0,(E|0)==0&(b|0)==0){y=w;break}else G=G+1|0}we=y,u[we>>2]=l,u[we+4>>2]=d}if(m=m+1|0,(m|0)>=(f|0))break r;d=Ie+(m<<3)|0,l=u[d>>2]|0,d=u[d+4>>2]|0}}while(!1);if((f+5|0)>>>0<11){be=85;break}if(Z=Bn((f|0)/6|0,8)|0,!Z){be=49;break}r:do if(ce){G=0,N=0;do{if(b=Se+(G<<3)|0,d=b,m=u[d>>2]|0,d=u[d+4>>2]|0,!((m|0)==0&(d|0)==0)){E=pe(m|0,d|0,56)|0,U()|0,E=E&7,l=E+1|0,w=d&-117440513,we=pe(m|0,d|0,45)|0,U()|0;i:do if(zt(we&127)|0){if(P=pe(m|0,d|0,52)|0,U()|0,P=P&15,P|0)for(y=1;;){if(we=Te(7,0,(15-y|0)*3|0)|0,!((m&we|0)==0&(w&(U()|0)|0)==0))break i;if(y>>>0

>>0)y=y+1|0;else break}d=Te(l|0,0,56)|0,m=d|m,d=U()|0|w,l=b,u[l>>2]=m,u[l+4>>2]=d,l=E+2|0}while(!1);(l|0)==7&&(we=Z+(N<<3)|0,u[we>>2]=m,u[we+4>>2]=d&-117440513,N=N+1|0)}G=G+1|0}while((G|0)!=(f|0));if(ce){if(G=((f|0)<0)<<31>>31,j=Te(ne|0,0,52)|0,z=U()|0,ne>>>0>15){if(!((oe|0)==0&(p|0)==0)){p=4,be=84;break t}for(p=0;;){if(p=p+1|0,(p|0)>=(f|0)){m=0,p=N;break r}if(we=Ie+(p<<3)|0,!((u[we>>2]|0)==0&(u[we+4>>2]|0)==0)){p=4,be=84;break t}}}for(P=0,m=0,w=oe;;){do if(!((w|0)==0&(p|0)==0)){if(b=pe(w|0,p|0,52)|0,U()|0,b=b&15,(b|0)<(ne|0)){p=12,be=84;break t}do if((b|0)==(ne|0))d=w,b=p;else{if(d=w|j,l=p&-15728641|z,b>>>0>>0){b=l;break}y=ne;do we=Te(7,0,(14-y|0)*3|0)|0,y=y+1|0,d=we|d,l=U()|0|l;while(y>>>0>>0);b=l}while(!1);for(y=_c(d|0,b|0,f|0,G|0)|0,U()|0,l=0;;){if((l|0)>(f|0)){be=77;break t}if(we=Se+(y<<3)|0,E=u[we+4>>2]|0,(E&-117440513|0)==(b|0)&&(u[we>>2]|0)==(d|0)){be=79;break}if(y=(y+1|0)%(f|0)|0,we=Se+(y<<3)|0,(u[we>>2]|0)==(d|0)&&(u[we+4>>2]|0)==(b|0))break;l=l+1|0}if((be|0)==79&&(be=0,!0&(E&117440512|0)==100663296))break;we=c+(m<<3)|0,u[we>>2]=w,u[we+4>>2]=p,m=m+1|0}while(!1);if(p=P+1|0,(p|0)>=(f|0)){p=N;break r}we=Ie+(p<<3)|0,P=p,w=u[we>>2]|0,p=u[we+4>>2]|0}}else m=0,p=N}else m=0,p=0;while(!1);if(Xo(Se|0,0,J|0)|0,Xh(Ie|0,Z|0,p<<3|0)|0,We(Z),p)c=c+(m<<3)|0,f=p;else break e}if((be|0)==17)!0&(p&117440512|0)==0?(p=4,be=28):be=22;else if((be|0)==32)Ve(23313,22674,362,22684);else{if((be|0)==42)return We(Ie),We(Se),we=10,we|0;if((be|0)==49)return We(Ie),We(Se),we=13,we|0;if((be|0)==77)Ve(23313,22674,462,22684);else{if((be|0)==84)return We(Z),We(Ie),We(Se),we=p,we|0;if((be|0)==85){Xh(c|0,Ie|0,f<<3|0)|0;break}}}if((be|0)==22)return We(Ie),We(Se),we=5,we|0;if((be|0)==28)return We(Ie),We(Se),we=p,we|0}while(!1);return We(Ie),We(Se),we=0,we|0}function PO(l,c,f,d,p,m,y){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,m=m|0,y=y|0;var b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0;if(Z=O,O=O+16|0,z=Z,!((f|0)>0|(f|0)==0&c>>>0>0))return z=0,O=Z,z|0;if((y|0)>=16)return z=12,O=Z,z|0;G=0,j=0,N=0,b=0;e:for(;;){if(w=l+(G<<3)|0,E=u[w>>2]|0,w=u[w+4>>2]|0,P=pe(E|0,w|0,52)|0,U()|0,(P&15|0)>(y|0)){b=12,E=11;break}if(lT(z,E,w,y),P=z,w=u[P>>2]|0,P=u[P+4>>2]|0,(w|0)==0&(P|0)==0)E=N;else{E=N;do{if(!((b|0)<(m|0)|(b|0)==(m|0)&E>>>0

>>0)){E=10;break e}N=d+(E<<3)|0,u[N>>2]=w,u[N+4>>2]=P,E=ot(E|0,b|0,1,0)|0,b=U()|0,AT(z),N=z,w=u[N>>2]|0,P=u[N+4>>2]|0}while(!((w|0)==0&(P|0)==0))}if(G=ot(G|0,j|0,1,0)|0,j=U()|0,(j|0)<(f|0)|(j|0)==(f|0)&G>>>0>>0)N=E;else{b=0,E=11;break}}return(E|0)==10?(z=14,O=Z,z|0):(E|0)==11?(O=Z,b|0):0}function IO(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0;G=O,O=O+16|0,N=G;e:do if((f|0)>0|(f|0)==0&c>>>0>0){for(w=0,y=0,m=0,P=0;;){if(E=l+(w<<3)|0,b=u[E>>2]|0,E=u[E+4>>2]|0,!((b|0)==0&(E|0)==0)&&(E=(Gh(b,E,d,N)|0)==0,b=N,y=ot(u[b>>2]|0,u[b+4>>2]|0,y|0,m|0)|0,m=U()|0,!E)){m=12;break}if(w=ot(w|0,P|0,1,0)|0,P=U()|0,!((P|0)<(f|0)|(P|0)==(f|0)&w>>>0>>0))break e}return O=G,m|0}else y=0,m=0;while(!1);return u[p>>2]=y,u[p+4>>2]=m,p=0,O=G,p|0}function RO(l,c){return l=l|0,c=c|0,c=pe(l|0,c|0,52)|0,U()|0,c&1|0}function Ai(l,c){l=l|0,c=c|0;var f=0,d=0,p=0;if(p=pe(l|0,c|0,52)|0,U()|0,p=p&15,!p)return p=0,p|0;for(d=1;;){if(f=pe(l|0,c|0,(15-d|0)*3|0)|0,U()|0,f=f&7,f|0){d=5;break}if(d>>>0

>>0)d=d+1|0;else{f=0,d=5;break}}return(d|0)==5?f|0:0}function Mm(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0;if(E=pe(l|0,c|0,52)|0,U()|0,E=E&15,!E)return b=c,E=l,tt(b|0),E|0;for(b=1,f=0;;){m=(15-b|0)*3|0,d=Te(7,0,m|0)|0,p=U()|0,y=pe(l|0,c|0,m|0)|0,U()|0,m=Te(Go(y&7)|0,0,m|0)|0,y=U()|0,l=m|l&~d,c=y|c&~p;e:do if(!f)if((m&d|0)==0&(y&p|0)==0)f=0;else if(d=pe(l|0,c|0,52)|0,U()|0,d=d&15,!d)f=1;else{f=1;t:for(;;){switch(y=pe(l|0,c|0,(15-f|0)*3|0)|0,U()|0,y&7){case 1:break t;case 0:break;default:{f=1;break e}}if(f>>>0>>0)f=f+1|0;else{f=1;break e}}for(f=1;;)if(y=(15-f|0)*3|0,p=pe(l|0,c|0,y|0)|0,U()|0,m=Te(7,0,y|0)|0,c=c&~(U()|0),y=Te(Go(p&7)|0,0,y|0)|0,l=l&~m|y,c=c|(U()|0),f>>>0>>0)f=f+1|0;else{f=1;break}}while(!1);if(b>>>0>>0)b=b+1|0;else break}return tt(c|0),l|0}function Wo(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0;if(d=pe(l|0,c|0,52)|0,U()|0,d=d&15,!d)return f=c,d=l,tt(f|0),d|0;for(f=1;m=(15-f|0)*3|0,y=pe(l|0,c|0,m|0)|0,U()|0,p=Te(7,0,m|0)|0,c=c&~(U()|0),m=Te(Go(y&7)|0,0,m|0)|0,l=m|l&~p,c=U()|0|c,f>>>0>>0;)f=f+1|0;return tt(c|0),l|0}function BO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0;if(E=pe(l|0,c|0,52)|0,U()|0,E=E&15,!E)return b=c,E=l,tt(b|0),E|0;for(b=1,f=0;;){m=(15-b|0)*3|0,d=Te(7,0,m|0)|0,p=U()|0,y=pe(l|0,c|0,m|0)|0,U()|0,m=Te(Gs(y&7)|0,0,m|0)|0,y=U()|0,l=m|l&~d,c=y|c&~p;e:do if(!f)if((m&d|0)==0&(y&p|0)==0)f=0;else if(d=pe(l|0,c|0,52)|0,U()|0,d=d&15,!d)f=1;else{f=1;t:for(;;){switch(y=pe(l|0,c|0,(15-f|0)*3|0)|0,U()|0,y&7){case 1:break t;case 0:break;default:{f=1;break e}}if(f>>>0>>0)f=f+1|0;else{f=1;break e}}for(f=1;;)if(p=(15-f|0)*3|0,m=Te(7,0,p|0)|0,y=c&~(U()|0),c=pe(l|0,c|0,p|0)|0,U()|0,c=Te(Gs(c&7)|0,0,p|0)|0,l=l&~m|c,c=y|(U()|0),f>>>0>>0)f=f+1|0;else{f=1;break}}while(!1);if(b>>>0>>0)b=b+1|0;else break}return tt(c|0),l|0}function Pm(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0;if(d=pe(l|0,c|0,52)|0,U()|0,d=d&15,!d)return f=c,d=l,tt(f|0),d|0;for(f=1;y=(15-f|0)*3|0,m=Te(7,0,y|0)|0,p=c&~(U()|0),c=pe(l|0,c|0,y|0)|0,U()|0,c=Te(Gs(c&7)|0,0,y|0)|0,l=c|l&~m,c=U()|0|p,f>>>0>>0;)f=f+1|0;return tt(c|0),l|0}function OO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(E=O,O=O+64|0,b=E+40|0,d=E+24|0,p=E+12|0,m=E,Te(c|0,0,52)|0,f=U()|0|134225919,!c)return(u[l+4>>2]|0)>2||(u[l+8>>2]|0)>2||(u[l+12>>2]|0)>2?(y=0,b=0,tt(y|0),O=E,b|0):(Te(Xb(l)|0,0,45)|0,y=U()|0|f,b=-1,tt(y|0),O=E,b|0);if(u[b>>2]=u[l>>2],u[b+4>>2]=u[l+4>>2],u[b+8>>2]=u[l+8>>2],u[b+12>>2]=u[l+12>>2],y=b+4|0,(c|0)>0)for(l=-1;u[d>>2]=u[y>>2],u[d+4>>2]=u[y+4>>2],u[d+8>>2]=u[y+8>>2],c&1?(cO(y),u[p>>2]=u[y>>2],u[p+4>>2]=u[y+4>>2],u[p+8>>2]=u[y+8>>2],Vh(p)):(Zb(y),u[p>>2]=u[y>>2],u[p+4>>2]=u[y+4>>2],u[p+8>>2]=u[y+8>>2],Ho(p)),Tm(d,p,m),kr(m),P=(15-c|0)*3|0,w=Te(7,0,P|0)|0,f=f&~(U()|0),P=Te(kh(m)|0,0,P|0)|0,l=P|l&~w,f=U()|0|f,(c|0)>1;)c=c+-1|0;else l=-1;e:do if((u[y>>2]|0)<=2&&(u[b+8>>2]|0)<=2&&(u[b+12>>2]|0)<=2){if(d=Xb(b)|0,c=Te(d|0,0,45)|0,c=c|l,l=U()|0|f&-1040385,m=Z8(b)|0,!(zt(d)|0)){if((m|0)<=0)break;for(p=0;;){if(d=pe(c|0,l|0,52)|0,U()|0,d=d&15,d)for(f=1;P=(15-f|0)*3|0,b=pe(c|0,l|0,P|0)|0,U()|0,w=Te(7,0,P|0)|0,l=l&~(U()|0),P=Te(Go(b&7)|0,0,P|0)|0,c=c&~w|P,l=l|(U()|0),f>>>0>>0;)f=f+1|0;if(p=p+1|0,(p|0)==(m|0))break e}}p=pe(c|0,l|0,52)|0,U()|0,p=p&15;t:do if(p){f=1;r:for(;;){switch(P=pe(c|0,l|0,(15-f|0)*3|0)|0,U()|0,P&7){case 1:break r;case 0:break;default:break t}if(f>>>0

>>0)f=f+1|0;else break t}if(Yb(d,u[b>>2]|0)|0)for(f=1;b=(15-f|0)*3|0,w=Te(7,0,b|0)|0,P=l&~(U()|0),l=pe(c|0,l|0,b|0)|0,U()|0,l=Te(Gs(l&7)|0,0,b|0)|0,c=c&~w|l,l=P|(U()|0),f>>>0

>>0;)f=f+1|0;else for(f=1;P=(15-f|0)*3|0,b=pe(c|0,l|0,P|0)|0,U()|0,w=Te(7,0,P|0)|0,l=l&~(U()|0),P=Te(Go(b&7)|0,0,P|0)|0,c=c&~w|P,l=l|(U()|0),f>>>0

>>0;)f=f+1|0}while(!1);if((m|0)>0){f=0;do c=Mm(c,l)|0,l=U()|0,f=f+1|0;while((f|0)!=(m|0))}}else c=0,l=0;while(!1);return w=l,P=c,tt(w|0),O=E,P|0}function Oi(l){return l=l|0,(l|0)%2|0|0}function aT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0;return p=O,O=O+16|0,d=p,c>>>0>15?(d=4,O=p,d|0):(u[l+4>>2]&2146435072|0)==2146435072||(u[l+8+4>>2]&2146435072|0)==2146435072?(d=3,O=p,d|0):(yO(l,c,d),c=OO(d,c)|0,d=U()|0,u[f>>2]=c,u[f+4>>2]=d,(c|0)==0&(d|0)==0&&Ve(23313,22674,786,22697),d=0,O=p,d|0)}function Im(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;if(p=f+4|0,m=pe(l|0,c|0,52)|0,U()|0,m=m&15,y=pe(l|0,c|0,45)|0,U()|0,d=(m|0)==0,zt(y&127)|0){if(d)return y=1,y|0;d=1}else{if(d)return y=0,y|0;!(u[p>>2]|0)&&!(u[f+8>>2]|0)?d=(u[f+12>>2]|0)!=0&1:d=1}for(f=1;f&1?Vh(p):Ho(p),y=pe(l|0,c|0,(15-f|0)*3|0)|0,U()|0,$b(p,y&7),f>>>0>>0;)f=f+1|0;return d|0}function gc(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(P=O,O=O+16|0,E=P,w=pe(l|0,c|0,45)|0,U()|0,w=w&127,w>>>0>121)return u[f>>2]=0,u[f+4>>2]=0,u[f+8>>2]=0,u[f+12>>2]=0,w=5,O=P,w|0;e:do if(zt(w)|0&&(m=pe(l|0,c|0,52)|0,U()|0,m=m&15,(m|0)!=0)){d=1;t:for(;;){switch(b=pe(l|0,c|0,(15-d|0)*3|0)|0,U()|0,b&7){case 5:break t;case 0:break;default:{d=c;break e}}if(d>>>0>>0)d=d+1|0;else{d=c;break e}}for(p=1,d=c;c=(15-p|0)*3|0,y=Te(7,0,c|0)|0,b=d&~(U()|0),d=pe(l|0,d|0,c|0)|0,U()|0,d=Te(Gs(d&7)|0,0,c|0)|0,l=l&~y|d,d=b|(U()|0),p>>>0>>0;)p=p+1|0}else d=c;while(!1);if(b=7696+(w*28|0)|0,u[f>>2]=u[b>>2],u[f+4>>2]=u[b+4>>2],u[f+8>>2]=u[b+8>>2],u[f+12>>2]=u[b+12>>2],!(Im(l,d,f)|0))return w=0,O=P,w|0;if(y=f+4|0,u[E>>2]=u[y>>2],u[E+4>>2]=u[y+4>>2],u[E+8>>2]=u[y+8>>2],m=pe(l|0,d|0,52)|0,U()|0,b=m&15,m&1?(Ho(y),m=b+1|0):m=b,!(zt(w)|0))d=0;else{e:do if(!b)d=0;else for(c=1;;){if(p=pe(l|0,d|0,(15-c|0)*3|0)|0,U()|0,p=p&7,p|0){d=p;break e}if(c>>>0>>0)c=c+1|0;else{d=0;break}}while(!1);d=(d|0)==4&1}if(!(pc(f,m,d,0)|0))(m|0)!=(b|0)&&(u[y>>2]=u[E>>2],u[y+4>>2]=u[E+4>>2],u[y+8>>2]=u[E+8>>2]);else{if(zt(w)|0)do;while(pc(f,m,0,0)|0);(m|0)!=(b|0)&&Zb(y)}return w=0,O=P,w|0}function fA(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;return m=O,O=O+16|0,d=m,p=gc(l,c,d)|0,p|0?(O=m,p|0):(p=pe(l|0,c|0,52)|0,U()|0,TO(d,p&15,f),p=0,O=m,p|0)}function hA(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0;if(y=O,O=O+16|0,m=y,d=gc(l,c,m)|0,d|0)return m=d,O=y,m|0;d=pe(l|0,c|0,45)|0,U()|0,d=(zt(d&127)|0)==0,p=pe(l|0,c|0,52)|0,U()|0,p=p&15;e:do if(!d){if(p|0)for(d=1;;){if(b=Te(7,0,(15-d|0)*3|0)|0,!((b&l|0)==0&((U()|0)&c|0)==0))break e;if(d>>>0

>>0)d=d+1|0;else break}return vm(m,p,0,5,f),b=0,O=y,b|0}while(!1);return Sm(m,p,0,6,f),b=0,O=y,b|0}function FO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;if(p=pe(l|0,c|0,45)|0,U()|0,!(zt(p&127)|0))return p=2,u[f>>2]=p,0;if(p=pe(l|0,c|0,52)|0,U()|0,p=p&15,!p)return p=5,u[f>>2]=p,0;for(d=1;;){if(m=Te(7,0,(15-d|0)*3|0)|0,!((m&l|0)==0&((U()|0)&c|0)==0)){d=2,l=6;break}if(d>>>0

>>0)d=d+1|0;else{d=5,l=6;break}}return(l|0)==6&&(u[f>>2]=d),0}function cT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0;N=O,O=O+128|0,w=N+112|0,m=N+96|0,P=N,p=pe(l|0,c|0,52)|0,U()|0,b=p&15,u[w>>2]=b,y=pe(l|0,c|0,45)|0,U()|0,y=y&127;e:do if(zt(y)|0){if(b|0)for(d=1;;){if(E=Te(7,0,(15-d|0)*3|0)|0,!((E&l|0)==0&((U()|0)&c|0)==0)){p=0;break e}if(d>>>0>>0)d=d+1|0;else break}if(p&1)p=1;else return E=Te(b+1|0,0,52)|0,P=U()|0|c&-15728641,w=Te(7,0,(14-b|0)*3|0)|0,P=cT((E|l)&~w,P&~(U()|0),f)|0,O=N,P|0}else p=0;while(!1);if(d=gc(l,c,m)|0,!d){p?(nT(m,w,P),E=5):(sT(m,w,P),E=6);e:do if(zt(y)|0)if(!b)l=5;else for(d=1;;){if(y=Te(7,0,(15-d|0)*3|0)|0,!((y&l|0)==0&((U()|0)&c|0)==0)){l=2;break e}if(d>>>0>>0)d=d+1|0;else{l=5;break}}else l=2;while(!1);Xo(f|0,-1,l<<2|0)|0;e:do if(p)for(m=0;;){if(y=P+(m<<4)|0,EO(y,u[w>>2]|0)|0,y=u[y>>2]|0,b=u[f>>2]|0,(b|0)==-1|(b|0)==(y|0))d=f;else{p=0;do{if(p=p+1|0,p>>>0>=l>>>0){d=1;break e}d=f+(p<<2)|0,b=u[d>>2]|0}while(!((b|0)==-1|(b|0)==(y|0)))}if(u[d>>2]=y,m=m+1|0,m>>>0>=E>>>0){d=0;break}}else for(m=0;;){if(y=P+(m<<4)|0,pc(y,u[w>>2]|0,0,1)|0,y=u[y>>2]|0,b=u[f>>2]|0,(b|0)==-1|(b|0)==(y|0))d=f;else{p=0;do{if(p=p+1|0,p>>>0>=l>>>0){d=1;break e}d=f+(p<<2)|0,b=u[d>>2]|0}while(!((b|0)==-1|(b|0)==(y|0)))}if(u[d>>2]=y,m=m+1|0,m>>>0>=E>>>0){d=0;break}}while(!1)}return P=d,O=N,P|0}function LO(){return 12}function Rm(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0;if(l>>>0>15)return b=4,b|0;if(Te(l|0,0,52)|0,b=U()|0|134225919,!l){f=0,d=0;do zt(d)|0&&(Te(d|0,0,45)|0,y=b|(U()|0),l=c+(f<<3)|0,u[l>>2]=-1,u[l+4>>2]=y,f=f+1|0),d=d+1|0;while((d|0)!=122);return f=0,f|0}f=0,y=0;do{if(zt(y)|0){for(Te(y|0,0,45)|0,d=1,p=-1,m=b|(U()|0);E=Te(7,0,(15-d|0)*3|0)|0,p=p&~E,m=m&~(U()|0),(d|0)!=(l|0);)d=d+1|0;E=c+(f<<3)|0,u[E>>2]=p,u[E+4>>2]=m,f=f+1|0}y=y+1|0}while((y|0)!=122);return f=0,f|0}function NO(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0;if(te=O,O=O+16|0,ce=te,oe=pe(l|0,c|0,52)|0,U()|0,oe=oe&15,f>>>0>15)return oe=4,O=te,oe|0;if((oe|0)<(f|0))return oe=12,O=te,oe|0;if((oe|0)!=(f|0))if(m=Te(f|0,0,52)|0,m=m|l,b=U()|0|c&-15728641,(oe|0)>(f|0)){E=f;do Z=Te(7,0,(14-E|0)*3|0)|0,E=E+1|0,m=Z|m,b=U()|0|b;while((E|0)<(oe|0));Z=m}else Z=m;else Z=l,b=c;z=pe(Z|0,b|0,45)|0,U()|0;e:do if(zt(z&127)|0){if(E=pe(Z|0,b|0,52)|0,U()|0,E=E&15,E|0)for(m=1;;){if(z=Te(7,0,(15-m|0)*3|0)|0,!((z&Z|0)==0&((U()|0)&b|0)==0)){w=33;break e}if(m>>>0>>0)m=m+1|0;else break}if(z=d,u[z>>2]=0,u[z+4>>2]=0,(oe|0)>(f|0)){for(z=c&-15728641,j=oe;;){if(G=j,j=j+-1|0,j>>>0>15|(oe|0)<(j|0)){w=19;break}if((oe|0)!=(j|0))if(m=Te(j|0,0,52)|0,m=m|l,E=U()|0|z,(oe|0)<(G|0))N=m;else{w=j;do N=Te(7,0,(14-w|0)*3|0)|0,w=w+1|0,m=N|m,E=U()|0|E;while((w|0)<(oe|0));N=m}else N=l,E=c;if(P=pe(N|0,E|0,45)|0,U()|0,!(zt(P&127)|0))m=0;else{P=pe(N|0,E|0,52)|0,U()|0,P=P&15;t:do if(!P)m=0;else for(w=1;;){if(m=pe(N|0,E|0,(15-w|0)*3|0)|0,U()|0,m=m&7,m|0)break t;if(w>>>0

>>0)w=w+1|0;else{m=0;break}}while(!1);m=(m|0)==0&1}if(E=pe(l|0,c|0,(15-G|0)*3|0)|0,U()|0,E=E&7,(E|0)==7){p=5,w=42;break}if(m=(m|0)!=0,(E|0)==1&m){p=5,w=42;break}if(N=E+(((E|0)!=0&m)<<31>>31)|0,N|0&&(w=oe-G|0,w=Ws(7,0,w,((w|0)<0)<<31>>31)|0,P=U()|0,m?(m=zr(w|0,P|0,5,0)|0,m=ot(m|0,U()|0,-5,-1)|0,m=jo(m|0,U()|0,6,0)|0,m=ot(m|0,U()|0,1,0)|0,E=U()|0):(m=w,E=P),G=N+-1|0,G=zr(w|0,P|0,G|0,((G|0)<0)<<31>>31|0)|0,G=ot(m|0,E|0,G|0,U()|0)|0,N=U()|0,P=d,P=ot(G|0,N|0,u[P>>2]|0,u[P+4>>2]|0)|0,N=U()|0,G=d,u[G>>2]=P,u[G+4>>2]=N),(j|0)<=(f|0)){w=37;break}}if((w|0)==19)Ve(23313,22674,1099,22710);else if((w|0)==37){y=d,p=u[y+4>>2]|0,y=u[y>>2]|0;break}else if((w|0)==42)return O=te,p|0}else p=0,y=0}else w=33;while(!1);e:do if((w|0)==33)if(z=d,u[z>>2]=0,u[z+4>>2]=0,(oe|0)>(f|0)){for(m=oe;;){if(p=pe(l|0,c|0,(15-m|0)*3|0)|0,U()|0,p=p&7,(p|0)==7){p=5;break}if(y=oe-m|0,y=Ws(7,0,y,((y|0)<0)<<31>>31)|0,p=zr(y|0,U()|0,p|0,0)|0,y=U()|0,z=d,y=ot(u[z>>2]|0,u[z+4>>2]|0,p|0,y|0)|0,p=U()|0,z=d,u[z>>2]=y,u[z+4>>2]=p,m=m+-1|0,(m|0)<=(f|0))break e}return O=te,p|0}else p=0,y=0;while(!1);return Gh(Z,b,oe,ce)|0&&Ve(23313,22674,1063,22725),oe=ce,ce=u[oe+4>>2]|0,((p|0)>-1|(p|0)==-1&y>>>0>4294967295)&((ce|0)>(p|0)|((ce|0)==(p|0)?(u[oe>>2]|0)>>>0>y>>>0:0))?(oe=0,O=te,oe|0):(Ve(23313,22674,1139,22710),0)}function DO(l,c,f,d,p,m){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,m=m|0;var y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0;if(N=O,O=O+16|0,y=N,p>>>0>15)return m=4,O=N,m|0;if(b=pe(f|0,d|0,52)|0,U()|0,b=b&15,(b|0)>(p|0))return m=12,O=N,m|0;if(Gh(f,d,p,y)|0&&Ve(23313,22674,1063,22725),P=y,w=u[P+4>>2]|0,!(((c|0)>-1|(c|0)==-1&l>>>0>4294967295)&((w|0)>(c|0)|((w|0)==(c|0)?(u[P>>2]|0)>>>0>l>>>0:0))))return m=2,O=N,m|0;P=p-b|0,p=Te(p|0,0,52)|0,E=U()|0|d&-15728641,w=m,u[w>>2]=p|f,u[w+4>>2]=E,w=pe(f|0,d|0,45)|0,U()|0;e:do if(zt(w&127)|0){if(b|0)for(y=1;;){if(w=Te(7,0,(15-y|0)*3|0)|0,!((w&f|0)==0&((U()|0)&d|0)==0))break e;if(y>>>0>>0)y=y+1|0;else break}if((P|0)<1)return m=0,O=N,m|0;for(w=b^15,d=-1,E=1,y=1;;){b=P-E|0,b=Ws(7,0,b,((b|0)<0)<<31>>31)|0,f=U()|0;do if(y)if(y=zr(b|0,f|0,5,0)|0,y=ot(y|0,U()|0,-5,-1)|0,y=jo(y|0,U()|0,6,0)|0,p=U()|0,(c|0)>(p|0)|(c|0)==(p|0)&l>>>0>y>>>0){c=ot(l|0,c|0,-1,-1)|0,c=Vr(c|0,U()|0,y|0,p|0)|0,y=U()|0,G=m,z=u[G>>2]|0,G=u[G+4>>2]|0,Z=(w+d|0)*3|0,j=Te(7,0,Z|0)|0,G=G&~(U()|0),d=jo(c|0,y|0,b|0,f|0)|0,l=U()|0,p=ot(d|0,l|0,2,0)|0,Z=Te(p|0,U()|0,Z|0)|0,G=U()|0|G,p=m,u[p>>2]=Z|z&~j,u[p+4>>2]=G,l=zr(d|0,l|0,b|0,f|0)|0,l=Vr(c|0,y|0,l|0,U()|0)|0,y=0,c=U()|0;break}else{Z=m,j=u[Z>>2]|0,Z=u[Z+4>>2]|0,z=Te(7,0,(w+d|0)*3|0)|0,Z=Z&~(U()|0),y=m,u[y>>2]=j&~z,u[y+4>>2]=Z,y=1;break}else j=m,p=u[j>>2]|0,j=u[j+4>>2]|0,d=(w+d|0)*3|0,G=Te(7,0,d|0)|0,j=j&~(U()|0),Z=jo(l|0,c|0,b|0,f|0)|0,y=U()|0,d=Te(Z|0,y|0,d|0)|0,j=U()|0|j,z=m,u[z>>2]=d|p&~G,u[z+4>>2]=j,y=zr(Z|0,y|0,b|0,f|0)|0,l=Vr(l|0,c|0,y|0,U()|0)|0,y=0,c=U()|0;while(!1);if((P|0)>(E|0))d=~E,E=E+1|0;else{c=0;break}}return O=N,c|0}while(!1);if((P|0)<1)return Z=0,O=N,Z|0;for(p=b^15,y=1;;)if(z=P-y|0,z=Ws(7,0,z,((z|0)<0)<<31>>31)|0,Z=U()|0,E=m,f=u[E>>2]|0,E=u[E+4>>2]|0,b=(p-y|0)*3|0,d=Te(7,0,b|0)|0,E=E&~(U()|0),G=jo(l|0,c|0,z|0,Z|0)|0,j=U()|0,b=Te(G|0,j|0,b|0)|0,E=U()|0|E,w=m,u[w>>2]=b|f&~d,u[w+4>>2]=E,Z=zr(G|0,j|0,z|0,Z|0)|0,l=Vr(l|0,c|0,Z|0,U()|0)|0,c=U()|0,(P|0)<=(y|0)){c=0;break}else y=y+1|0;return O=N,c|0}function lT(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0;p=pe(c|0,f|0,52)|0,U()|0,p=p&15,(c|0)==0&(f|0)==0|((d|0)>15|(p|0)>(d|0))?(d=-1,p=-1,c=0,f=0):(m=wO(c,f,p+1|0,d)|0,f=(U()|0)&-15728641,c=Te(d|0,0,52)|0,c=m|c,f=f|(U()|0),m=(Ht(c,f)|0)==0,d=m?-1:d),m=l,u[m>>2]=c,u[m+4>>2]=f,u[l+8>>2]=p,u[l+12>>2]=d}function AT(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0;if(f=l,c=u[f>>2]|0,f=u[f+4>>2]|0,!((c|0)==0&(f|0)==0)&&(d=pe(c|0,f|0,52)|0,U()|0,d=d&15,b=Te(1,0,(d^15)*3|0)|0,c=ot(b|0,U()|0,c|0,f|0)|0,f=U()|0,b=l,u[b>>2]=c,u[b+4>>2]=f,b=l+8|0,y=u[b>>2]|0,!((d|0)<(y|0)))){for(E=l+12|0,m=d;;){if((m|0)==(y|0)){d=5;break}if(w=(m|0)==(u[E>>2]|0),p=(15-m|0)*3|0,d=pe(c|0,f|0,p|0)|0,U()|0,d=d&7,w&((d|0)==1&!0)){d=7;break}if(!((d|0)==7&!0)){d=10;break}if(w=Te(1,0,p|0)|0,c=ot(c|0,f|0,w|0,U()|0)|0,f=U()|0,w=l,u[w>>2]=c,u[w+4>>2]=f,(m|0)>(y|0))m=m+-1|0;else{d=10;break}}if((d|0)==5){w=l,u[w>>2]=0,u[w+4>>2]=0,u[b>>2]=-1,u[E>>2]=-1;return}else if((d|0)==7){y=Te(1,0,p|0)|0,y=ot(c|0,f|0,y|0,U()|0)|0,b=U()|0,w=l,u[w>>2]=y,u[w+4>>2]=b,u[E>>2]=m+-1;return}else if((d|0)==10)return}}function dA(l){l=+l;var c=0;return c=l<0?l+6.283185307179586:l,+(l>=6.283185307179586?c+-6.283185307179586:c)}function mc(l,c){return l=l|0,c=c|0,+vt(+(+F[l>>3]-+F[c>>3]))<17453292519943298e-27?(c=+vt(+(+F[l+8>>3]-+F[c+8>>3]))<17453292519943298e-27,c|0):(c=0,c|0)}function UO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;return p=+F[c>>3],d=+F[l>>3],m=+yt(+((p-d)*.5)),f=+yt(+((+F[c+8>>3]-+F[l+8>>3])*.5)),f=m*m+f*(+_t(+p)*+_t(+d)*f),+(+Bi(+ +jt(+f),+ +jt(+(1-f)))*2)}function pA(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;return p=+F[c>>3],d=+F[l>>3],m=+yt(+((p-d)*.5)),f=+yt(+((+F[c+8>>3]-+F[l+8>>3])*.5)),f=m*m+f*(+_t(+p)*+_t(+d)*f),+(+Bi(+ +jt(+f),+ +jt(+(1-f)))*2*6371.007180918475)}function kO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;return p=+F[c>>3],d=+F[l>>3],m=+yt(+((p-d)*.5)),f=+yt(+((+F[c+8>>3]-+F[l+8>>3])*.5)),f=m*m+f*(+_t(+p)*+_t(+d)*f),+(+Bi(+ +jt(+f),+ +jt(+(1-f)))*2*6371.007180918475*1e3)}function VO(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0;return m=+F[c>>3],d=+_t(+m),p=+F[c+8>>3]-+F[l+8>>3],y=d*+yt(+p),f=+F[l>>3],+ +Bi(+y,+(+yt(+m)*+_t(+f)-+_t(+p)*(d*+yt(+f))))}function zO(l,c,f,d){l=l|0,c=+c,f=+f,d=d|0;var p=0,m=0,y=0,b=0;if(f<1e-16){u[d>>2]=u[l>>2],u[d+4>>2]=u[l+4>>2],u[d+8>>2]=u[l+8>>2],u[d+12>>2]=u[l+12>>2];return}m=c<0?c+6.283185307179586:c,m=c>=6.283185307179586?m+-6.283185307179586:m;do if(m<1e-16)c=+F[l>>3]+f,F[d>>3]=c,p=d;else{if(p=+vt(+(m+-3.141592653589793))<1e-16,c=+F[l>>3],p){c=c-f,F[d>>3]=c,p=d;break}if(y=+_t(+f),f=+yt(+f),c=y*+yt(+c)+ +_t(+m)*(f*+_t(+c)),c=c>1?1:c,c=+L8(+(c<-1?-1:c)),F[d>>3]=c,+vt(+(c+-1.5707963267948966))<1e-16){F[d>>3]=1.5707963267948966,F[d+8>>3]=0;return}if(+vt(+(c+1.5707963267948966))<1e-16){F[d>>3]=-1.5707963267948966,F[d+8>>3]=0;return}if(b=+_t(+c),m=f*+yt(+m)/b,f=+F[l>>3],c=(y-+yt(+c)*+yt(+f))/+_t(+f)/b,y=m>1?1:m,c=c>1?1:c,c=+F[l+8>>3]+ +Bi(+(y<-1?-1:y),+(c<-1?-1:c)),c>3.141592653589793)do c=c+-6.283185307179586;while(c>3.141592653589793);if(c<-3.141592653589793)do c=c+6.283185307179586;while(c<-3.141592653589793);F[d+8>>3]=c;return}while(!1);if(+vt(+(c+-1.5707963267948966))<1e-16){F[p>>3]=1.5707963267948966,F[d+8>>3]=0;return}if(+vt(+(c+1.5707963267948966))<1e-16){F[p>>3]=-1.5707963267948966,F[d+8>>3]=0;return}if(c=+F[l+8>>3],c>3.141592653589793)do c=c+-6.283185307179586;while(c>3.141592653589793);if(c<-3.141592653589793)do c=c+6.283185307179586;while(c<-3.141592653589793);F[d+8>>3]=c}function HO(l,c){return l=l|0,c=c|0,l>>>0>15?(c=4,c|0):(F[c>>3]=+F[20528+(l<<3)>>3],c=0,c|0)}function GO(l,c){return l=l|0,c=c|0,l>>>0>15?(c=4,c|0):(F[c>>3]=+F[20656+(l<<3)>>3],c=0,c|0)}function WO(l,c){return l=l|0,c=c|0,l>>>0>15?(c=4,c|0):(F[c>>3]=+F[20784+(l<<3)>>3],c=0,c|0)}function jO(l,c){return l=l|0,c=c|0,l>>>0>15?(c=4,c|0):(F[c>>3]=+F[20912+(l<<3)>>3],c=0,c|0)}function Bm(l,c){l=l|0,c=c|0;var f=0;return l>>>0>15?(c=4,c|0):(f=Ws(7,0,l,((l|0)<0)<<31>>31)|0,f=zr(f|0,U()|0,120,0)|0,l=U()|0,u[c>>2]=f|2,u[c+4>>2]=l,c=0,c|0)}function uT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0;return G=+F[c>>3],P=+F[l>>3],E=+yt(+((G-P)*.5)),m=+F[c+8>>3],w=+F[l+8>>3],y=+yt(+((m-w)*.5)),b=+_t(+P),N=+_t(+G),y=E*E+y*(N*b*y),y=+Bi(+ +jt(+y),+ +jt(+(1-y)))*2,E=+F[f>>3],G=+yt(+((E-G)*.5)),d=+F[f+8>>3],m=+yt(+((d-m)*.5)),p=+_t(+E),m=G*G+m*(N*p*m),m=+Bi(+ +jt(+m),+ +jt(+(1-m)))*2,E=+yt(+((P-E)*.5)),d=+yt(+((w-d)*.5)),d=E*E+d*(b*p*d),d=+Bi(+ +jt(+d),+ +jt(+(1-d)))*2,p=(y+m+d)*.5,+(+gm(+ +jt(+(+AA(+(p*.5))*+AA(+((p-y)*.5))*+AA(+((p-m)*.5))*+AA(+((p-d)*.5)))))*4)}function Om(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0;if(b=O,O=O+192|0,m=b+168|0,y=b,p=fA(l,c,m)|0,p|0)return f=p,O=b,f|0;if(hA(l,c,y)|0&&Ve(23313,22742,386,22751),c=u[y>>2]|0,(c|0)>0){if(d=+uT(y+8|0,y+8+(((c|0)!=1&1)<<4)|0,m)+0,(c|0)!=1){l=1;do p=l,l=l+1|0,d=d+ +uT(y+8+(p<<4)|0,y+8+(((l|0)%(c|0)|0)<<4)|0,m);while((l|0)<(c|0))}}else d=0;return F[f>>3]=d,f=0,O=b,f|0}function XO(l,c,f){return l=l|0,c=c|0,f=f|0,l=Om(l,c,f)|0,l|0||(F[f>>3]=+F[f>>3]*6371.007180918475*6371.007180918475),l|0}function YO(l,c,f){return l=l|0,c=c|0,f=f|0,l=Om(l,c,f)|0,l|0||(F[f>>3]=+F[f>>3]*6371.007180918475*6371.007180918475*1e3*1e3),l|0}function QO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(b=O,O=O+176|0,y=b,l=Hh(l,c,y)|0,l|0)return y=l,O=b,y|0;if(F[f>>3]=0,l=u[y>>2]|0,(l|0)<=1)return y=0,O=b,y|0;c=l+-1|0,l=0,d=+F[y+8>>3],p=+F[y+16>>3],m=0;do l=l+1|0,w=d,d=+F[y+8+(l<<4)>>3],P=+yt(+((d-w)*.5)),E=p,p=+F[y+8+(l<<4)+8>>3],E=+yt(+((p-E)*.5)),E=P*P+E*(+_t(+d)*+_t(+w)*E),m=m+ +Bi(+ +jt(+E),+ +jt(+(1-E)))*2;while((l|0)<(c|0));return F[f>>3]=m,y=0,O=b,y|0}function qO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(b=O,O=O+176|0,y=b,l=Hh(l,c,y)|0,l|0)return y=l,m=+F[f>>3],m=m*6371.007180918475,F[f>>3]=m,O=b,y|0;if(F[f>>3]=0,l=u[y>>2]|0,(l|0)<=1)return y=0,m=0,m=m*6371.007180918475,F[f>>3]=m,O=b,y|0;c=l+-1|0,l=0,d=+F[y+8>>3],p=+F[y+16>>3],m=0;do l=l+1|0,w=d,d=+F[y+8+(l<<4)>>3],P=+yt(+((d-w)*.5)),E=p,p=+F[y+8+(l<<4)+8>>3],E=+yt(+((p-E)*.5)),E=P*P+E*(+_t(+w)*+_t(+d)*E),m=m+ +Bi(+ +jt(+E),+ +jt(+(1-E)))*2;while((l|0)!=(c|0));return F[f>>3]=m,y=0,P=m,P=P*6371.007180918475,F[f>>3]=P,O=b,y|0}function KO(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(b=O,O=O+176|0,y=b,l=Hh(l,c,y)|0,l|0)return y=l,m=+F[f>>3],m=m*6371.007180918475,m=m*1e3,F[f>>3]=m,O=b,y|0;if(F[f>>3]=0,l=u[y>>2]|0,(l|0)<=1)return y=0,m=0,m=m*6371.007180918475,m=m*1e3,F[f>>3]=m,O=b,y|0;c=l+-1|0,l=0,d=+F[y+8>>3],p=+F[y+16>>3],m=0;do l=l+1|0,w=d,d=+F[y+8+(l<<4)>>3],P=+yt(+((d-w)*.5)),E=p,p=+F[y+8+(l<<4)+8>>3],E=+yt(+((p-E)*.5)),E=P*P+E*(+_t(+w)*+_t(+d)*E),m=m+ +Bi(+ +jt(+E),+ +jt(+(1-E)))*2;while((l|0)!=(c|0));return F[f>>3]=m,y=0,P=m,P=P*6371.007180918475,P=P*1e3,F[f>>3]=P,O=b,y|0}function JO(l){l=l|0;var c=0,f=0,d=0;return c=Bn(1,12)|0,c||Ve(22832,22787,49,22845),f=l+4|0,d=u[f>>2]|0,d|0?(d=d+8|0,u[d>>2]=c,u[f>>2]=c,c|0):(u[l>>2]|0&&Ve(22862,22787,61,22885),d=l,u[d>>2]=c,u[f>>2]=c,c|0)}function ZO(l,c){l=l|0,c=c|0;var f=0,d=0;return d=Rn(24)|0,d||Ve(22899,22787,78,22913),u[d>>2]=u[c>>2],u[d+4>>2]=u[c+4>>2],u[d+8>>2]=u[c+8>>2],u[d+12>>2]=u[c+12>>2],u[d+16>>2]=0,c=l+4|0,f=u[c>>2]|0,f|0?(u[f+16>>2]=d,u[c>>2]=d,d|0):(u[l>>2]|0&&Ve(22928,22787,82,22913),u[l>>2]=d,u[c>>2]=d,d|0)}function fT(l){l=l|0;var c=0,f=0,d=0,p=0;if(l)for(d=1;;){if(c=u[l>>2]|0,c|0)do{if(f=u[c>>2]|0,f|0)do p=f,f=u[f+16>>2]|0,We(p);while(f|0);p=c,c=u[c+8>>2]|0,We(p)}while(c|0);if(c=l,l=u[l+8>>2]|0,d||We(c),l)d=0;else break}}function $O(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0,St=0,dt=0,pt=0,Je=0,qe=0,Ze=0,It=0,je=0;if(p=l+8|0,u[p>>2]|0)return je=1,je|0;if(d=u[l>>2]|0,!d)return je=0,je|0;c=d,f=0;do f=f+1|0,c=u[c+8>>2]|0;while(c|0);if(f>>>0<2)return je=0,je|0;Ze=Rn(f<<2)|0,Ze||Ve(22948,22787,317,22967),qe=Rn(f<<5)|0,qe||Ve(22989,22787,321,22967),u[l>>2]=0,Ie=l+4|0,u[Ie>>2]=0,u[p>>2]=0,f=0,Je=0,Se=0,N=0;e:for(;;){if(P=u[d>>2]|0,P){m=0,y=P;do{if(E=+F[y+8>>3],c=y,y=u[y+16>>2]|0,w=(y|0)==0,p=w?P:y,b=+F[p+8>>3],+vt(+(E-b))>3.141592653589793){je=14;break}m=m+(b-E)*(+F[c>>3]+ +F[p>>3])}while(!w);if((je|0)==14){je=0,m=0,c=P;do J=+F[c+8>>3],pt=c+16|0,dt=u[pt>>2]|0,dt=dt|0?dt:P,ne=+F[dt+8>>3],m=m+(+F[c>>3]+ +F[dt>>3])*((ne<0?ne+6.283185307179586:ne)-(J<0?J+6.283185307179586:J)),c=u[(c|0?pt:d)>>2]|0;while(c|0)}m>0?(u[Ze+(Je<<2)>>2]=d,Je=Je+1|0,p=Se,c=N):je=19}else je=19;if((je|0)==19){je=0;do if(f){if(c=f+8|0,u[c>>2]|0){je=21;break e}if(f=Bn(1,12)|0,!f){je=23;break e}u[c>>2]=f,p=f+4|0,y=f,c=N}else if(N){p=Ie,y=N+8|0,c=d,f=l;break}else if(u[l>>2]|0){je=27;break e}else{p=Ie,y=l,c=d,f=l;break}while(!1);if(u[y>>2]=d,u[p>>2]=d,y=qe+(Se<<5)|0,w=u[d>>2]|0,w){for(P=qe+(Se<<5)+8|0,F[P>>3]=17976931348623157e292,N=qe+(Se<<5)+24|0,F[N>>3]=17976931348623157e292,F[y>>3]=-17976931348623157e292,G=qe+(Se<<5)+16|0,F[G>>3]=-17976931348623157e292,oe=17976931348623157e292,te=-17976931348623157e292,p=0,j=w,E=17976931348623157e292,Z=17976931348623157e292,ce=-17976931348623157e292,b=-17976931348623157e292;m=+F[j>>3],J=+F[j+8>>3],j=u[j+16>>2]|0,z=(j|0)==0,ne=+F[(z?w:j)+8>>3],m>3]=m,E=m),J>3]=J,Z=J),m>ce?F[y>>3]=m:m=ce,J>b&&(F[G>>3]=J,b=J),oe=J>0&Jte?J:te,p=p|+vt(+(J-ne))>3.141592653589793,!z;)ce=m;p&&(F[G>>3]=te,F[N>>3]=oe)}else u[y>>2]=0,u[y+4>>2]=0,u[y+8>>2]=0,u[y+12>>2]=0,u[y+16>>2]=0,u[y+20>>2]=0,u[y+24>>2]=0,u[y+28>>2]=0;p=Se+1|0}if(pt=d+8|0,d=u[pt>>2]|0,u[pt>>2]=0,d)Se=p,N=c;else{je=45;break}}if((je|0)==21)Ve(22765,22787,35,22799);else if((je|0)==23)Ve(22819,22787,37,22799);else if((je|0)==27)Ve(22862,22787,61,22885);else if((je|0)==45){e:do if((Je|0)>0){for(pt=(p|0)==0,St=p<<2,dt=(l|0)==0,we=0,c=0;;){if(be=u[Ze+(we<<2)>>2]|0,pt)je=73;else{if(Se=Rn(St)|0,!Se){je=50;break}if(Ie=Rn(St)|0,!Ie){je=52;break}t:do if(dt)f=0;else{for(p=0,f=0,y=l;d=qe+(p<<5)|0,hT(u[y>>2]|0,d,u[be>>2]|0)|0?(u[Se+(f<<2)>>2]=y,u[Ie+(f<<2)>>2]=d,z=f+1|0):z=f,y=u[y+8>>2]|0,y;)p=p+1|0,f=z;if((z|0)>0)if(d=u[Se>>2]|0,(z|0)==1)f=d;else for(G=0,j=-1,f=d,N=d;;){for(w=u[N>>2]|0,d=0,y=0;p=u[u[Se+(y<<2)>>2]>>2]|0,(p|0)==(w|0)?P=d:P=d+((hT(p,u[Ie+(y<<2)>>2]|0,u[w>>2]|0)|0)&1)|0,y=y+1|0,(y|0)!=(z|0);)d=P;if(p=(P|0)>(j|0),f=p?N:f,d=G+1|0,(d|0)==(z|0))break t;G=d,j=p?P:j,N=u[Se+(d<<2)>>2]|0}else f=0}while(!1);if(We(Se),We(Ie),f){if(p=f+4|0,d=u[p>>2]|0,d)f=d+8|0;else if(u[f>>2]|0){je=70;break}u[f>>2]=be,u[p>>2]=be}else je=73}if((je|0)==73){if(je=0,c=u[be>>2]|0,c|0)do Ie=c,c=u[c+16>>2]|0,We(Ie);while(c|0);We(be),c=1}if(we=we+1|0,(we|0)>=(Je|0)){It=c;break e}}(je|0)==50?Ve(23004,22787,249,23023):(je|0)==52?Ve(23042,22787,252,23023):(je|0)==70&&Ve(22862,22787,61,22885)}else It=0;while(!1);return We(Ze),We(qe),je=It,je|0}return 0}function hT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0;if(!(qb(c,f)|0)||(c=Qb(c)|0,d=+F[f>>3],p=+F[f+8>>3],p=c&p<0?p+6.283185307179586:p,l=u[l>>2]|0,!l))return l=0,l|0;if(c){c=0,w=p,f=l;e:for(;;){for(;y=+F[f>>3],p=+F[f+8>>3],f=f+16|0,P=u[f>>2]|0,P=P|0?P:l,m=+F[P>>3],b=+F[P+8>>3],y>m?(E=y,y=b):(E=m,m=y,y=p,p=b),d=d==m|d==E?d+2220446049250313e-31:d,!!(dE);)if(f=u[f>>2]|0,!f){f=22;break e}if(b=y<0?y+6.283185307179586:y,y=p<0?p+6.283185307179586:p,w=b==w|y==w?w+-2220446049250313e-31:w,E=b+(y-b)*((d-m)/(E-m)),(E<0?E+6.283185307179586:E)>w&&(c=c^1),f=u[f>>2]|0,!f){f=22;break}}if((f|0)==22)return c|0}else{c=0,w=p,f=l;e:for(;;){for(;y=+F[f>>3],p=+F[f+8>>3],f=f+16|0,P=u[f>>2]|0,P=P|0?P:l,m=+F[P>>3],b=+F[P+8>>3],y>m?(E=y,y=b):(E=m,m=y,y=p,p=b),d=d==m|d==E?d+2220446049250313e-31:d,!!(dE);)if(f=u[f>>2]|0,!f){f=22;break e}if(w=y==w|p==w?w+-2220446049250313e-31:w,y+(p-y)*((d-m)/(E-m))>w&&(c=c^1),f=u[f>>2]|0,!f){f=22;break}}if((f|0)==22)return c|0}return 0}function ls(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0;if(te=O,O=O+32|0,oe=te+16|0,ce=te,m=pe(l|0,c|0,52)|0,U()|0,m=m&15,j=pe(f|0,d|0,52)|0,U()|0,(m|0)!=(j&15|0))return oe=12,O=te,oe|0;if(w=pe(l|0,c|0,45)|0,U()|0,w=w&127,P=pe(f|0,d|0,45)|0,U()|0,P=P&127,w>>>0>121|P>>>0>121)return oe=5,O=te,oe|0;if(j=(w|0)!=(P|0),j){if(b=bm(w,P)|0,(b|0)==7)return oe=1,O=te,oe|0;E=bm(P,w)|0,(E|0)==7?Ve(23066,23090,161,23100):(z=b,y=E)}else z=0,y=0;N=zt(w)|0,G=zt(P)|0,u[oe>>2]=0,u[oe+4>>2]=0,u[oe+8>>2]=0,u[oe+12>>2]=0;do if(z){if(P=u[4272+(w*28|0)+(z<<2)>>2]|0,b=(P|0)>0,G)if(b){w=0,E=f,b=d;do E=BO(E,b)|0,b=U()|0,y=Gs(y)|0,(y|0)==1&&(y=Gs(1)|0),w=w+1|0;while((w|0)!=(P|0));P=y,w=E,E=b}else P=y,w=f,E=d;else if(b){w=0,E=f,b=d;do E=Pm(E,b)|0,b=U()|0,y=Gs(y)|0,w=w+1|0;while((w|0)!=(P|0));P=y,w=E,E=b}else P=y,w=f,E=d;if(Im(w,E,oe)|0,j||Ve(23115,23090,191,23100),b=(N|0)!=0,y=(G|0)!=0,b&y&&Ve(23142,23090,192,23100),b){if(y=Ai(l,c)|0,(y|0)==7){m=5;break}if(ke[21872+(y*7|0)+z>>0]|0){m=1;break}E=u[21040+(y*28|0)+(z<<2)>>2]|0,w=E}else if(y){if(y=Ai(w,E)|0,(y|0)==7){m=5;break}if(ke[21872+(y*7|0)+P>>0]|0){m=1;break}w=0,E=u[21040+(P*28|0)+(y<<2)>>2]|0}else w=0,E=0;if((w|E|0)<0)m=5;else{if((E|0)>0){b=oe+4|0,y=0;do zh(b),y=y+1|0;while((y|0)!=(E|0))}if(u[ce>>2]=0,u[ce+4>>2]=0,u[ce+8>>2]=0,$b(ce,z),m|0)for(;Oi(m)|0?Vh(ce):Ho(ce),(m|0)>1;)m=m+-1|0;if((w|0)>0){m=0;do zh(ce),m=m+1|0;while((m|0)!=(w|0))}Z=oe+4|0,Zr(Z,ce,Z),kr(Z),Z=51}}else if(Im(f,d,oe)|0,(N|0)!=0&(G|0)!=0)if((P|0)!=(w|0)&&Ve(23173,23090,261,23100),y=Ai(l,c)|0,m=Ai(f,d)|0,(y|0)==7|(m|0)==7)m=5;else if(ke[21872+(y*7|0)+m>>0]|0)m=1;else if(y=u[21040+(y*28|0)+(m<<2)>>2]|0,(y|0)>0){b=oe+4|0,m=0;do zh(b),m=m+1|0;while((m|0)!=(y|0));Z=51}else Z=51;else Z=51;while(!1);return(Z|0)==51&&(m=oe+4|0,u[p>>2]=u[m>>2],u[p+4>>2]=u[m+4>>2],u[p+8>>2]=u[m+8>>2],m=0),oe=m,O=te,oe|0}function dT(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0;if(Z=O,O=O+48|0,w=Z+36|0,y=Z+24|0,b=Z+12|0,E=Z,p=pe(l|0,c|0,52)|0,U()|0,p=p&15,G=pe(l|0,c|0,45)|0,U()|0,G=G&127,G>>>0>121)return d=5,O=Z,d|0;if(P=zt(G)|0,Te(p|0,0,52)|0,ce=U()|0|134225919,m=d,u[m>>2]=-1,u[m+4>>2]=ce,!p)return p=kh(f)|0,(p|0)==7||(p=xm(G,p)|0,(p|0)==127)?(ce=1,O=Z,ce|0):(j=Te(p|0,0,45)|0,z=U()|0,G=d,z=u[G+4>>2]&-1040385|z,ce=d,u[ce>>2]=u[G>>2]|j,u[ce+4>>2]=z,ce=0,O=Z,ce|0);for(u[w>>2]=u[f>>2],u[w+4>>2]=u[f+4>>2],u[w+8>>2]=u[f+8>>2],f=p;;){if(m=f,f=f+-1|0,u[y>>2]=u[w>>2],u[y+4>>2]=u[w+4>>2],u[y+8>>2]=u[w+8>>2],Oi(m)|0){if(p=oO(w)|0,p|0){f=13;break}u[b>>2]=u[w>>2],u[b+4>>2]=u[w+4>>2],u[b+8>>2]=u[w+8>>2],Vh(b)}else{if(p=aO(w)|0,p|0){f=13;break}u[b>>2]=u[w>>2],u[b+4>>2]=u[w+4>>2],u[b+8>>2]=u[w+8>>2],Ho(b)}if(Tm(y,b,E),kr(E),p=d,te=u[p>>2]|0,p=u[p+4>>2]|0,ne=(15-m|0)*3|0,oe=Te(7,0,ne|0)|0,p=p&~(U()|0),ne=Te(kh(E)|0,0,ne|0)|0,p=U()|0|p,ce=d,u[ce>>2]=ne|te&~oe,u[ce+4>>2]=p,(m|0)<=1){f=14;break}}e:do if((f|0)!=13&&(f|0)==14)if((u[w>>2]|0)<=1&&(u[w+4>>2]|0)<=1&&(u[w+8>>2]|0)<=1){f=kh(w)|0,p=xm(G,f)|0,(p|0)==127?E=0:E=zt(p)|0;t:do if(f){if(P){if(p=Ai(l,c)|0,(p|0)==7){p=5;break e}if(m=u[21248+(p*28|0)+(f<<2)>>2]|0,(m|0)>0){p=f,f=0;do p=Go(p)|0,f=f+1|0;while((f|0)!=(m|0))}else p=f;if((p|0)==1){p=9;break e}f=xm(G,p)|0,(f|0)==127&&Ve(23200,23090,411,23230),zt(f)|0?Ve(23245,23090,412,23230):(z=f,j=m,N=p)}else z=p,j=0,N=f;if(b=u[4272+(G*28|0)+(N<<2)>>2]|0,(b|0)<=-1&&Ve(23276,23090,419,23230),!E){if((j|0)<0){p=5;break e}if(j|0){m=d,p=0,f=u[m>>2]|0,m=u[m+4>>2]|0;do f=Wo(f,m)|0,m=U()|0,ne=d,u[ne>>2]=f,u[ne+4>>2]=m,p=p+1|0;while((p|0)<(j|0))}if((b|0)<=0){p=z,f=58;break}for(m=d,p=0,f=u[m>>2]|0,m=u[m+4>>2]|0;;)if(f=Wo(f,m)|0,m=U()|0,ne=d,u[ne>>2]=f,u[ne+4>>2]=m,p=p+1|0,(p|0)==(b|0)){p=z,f=58;break t}}if(y=bm(z,G)|0,(y|0)==7&&Ve(23066,23090,428,23230),p=d,f=u[p>>2]|0,p=u[p+4>>2]|0,(b|0)>0){m=0;do f=Wo(f,p)|0,p=U()|0,ne=d,u[ne>>2]=f,u[ne+4>>2]=p,m=m+1|0;while((m|0)!=(b|0))}if(p=Ai(f,p)|0,(p|0)==7&&Ve(23313,23090,440,23230),f=ym(z)|0,f=u[(f?21664:21456)+(y*28|0)+(p<<2)>>2]|0,(f|0)<0&&Ve(23313,23090,454,23230),!f)p=z,f=58;else{y=d,p=0,m=u[y>>2]|0,y=u[y+4>>2]|0;do m=Mm(m,y)|0,y=U()|0,ne=d,u[ne>>2]=m,u[ne+4>>2]=y,p=p+1|0;while((p|0)<(f|0));p=z,f=58}}else if((P|0)!=0&(E|0)!=0){if(f=Ai(l,c)|0,m=d,m=Ai(u[m>>2]|0,u[m+4>>2]|0)|0,(f|0)==7|(m|0)==7){p=5;break e}if(m=u[21248+(f*28|0)+(m<<2)>>2]|0,(m|0)<0){p=5;break e}if(!m)f=59;else{b=d,f=0,y=u[b>>2]|0,b=u[b+4>>2]|0;do y=Wo(y,b)|0,b=U()|0,ne=d,u[ne>>2]=y,u[ne+4>>2]=b,f=f+1|0;while((f|0)<(m|0));f=58}}else f=58;while(!1);if((f|0)==58&&E&&(f=59),(f|0)==59&&(ne=d,(Ai(u[ne>>2]|0,u[ne+4>>2]|0)|0)==1)){p=9;break}ne=d,oe=u[ne>>2]|0,ne=u[ne+4>>2]&-1040385,te=Te(p|0,0,45)|0,ne=ne|(U()|0),p=d,u[p>>2]=oe|te,u[p+4>>2]=ne,p=0}else p=1;while(!1);return ne=p,O=Z,ne|0}function eF(l,c,f,d,p,m){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0,m=m|0;var y=0,b=0;return b=O,O=O+16|0,y=b,p?l=15:(l=ls(l,c,f,d,y)|0,l||(lO(y,m),l=0)),O=b,l|0}function tF(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0;return y=O,O=O+16|0,m=y,d?f=15:(f=AO(f,m)|0,f||(f=dT(l,c,m,p)|0)),O=y,f|0}function rF(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0;return E=O,O=O+32|0,y=E+12|0,b=E,m=ls(l,c,l,c,y)|0,m|0?(b=m,O=E,b|0):(l=ls(l,c,f,d,b)|0,l|0?(b=l,O=E,b|0):(y=Em(y,b)|0,b=p,u[b>>2]=y,u[b+4>>2]=((y|0)<0)<<31>>31,b=0,O=E,b|0))}function iF(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0;return E=O,O=O+32|0,y=E+12|0,b=E,m=ls(l,c,l,c,y)|0,!m&&(m=ls(l,c,f,d,b)|0,!m)?(d=Em(y,b)|0,d=ot(d|0,((d|0)<0)<<31>>31|0,1,0)|0,y=U()|0,b=p,u[b>>2]=d,u[b+4>>2]=y,b=0,O=E,b|0):(b=m,O=E,b|0)}function nF(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0,we=0;if(be=O,O=O+48|0,y=be+24|0,b=be+12|0,Ie=be,m=ls(l,c,l,c,y)|0,!m&&(m=ls(l,c,f,d,b)|0,!m)){J=Em(y,b)|0,Se=((J|0)<0)<<31>>31,u[y>>2]=0,u[y+4>>2]=0,u[y+8>>2]=0,u[b>>2]=0,u[b+4>>2]=0,u[b+8>>2]=0,ls(l,c,l,c,y)|0&&Ve(23313,23090,691,23299),ls(l,c,f,d,b)|0&&Ve(23313,23090,696,23299),iT(y),iT(b),J?(N=u[y>>2]|0,z=+(J|0),oe=y+4|0,G=u[oe>>2]|0,te=y+8|0,j=u[te>>2]|0,ne=y,d=N,m=G,f=j,Z=+((u[b>>2]|0)-N|0)/z,ce=+((u[b+4>>2]|0)-G|0)/z,z=+((u[b+8>>2]|0)-j|0)/z):(m=y+4|0,f=y+8|0,oe=m,te=f,ne=y,d=u[y>>2]|0,m=u[m>>2]|0,f=u[f>>2]|0,Z=0,ce=0,z=0),u[Ie>>2]=d,j=Ie+4|0,u[j>>2]=m,G=Ie+8|0,u[G>>2]=f;e:do if((J|0)<0)m=0;else for(P=0,N=0,m=d;;){w=+(N>>>0)+4294967296*+(P|0),we=Z*w+ +(m|0),E=ce*w+ +(u[oe>>2]|0),w=z*w+ +(u[te>>2]|0),f=~~+jh(+we),y=~~+jh(+E),m=~~+jh(+w),we=+vt(+(+(f|0)-we)),E=+vt(+(+(y|0)-E)),w=+vt(+(+(m|0)-w));do if(we>E&we>w)f=0-(y+m)|0,d=y;else if(b=0-f|0,E>w){d=b-m|0;break}else{d=y,m=b-y|0;break}while(!1);if(u[Ie>>2]=f,u[j>>2]=d,u[G>>2]=m,uO(Ie),m=dT(l,c,Ie,p+(N<<3)|0)|0,m|0)break e;if(!((P|0)<(Se|0)|(P|0)==(Se|0)&N>>>0>>0)){m=0;break e}m=ot(N|0,P|0,1,0)|0,b=U()|0,P=b,N=m,m=u[ne>>2]|0}while(!1);return Ie=m,O=be,Ie|0}return Ie=m,O=be,Ie|0}function Ws(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0;if((f|0)==0&(d|0)==0)return p=0,m=1,tt(p|0),m|0;m=l,p=c,l=1,c=0;do y=(f&1|0)==0&!0,l=zr((y?1:m)|0,(y?0:p)|0,l|0,c|0)|0,c=U()|0,f=vT(f|0,d|0,1)|0,d=U()|0,m=zr(m|0,p|0,m|0,p|0)|0,p=U()|0;while(!((f|0)==0&(d|0)==0));return tt(c|0),l|0}function pT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0;if(!(qb(c,f)|0)||(c=Qb(c)|0,d=+F[f>>3],p=+F[f+8>>3],p=c&p<0?p+6.283185307179586:p,G=u[l>>2]|0,(G|0)<=0))return G=0,G|0;if(N=u[l+4>>2]|0,c){c=0,P=p,f=-1,l=0;e:for(;;){for(w=l;y=+F[N+(w<<4)>>3],p=+F[N+(w<<4)+8>>3],l=(f+2|0)%(G|0)|0,m=+F[N+(l<<4)>>3],b=+F[N+(l<<4)+8>>3],y>m?(E=y,y=b):(E=m,m=y,y=p,p=b),d=d==m|d==E?d+2220446049250313e-31:d,!!(dE);)if(f=w+1|0,(f|0)>=(G|0)){f=22;break e}else l=w,w=f,f=l;if(b=y<0?y+6.283185307179586:y,y=p<0?p+6.283185307179586:p,P=b==P|y==P?P+-2220446049250313e-31:P,E=b+(y-b)*((d-m)/(E-m)),(E<0?E+6.283185307179586:E)>P&&(c=c^1),l=w+1|0,(l|0)>=(G|0)){f=22;break}else f=w}if((f|0)==22)return c|0}else{c=0,P=p,f=-1,l=0;e:for(;;){for(w=l;y=+F[N+(w<<4)>>3],p=+F[N+(w<<4)+8>>3],l=(f+2|0)%(G|0)|0,m=+F[N+(l<<4)>>3],b=+F[N+(l<<4)+8>>3],y>m?(E=y,y=b):(E=m,m=y,y=p,p=b),d=d==m|d==E?d+2220446049250313e-31:d,!!(dE);)if(f=w+1|0,(f|0)>=(G|0)){f=22;break e}else l=w,w=f,f=l;if(P=y==P|p==P?P+-2220446049250313e-31:P,y+(p-y)*((d-m)/(E-m))>P&&(c=c^1),l=w+1|0,(l|0)>=(G|0)){f=22;break}else f=w}if((f|0)==22)return c|0}return 0}function gT(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0;if(z=u[l>>2]|0,!z){u[c>>2]=0,u[c+4>>2]=0,u[c+8>>2]=0,u[c+12>>2]=0,u[c+16>>2]=0,u[c+20>>2]=0,u[c+24>>2]=0,u[c+28>>2]=0;return}if(Z=c+8|0,F[Z>>3]=17976931348623157e292,ce=c+24|0,F[ce>>3]=17976931348623157e292,F[c>>3]=-17976931348623157e292,oe=c+16|0,F[oe>>3]=-17976931348623157e292,!((z|0)<=0)){for(G=u[l+4>>2]|0,w=17976931348623157e292,P=-17976931348623157e292,N=0,l=-1,m=17976931348623157e292,y=17976931348623157e292,E=-17976931348623157e292,d=-17976931348623157e292,j=0;f=+F[G+(j<<4)>>3],b=+F[G+(j<<4)+8>>3],l=l+2|0,p=+F[G+(((l|0)==(z|0)?0:l)<<4)+8>>3],f>3]=f,m=f),b>3]=b,y=b),f>E?F[c>>3]=f:f=E,b>d&&(F[oe>>3]=b,d=b),w=b>0&bP?b:P,N=N|+vt(+(b-p))>3.141592653589793,l=j+1|0,(l|0)!=(z|0);)te=j,E=f,j=l,l=te;N&&(F[oe>>3]=P,F[ce>>3]=w)}}function sF(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0,Ie=0,be=0;if(z=u[l>>2]|0,z){if(Z=c+8|0,F[Z>>3]=17976931348623157e292,ce=c+24|0,F[ce>>3]=17976931348623157e292,F[c>>3]=-17976931348623157e292,oe=c+16|0,F[oe>>3]=-17976931348623157e292,(z|0)>0){for(p=u[l+4>>2]|0,G=17976931348623157e292,j=-17976931348623157e292,d=0,f=-1,E=17976931348623157e292,w=17976931348623157e292,N=-17976931348623157e292,y=-17976931348623157e292,te=0;m=+F[p+(te<<4)>>3],P=+F[p+(te<<4)+8>>3],Ie=f+2|0,b=+F[p+(((Ie|0)==(z|0)?0:Ie)<<4)+8>>3],m>3]=m,E=m),P>3]=P,w=P),m>N?F[c>>3]=m:m=N,P>y&&(F[oe>>3]=P,y=P),G=P>0&Pj?P:j,d=d|+vt(+(P-b))>3.141592653589793,f=te+1|0,(f|0)!=(z|0);)Ie=te,N=m,te=f,f=Ie;d&&(F[oe>>3]=j,F[ce>>3]=G)}}else u[c>>2]=0,u[c+4>>2]=0,u[c+8>>2]=0,u[c+12>>2]=0,u[c+16>>2]=0,u[c+20>>2]=0,u[c+24>>2]=0,u[c+28>>2]=0;if(Ie=l+8|0,f=u[Ie>>2]|0,!((f|0)<=0)){Se=l+12|0,J=0;do if(p=u[Se>>2]|0,d=J,J=J+1|0,ce=c+(J<<5)|0,oe=u[p+(d<<3)>>2]|0,oe){if(te=c+(J<<5)+8|0,F[te>>3]=17976931348623157e292,l=c+(J<<5)+24|0,F[l>>3]=17976931348623157e292,F[ce>>3]=-17976931348623157e292,ne=c+(J<<5)+16|0,F[ne>>3]=-17976931348623157e292,(oe|0)>0){for(z=u[p+(d<<3)+4>>2]|0,G=17976931348623157e292,j=-17976931348623157e292,p=0,d=-1,Z=0,E=17976931348623157e292,w=17976931348623157e292,P=-17976931348623157e292,y=-17976931348623157e292;m=+F[z+(Z<<4)>>3],N=+F[z+(Z<<4)+8>>3],d=d+2|0,b=+F[z+(((d|0)==(oe|0)?0:d)<<4)+8>>3],m>3]=m,E=m),N>3]=N,w=N),m>P?F[ce>>3]=m:m=P,N>y&&(F[ne>>3]=N,y=N),G=N>0&Nj?N:j,p=p|+vt(+(N-b))>3.141592653589793,d=Z+1|0,(d|0)!=(oe|0);)be=Z,Z=d,P=m,d=be;p&&(F[ne>>3]=j,F[l>>3]=G)}}else u[ce>>2]=0,u[ce+4>>2]=0,u[ce+8>>2]=0,u[ce+12>>2]=0,u[ce+16>>2]=0,u[ce+20>>2]=0,u[ce+24>>2]=0,u[ce+28>>2]=0,f=u[Ie>>2]|0;while((J|0)<(f|0))}}function oF(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;if(!(pT(l,c,f)|0))return p=0,p|0;if(p=l+8|0,(u[p>>2]|0)<=0)return p=1,p|0;for(d=l+12|0,l=0;;){if(m=l,l=l+1|0,pT((u[d>>2]|0)+(m<<3)|0,c+(l<<5)|0,f)|0){l=0,d=6;break}if((l|0)>=(u[p>>2]|0)){l=1,d=6;break}}return(d|0)==6?l|0:0}function aF(){return 8}function cF(){return 16}function lF(){return 168}function AF(){return 8}function uF(){return 16}function fF(){return 12}function hF(){return 8}function dF(l){return l=l|0,+(+((u[l>>2]|0)>>>0)+4294967296*+(u[l+4>>2]|0))}function pF(l){l=l|0;var c=0,f=0;return f=+F[l>>3],c=+F[l+8>>3],+ +jt(+(f*f+c*c))}function mT(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0;w=+F[l>>3],E=+F[c>>3]-w,b=+F[l+8>>3],y=+F[c+8>>3]-b,N=+F[f>>3],m=+F[d>>3]-N,G=+F[f+8>>3],P=+F[d+8>>3]-G,m=(m*(b-G)-(w-N)*P)/(E*P-y*m),F[p>>3]=w+E*m,F[p+8>>3]=b+y*m}function _T(l,c){return l=l|0,c=c|0,+vt(+(+F[l>>3]-+F[c>>3]))<11920928955078125e-23?(c=+vt(+(+F[l+8>>3]-+F[c+8>>3]))<11920928955078125e-23,c|0):(c=0,c|0)}function cr(l,c){l=l|0,c=c|0;var f=0,d=0,p=0;return p=+F[l>>3]-+F[c>>3],d=+F[l+8>>3]-+F[c+8>>3],f=+F[l+16>>3]-+F[c+16>>3],+(p*p+d*d+f*f)}function gF(l,c){l=l|0,c=c|0;var f=0,d=0,p=0;f=+F[l>>3],d=+_t(+f),f=+yt(+f),F[c+16>>3]=f,f=+F[l+8>>3],p=d*+_t(+f),F[c>>3]=p,f=d*+yt(+f),F[c+8>>3]=f}function mF(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;if(m=O,O=O+16|0,p=m,d=Ht(l,c)|0,(f+-1|0)>>>0>5||(d=(d|0)!=0,(f|0)==1&d))return p=-1,O=m,p|0;do if(gA(l,c,p)|0)d=-1;else if(d){d=((u[21936+(f<<2)>>2]|0)+5-(u[p>>2]|0)|0)%5|0;break}else{d=((u[21968+(f<<2)>>2]|0)+6-(u[p>>2]|0)|0)%6|0;break}while(!1);return p=d,O=m,p|0}function gA(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0,w=0;if(w=O,O=O+32|0,y=w+16|0,b=w,d=gc(l,c,y)|0,d|0)return f=d,O=w,f|0;m=oT(l,c)|0,E=Ai(l,c)|0,$8(m,b),d=eO(m,u[y>>2]|0)|0;e:do if(zt(m)|0){do switch(m|0){case 4:{l=0;break}case 14:{l=1;break}case 24:{l=2;break}case 38:{l=3;break}case 49:{l=4;break}case 58:{l=5;break}case 63:{l=6;break}case 72:{l=7;break}case 83:{l=8;break}case 97:{l=9;break}case 107:{l=10;break}case 117:{l=11;break}default:{d=1;break e}}while(!1);if(p=u[22e3+(l*24|0)+8>>2]|0,c=u[22e3+(l*24|0)+16>>2]|0,l=u[y>>2]|0,(l|0)!=(u[b>>2]|0)&&(b=ym(m)|0,l=u[y>>2]|0,b|(l|0)==(c|0)&&(d=(d+1|0)%6|0)),(E|0)==3&(l|0)==(c|0)){d=(d+5|0)%6|0,p=22;break}(E|0)==5&(l|0)==(p|0)&&(d=(d+1|0)%6|0),p=22}else p=22;while(!1);return(p|0)==22&&(u[f>>2]=d,d=0),f=d,O=w,f|0}function Fi(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0;if(ne=O,O=O+32|0,te=ne+24|0,ce=ne+20|0,z=ne+8|0,j=ne+16|0,G=ne,E=(Ht(l,c)|0)==0,E=E?6:5,P=pe(l|0,c|0,52)|0,U()|0,P=P&15,E>>>0<=f>>>0)return d=2,O=ne,d|0;N=(P|0)==0,!N&&(Z=Te(7,0,(P^15)*3|0)|0,(Z&l|0)==0&((U()|0)&c|0)==0)?p=f:m=4;e:do if((m|0)==4){if(p=(Ht(l,c)|0)!=0,((p?4:5)|0)<(f|0)||gA(l,c,te)|0||(m=(u[te>>2]|0)+f|0,p?p=22288+(((m|0)%5|0)<<2)|0:p=22320+(((m|0)%6|0)<<2)|0,Z=u[p>>2]|0,(Z|0)==7))return d=1,O=ne,d|0;u[ce>>2]=0,p=vr(l,c,Z,ce,z)|0;do if(!p){if(b=z,w=u[b>>2]|0,b=u[b+4>>2]|0,y=b>>>0>>0|(b|0)==(c|0)&w>>>0>>0,m=y?w:l,y=y?b:c,!N&&(N=Te(7,0,(P^15)*3|0)|0,(w&N|0)==0&(b&(U()|0)|0)==0))p=f;else{if(b=(f+-1+E|0)%(E|0)|0,p=Ht(l,c)|0,(b|0)<0&&Ve(23313,23315,245,23324),E=(p|0)!=0,((E?4:5)|0)<(b|0)&&Ve(23313,23315,245,23324),gA(l,c,te)|0&&Ve(23313,23315,245,23324),p=(u[te>>2]|0)+b|0,E?p=22288+(((p|0)%5|0)<<2)|0:p=22320+(((p|0)%6|0)<<2)|0,b=u[p>>2]|0,(b|0)==7&&Ve(23313,23315,245,23324),u[j>>2]=0,p=vr(l,c,b,j,G)|0,p|0)break;w=G,E=u[w>>2]|0,w=u[w+4>>2]|0;do if(w>>>0>>0|(w|0)==(y|0)&E>>>0>>0){if(Ht(E,w)|0?m=_m(E,w,l,c)|0:m=u[22384+((((u[j>>2]|0)+(u[22352+(b<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,p=Ht(E,w)|0,(m+-1|0)>>>0>5){p=-1,m=E,y=w;break}if(p=(p|0)!=0,(m|0)==1&p){p=-1,m=E,y=w;break}do if(gA(E,w,te)|0)p=-1;else if(p){p=((u[21936+(m<<2)>>2]|0)+5-(u[te>>2]|0)|0)%5|0;break}else{p=((u[21968+(m<<2)>>2]|0)+6-(u[te>>2]|0)|0)%6|0;break}while(!1);m=E,y=w}else p=f;while(!1);b=z,w=u[b>>2]|0,b=u[b+4>>2]|0}if((m|0)==(w|0)&(y|0)==(b|0)){if(E=(Ht(w,b)|0)!=0,E?l=_m(w,b,l,c)|0:l=u[22384+((((u[ce>>2]|0)+(u[22352+(Z<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,p=Ht(w,b)|0,(l+-1|0)>>>0<=5&&(oe=(p|0)!=0,!((l|0)==1&oe)))do if(gA(w,b,te)|0)p=-1;else if(oe){p=((u[21936+(l<<2)>>2]|0)+5-(u[te>>2]|0)|0)%5|0;break}else{p=((u[21968+(l<<2)>>2]|0)+6-(u[te>>2]|0)|0)%6|0;break}while(!1);else p=-1;p=p+1|0,p=(p|0)==6|E&(p|0)==5?0:p}c=y,l=m;break e}while(!1);return d=p,O=ne,d|0}while(!1);return oe=Te(p|0,0,56)|0,te=U()|0|c&-2130706433|536870912,u[d>>2]=oe|l,u[d+4>>2]=te,d=0,O=ne,d|0}function _F(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;return m=(Ht(l,c)|0)==0,d=Fi(l,c,0,f)|0,p=(d|0)==0,m?!p||(d=Fi(l,c,1,f+8|0)|0,d|0)||(d=Fi(l,c,2,f+16|0)|0,d|0)||(d=Fi(l,c,3,f+24|0)|0,d|0)||(d=Fi(l,c,4,f+32|0)|0,d)?(m=d,m|0):Fi(l,c,5,f+40|0)|0:!p||(d=Fi(l,c,1,f+8|0)|0,d|0)||(d=Fi(l,c,2,f+16|0)|0,d|0)||(d=Fi(l,c,3,f+24|0)|0,d|0)||(d=Fi(l,c,4,f+32|0)|0,d|0)?(m=d,m|0):(m=f+40|0,u[m>>2]=0,u[m+4>>2]=0,m=0,m|0)}function yF(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0,b=0,E=0;return E=O,O=O+192|0,p=E,m=E+168|0,y=pe(l|0,c|0,56)|0,U()|0,y=y&7,b=c&-2130706433|134217728,d=gc(l,b,m)|0,d|0?(b=d,O=E,b|0):(c=pe(l|0,c|0,52)|0,U()|0,c=c&15,Ht(l,b)|0?vm(m,c,y,1,p):Sm(m,c,y,1,p),b=p+8|0,u[f>>2]=u[b>>2],u[f+4>>2]=u[b+4>>2],u[f+8>>2]=u[b+8>>2],u[f+12>>2]=u[b+12>>2],b=0,O=E,b|0)}function xF(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;return p=O,O=O+16|0,f=p,!(!0&(c&2013265920|0)==536870912)||(d=c&-2130706433|134217728,!(wm(l,d)|0))?(d=0,O=p,d|0):(m=pe(l|0,c|0,56)|0,U()|0,m=(Fi(l,d,m&7,f)|0)==0,d=f,d=m&((u[d>>2]|0)==(l|0)?(u[d+4>>2]|0)==(c|0):0)&1,O=p,d|0)}function yT(l,c,f){l=l|0,c=c|0,f=f|0;var d=0;(c|0)>0?(d=Bn(c,4)|0,u[l>>2]=d,d||Ve(23337,23360,40,23374)):u[l>>2]=0,u[l+4>>2]=c,u[l+8>>2]=0,u[l+12>>2]=f}function xT(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0;p=l+4|0,m=l+12|0,y=l+8|0;e:for(;;){for(f=u[p>>2]|0,c=0;;){if((c|0)>=(f|0))break e;if(d=u[l>>2]|0,b=u[d+(c<<2)>>2]|0,!b)c=c+1|0;else break}c=d+(~~(+vt(+(+Er(10,+ +(15-(u[m>>2]|0)|0))*(+F[b>>3]+ +F[b+8>>3])))%+(f|0))>>>0<<2)|0,f=u[c>>2]|0;t:do if(f|0){if(d=b+32|0,(f|0)==(b|0))u[c>>2]=u[d>>2];else{if(f=f+32|0,c=u[f>>2]|0,!c)break;for(;(c|0)!=(b|0);)if(f=c+32|0,c=u[f>>2]|0,!c)break t;u[f>>2]=u[d>>2]}We(b),u[y>>2]=(u[y>>2]|0)+-1}while(!1)}We(u[l>>2]|0)}function bT(l){l=l|0;var c=0,f=0,d=0;for(d=u[l+4>>2]|0,f=0;;){if((f|0)>=(d|0)){c=0,f=4;break}if(c=u[(u[l>>2]|0)+(f<<2)>>2]|0,!c)f=f+1|0;else{f=4;break}}return(f|0)==4?c|0:0}function TT(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;if(f=~~(+vt(+(+Er(10,+ +(15-(u[l+12>>2]|0)|0))*(+F[c>>3]+ +F[c+8>>3])))%+(u[l+4>>2]|0))>>>0,f=(u[l>>2]|0)+(f<<2)|0,d=u[f>>2]|0,!d)return m=1,m|0;m=c+32|0;do if((d|0)!=(c|0)){if(f=u[d+32>>2]|0,!f)return m=1,m|0;for(p=f;;){if((p|0)==(c|0)){p=8;break}if(f=u[p+32>>2]|0,f)d=p,p=f;else{f=1,p=10;break}}if((p|0)==8){u[d+32>>2]=u[m>>2];break}else if((p|0)==10)return f|0}else u[f>>2]=u[m>>2];while(!1);return We(c),m=l+8|0,u[m>>2]=(u[m>>2]|0)+-1,m=0,m|0}function bF(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;m=Rn(40)|0,m||Ve(23390,23360,98,23403),u[m>>2]=u[c>>2],u[m+4>>2]=u[c+4>>2],u[m+8>>2]=u[c+8>>2],u[m+12>>2]=u[c+12>>2],p=m+16|0,u[p>>2]=u[f>>2],u[p+4>>2]=u[f+4>>2],u[p+8>>2]=u[f+8>>2],u[p+12>>2]=u[f+12>>2],u[m+32>>2]=0,p=~~(+vt(+(+Er(10,+ +(15-(u[l+12>>2]|0)|0))*(+F[c>>3]+ +F[c+8>>3])))%+(u[l+4>>2]|0))>>>0,p=(u[l>>2]|0)+(p<<2)|0,d=u[p>>2]|0;do if(!d)u[p>>2]=m;else{for(;!(mc(d,c)|0&&mc(d+16|0,f)|0);)if(p=u[d+32>>2]|0,d=p|0?p:d,!(u[d+32>>2]|0)){y=10;break}if((y|0)==10){u[d+32>>2]=m;break}return We(m),y=d,y|0}while(!1);return y=l+8|0,u[y>>2]=(u[y>>2]|0)+1,y=m,y|0}function TF(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0;if(p=~~(+vt(+(+Er(10,+ +(15-(u[l+12>>2]|0)|0))*(+F[c>>3]+ +F[c+8>>3])))%+(u[l+4>>2]|0))>>>0,p=u[(u[l>>2]|0)+(p<<2)>>2]|0,!p)return f=0,f|0;if(!f){for(l=p;;){if(mc(l,c)|0){d=10;break}if(l=u[l+32>>2]|0,!l){l=0,d=10;break}}if((d|0)==10)return l|0}for(l=p;;){if(mc(l,c)|0&&mc(l+16|0,f)|0){d=10;break}if(l=u[l+32>>2]|0,!l){l=0,d=10;break}}return(d|0)==10?l|0:0}function EF(l,c){l=l|0,c=c|0;var f=0;if(f=~~(+vt(+(+Er(10,+ +(15-(u[l+12>>2]|0)|0))*(+F[c>>3]+ +F[c+8>>3])))%+(u[l+4>>2]|0))>>>0,l=u[(u[l>>2]|0)+(f<<2)>>2]|0,!l)return f=0,f|0;for(;;){if(mc(l,c)|0){c=5;break}if(l=u[l+32>>2]|0,!l){l=0,c=5;break}}return(c|0)==5?l|0:0}function vF(){return 23424}function SF(l){return l=+l,+ +wT(+l)}function js(l){return l=+l,~~+SF(l)|0}function Rn(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0,Z=0,ce=0,oe=0,te=0,ne=0,J=0,Se=0;Se=O,O=O+16|0,G=Se;do if(l>>>0<245){if(w=l>>>0<11?16:l+11&-8,l=w>>>3,N=u[5857]|0,f=N>>>l,f&3|0)return c=(f&1^1)+l|0,l=23468+(c<<1<<2)|0,f=l+8|0,d=u[f>>2]|0,p=d+8|0,m=u[p>>2]|0,(m|0)==(l|0)?u[5857]=N&~(1<>2]=l,u[f>>2]=m),J=c<<3,u[d+4>>2]=J|3,J=d+J+4|0,u[J>>2]=u[J>>2]|1,J=p,O=Se,J|0;if(P=u[5859]|0,w>>>0>P>>>0){if(f|0)return c=2<>>12&16,c=c>>>b,f=c>>>5&8,c=c>>>f,m=c>>>2&4,c=c>>>m,l=c>>>1&2,c=c>>>l,d=c>>>1&1,d=(f|b|m|l|d)+(c>>>d)|0,c=23468+(d<<1<<2)|0,l=c+8|0,m=u[l>>2]|0,b=m+8|0,f=u[b>>2]|0,(f|0)==(c|0)?(l=N&~(1<>2]=c,u[l>>2]=f,l=N),J=d<<3,y=J-w|0,u[m+4>>2]=w|3,p=m+w|0,u[p+4>>2]=y|1,u[m+J>>2]=y,P|0&&(d=u[5862]|0,c=P>>>3,f=23468+(c<<1<<2)|0,c=1<>2]|0):(u[5857]=l|c,c=f,l=f+8|0),u[l>>2]=d,u[c+12>>2]=d,u[d+8>>2]=c,u[d+12>>2]=f),u[5859]=y,u[5862]=p,J=b,O=Se,J|0;if(m=u[5858]|0,m){for(f=(m&0-m)+-1|0,p=f>>>12&16,f=f>>>p,d=f>>>5&8,f=f>>>d,y=f>>>2&4,f=f>>>y,b=f>>>1&2,f=f>>>b,E=f>>>1&1,E=u[23732+((d|p|y|b|E)+(f>>>E)<<2)>>2]|0,f=E,b=E,E=(u[E+4>>2]&-8)-w|0;l=u[f+16>>2]|0,!(!l&&(l=u[f+20>>2]|0,!l));)y=(u[l+4>>2]&-8)-w|0,p=y>>>0>>0,f=l,b=p?l:b,E=p?y:E;if(y=b+w|0,y>>>0>b>>>0){p=u[b+24>>2]|0,c=u[b+12>>2]|0;do if((c|0)==(b|0)){if(l=b+20|0,c=u[l>>2]|0,!c&&(l=b+16|0,c=u[l>>2]|0,!c)){f=0;break}for(;;)if(d=c+20|0,f=u[d>>2]|0,f)c=f,l=d;else if(d=c+16|0,f=u[d>>2]|0,f)c=f,l=d;else break;u[l>>2]=0,f=c}else f=u[b+8>>2]|0,u[f+12>>2]=c,u[c+8>>2]=f,f=c;while(!1);do if(p|0){if(c=u[b+28>>2]|0,l=23732+(c<<2)|0,(b|0)==(u[l>>2]|0)){if(u[l>>2]=f,!f){u[5858]=m&~(1<>2]|0)==(b|0)?J:p+20|0)>>2]=f,!f)break;u[f+24>>2]=p,c=u[b+16>>2]|0,c|0&&(u[f+16>>2]=c,u[c+24>>2]=f),c=u[b+20>>2]|0,c|0&&(u[f+20>>2]=c,u[c+24>>2]=f)}while(!1);return E>>>0<16?(J=E+w|0,u[b+4>>2]=J|3,J=b+J+4|0,u[J>>2]=u[J>>2]|1):(u[b+4>>2]=w|3,u[y+4>>2]=E|1,u[y+E>>2]=E,P|0&&(d=u[5862]|0,c=P>>>3,f=23468+(c<<1<<2)|0,c=1<>2]|0):(u[5857]=c|N,c=f,l=f+8|0),u[l>>2]=d,u[c+12>>2]=d,u[d+8>>2]=c,u[d+12>>2]=f),u[5859]=E,u[5862]=y),J=b+8|0,O=Se,J|0}else N=w}else N=w}else N=w}else if(l>>>0<=4294967231)if(l=l+11|0,w=l&-8,d=u[5858]|0,d){p=0-w|0,l=l>>>8,l?w>>>0>16777215?E=31:(N=(l+1048320|0)>>>16&8,Z=l<>>16&4,Z=Z<>>16&2,E=14-(b|N|E)+(Z<>>15)|0,E=w>>>(E+7|0)&1|E<<1):E=0,f=u[23732+(E<<2)>>2]|0;e:do if(!f)f=0,l=0,Z=61;else for(l=0,b=w<<((E|0)==31?0:25-(E>>>1)|0),m=0;;){if(y=(u[f+4>>2]&-8)-w|0,y>>>0

>>0)if(y)l=f,p=y;else{l=f,p=0,Z=65;break e}if(Z=u[f+20>>2]|0,f=u[f+16+(b>>>31<<2)>>2]|0,m=(Z|0)==0|(Z|0)==(f|0)?m:Z,f)b=b<<1;else{f=m,Z=61;break}}while(!1);if((Z|0)==61){if((f|0)==0&(l|0)==0){if(l=2<>>12&16,N=N>>>y,m=N>>>5&8,N=N>>>m,b=N>>>2&4,N=N>>>b,E=N>>>1&2,N=N>>>E,f=N>>>1&1,l=0,f=u[23732+((m|y|b|E|f)+(N>>>f)<<2)>>2]|0}f?Z=65:(b=l,y=p)}if((Z|0)==65)for(m=f;;)if(N=(u[m+4>>2]&-8)-w|0,f=N>>>0

>>0,p=f?N:p,l=f?m:l,f=u[m+16>>2]|0,f||(f=u[m+20>>2]|0),f)m=f;else{b=l,y=p;break}if(b|0&&y>>>0<((u[5859]|0)-w|0)>>>0&&(P=b+w|0,P>>>0>b>>>0)){m=u[b+24>>2]|0,c=u[b+12>>2]|0;do if((c|0)==(b|0)){if(l=b+20|0,c=u[l>>2]|0,!c&&(l=b+16|0,c=u[l>>2]|0,!c)){c=0;break}for(;;)if(p=c+20|0,f=u[p>>2]|0,f)c=f,l=p;else if(p=c+16|0,f=u[p>>2]|0,f)c=f,l=p;else break;u[l>>2]=0}else J=u[b+8>>2]|0,u[J+12>>2]=c,u[c+8>>2]=J;while(!1);do if(m){if(l=u[b+28>>2]|0,f=23732+(l<<2)|0,(b|0)==(u[f>>2]|0)){if(u[f>>2]=c,!c){d=d&~(1<>2]|0)==(b|0)?J:m+20|0)>>2]=c,!c)break;u[c+24>>2]=m,l=u[b+16>>2]|0,l|0&&(u[c+16>>2]=l,u[l+24>>2]=c),l=u[b+20>>2]|0,l&&(u[c+20>>2]=l,u[l+24>>2]=c)}while(!1);e:do if(y>>>0<16)J=y+w|0,u[b+4>>2]=J|3,J=b+J+4|0,u[J>>2]=u[J>>2]|1;else{if(u[b+4>>2]=w|3,u[P+4>>2]=y|1,u[P+y>>2]=y,c=y>>>3,y>>>0<256){f=23468+(c<<1<<2)|0,l=u[5857]|0,c=1<>2]|0):(u[5857]=l|c,c=f,l=f+8|0),u[l>>2]=P,u[c+12>>2]=P,u[P+8>>2]=c,u[P+12>>2]=f;break}if(c=y>>>8,c?y>>>0>16777215?f=31:(ne=(c+1048320|0)>>>16&8,J=c<>>16&4,J=J<>>16&2,f=14-(te|ne|f)+(J<>>15)|0,f=y>>>(f+7|0)&1|f<<1):f=0,c=23732+(f<<2)|0,u[P+28>>2]=f,l=P+16|0,u[l+4>>2]=0,u[l>>2]=0,l=1<>2]=P,u[P+24>>2]=c,u[P+12>>2]=P,u[P+8>>2]=P;break}c=u[c>>2]|0;t:do if((u[c+4>>2]&-8|0)!=(y|0)){for(d=y<<((f|0)==31?0:25-(f>>>1)|0);f=c+16+(d>>>31<<2)|0,l=u[f>>2]|0,!!l;)if((u[l+4>>2]&-8|0)==(y|0)){c=l;break t}else d=d<<1,c=l;u[f>>2]=P,u[P+24>>2]=c,u[P+12>>2]=P,u[P+8>>2]=P;break e}while(!1);ne=c+8|0,J=u[ne>>2]|0,u[J+12>>2]=P,u[ne>>2]=P,u[P+8>>2]=J,u[P+12>>2]=c,u[P+24>>2]=0}while(!1);return J=b+8|0,O=Se,J|0}else N=w}else N=w;else N=-1;while(!1);if(f=u[5859]|0,f>>>0>=N>>>0)return c=f-N|0,l=u[5862]|0,c>>>0>15?(J=l+N|0,u[5862]=J,u[5859]=c,u[J+4>>2]=c|1,u[l+f>>2]=c,u[l+4>>2]=N|3):(u[5859]=0,u[5862]=0,u[l+4>>2]=f|3,J=l+f+4|0,u[J>>2]=u[J>>2]|1),J=l+8|0,O=Se,J|0;if(y=u[5860]|0,y>>>0>N>>>0)return te=y-N|0,u[5860]=te,J=u[5863]|0,ne=J+N|0,u[5863]=ne,u[ne+4>>2]=te|1,u[J+4>>2]=N|3,J=J+8|0,O=Se,J|0;if(u[5975]|0?l=u[5977]|0:(u[5977]=4096,u[5976]=4096,u[5978]=-1,u[5979]=-1,u[5980]=0,u[5968]=0,u[5975]=G&-16^1431655768,l=4096),b=N+48|0,E=N+47|0,m=l+E|0,p=0-l|0,w=m&p,w>>>0<=N>>>0||(l=u[5967]|0,l|0&&(P=u[5965]|0,G=P+w|0,G>>>0<=P>>>0|G>>>0>l>>>0)))return J=0,O=Se,J|0;e:do if(u[5968]&4)c=0,Z=143;else{f=u[5863]|0;t:do if(f){for(d=23876;G=u[d>>2]|0,!(G>>>0<=f>>>0&&(G+(u[d+4>>2]|0)|0)>>>0>f>>>0);)if(l=u[d+8>>2]|0,l)d=l;else{Z=128;break t}if(c=m-y&p,c>>>0<2147483647)if(l=Xs(c|0)|0,(l|0)==((u[d>>2]|0)+(u[d+4>>2]|0)|0)){if((l|0)!=-1){y=c,m=l,Z=145;break e}}else d=l,Z=136;else c=0}else Z=128;while(!1);do if((Z|0)==128)if(f=Xs(0)|0,(f|0)!=-1&&(c=f,j=u[5976]|0,z=j+-1|0,c=(z&c|0?(z+c&0-j)-c|0:0)+w|0,j=u[5965]|0,z=c+j|0,c>>>0>N>>>0&c>>>0<2147483647)){if(G=u[5967]|0,G|0&&z>>>0<=j>>>0|z>>>0>G>>>0){c=0;break}if(l=Xs(c|0)|0,(l|0)==(f|0)){y=c,m=f,Z=145;break e}else d=l,Z=136}else c=0;while(!1);do if((Z|0)==136){if(f=0-c|0,!(b>>>0>c>>>0&(c>>>0<2147483647&(d|0)!=-1)))if((d|0)==-1){c=0;break}else{y=c,m=d,Z=145;break e}if(l=u[5977]|0,l=E-c+l&0-l,l>>>0>=2147483647){y=c,m=d,Z=145;break e}if((Xs(l|0)|0)==-1){Xs(f|0)|0,c=0;break}else{y=l+c|0,m=d,Z=145;break e}}while(!1);u[5968]=u[5968]|4,Z=143}while(!1);if((Z|0)==143&&w>>>0<2147483647&&(te=Xs(w|0)|0,z=Xs(0)|0,ce=z-te|0,oe=ce>>>0>(N+40|0)>>>0,!((te|0)==-1|oe^1|te>>>0>>0&((te|0)!=-1&(z|0)!=-1)^1))&&(y=oe?ce:c,m=te,Z=145),(Z|0)==145){c=(u[5965]|0)+y|0,u[5965]=c,c>>>0>(u[5966]|0)>>>0&&(u[5966]=c),E=u[5863]|0;e:do if(E){for(c=23876;;){if(l=u[c>>2]|0,f=u[c+4>>2]|0,(m|0)==(l+f|0)){Z=154;break}if(d=u[c+8>>2]|0,d)c=d;else break}if((Z|0)==154&&(ne=c+4|0,(u[c+12>>2]&8|0)==0)&&m>>>0>E>>>0&l>>>0<=E>>>0){u[ne>>2]=f+y,J=(u[5860]|0)+y|0,te=E+8|0,te=te&7|0?0-te&7:0,ne=E+te|0,te=J-te|0,u[5863]=ne,u[5860]=te,u[ne+4>>2]=te|1,u[E+J+4>>2]=40,u[5864]=u[5979];break}for(m>>>0<(u[5861]|0)>>>0&&(u[5861]=m),f=m+y|0,c=23876;;){if((u[c>>2]|0)==(f|0)){Z=162;break}if(l=u[c+8>>2]|0,l)c=l;else break}if((Z|0)==162&&!(u[c+12>>2]&8|0)){u[c>>2]=m,P=c+4|0,u[P>>2]=(u[P>>2]|0)+y,P=m+8|0,P=m+(P&7|0?0-P&7:0)|0,c=f+8|0,c=f+(c&7|0?0-c&7:0)|0,w=P+N|0,b=c-P-N|0,u[P+4>>2]=N|3;t:do if((E|0)==(c|0))J=(u[5860]|0)+b|0,u[5860]=J,u[5863]=w,u[w+4>>2]=J|1;else{if((u[5862]|0)==(c|0)){J=(u[5859]|0)+b|0,u[5859]=J,u[5862]=w,u[w+4>>2]=J|1,u[w+J>>2]=J;break}if(l=u[c+4>>2]|0,(l&3|0)==1){y=l&-8,d=l>>>3;r:do if(l>>>0<256)if(l=u[c+8>>2]|0,f=u[c+12>>2]|0,(f|0)==(l|0)){u[5857]=u[5857]&~(1<>2]=f,u[f+8>>2]=l;break}else{m=u[c+24>>2]|0,l=u[c+12>>2]|0;do if((l|0)==(c|0)){if(f=c+16|0,d=f+4|0,l=u[d>>2]|0,l)f=d;else if(l=u[f>>2]|0,!l){l=0;break}for(;;)if(p=l+20|0,d=u[p>>2]|0,d)l=d,f=p;else if(p=l+16|0,d=u[p>>2]|0,d)l=d,f=p;else break;u[f>>2]=0}else J=u[c+8>>2]|0,u[J+12>>2]=l,u[l+8>>2]=J;while(!1);if(!m)break;f=u[c+28>>2]|0,d=23732+(f<<2)|0;do if((u[d>>2]|0)!=(c|0)){if(J=m+16|0,u[((u[J>>2]|0)==(c|0)?J:m+20|0)>>2]=l,!l)break r}else{if(u[d>>2]=l,l|0)break;u[5858]=u[5858]&~(1<>2]=m,f=c+16|0,d=u[f>>2]|0,d|0&&(u[l+16>>2]=d,u[d+24>>2]=l),f=u[f+4>>2]|0,!f)break;u[l+20>>2]=f,u[f+24>>2]=l}while(!1);c=c+y|0,p=y+b|0}else p=b;if(c=c+4|0,u[c>>2]=u[c>>2]&-2,u[w+4>>2]=p|1,u[w+p>>2]=p,c=p>>>3,p>>>0<256){f=23468+(c<<1<<2)|0,l=u[5857]|0,c=1<>2]|0):(u[5857]=l|c,c=f,l=f+8|0),u[l>>2]=w,u[c+12>>2]=w,u[w+8>>2]=c,u[w+12>>2]=f;break}c=p>>>8;do if(!c)d=0;else{if(p>>>0>16777215){d=31;break}ne=(c+1048320|0)>>>16&8,J=c<>>16&4,J=J<>>16&2,d=14-(te|ne|d)+(J<>>15)|0,d=p>>>(d+7|0)&1|d<<1}while(!1);if(c=23732+(d<<2)|0,u[w+28>>2]=d,l=w+16|0,u[l+4>>2]=0,u[l>>2]=0,l=u[5858]|0,f=1<>2]=w,u[w+24>>2]=c,u[w+12>>2]=w,u[w+8>>2]=w;break}c=u[c>>2]|0;r:do if((u[c+4>>2]&-8|0)!=(p|0)){for(d=p<<((d|0)==31?0:25-(d>>>1)|0);f=c+16+(d>>>31<<2)|0,l=u[f>>2]|0,!!l;)if((u[l+4>>2]&-8|0)==(p|0)){c=l;break r}else d=d<<1,c=l;u[f>>2]=w,u[w+24>>2]=c,u[w+12>>2]=w,u[w+8>>2]=w;break t}while(!1);ne=c+8|0,J=u[ne>>2]|0,u[J+12>>2]=w,u[ne>>2]=w,u[w+8>>2]=J,u[w+12>>2]=c,u[w+24>>2]=0}while(!1);return J=P+8|0,O=Se,J|0}for(c=23876;l=u[c>>2]|0,!(l>>>0<=E>>>0&&(J=l+(u[c+4>>2]|0)|0,J>>>0>E>>>0));)c=u[c+8>>2]|0;p=J+-47|0,l=p+8|0,l=p+(l&7|0?0-l&7:0)|0,p=E+16|0,l=l>>>0

>>0?E:l,c=l+8|0,f=y+-40|0,te=m+8|0,te=te&7|0?0-te&7:0,ne=m+te|0,te=f-te|0,u[5863]=ne,u[5860]=te,u[ne+4>>2]=te|1,u[m+f+4>>2]=40,u[5864]=u[5979],f=l+4|0,u[f>>2]=27,u[c>>2]=u[5969],u[c+4>>2]=u[5970],u[c+8>>2]=u[5971],u[c+12>>2]=u[5972],u[5969]=m,u[5970]=y,u[5972]=0,u[5971]=c,c=l+24|0;do ne=c,c=c+4|0,u[c>>2]=7;while((ne+8|0)>>>0>>0);if((l|0)!=(E|0)){if(m=l-E|0,u[f>>2]=u[f>>2]&-2,u[E+4>>2]=m|1,u[l>>2]=m,c=m>>>3,m>>>0<256){f=23468+(c<<1<<2)|0,l=u[5857]|0,c=1<>2]|0):(u[5857]=l|c,c=f,l=f+8|0),u[l>>2]=E,u[c+12>>2]=E,u[E+8>>2]=c,u[E+12>>2]=f;break}if(c=m>>>8,c?m>>>0>16777215?d=31:(ne=(c+1048320|0)>>>16&8,J=c<>>16&4,J=J<>>16&2,d=14-(te|ne|d)+(J<>>15)|0,d=m>>>(d+7|0)&1|d<<1):d=0,f=23732+(d<<2)|0,u[E+28>>2]=d,u[E+20>>2]=0,u[p>>2]=0,c=u[5858]|0,l=1<>2]=E,u[E+24>>2]=f,u[E+12>>2]=E,u[E+8>>2]=E;break}c=u[f>>2]|0;t:do if((u[c+4>>2]&-8|0)!=(m|0)){for(d=m<<((d|0)==31?0:25-(d>>>1)|0);f=c+16+(d>>>31<<2)|0,l=u[f>>2]|0,!!l;)if((u[l+4>>2]&-8|0)==(m|0)){c=l;break t}else d=d<<1,c=l;u[f>>2]=E,u[E+24>>2]=c,u[E+12>>2]=E,u[E+8>>2]=E;break e}while(!1);ne=c+8|0,J=u[ne>>2]|0,u[J+12>>2]=E,u[ne>>2]=E,u[E+8>>2]=J,u[E+12>>2]=c,u[E+24>>2]=0}}else J=u[5861]|0,(J|0)==0|m>>>0>>0&&(u[5861]=m),u[5969]=m,u[5970]=y,u[5972]=0,u[5866]=u[5975],u[5865]=-1,u[5870]=23468,u[5869]=23468,u[5872]=23476,u[5871]=23476,u[5874]=23484,u[5873]=23484,u[5876]=23492,u[5875]=23492,u[5878]=23500,u[5877]=23500,u[5880]=23508,u[5879]=23508,u[5882]=23516,u[5881]=23516,u[5884]=23524,u[5883]=23524,u[5886]=23532,u[5885]=23532,u[5888]=23540,u[5887]=23540,u[5890]=23548,u[5889]=23548,u[5892]=23556,u[5891]=23556,u[5894]=23564,u[5893]=23564,u[5896]=23572,u[5895]=23572,u[5898]=23580,u[5897]=23580,u[5900]=23588,u[5899]=23588,u[5902]=23596,u[5901]=23596,u[5904]=23604,u[5903]=23604,u[5906]=23612,u[5905]=23612,u[5908]=23620,u[5907]=23620,u[5910]=23628,u[5909]=23628,u[5912]=23636,u[5911]=23636,u[5914]=23644,u[5913]=23644,u[5916]=23652,u[5915]=23652,u[5918]=23660,u[5917]=23660,u[5920]=23668,u[5919]=23668,u[5922]=23676,u[5921]=23676,u[5924]=23684,u[5923]=23684,u[5926]=23692,u[5925]=23692,u[5928]=23700,u[5927]=23700,u[5930]=23708,u[5929]=23708,u[5932]=23716,u[5931]=23716,J=y+-40|0,te=m+8|0,te=te&7|0?0-te&7:0,ne=m+te|0,te=J-te|0,u[5863]=ne,u[5860]=te,u[ne+4>>2]=te|1,u[m+J+4>>2]=40,u[5864]=u[5979];while(!1);if(c=u[5860]|0,c>>>0>N>>>0)return te=c-N|0,u[5860]=te,J=u[5863]|0,ne=J+N|0,u[5863]=ne,u[ne+4>>2]=te|1,u[J+4>>2]=N|3,J=J+8|0,O=Se,J|0}return J=vF()|0,u[J>>2]=12,J=0,O=Se,J|0}function We(l){l=l|0;var c=0,f=0,d=0,p=0,m=0,y=0,b=0,E=0;if(l){f=l+-8|0,p=u[5861]|0,l=u[l+-4>>2]|0,c=l&-8,E=f+c|0;do if(l&1)b=f,y=f;else{if(d=u[f>>2]|0,!(l&3)||(y=f+(0-d)|0,m=d+c|0,y>>>0

>>0))return;if((u[5862]|0)==(y|0)){if(l=E+4|0,c=u[l>>2]|0,(c&3|0)!=3){b=y,c=m;break}u[5859]=m,u[l>>2]=c&-2,u[y+4>>2]=m|1,u[y+m>>2]=m;return}if(f=d>>>3,d>>>0<256)if(l=u[y+8>>2]|0,c=u[y+12>>2]|0,(c|0)==(l|0)){u[5857]=u[5857]&~(1<>2]=c,u[c+8>>2]=l,b=y,c=m;break}p=u[y+24>>2]|0,l=u[y+12>>2]|0;do if((l|0)==(y|0)){if(c=y+16|0,f=c+4|0,l=u[f>>2]|0,l)c=f;else if(l=u[c>>2]|0,!l){l=0;break}for(;;)if(d=l+20|0,f=u[d>>2]|0,f)l=f,c=d;else if(d=l+16|0,f=u[d>>2]|0,f)l=f,c=d;else break;u[c>>2]=0}else b=u[y+8>>2]|0,u[b+12>>2]=l,u[l+8>>2]=b;while(!1);if(p){if(c=u[y+28>>2]|0,f=23732+(c<<2)|0,(u[f>>2]|0)==(y|0)){if(u[f>>2]=l,!l){u[5858]=u[5858]&~(1<>2]|0)==(y|0)?b:p+20|0)>>2]=l,!l){b=y,c=m;break}u[l+24>>2]=p,c=y+16|0,f=u[c>>2]|0,f|0&&(u[l+16>>2]=f,u[f+24>>2]=l),c=u[c+4>>2]|0,c?(u[l+20>>2]=c,u[c+24>>2]=l,b=y,c=m):(b=y,c=m)}else b=y,c=m}while(!1);if(!(y>>>0>=E>>>0)&&(l=E+4|0,d=u[l>>2]|0,!!(d&1))){if(d&2)u[l>>2]=d&-2,u[b+4>>2]=c|1,u[y+c>>2]=c,p=c;else{if((u[5863]|0)==(E|0)){if(E=(u[5860]|0)+c|0,u[5860]=E,u[5863]=b,u[b+4>>2]=E|1,(b|0)!=(u[5862]|0))return;u[5862]=0,u[5859]=0;return}if((u[5862]|0)==(E|0)){E=(u[5859]|0)+c|0,u[5859]=E,u[5862]=y,u[b+4>>2]=E|1,u[y+E>>2]=E;return}p=(d&-8)+c|0,f=d>>>3;do if(d>>>0<256)if(c=u[E+8>>2]|0,l=u[E+12>>2]|0,(l|0)==(c|0)){u[5857]=u[5857]&~(1<>2]=l,u[l+8>>2]=c;break}else{m=u[E+24>>2]|0,l=u[E+12>>2]|0;do if((l|0)==(E|0)){if(c=E+16|0,f=c+4|0,l=u[f>>2]|0,l)c=f;else if(l=u[c>>2]|0,!l){f=0;break}for(;;)if(d=l+20|0,f=u[d>>2]|0,f)l=f,c=d;else if(d=l+16|0,f=u[d>>2]|0,f)l=f,c=d;else break;u[c>>2]=0,f=l}else f=u[E+8>>2]|0,u[f+12>>2]=l,u[l+8>>2]=f,f=l;while(!1);if(m|0){if(l=u[E+28>>2]|0,c=23732+(l<<2)|0,(u[c>>2]|0)==(E|0)){if(u[c>>2]=f,!f){u[5858]=u[5858]&~(1<>2]|0)==(E|0)?d:m+20|0)>>2]=f,!f)break;u[f+24>>2]=m,l=E+16|0,c=u[l>>2]|0,c|0&&(u[f+16>>2]=c,u[c+24>>2]=f),l=u[l+4>>2]|0,l|0&&(u[f+20>>2]=l,u[l+24>>2]=f)}}while(!1);if(u[b+4>>2]=p|1,u[y+p>>2]=p,(b|0)==(u[5862]|0)){u[5859]=p;return}}if(l=p>>>3,p>>>0<256){f=23468+(l<<1<<2)|0,c=u[5857]|0,l=1<>2]|0):(u[5857]=c|l,l=f,c=f+8|0),u[c>>2]=b,u[l+12>>2]=b,u[b+8>>2]=l,u[b+12>>2]=f;return}l=p>>>8,l?p>>>0>16777215?d=31:(y=(l+1048320|0)>>>16&8,E=l<>>16&4,E=E<>>16&2,d=14-(m|y|d)+(E<>>15)|0,d=p>>>(d+7|0)&1|d<<1):d=0,l=23732+(d<<2)|0,u[b+28>>2]=d,u[b+20>>2]=0,u[b+16>>2]=0,c=u[5858]|0,f=1<>2]=b,u[b+24>>2]=l,u[b+12>>2]=b,u[b+8>>2]=b;else{l=u[l>>2]|0;t:do if((u[l+4>>2]&-8|0)!=(p|0)){for(d=p<<((d|0)==31?0:25-(d>>>1)|0);f=l+16+(d>>>31<<2)|0,c=u[f>>2]|0,!!c;)if((u[c+4>>2]&-8|0)==(p|0)){l=c;break t}else d=d<<1,l=c;u[f>>2]=b,u[b+24>>2]=l,u[b+12>>2]=b,u[b+8>>2]=b;break e}while(!1);y=l+8|0,E=u[y>>2]|0,u[E+12>>2]=b,u[y>>2]=b,u[b+8>>2]=E,u[b+12>>2]=l,u[b+24>>2]=0}while(!1);if(E=(u[5865]|0)+-1|0,u[5865]=E,!(E|0)){for(l=23884;l=u[l>>2]|0,l;)l=l+8|0;u[5865]=-1}}}}function Bn(l,c){l=l|0,c=c|0;var f=0;return l?(f=In(c,l)|0,(c|l)>>>0>65535&&(f=((f>>>0)/(l>>>0)|0|0)==(c|0)?f:-1)):f=0,l=Rn(f)|0,!l||!(u[l+-4>>2]&3)||Xo(l|0,0,f|0)|0,l|0}function ot(l,c,f,d){return l=l|0,c=c|0,f=f|0,d=d|0,f=l+f>>>0,tt(c+d+(f>>>0>>0|0)>>>0|0),f|0|0}function Vr(l,c,f,d){return l=l|0,c=c|0,f=f|0,d=d|0,d=c-d-(f>>>0>l>>>0|0)>>>0,tt(d|0),l-f>>>0|0|0}function ET(l){return l=l|0,(l?31-(Vo(l^l-1)|0)|0:32)|0}function Fm(l,c,f,d,p){l=l|0,c=c|0,f=f|0,d=d|0,p=p|0;var m=0,y=0,b=0,E=0,w=0,P=0,N=0,G=0,j=0,z=0;if(P=l,E=c,w=E,y=f,G=d,b=G,!w)return m=(p|0)!=0,b?m?(u[p>>2]=l|0,u[p+4>>2]=c&0,G=0,p=0,tt(G|0),p|0):(G=0,p=0,tt(G|0),p|0):(m&&(u[p>>2]=(P>>>0)%(y>>>0),u[p+4>>2]=0),G=0,p=(P>>>0)/(y>>>0)>>>0,tt(G|0),p|0);m=(b|0)==0;do if(y){if(!m){if(m=(Vo(b|0)|0)-(Vo(w|0)|0)|0,m>>>0<=31){N=m+1|0,b=31-m|0,c=m-31>>31,y=N,l=P>>>(N>>>0)&c|w<>>(N>>>0)&c,m=0,b=P<>2]=l|0,u[p+4>>2]=E|c&0,G=0,p=0,tt(G|0),p|0):(G=0,p=0,tt(G|0),p|0)}if(m=y-1|0,m&y|0){b=(Vo(y|0)|0)+33-(Vo(w|0)|0)|0,z=64-b|0,N=32-b|0,E=N>>31,j=b-32|0,c=j>>31,y=b,l=N-1>>31&w>>>(j>>>0)|(w<>>(b>>>0))&c,c=c&w>>>(b>>>0),m=P<>>(j>>>0))&E|P<>31;break}return p|0&&(u[p>>2]=m&P,u[p+4>>2]=0),(y|0)==1?(j=E|c&0,z=l|0|0,tt(j|0),z|0):(z=ET(y|0)|0,j=w>>>(z>>>0)|0,z=w<<32-z|P>>>(z>>>0)|0,tt(j|0),z|0)}else{if(m)return p|0&&(u[p>>2]=(w>>>0)%(y>>>0),u[p+4>>2]=0),j=0,z=(w>>>0)/(y>>>0)>>>0,tt(j|0),z|0;if(!P)return p|0&&(u[p>>2]=0,u[p+4>>2]=(w>>>0)%(b>>>0)),j=0,z=(w>>>0)/(b>>>0)>>>0,tt(j|0),z|0;if(m=b-1|0,!(m&b))return p|0&&(u[p>>2]=l|0,u[p+4>>2]=m&w|c&0),j=0,z=w>>>((ET(b|0)|0)>>>0),tt(j|0),z|0;if(m=(Vo(b|0)|0)-(Vo(w|0)|0)|0,m>>>0<=30){c=m+1|0,b=31-m|0,y=c,l=w<>>(c>>>0),c=w>>>(c>>>0),m=0,b=P<>2]=l|0,u[p+4>>2]=E|c&0,j=0,z=0,tt(j|0),z|0):(j=0,z=0,tt(j|0),z|0)}while(!1);if(!y)w=b,E=0,b=0;else{N=f|0|0,P=G|d&0,w=ot(N|0,P|0,-1,-1)|0,f=U()|0,E=b,b=0;do d=E,E=m>>>31|E<<1,m=b|m<<1,d=l<<1|d>>>31|0,G=l>>>31|c<<1|0,Vr(w|0,f|0,d|0,G|0)|0,z=U()|0,j=z>>31|((z|0)<0?-1:0)<<1,b=j&1,l=Vr(d|0,G|0,j&N|0,(((z|0)<0?-1:0)>>31|((z|0)<0?-1:0)<<1)&P|0)|0,c=U()|0,y=y-1|0;while(y|0);w=E,E=0}return y=0,p|0&&(u[p>>2]=l,u[p+4>>2]=c),j=(m|0)>>>31|(w|y)<<1|(y<<1|m>>>31)&0|E,z=(m<<1|0)&-2|b,tt(j|0),z|0}function jo(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0;return w=c>>31|((c|0)<0?-1:0)<<1,E=((c|0)<0?-1:0)>>31|((c|0)<0?-1:0)<<1,m=d>>31|((d|0)<0?-1:0)<<1,p=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,b=Vr(w^l|0,E^c|0,w|0,E|0)|0,y=U()|0,l=m^w,c=p^E,Vr((Fm(b,y,Vr(m^f|0,p^d|0,m|0,p|0)|0,U()|0,0)|0)^l|0,(U()|0)^c|0,l|0,c|0)|0}function wF(l,c){l=l|0,c=c|0;var f=0,d=0,p=0,m=0;return m=l&65535,p=c&65535,f=In(p,m)|0,d=l>>>16,l=(f>>>16)+(In(p,d)|0)|0,p=c>>>16,c=In(p,m)|0,tt((l>>>16)+(In(p,d)|0)+(((l&65535)+c|0)>>>16)|0),l+c<<16|f&65535|0|0}function zr(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0;return p=l,m=f,f=wF(p,m)|0,l=U()|0,tt((In(c,m)|0)+(In(d,p)|0)+l|l&0|0),f|0|0|0}function Wh(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0,y=0,b=0,E=0,w=0;return p=O,O=O+16|0,b=p|0,y=c>>31|((c|0)<0?-1:0)<<1,m=((c|0)<0?-1:0)>>31|((c|0)<0?-1:0)<<1,w=d>>31|((d|0)<0?-1:0)<<1,E=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,l=Vr(y^l|0,m^c|0,y|0,m|0)|0,c=U()|0,Fm(l,c,Vr(w^f|0,E^d|0,w|0,E|0)|0,U()|0,b)|0,d=Vr(u[b>>2]^y|0,u[b+4>>2]^m|0,y|0,m|0)|0,f=U()|0,O=p,tt(f|0),d|0}function _c(l,c,f,d){l=l|0,c=c|0,f=f|0,d=d|0;var p=0,m=0;return m=O,O=O+16|0,p=m|0,Fm(l,c,f,d,p)|0,O=m,tt(u[p+4>>2]|0),u[p>>2]|0|0}function vT(l,c,f){return l=l|0,c=c|0,f=f|0,(f|0)<32?(tt(c>>f|0),l>>>f|(c&(1<>f-32|0)}function pe(l,c,f){return l=l|0,c=c|0,f=f|0,(f|0)<32?(tt(c>>>f|0),l>>>f|(c&(1<>>f-32|0)}function Te(l,c,f){return l=l|0,c=c|0,f=f|0,(f|0)<32?(tt(c<>>32-f|0),l<=0?+Tr(l+.5):+dc(l-.5)}function Xh(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0;if((f|0)>=8192)return U8(l|0,c|0,f|0)|0,l|0;if(m=l|0,p=l+f|0,(l&3)==(c&3)){for(;l&3;){if(!f)return m|0;ke[l>>0]=ke[c>>0]|0,l=l+1|0,c=c+1|0,f=f-1|0}for(f=p&-4|0,d=f-64|0;(l|0)<=(d|0);)u[l>>2]=u[c>>2],u[l+4>>2]=u[c+4>>2],u[l+8>>2]=u[c+8>>2],u[l+12>>2]=u[c+12>>2],u[l+16>>2]=u[c+16>>2],u[l+20>>2]=u[c+20>>2],u[l+24>>2]=u[c+24>>2],u[l+28>>2]=u[c+28>>2],u[l+32>>2]=u[c+32>>2],u[l+36>>2]=u[c+36>>2],u[l+40>>2]=u[c+40>>2],u[l+44>>2]=u[c+44>>2],u[l+48>>2]=u[c+48>>2],u[l+52>>2]=u[c+52>>2],u[l+56>>2]=u[c+56>>2],u[l+60>>2]=u[c+60>>2],l=l+64|0,c=c+64|0;for(;(l|0)<(f|0);)u[l>>2]=u[c>>2],l=l+4|0,c=c+4|0}else for(f=p-4|0;(l|0)<(f|0);)ke[l>>0]=ke[c>>0]|0,ke[l+1>>0]=ke[c+1>>0]|0,ke[l+2>>0]=ke[c+2>>0]|0,ke[l+3>>0]=ke[c+3>>0]|0,l=l+4|0,c=c+4|0;for(;(l|0)<(p|0);)ke[l>>0]=ke[c>>0]|0,l=l+1|0,c=c+1|0;return m|0}function Xo(l,c,f){l=l|0,c=c|0,f=f|0;var d=0,p=0,m=0,y=0;if(m=l+f|0,c=c&255,(f|0)>=67){for(;l&3;)ke[l>>0]=c,l=l+1|0;for(d=m&-4|0,y=c|c<<8|c<<16|c<<24,p=d-64|0;(l|0)<=(p|0);)u[l>>2]=y,u[l+4>>2]=y,u[l+8>>2]=y,u[l+12>>2]=y,u[l+16>>2]=y,u[l+20>>2]=y,u[l+24>>2]=y,u[l+28>>2]=y,u[l+32>>2]=y,u[l+36>>2]=y,u[l+40>>2]=y,u[l+44>>2]=y,u[l+48>>2]=y,u[l+52>>2]=y,u[l+56>>2]=y,u[l+60>>2]=y,l=l+64|0;for(;(l|0)<(d|0);)u[l>>2]=y,l=l+4|0}for(;(l|0)<(m|0);)ke[l>>0]=c,l=l+1|0;return m-f|0}function wT(l){return l=+l,l>=0?+Tr(l+.5):+dc(l-.5)}function Xs(l){l=l|0;var c=0,f=0,d=0;return d=D8()|0,f=u[li>>2]|0,c=f+l|0,(l|0)>0&(c|0)<(f|0)|(c|0)<0?(V8(c|0)|0,zb(12),-1):(c|0)>(d|0)&&!(k8(c|0)|0)?(zb(12),-1):(u[li>>2]=c,f|0)}return{___divdi3:jo,___muldi3:zr,___remdi3:Wh,___uremdi3:_c,_areNeighborCells:fO,_bitshift64Ashr:vT,_bitshift64Lshr:pe,_bitshift64Shl:Te,_calloc:Bn,_cellAreaKm2:XO,_cellAreaM2:YO,_cellAreaRads2:Om,_cellToBoundary:hA,_cellToCenterChild:CO,_cellToChildPos:NO,_cellToChildren:SO,_cellToChildrenSize:Gh,_cellToLatLng:fA,_cellToLocalIj:eF,_cellToParent:Cm,_cellToVertex:Fi,_cellToVertexes:_F,_cellsToDirectedEdge:hO,_cellsToLinkedMultiPolygon:J8,_childPosToCell:DO,_compactCells:MO,_destroyLinkedMultiPolygon:fT,_directedEdgeToBoundary:Hh,_directedEdgeToCells:mO,_edgeLengthKm:qO,_edgeLengthM:KO,_edgeLengthRads:QO,_emscripten_replace_memory:z8,_free:We,_getBaseCellNumber:oT,_getDirectedEdgeDestination:pO,_getDirectedEdgeOrigin:dO,_getHexagonAreaAvgKm2:HO,_getHexagonAreaAvgM2:GO,_getHexagonEdgeLengthAvgKm:WO,_getHexagonEdgeLengthAvgM:jO,_getIcosahedronFaces:cT,_getNumCells:Bm,_getPentagons:Rm,_getRes0Cells:rO,_getResolution:vO,_greatCircleDistanceKm:pA,_greatCircleDistanceM:kO,_greatCircleDistanceRads:UO,_gridDisk:Hb,_gridDiskDistances:Gb,_gridDistance:rF,_gridPathCells:nF,_gridPathCellsSize:iF,_gridRingUnsafe:Y8,_i64Add:ot,_i64Subtract:Vr,_isPentagon:Ht,_isResClassIII:RO,_isValidCell:wm,_isValidDirectedEdge:gO,_isValidVertex:xF,_latLngToCell:aT,_llvm_maxnum_f64:ST,_llvm_minnum_f64:Lm,_llvm_round_f64:jh,_localIjToCell:tF,_malloc:Rn,_maxFaceCount:FO,_maxGridDiskSize:X8,_maxPolygonToCellsSize:Q8,_memcpy:Xh,_memset:Xo,_originToDirectedEdges:_O,_pentagonCount:LO,_polygonToCells:q8,_readInt64AsDoubleFromPointer:dF,_res0CellCount:tO,_round:wT,_sbrk:Xs,_sizeOfCellBoundary:lF,_sizeOfCoordIJ:hF,_sizeOfGeoLoop:AF,_sizeOfGeoPolygon:uF,_sizeOfH3Index:aF,_sizeOfLatLng:cF,_sizeOfLinkedGeoPolygon:fF,_uncompactCells:PO,_uncompactCellsSize:IO,_vertexToLatLng:yF,establishStackSpace:j8,stackAlloc:H8,stackRestore:W8,stackSave:G8}}(Ph,im,he),Cb=e.___divdi3=_e.___divdi3,nA=e.___muldi3=_e.___muldi3,Mb=e.___remdi3=_e.___remdi3,Pb=e.___uremdi3=_e.___uremdi3,nm=e._areNeighborCells=_e._areNeighborCells,Ih=e._bitshift64Ashr=_e._bitshift64Ashr,Ib=e._bitshift64Lshr=_e._bitshift64Lshr,sm=e._bitshift64Shl=_e._bitshift64Shl,Rb=e._calloc=_e._calloc,om=e._cellAreaKm2=_e._cellAreaKm2,am=e._cellAreaM2=_e._cellAreaM2,cm=e._cellAreaRads2=_e._cellAreaRads2,lm=e._cellToBoundary=_e._cellToBoundary,Rh=e._cellToCenterChild=_e._cellToCenterChild,Hs=e._cellToChildPos=_e._cellToChildPos,uc=e._cellToChildren=_e._cellToChildren,fc=e._cellToChildrenSize=_e._cellToChildrenSize,sA=e._cellToLatLng=_e._cellToLatLng,Bh=e._cellToLocalIj=_e._cellToLocalIj,Bb=e._cellToParent=_e._cellToParent,Ob=e._cellToVertex=_e._cellToVertex,oA=e._cellToVertexes=_e._cellToVertexes,xi=e._cellsToDirectedEdge=_e._cellsToDirectedEdge,Uo=e._cellsToLinkedMultiPolygon=_e._cellsToLinkedMultiPolygon,as=e._childPosToCell=_e._childPosToCell,Cn=e._compactCells=_e._compactCells,hc=e._destroyLinkedMultiPolygon=_e._destroyLinkedMultiPolygon,tn=e._directedEdgeToBoundary=_e._directedEdgeToBoundary,Mn=e._directedEdgeToCells=_e._directedEdgeToCells,Am=e._edgeLengthKm=_e._edgeLengthKm,um=e._edgeLengthM=_e._edgeLengthM,aA=e._edgeLengthRads=_e._edgeLengthRads,bi=e._emscripten_replace_memory=_e._emscripten_replace_memory,cA=e._free=_e._free,Oh=e._getBaseCellNumber=_e._getBaseCellNumber,Fh=e._getDirectedEdgeDestination=_e._getDirectedEdgeDestination,Lh=e._getDirectedEdgeOrigin=_e._getDirectedEdgeOrigin,Nh=e._getHexagonAreaAvgKm2=_e._getHexagonAreaAvgKm2,lA=e._getHexagonAreaAvgM2=_e._getHexagonAreaAvgM2,Pn=e._getHexagonEdgeLengthAvgKm=_e._getHexagonEdgeLengthAvgKm,Fb=e._getHexagonEdgeLengthAvgM=_e._getHexagonEdgeLengthAvgM,fm=e._getIcosahedronFaces=_e._getIcosahedronFaces,Dh=e._getNumCells=_e._getNumCells,hm=e._getPentagons=_e._getPentagons,Lb=e._getRes0Cells=_e._getRes0Cells,Nb=e._getResolution=_e._getResolution,I=e._greatCircleDistanceKm=_e._greatCircleDistanceKm,D=e._greatCircleDistanceM=_e._greatCircleDistanceM,W=e._greatCircleDistanceRads=_e._greatCircleDistanceRads,se=e._gridDisk=_e._gridDisk,ge=e._gridDiskDistances=_e._gridDiskDistances,Be=e._gridDistance=_e._gridDistance,ct=e._gridPathCells=_e._gridPathCells,hr=e._gridPathCellsSize=_e._gridPathCellsSize,xr=e._gridRingUnsafe=_e._gridRingUnsafe,Ur=e._i64Add=_e._i64Add,rn=e._i64Subtract=_e._i64Subtract,mte=e._isPentagon=_e._isPentagon,_te=e._isResClassIII=_e._isResClassIII,yte=e._isValidCell=_e._isValidCell,xte=e._isValidDirectedEdge=_e._isValidDirectedEdge,bte=e._isValidVertex=_e._isValidVertex,Tte=e._latLngToCell=_e._latLngToCell,Ete=e._llvm_maxnum_f64=_e._llvm_maxnum_f64,vte=e._llvm_minnum_f64=_e._llvm_minnum_f64,Ste=e._llvm_round_f64=_e._llvm_round_f64,wte=e._localIjToCell=_e._localIjToCell,Cte=e._malloc=_e._malloc,Mte=e._maxFaceCount=_e._maxFaceCount,Pte=e._maxGridDiskSize=_e._maxGridDiskSize,Ite=e._maxPolygonToCellsSize=_e._maxPolygonToCellsSize,Rte=e._memcpy=_e._memcpy,Bte=e._memset=_e._memset,Ote=e._originToDirectedEdges=_e._originToDirectedEdges,Fte=e._pentagonCount=_e._pentagonCount,Lte=e._polygonToCells=_e._polygonToCells,Nte=e._readInt64AsDoubleFromPointer=_e._readInt64AsDoubleFromPointer,Dte=e._res0CellCount=_e._res0CellCount,Ute=e._round=_e._round,kte=e._sbrk=_e._sbrk,Vte=e._sizeOfCellBoundary=_e._sizeOfCellBoundary,zte=e._sizeOfCoordIJ=_e._sizeOfCoordIJ,Hte=e._sizeOfGeoLoop=_e._sizeOfGeoLoop,Gte=e._sizeOfGeoPolygon=_e._sizeOfGeoPolygon,Wte=e._sizeOfH3Index=_e._sizeOfH3Index,jte=e._sizeOfLatLng=_e._sizeOfLatLng,Xte=e._sizeOfLinkedGeoPolygon=_e._sizeOfLinkedGeoPolygon,Yte=e._uncompactCells=_e._uncompactCells,Qte=e._uncompactCellsSize=_e._uncompactCellsSize,qte=e._vertexToLatLng=_e._vertexToLatLng,Kte=e.establishStackSpace=_e.establishStackSpace,Db=e.stackAlloc=_e.stackAlloc,B8=e.stackRestore=_e.stackRestore,O8=e.stackSave=_e.stackSave;if(e.asm=_e,e.cwrap=k,e.setValue=v,e.getValue=S,Pe){Qt(Pe)||(Pe=o(Pe));{Ac("memory initializer");var dm=function(ee){ee.byteLength&&(ee=new Uint8Array(ee)),Ne.set(ee,T),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,Ce("memory initializer")},Ub=function(){a(Pe,dm,function(){throw"could not load memory initializer "+Pe})},kb=iA(Pe);if(kb)dm(kb.buffer);else if(e.memoryInitializerRequest){var Vb=function(){var ee=e.memoryInitializerRequest,Ae=ee.response;if(ee.status!==200&&ee.status!==0){var Ee=iA(e.memoryInitializerRequestURL);if(Ee)Ae=Ee.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+ee.status+", retrying "+Pe),Ub();return}}dm(Ae)};e.memoryInitializerRequest.response?setTimeout(Vb,0):e.memoryInitializerRequest.addEventListener("load",Vb)}else Ub()}}var Uh;$i=function ee(){Uh||pm(),Uh||($i=ee)};function pm(ee){if(ee=ee||n,Zi>0||(oi(),Zi>0))return;function Ae(){Uh||(Uh=!0,!C&&(Sn(),ss(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Ri()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),Ae()},1)):Ae()}e.run=pm;function ko(ee){throw e.onAbort&&e.onAbort(ee),ee+="",A(ee),h(ee),C=!0,"abort("+ee+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=ko,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return pm(),t}(typeof bt=="object"?bt:{}),$e="number",ze=$e,ih=$e,Xe=$e,Ye=$e,Qr=$e,Le=$e,oQ=[["sizeOfH3Index",$e],["sizeOfLatLng",$e],["sizeOfCellBoundary",$e],["sizeOfGeoLoop",$e],["sizeOfGeoPolygon",$e],["sizeOfLinkedGeoPolygon",$e],["sizeOfCoordIJ",$e],["readInt64AsDoubleFromPointer",$e],["isValidCell",ih,[Xe,Ye]],["latLngToCell",ze,[$e,$e,Qr,Le]],["cellToLatLng",ze,[Xe,Ye,Le]],["cellToBoundary",ze,[Xe,Ye,Le]],["maxGridDiskSize",ze,[$e,Le]],["gridDisk",ze,[Xe,Ye,$e,Le]],["gridDiskDistances",ze,[Xe,Ye,$e,Le,Le]],["gridRingUnsafe",ze,[Xe,Ye,$e,Le]],["maxPolygonToCellsSize",ze,[Le,Qr,$e,Le]],["polygonToCells",ze,[Le,Qr,$e,Le]],["cellsToLinkedMultiPolygon",ze,[Le,$e,Le]],["destroyLinkedMultiPolygon",null,[Le]],["compactCells",ze,[Le,Le,$e,$e]],["uncompactCells",ze,[Le,$e,$e,Le,$e,Qr]],["uncompactCellsSize",ze,[Le,$e,$e,Qr,Le]],["isPentagon",ih,[Xe,Ye]],["isResClassIII",ih,[Xe,Ye]],["getBaseCellNumber",$e,[Xe,Ye]],["getResolution",$e,[Xe,Ye]],["maxFaceCount",ze,[Xe,Ye,Le]],["getIcosahedronFaces",ze,[Xe,Ye,Le]],["cellToParent",ze,[Xe,Ye,Qr,Le]],["cellToChildren",ze,[Xe,Ye,Qr,Le]],["cellToCenterChild",ze,[Xe,Ye,Qr,Le]],["cellToChildrenSize",ze,[Xe,Ye,Qr,Le]],["cellToChildPos",ze,[Xe,Ye,Qr,Le]],["childPosToCell",ze,[$e,$e,Xe,Ye,Qr,Le]],["areNeighborCells",ze,[Xe,Ye,Xe,Ye,Le]],["cellsToDirectedEdge",ze,[Xe,Ye,Xe,Ye,Le]],["getDirectedEdgeOrigin",ze,[Xe,Ye,Le]],["getDirectedEdgeDestination",ze,[Xe,Ye,Le]],["isValidDirectedEdge",ih,[Xe,Ye]],["directedEdgeToCells",ze,[Xe,Ye,Le]],["originToDirectedEdges",ze,[Xe,Ye,Le]],["directedEdgeToBoundary",ze,[Xe,Ye,Le]],["gridDistance",ze,[Xe,Ye,Xe,Ye,Le]],["gridPathCells",ze,[Xe,Ye,Xe,Ye,Le]],["gridPathCellsSize",ze,[Xe,Ye,Xe,Ye,Le]],["cellToLocalIj",ze,[Xe,Ye,Xe,Ye,$e,Le]],["localIjToCell",ze,[Xe,Ye,Le,$e,Le]],["getHexagonAreaAvgM2",ze,[Qr,Le]],["getHexagonAreaAvgKm2",ze,[Qr,Le]],["getHexagonEdgeLengthAvgM",ze,[Qr,Le]],["getHexagonEdgeLengthAvgKm",ze,[Qr,Le]],["greatCircleDistanceM",$e,[Le,Le]],["greatCircleDistanceKm",$e,[Le,Le]],["greatCircleDistanceRads",$e,[Le,Le]],["cellAreaM2",ze,[Xe,Ye,Le]],["cellAreaKm2",ze,[Xe,Ye,Le]],["cellAreaRads2",ze,[Xe,Ye,Le]],["edgeLengthM",ze,[Xe,Ye,Le]],["edgeLengthKm",ze,[Xe,Ye,Le]],["edgeLengthRads",ze,[Xe,Ye,Le]],["getNumCells",ze,[Qr,Le]],["getRes0Cells",ze,[Le]],["res0CellCount",$e],["getPentagons",ze,[$e,Le]],["pentagonCount",$e],["cellToVertex",ze,[Xe,Ye,$e,Le]],["cellToVertexes",ze,[Xe,Ye,Le]],["vertexToLatLng",ze,[Xe,Ye,Le]],["isValidVertex",ih,[Xe,Ye]]],aQ=0,cQ=1,lQ=2,AQ=3,GI=4,uQ=5,fQ=6,hQ=7,dQ=8,pQ=9,gQ=10,mQ=11,_Q=12,yQ=13,xQ=14,bQ=15,Nr={};Nr[aQ]="Success";Nr[cQ]="The operation failed but a more specific error is not available";Nr[lQ]="Argument was outside of acceptable range";Nr[AQ]="Latitude or longitude arguments were outside of acceptable range";Nr[GI]="Resolution argument was outside of acceptable range";Nr[uQ]="Cell argument was not valid";Nr[fQ]="Directed edge argument was not valid";Nr[hQ]="Undirected edge argument was not valid";Nr[dQ]="Vertex argument was not valid";Nr[pQ]="Pentagon distortion was encountered";Nr[gQ]="Duplicate input";Nr[mQ]="Cell arguments were not neighbors";Nr[_Q]="Cell arguments had incompatible resolutions";Nr[yQ]="Memory allocation failed";Nr[xQ]="Bounds of provided memory were insufficient";Nr[bQ]="Mode or flags argument was not valid";var WI=1e3,TQ=1001,jI=1002,kp={};kp[WI]="Unknown unit";kp[TQ]="Array length out of bounds";kp[jI]="Got unexpected null value for H3 index";var EQ="Unknown error";function XI(t,e,r){var i=r&&"value"in r,n=new Error((t[e]||EQ)+" (code: "+e+(i?", value: "+r.value:"")+")");return n.code=e,n}function YI(t,e){var r=arguments.length===2?{value:e}:{};return XI(Nr,t,r)}function QI(t,e){var r=arguments.length===2?{value:e}:{};return XI(kp,t,r)}function qa(t){if(t!==0)throw YI(t)}var ur={};oQ.forEach(function(e){ur[e[0]]=bt.cwrap.apply(bt,e)});var Il=16;var qI=4,VI=4,Io=8,vQ=8,Dp=ur.sizeOfH3Index(),KI=ur.sizeOfLatLng(),SQ=ur.sizeOfCellBoundary(),PMe=ur.sizeOfGeoPolygon(),IMe=ur.sizeOfGeoLoop(),wQ=ur.sizeOfLinkedGeoPolygon(),RMe=ur.sizeOfCoordIJ(),zI={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"};function CQ(t){if(typeof t!="number"||t<0||t>15||Math.floor(t)!==t)throw YI(GI,t);return t}function MQ(t){if(!t)throw QI(jI);return t}var BMe=Math.pow(2,32)-1;var PQ=/[^0-9a-fA-F]/;function Ka(t){if(Array.isArray(t)&&t.length===2&&Number.isInteger(t[0])&&Number.isInteger(t[1]))return t;if(typeof t!="string"||PQ.test(t))return[0,0];var e=parseInt(t.substring(0,t.length-8),Il),r=parseInt(t.substring(t.length-8),Il);return[r,e]}function HI(t){if(t>=0)return t.toString(Il);t=t&2147483647;var e=JI(8,t.toString(Il)),r=(parseInt(e[0],Il)+8).toString(Il);return e=r+e.substring(1),e}function IQ(t,e){return HI(e)+JI(8,HI(t))}function JI(t,e){for(var r=t-e.length,i="",n=0;n180?r[0]-=360:i<-180&&(r[0]+=360)}}function VQ(t,e,r){let[i,n]=nh(t),s=e.length;Vp(e,n);let o=e[0]===e[s-1]?s-1:s;for(let a=0;at.hexagon},extruded:!0},Ja=class t extends Gt{static{this.defaultProps=GQ}static{this.layerName="H3HexagonLayer"}static{this._checkH3Lib=()=>{}}initializeState(){t._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let i=this._calculateH3DataProps();this.setState(i)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,i=!1,{iterable:n,objectInfo:s}=nr(this.props.data);for(let o of n){s.index++;let a=this.props.getHexagon(o,s),A=eR(a);if(e<0){if(e=A,!this.props.highPrecision)break}else if(e!==A){i=!0;break}if($I(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?sR(e,"km"):0,hasMultipleRes:i,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:i}=this.state,{viewport:n}=this.context;return!!n?.resolution||i||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:i,centerHex:n}=this.state;if(r<0)return;let s=this.props.centerHexagon||tR(e.latitude,e.longitude,r);if(n===s)return;if(n)try{if(nR(n,s)*i{let T=e.projectFlat(x);return[(T[0]-g)/o[0],(T[1]-_)/o[1]]}),this.setState({centerHex:s,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:i,extruded:n,wireframe:s,stroked:o,filled:a,lineWidthUnits:A,lineWidthScale:h,lineWidthMinPixels:g,lineWidthMaxPixels:_,getFillColor:x,getElevation:T,getLineColor:v,getLineWidth:S,transitions:C,updateTriggers:M}=this.props;return{elevationScale:e,extruded:n,coverage:i,wireframe:s,stroked:o,filled:a,lineWidthUnits:A,lineWidthScale:h,lineWidthMinPixels:g,lineWidthMaxPixels:_,material:r,getElevation:T,getFillColor:x,getLineColor:v,getLineWidth:S,transitions:C,updateTriggers:{getFillColor:M.getFillColor,getElevation:M.getElevation,getLineColor:M.getLineColor,getLineWidth:M.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:i,coverage:n}=this.props,s=this.getSubLayerClass("hexagon-cell-hifi",_n),o=this._getForwardProps();return o.updateTriggers.getPolygon=HQ(i.getHexagon,n),new s(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,A)=>{let h=r(a,A);return aR(M3(h,n))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:i}=this.props,n=this.getSubLayerClass("hexagon-cell",pn),s=this._getForwardProps();return s.updateTriggers.getPosition=i.getHexagon,new n(s,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:s.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:oR.bind(null,r)})}};var WQ={getHexagons:{type:"accessor",value:t=>t.hexagons}},sh=class extends Pi{static{this.layerName="H3ClusterLayer"}static{this.defaultProps=WQ}initializeState(){Ja._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:i,getHexagons:n}=e,s=[],{iterable:o,objectInfo:a}=nr(i);for(let A of o){a.index++;let h=n(A,a),g=iR(h,!0);for(let _ of g){for(let x of _)Vp(x);s.push(this.getSubLayerRow({polygon:_},A,a.index))}}this.setState({polygons:s})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:i,getLineWidth:n}=this.props;return{data:this.state.polygons,getPolygon:s=>s.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(i),getLineWidth:this.getSubLayerAccessor(n)}}};var P3=Math.PI/180,zp=new Float32Array(16),cR=new Float32Array(12);function lR(t,e,r){let i=e[0]*P3,n=e[1]*P3,s=e[2]*P3,o=Math.sin(s),a=Math.sin(i),A=Math.sin(n),h=Math.cos(s),g=Math.cos(i),_=Math.cos(n),x=r[0],T=r[1],v=r[2];t[0]=x*_*g,t[1]=x*A*g,t[2]=x*-a,t[3]=T*(-A*h+_*a*o),t[4]=T*(_*h+A*a*o),t[5]=T*g*o,t[6]=v*(A*o+_*a*h),t[7]=v*(-_*o+A*a*h),t[8]=v*g*h}function AR(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var Hp={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:r}){let{data:i,getOrientation:n,getScale:s,getTranslation:o,getTransformMatrix:a}=this.props,A=Array.isArray(a),h=A&&a.length===16,g=Array.isArray(s),_=Array.isArray(n),x=Array.isArray(o),T=h||!A&&!!a(i[0]);T?t.constant=h:t.constant=_&&g&&x;let v=t.value;if(t.constant){let S;T?(zp.set(a),S=AR(zp)):(S=cR,lR(S,n,s),S.set(o,9)),t.value=new Float32Array(S)}else{let S=e*t.size,{iterable:C,objectInfo:M}=nr(i,e,r);for(let R of C){M.index++;let B;if(T)zp.set(h?a:a(R,M)),B=AR(zp);else{B=cR;let k=_?n:n(R,M),Q=g?s:s(R,M);lR(B,k,Q),B.set(x?o:o(R,M),9)}v[S++]=B[0],v[S++]=B[1],v[S++]=B[2],v[S++]=B[3],v[S++]=B[4],v[S++]=B[5],v[S++]=B[6],v[S++]=B[7],v[S++]=B[8],v[S++]=B[9],v[S++]=B[10],v[S++]=B[11]}}}};function Gp(t,e){return e===Oe.CARTESIAN||e===Oe.METER_OFFSETS||e===Oe.DEFAULT&&!t.isGeospatial}var uR=`#version 300 es +#define SHADER_NAME simple-mesh-layer-vs +uniform float sizeScale; +uniform bool composeModelMatrix; +in vec3 positions; +in vec3 normals; +in vec3 colors; +in vec2 texCoords; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in vec4 instanceColors; +in vec3 instancePickingColors; +in vec3 instanceModelMatrixCol0; +in vec3 instanceModelMatrixCol1; +in vec3 instanceModelMatrixCol2; +in vec3 instanceTranslation; +out vec2 vTexCoord; +out vec3 cameraPosition; +out vec3 normals_commonspace; +out vec4 position_commonspace; +out vec4 vColor; +void main(void) { +geometry.worldPosition = instancePositions; +geometry.uv = texCoords; +geometry.pickingColor = instancePickingColors; +vTexCoord = texCoords; +cameraPosition = project_uCameraPosition; +vColor = vec4(colors * instanceColors.rgb, instanceColors.a); +mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); +vec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation; +if (composeModelMatrix) { +DECKGL_FILTER_SIZE(pos, geometry); +normals_commonspace = project_normal(instanceModelMatrix * normals); +geometry.worldPosition += pos; +gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace); +geometry.position = position_commonspace; +} +else { +pos = project_size(pos); +DECKGL_FILTER_SIZE(pos, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace); +geometry.position = position_commonspace; +normals_commonspace = project_normal(instanceModelMatrix * normals); +} +geometry.normal = normals_commonspace; +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var fR=`#version 300 es +#define SHADER_NAME simple-mesh-layer-fs +precision highp float; +uniform bool hasTexture; +uniform sampler2D sampler; +uniform bool flatShading; +uniform float opacity; +in vec2 vTexCoord; +in vec3 cameraPosition; +in vec3 normals_commonspace; +in vec4 position_commonspace; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +geometry.uv = vTexCoord; +vec3 normal; +if (flatShading) { +normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); +} else { +normal = normals_commonspace; +} +vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor; +DECKGL_FILTER_COLOR(color, geometry); +vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); +fragColor = vec4(lightColor, color.a * opacity); +} +`;function I3(t){let e=t.positions||t.POSITION;me.assert(e,'no "postions" or "POSITION" attribute in mesh');let r=e.value.length/e.size,i=t.COLOR_0||t.colors;i||(i={size:3,value:new Float32Array(r*3).fill(1)});let n=t.NORMAL||t.normals;n||(n={size:3,value:new Float32Array(r*3).fill(0)});let s=t.TEXCOORD_0||t.texCoords;return s||(s={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:i,normals:n,texCoords:s}}function hR(t){return t instanceof mt?(t.attributes=I3(t.attributes),t):t.attributes?new mt({...t,topology:"triangle-list",attributes:I3(t.attributes)}):new mt({topology:"triangle-list",attributes:I3(t)})}var jQ=[0,0,0,255],XQ={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:jQ},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},Os=class extends ht{static{this.defaultProps=XQ}static{this.layerName="SimpleMeshLayer"}getShaders(){return super.getShaders({vs:uR,fs:fR,modules:[xt,ha,Mt]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;let{mesh:r}=this.props;if(!r)return null;if(e=r.header?.boundingBox,!e){let{attributes:i}=hR(r);i.POSITION=i.POSITION||i.positions,e=us(i)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:Hp}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:n}=e;if(r.mesh!==i.mesh||n.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),r.mesh){this.state.model=this.getModel(r.mesh);let s=r.mesh.attributes||r.mesh;this.setState({hasNormals:!!(s.NORMAL||s.normals)})}this.getAttributeManager().invalidateAll()}r.texture!==i.texture&&r.texture instanceof $t&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){let{model:r}=this.state;if(!r)return;let{viewport:i,renderPass:n}=this.context,{sizeScale:s,coordinateSystem:o,_instanced:a}=this.props;r.setUniforms(e),r.setUniforms({sizeScale:s,composeModelMatrix:!a||Gp(i,o),flatShading:!this.state.hasNormals}),r.draw(n)}get isLoaded(){return!!(this.state?.model&&super.isLoaded)}getModel(e){let r=new Qe(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:hR(e),isInstanced:!0}),{texture:i}=this.props,{emptyTexture:n}=this.state;return r.setBindings({sampler:i||n}),r.setUniforms({hasTexture:!!i}),r}setTexture(e){let{emptyTexture:r,model:i}=this.state;i&&(i.setBindings({sampler:e||r}),i.setUniforms({hasTexture:!!e}))}};var R3=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { +vec3 color; +}; +struct PointLight { +vec3 color; +vec3 position; +vec3 attenuation; +}; +struct DirectionalLight { +vec3 color; +vec3 direction; +}; +uniform AmbientLight lighting_uAmbientLight; +uniform PointLight lighting_uPointLight[MAX_LIGHTS]; +uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS]; +uniform int lighting_uPointLightCount; +uniform int lighting_uDirectionalLightCount; +uniform bool lighting_uEnabled; +float getPointLightAttenuation(PointLight pointLight, float distance) { +return pointLight.attenuation.x ++ pointLight.attenuation.y * distance ++ pointLight.attenuation.z * distance * distance; +} +#endif +`;var YQ={lightSources:{}};function B3(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/255)}function QQ({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let i={};return t?i["lighting_uAmbientLight.color"]=B3(t):i["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((n,s)=>{i[`lighting_uPointLight[${s}].color`]=B3(n),i[`lighting_uPointLight[${s}].position`]=n.position,i[`lighting_uPointLight[${s}].attenuation`]=n.attenuation||[1,0,0]}),i.lighting_uPointLightCount=e.length,r.forEach((n,s)=>{i[`lighting_uDirectionalLight[${s}].color`]=B3(n),i[`lighting_uDirectionalLight[${s}].direction`]=n.direction}),i.lighting_uDirectionalLightCount=r.length,i}function dR(t=YQ){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:i}=t.lightSources||{};return e||r&&r.length>0||i&&i.length>0?Object.assign({},QQ({ambientLight:e,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return dR({lightSources:e})}return{}}var pR={name:"lights",vs:R3,fs:R3,getUniforms:dR,defines:{MAX_LIGHTS:3}};var gR=`uniform mat4 u_MVPMatrix; +uniform mat4 u_ModelMatrix; +uniform mat4 u_NormalMatrix; +out vec3 pbr_vPosition; +out vec2 pbr_vUV; +#ifdef HAS_NORMALS +# ifdef HAS_TANGENTS +out mat3 pbr_vTBN; +# else +out vec3 pbr_vNormal; +# endif +#endif +void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) +{ +vec4 pos = u_ModelMatrix * position; +pbr_vPosition = vec3(pos.xyz) / pos.w; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0))); +vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0))); +vec3 bitangentW = cross(normalW, tangentW) * tangent.w; +pbr_vTBN = mat3(tangentW, bitangentW, normalW); +#else +pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0))); +#endif +#endif +#ifdef HAS_UV +pbr_vUV = uv; +#else +pbr_vUV = vec2(0.,0.); +#endif +} +`;var mR=`precision highp float; +uniform bool pbr_uUnlit; +#ifdef USE_IBL +uniform samplerCube u_DiffuseEnvSampler; +uniform samplerCube u_SpecularEnvSampler; +uniform sampler2D u_brdfLUT; +uniform vec2 u_ScaleIBLAmbient; +#endif +#ifdef HAS_BASECOLORMAP +uniform sampler2D u_BaseColorSampler; +#endif +#ifdef HAS_NORMALMAP +uniform sampler2D u_NormalSampler; +uniform float u_NormalScale; +#endif +#ifdef HAS_EMISSIVEMAP +uniform sampler2D u_EmissiveSampler; +uniform vec3 u_EmissiveFactor; +#endif +#ifdef HAS_METALROUGHNESSMAP +uniform sampler2D u_MetallicRoughnessSampler; +#endif +#ifdef HAS_OCCLUSIONMAP +uniform sampler2D u_OcclusionSampler; +uniform float u_OcclusionStrength; +#endif +#ifdef ALPHA_CUTOFF +uniform float u_AlphaCutoff; +#endif +uniform vec2 u_MetallicRoughnessValues; +uniform vec4 u_BaseColorFactor; +uniform vec3 u_Camera; +#ifdef PBR_DEBUG +uniform vec4 u_ScaleDiffBaseMR; +uniform vec4 u_ScaleFGDSpec; +#endif +in vec3 pbr_vPosition; +in vec2 pbr_vUV; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +in mat3 pbr_vTBN; +#else +in vec3 pbr_vNormal; +#endif +#endif +struct PBRInfo +{ +float NdotL; +float NdotV; +float NdotH; +float LdotH; +float VdotH; +float perceptualRoughness; +float metalness; +vec3 reflectance0; +vec3 reflectance90; +float alphaRoughness; +vec3 diffuseColor; +vec3 specularColor; +vec3 n; +vec3 v; +}; +const float M_PI = 3.141592653589793; +const float c_MinRoughness = 0.04; +vec4 SRGBtoLINEAR(vec4 srgbIn) +{ +#ifdef MANUAL_SRGB +#ifdef SRGB_FAST_APPROXIMATION +vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); +#else +vec3 bLess = step(vec3(0.04045),srgbIn.xyz); +vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); +#endif +return vec4(linOut,srgbIn.w);; +#else +return srgbIn; +#endif +} +vec3 getNormal() +{ +#ifndef HAS_TANGENTS +vec3 pos_dx = dFdx(pbr_vPosition); +vec3 pos_dy = dFdy(pbr_vPosition); +vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); +vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); +vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); +#ifdef HAS_NORMALS +vec3 ng = normalize(pbr_vNormal); +#else +vec3 ng = cross(pos_dx, pos_dy); +#endif +t = normalize(t - ng * dot(ng, t)); +vec3 b = normalize(cross(ng, t)); +mat3 tbn = mat3(t, b, ng); +#else +mat3 tbn = pbr_vTBN; +#endif +#ifdef HAS_NORMALMAP +vec3 n = texture(u_NormalSampler, pbr_vUV).rgb; +n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0))); +#else +vec3 n = normalize(tbn[2].xyz); +#endif +return n; +} +#ifdef USE_IBL +vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) +{ +float mipCount = 9.0; +float lod = (pbrInputs.perceptualRoughness * mipCount); +vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT, +vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb; +vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb; +#ifdef USE_TEX_LOD +vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb; +#else +vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb; +#endif +vec3 diffuse = diffuseLight * pbrInputs.diffuseColor; +vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); +diffuse *= u_ScaleIBLAmbient.x; +specular *= u_ScaleIBLAmbient.y; +return diffuse + specular; +} +#endif +vec3 diffuse(PBRInfo pbrInputs) +{ +return pbrInputs.diffuseColor / M_PI; +} +vec3 specularReflection(PBRInfo pbrInputs) +{ +return pbrInputs.reflectance0 + +(pbrInputs.reflectance90 - pbrInputs.reflectance0) * +pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); +} +float geometricOcclusion(PBRInfo pbrInputs) +{ +float NdotL = pbrInputs.NdotL; +float NdotV = pbrInputs.NdotV; +float r = pbrInputs.alphaRoughness; +float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); +float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); +return attenuationL * attenuationV; +} +float microfacetDistribution(PBRInfo pbrInputs) +{ +float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; +float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; +return roughnessSq / (M_PI * f * f); +} +void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) { +pbrInputs.NdotL = 1.0; +pbrInputs.NdotH = 0.0; +pbrInputs.LdotH = 0.0; +pbrInputs.VdotH = 1.0; +} +void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) { +vec3 n = pbrInputs.n; +vec3 v = pbrInputs.v; +vec3 l = normalize(lightDirection); +vec3 h = normalize(l+v); +pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0); +pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0); +pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0); +pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0); +} +void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) { +vec3 light_direction = normalize(pointLight.position - pbr_vPosition); +PBRInfo_setDirectionalLight(pbrInputs, light_direction); +} +vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) { +vec3 F = specularReflection(pbrInputs); +float G = geometricOcclusion(pbrInputs); +float D = microfacetDistribution(pbrInputs); +vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); +vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV); +return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib); +} +vec4 pbr_filterColor(vec4 colorUnused) +{ +#ifdef HAS_BASECOLORMAP +vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor; +#else +vec4 baseColor = u_BaseColorFactor; +#endif +#ifdef ALPHA_CUTOFF +if (baseColor.a < u_AlphaCutoff) { +discard; +} +#endif +vec3 color = vec3(0, 0, 0); +if(pbr_uUnlit){ +color.rgb = baseColor.rgb; +} +else{ +float perceptualRoughness = u_MetallicRoughnessValues.y; +float metallic = u_MetallicRoughnessValues.x; +#ifdef HAS_METALROUGHNESSMAP +vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV); +perceptualRoughness = mrSample.g * perceptualRoughness; +metallic = mrSample.b * metallic; +#endif +perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); +metallic = clamp(metallic, 0.0, 1.0); +float alphaRoughness = perceptualRoughness * perceptualRoughness; +vec3 f0 = vec3(0.04); +vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); +diffuseColor *= 1.0 - metallic; +vec3 specularColor = mix(f0, baseColor.rgb, metallic); +float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); +float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); +vec3 specularEnvironmentR0 = specularColor.rgb; +vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; +vec3 n = getNormal(); +vec3 v = normalize(u_Camera - pbr_vPosition); +float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); +vec3 reflection = -normalize(reflect(v, n)); +PBRInfo pbrInputs = PBRInfo( +0.0, +NdotV, +0.0, +0.0, +0.0, +perceptualRoughness, +metallic, +specularEnvironmentR0, +specularEnvironmentR90, +alphaRoughness, +diffuseColor, +specularColor, +n, +v +); +#ifdef USE_LIGHTS +PBRInfo_setAmbientLight(pbrInputs); +color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); +for(int i = 0; i < lighting_uDirectionalLightCount; i++) { +if (i < lighting_uDirectionalLightCount) { +PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); +color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); +} +} +for(int i = 0; i < lighting_uPointLightCount; i++) { +if (i < lighting_uPointLightCount) { +PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); +float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); +color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation); +} +} +#endif +#ifdef USE_IBL +color += getIBLContribution(pbrInputs, n, reflection); +#endif +#ifdef HAS_OCCLUSIONMAP +float ao = texture(u_OcclusionSampler, pbr_vUV).r; +color = mix(color, color * ao, u_OcclusionStrength); +#endif +#ifdef HAS_EMISSIVEMAP +vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor; +color += emissive; +#endif +#ifdef PBR_DEBUG +color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y); +color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z); +color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w); +#endif +} +return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); +} +`;var O3={name:"pbr",vs:gR,fs:mR,defines:{LIGHTING_FRAGMENT:1},dependencies:[pR]};var xn;(function(t){t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.LINEAR=9729]="LINEAR",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(xn||(xn={}));function ah(t,e,r,i){let n={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};n.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:s}=i;return s&&(n.bindings.u_DiffuseEnvSampler=s.diffuseEnvSampler,n.bindings.u_SpecularEnvSampler=s.specularEnvSampler,n.bindings.u_brdfLUT=s.brdfLutTexture,n.uniforms.u_ScaleIBLAmbient=[1,1]),i?.pbrDebug&&(n.defines.PBR_DEBUG=1,n.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],n.uniforms.u_ScaleFGDSpec=[0,0,0,0]),r.NORMAL&&(n.defines.HAS_NORMALS=1),r.TANGENT&&i?.useTangents&&(n.defines.HAS_TANGENTS=1),r.TEXCOORD_0&&(n.defines.HAS_UV=1),i?.imageBasedLightingEnvironment&&(n.defines.USE_IBL=1),i?.lights&&(n.defines.USE_LIGHTS=1),e&&qQ(t,e,n),n}function qQ(t,e,r){if(r.uniforms.pbr_uUnlit=!!e.unlit,e.pbrMetallicRoughness&&KQ(t,e.pbrMetallicRoughness,r),e.normalTexture){oh(t,e.normalTexture,"u_NormalSampler","HAS_NORMALMAP",r);let{scale:i=1}=e.normalTexture;r.uniforms.u_NormalScale=i}if(e.occlusionTexture){oh(t,e.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",r);let{strength:i=1}=e.occlusionTexture;r.uniforms.u_OcclusionStrength=i}switch(e.emissiveTexture&&(oh(t,e.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",r),r.uniforms.u_EmissiveFactor=e.emissiveFactor||[0,0,0]),e.alphaMode){case"MASK":let{alphaCutoff:i=.5}=e;r.defines.ALPHA_CUTOFF=1,r.uniforms.u_AlphaCutoff=i;break;case"BLEND":le.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),r.parameters.blendColorOperation="add",r.parameters.blendColorSrcFactor="src-alpha",r.parameters.blendColorDstFactor="one-minus-src-alpha",r.parameters.blendAlphaOperation="add",r.parameters.blendAlphaSrcFactor="one",r.parameters.blendAlphaDstFactor="one-minus-src-alpha",r.glParameters.blend=!0,r.glParameters.blendEquation=xn.FUNC_ADD,r.glParameters.blendFunc=[xn.SRC_ALPHA,xn.ONE_MINUS_SRC_ALPHA,xn.ONE,xn.ONE_MINUS_SRC_ALPHA];break}}function KQ(t,e,r){e.baseColorTexture&&oh(t,e.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",r),r.uniforms.u_BaseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&oh(t,e.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",r);let{metallicFactor:i=1,roughnessFactor:n=1}=e;r.uniforms.u_MetallicRoughnessValues=[i,n]}function oh(t,e,r,i=null,n){let s=e?.texture?.sampler?.parameters||{},o=e.texture.source.image,a,A={};o.compressed?(a=o,A={[xn.TEXTURE_MIN_FILTER]:o.data.length>1?xn.LINEAR_MIPMAP_NEAREST:xn.LINEAR}):a={data:o};let h=t.createTexture({id:e.uniformName||e.id,parameters:{...s,...A},pixelStore:{[xn.UNPACK_FLIP_Y_WEBGL]:!1},...a});n.bindings[r]=h,i&&(n.defines[i]=1),n.generatedTextures.push(h)}var _R="4.2.1";var Wp={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},yR;async function L3(t){Vm(t.modules);let e=zm("basis");return e||(yR||=JQ(t),await yR)}async function JQ(t){let e=null,r=null;return[e,r]=await Promise.all([await Ln(Wp.TRANSCODER,"textures",t),await Ln(Wp.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await ZQ(e,r)}function ZQ(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(i=>{t(r).then(n=>{let{BasisFile:s,initializeBasis:o}=n;o(),i({BasisFile:s})})})}var F3;async function N3(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(F3=F3||$Q(t),await F3)}async function $Q(t){let e=null,r=null;return[e,r]=await Promise.all([await Ln(Wp.ENCODER,"textures",t),await Ln(Wp.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await eq(e,r)}function eq(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(i=>{t(r).then(n=>{let{BasisFile:s,KTX2File:o,initializeBasis:a,BasisEncoder:A}=n;a(),i({BasisFile:s,KTX2File:o,BasisEncoder:A})})})}var Za={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919};var tq=["","WEBKIT_","MOZ_"],xR={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},jp=null;function bR(t){if(!jp){t=t||rq()||void 0,jp=new Set;for(let e of tq)for(let r in xR)if(t&&t.getExtension(`${e}${r}`)){let i=xR[r];jp.add(i)}}return jp}function rq(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var wPe=new Uint8Array([0]);var TR,ER,vR,SR,wR,CR,MR,PR;(function(t){t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB"})(TR||(TR={})),function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(ER||(ER={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(vR||(vR={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(SR||(SR={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(wR||(wR={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(CR||(CR={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(MR||(MR={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(PR||(PR={}));var Ii=[171,75,84,88,32,50,48,187,13,10,26,10];function IR(t){let e=new Uint8Array(t);return!(e.byteLength{hq(i,n,s,o),lq(s,s._node)})}},Yp=class{animations;constructor(e){this.animations=e.animations.map((r,i)=>{let n=r.name||`Animation-${i}`,s=r.samplers.map(({input:a,interpolation:A="LINEAR",output:h})=>({input:FR(e.accessors[a]),interpolation:A,output:FR(e.accessors[h])})),o=r.channels.map(({sampler:a,target:A})=>({sampler:s[a],target:e.nodes[A.node],path:A.path}));return new z3({name:n,channels:o})})}animate(e){this.setTime(e)}setTime(e){this.animations.forEach(r=>r.animate(e))}getAnimations(){return this.animations}};function FR(t){if(!t._animation){let e=aq[t.componentType],r=oq[t.type],i=r*t.count,{buffer:n,byteOffset:s}=t.bufferView.data,o=new e(n,s+(t.byteOffset||0),i);if(r===1)t._animation=Array.from(o);else{let a=[];for(let A=0;Ax>=a),h=Math.max(0,A-1);if(!Array.isArray(n[s]))switch(s){case"translation":n[s]=[0,0,0];break;case"rotation":n[s]=[0,0,0,1];break;case"scale":n[s]=[1,1,1];break;default:le.warn(`Bad animation path ${s}`)()}He(n[s].length===i[h].length);let g=e[h],_=e[A];switch(r){case"STEP":fq(n,s,i[h]);break;case"LINEAR":if(_>g){let x=(a-g)/(_-g);Aq(n,s,i[h],i[A],x)}break;case"CUBICSPLINE":if(_>g){let x=(a-g)/(_-g),T=_-g,v=i[3*h+1],S=i[3*h+2],C=i[3*A+0],M=i[3*A+1];uq(n,s,{p0:v,outTangent0:S,inTangent1:C,p1:M,tDiff:T,ratio:x})}break;default:le.warn(`Interpolation ${r} not supported`)();break}}var H3=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { +vec3 color; +}; +struct PointLight { +vec3 color; +vec3 position; +vec3 attenuation; +}; +struct DirectionalLight { +vec3 color; +vec3 direction; +}; +uniform AmbientLight lighting_uAmbientLight; +uniform PointLight lighting_uPointLight[MAX_LIGHTS]; +uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS]; +uniform int lighting_uPointLightCount; +uniform int lighting_uDirectionalLightCount; +uniform bool lighting_uEnabled; +float getPointLightAttenuation(PointLight pointLight, float distance) { +return pointLight.attenuation.x ++ pointLight.attenuation.y * distance ++ pointLight.attenuation.z * distance * distance; +} +#endif +`;var dq={lightSources:{}};function G3(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/255)}function pq({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let i={};return t?i["lighting_uAmbientLight.color"]=G3(t):i["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((n,s)=>{i[`lighting_uPointLight[${s}].color`]=G3(n),i[`lighting_uPointLight[${s}].position`]=n.position,i[`lighting_uPointLight[${s}].attenuation`]=n.attenuation||[1,0,0]}),i.lighting_uPointLightCount=e.length,r.forEach((n,s)=>{i[`lighting_uDirectionalLight[${s}].color`]=G3(n),i[`lighting_uDirectionalLight[${s}].direction`]=n.direction}),i.lighting_uDirectionalLightCount=r.length,i}function LR(t=dq){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:i}=t.lightSources||{};return e||r&&r.length>0||i&&i.length>0?Object.assign({},pq({ambientLight:e,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return LR({lightSources:e})}return{}}var NR={name:"lights",vs:H3,fs:H3,getUniforms:LR,defines:{MAX_LIGHTS:3}};var DR=`uniform mat4 u_MVPMatrix; +uniform mat4 u_ModelMatrix; +uniform mat4 u_NormalMatrix; +out vec3 pbr_vPosition; +out vec2 pbr_vUV; +#ifdef HAS_NORMALS +# ifdef HAS_TANGENTS +out mat3 pbr_vTBN; +# else +out vec3 pbr_vNormal; +# endif +#endif +void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) +{ +vec4 pos = u_ModelMatrix * position; +pbr_vPosition = vec3(pos.xyz) / pos.w; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0))); +vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0))); +vec3 bitangentW = cross(normalW, tangentW) * tangent.w; +pbr_vTBN = mat3(tangentW, bitangentW, normalW); +#else +pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0))); +#endif +#endif +#ifdef HAS_UV +pbr_vUV = uv; +#else +pbr_vUV = vec2(0.,0.); +#endif +} +`;var UR=`precision highp float; +uniform bool pbr_uUnlit; +#ifdef USE_IBL +uniform samplerCube u_DiffuseEnvSampler; +uniform samplerCube u_SpecularEnvSampler; +uniform sampler2D u_brdfLUT; +uniform vec2 u_ScaleIBLAmbient; +#endif +#ifdef HAS_BASECOLORMAP +uniform sampler2D u_BaseColorSampler; +#endif +#ifdef HAS_NORMALMAP +uniform sampler2D u_NormalSampler; +uniform float u_NormalScale; +#endif +#ifdef HAS_EMISSIVEMAP +uniform sampler2D u_EmissiveSampler; +uniform vec3 u_EmissiveFactor; +#endif +#ifdef HAS_METALROUGHNESSMAP +uniform sampler2D u_MetallicRoughnessSampler; +#endif +#ifdef HAS_OCCLUSIONMAP +uniform sampler2D u_OcclusionSampler; +uniform float u_OcclusionStrength; +#endif +#ifdef ALPHA_CUTOFF +uniform float u_AlphaCutoff; +#endif +uniform vec2 u_MetallicRoughnessValues; +uniform vec4 u_BaseColorFactor; +uniform vec3 u_Camera; +#ifdef PBR_DEBUG +uniform vec4 u_ScaleDiffBaseMR; +uniform vec4 u_ScaleFGDSpec; +#endif +in vec3 pbr_vPosition; +in vec2 pbr_vUV; +#ifdef HAS_NORMALS +#ifdef HAS_TANGENTS +in mat3 pbr_vTBN; +#else +in vec3 pbr_vNormal; +#endif +#endif +struct PBRInfo +{ +float NdotL; +float NdotV; +float NdotH; +float LdotH; +float VdotH; +float perceptualRoughness; +float metalness; +vec3 reflectance0; +vec3 reflectance90; +float alphaRoughness; +vec3 diffuseColor; +vec3 specularColor; +vec3 n; +vec3 v; +}; +const float M_PI = 3.141592653589793; +const float c_MinRoughness = 0.04; +vec4 SRGBtoLINEAR(vec4 srgbIn) +{ +#ifdef MANUAL_SRGB +#ifdef SRGB_FAST_APPROXIMATION +vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); +#else +vec3 bLess = step(vec3(0.04045),srgbIn.xyz); +vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); +#endif +return vec4(linOut,srgbIn.w);; +#else +return srgbIn; +#endif +} +vec3 getNormal() +{ +#ifndef HAS_TANGENTS +vec3 pos_dx = dFdx(pbr_vPosition); +vec3 pos_dy = dFdy(pbr_vPosition); +vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); +vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); +vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); +#ifdef HAS_NORMALS +vec3 ng = normalize(pbr_vNormal); +#else +vec3 ng = cross(pos_dx, pos_dy); +#endif +t = normalize(t - ng * dot(ng, t)); +vec3 b = normalize(cross(ng, t)); +mat3 tbn = mat3(t, b, ng); +#else +mat3 tbn = pbr_vTBN; +#endif +#ifdef HAS_NORMALMAP +vec3 n = texture(u_NormalSampler, pbr_vUV).rgb; +n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0))); +#else +vec3 n = normalize(tbn[2].xyz); +#endif +return n; +} +#ifdef USE_IBL +vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) +{ +float mipCount = 9.0; +float lod = (pbrInputs.perceptualRoughness * mipCount); +vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT, +vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb; +vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb; +#ifdef USE_TEX_LOD +vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb; +#else +vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb; +#endif +vec3 diffuse = diffuseLight * pbrInputs.diffuseColor; +vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); +diffuse *= u_ScaleIBLAmbient.x; +specular *= u_ScaleIBLAmbient.y; +return diffuse + specular; +} +#endif +vec3 diffuse(PBRInfo pbrInputs) +{ +return pbrInputs.diffuseColor / M_PI; +} +vec3 specularReflection(PBRInfo pbrInputs) +{ +return pbrInputs.reflectance0 + +(pbrInputs.reflectance90 - pbrInputs.reflectance0) * +pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); +} +float geometricOcclusion(PBRInfo pbrInputs) +{ +float NdotL = pbrInputs.NdotL; +float NdotV = pbrInputs.NdotV; +float r = pbrInputs.alphaRoughness; +float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); +float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); +return attenuationL * attenuationV; +} +float microfacetDistribution(PBRInfo pbrInputs) +{ +float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; +float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; +return roughnessSq / (M_PI * f * f); +} +void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) { +pbrInputs.NdotL = 1.0; +pbrInputs.NdotH = 0.0; +pbrInputs.LdotH = 0.0; +pbrInputs.VdotH = 1.0; +} +void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) { +vec3 n = pbrInputs.n; +vec3 v = pbrInputs.v; +vec3 l = normalize(lightDirection); +vec3 h = normalize(l+v); +pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0); +pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0); +pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0); +pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0); +} +void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) { +vec3 light_direction = normalize(pointLight.position - pbr_vPosition); +PBRInfo_setDirectionalLight(pbrInputs, light_direction); +} +vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) { +vec3 F = specularReflection(pbrInputs); +float G = geometricOcclusion(pbrInputs); +float D = microfacetDistribution(pbrInputs); +vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); +vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV); +return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib); +} +vec4 pbr_filterColor(vec4 colorUnused) +{ +#ifdef HAS_BASECOLORMAP +vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor; +#else +vec4 baseColor = u_BaseColorFactor; +#endif +#ifdef ALPHA_CUTOFF +if (baseColor.a < u_AlphaCutoff) { +discard; +} +#endif +vec3 color = vec3(0, 0, 0); +if(pbr_uUnlit){ +color.rgb = baseColor.rgb; +} +else{ +float perceptualRoughness = u_MetallicRoughnessValues.y; +float metallic = u_MetallicRoughnessValues.x; +#ifdef HAS_METALROUGHNESSMAP +vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV); +perceptualRoughness = mrSample.g * perceptualRoughness; +metallic = mrSample.b * metallic; +#endif +perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); +metallic = clamp(metallic, 0.0, 1.0); +float alphaRoughness = perceptualRoughness * perceptualRoughness; +vec3 f0 = vec3(0.04); +vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); +diffuseColor *= 1.0 - metallic; +vec3 specularColor = mix(f0, baseColor.rgb, metallic); +float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); +float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); +vec3 specularEnvironmentR0 = specularColor.rgb; +vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; +vec3 n = getNormal(); +vec3 v = normalize(u_Camera - pbr_vPosition); +float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); +vec3 reflection = -normalize(reflect(v, n)); +PBRInfo pbrInputs = PBRInfo( +0.0, +NdotV, +0.0, +0.0, +0.0, +perceptualRoughness, +metallic, +specularEnvironmentR0, +specularEnvironmentR90, +alphaRoughness, +diffuseColor, +specularColor, +n, +v +); +#ifdef USE_LIGHTS +PBRInfo_setAmbientLight(pbrInputs); +color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); +for(int i = 0; i < lighting_uDirectionalLightCount; i++) { +if (i < lighting_uDirectionalLightCount) { +PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); +color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); +} +} +for(int i = 0; i < lighting_uPointLightCount; i++) { +if (i < lighting_uPointLightCount) { +PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); +float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); +color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation); +} +} +#endif +#ifdef USE_IBL +color += getIBLContribution(pbrInputs, n, reflection); +#endif +#ifdef HAS_OCCLUSIONMAP +float ao = texture(u_OcclusionSampler, pbr_vUV).r; +color = mix(color, color * ao, u_OcclusionStrength); +#endif +#ifdef HAS_EMISSIVEMAP +vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor; +color += emissive; +#endif +#ifdef PBR_DEBUG +color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y); +color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z); +color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w); +#endif +} +return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); +} +`;var W3={name:"pbr",vs:DR,fs:UR,defines:{LIGHTING_FRAGMENT:1},dependencies:[NR]};var gq=` +#pragma vscode_glsllint_stage: vert +#if (__VERSION__ < 300) + #define _attr attribute +#else + #define _attr in +#endif + + // _attr vec4 POSITION; + _attr vec4 positions; + + #ifdef HAS_NORMALS + // _attr vec4 NORMAL; + _attr vec4 normals; + #endif + + #ifdef HAS_TANGENTS + _attr vec4 TANGENT; + #endif + + #ifdef HAS_UV + // _attr vec2 TEXCOORD_0; + _attr vec2 texCoords; + #endif + + void main(void) { + vec4 _NORMAL = vec4(0.); + vec4 _TANGENT = vec4(0.); + vec2 _TEXCOORD_0 = vec2(0.); + + #ifdef HAS_NORMALS + _NORMAL = normals; + #endif + + #ifdef HAS_TANGENTS + _TANGENT = TANGENT; + #endif + + #ifdef HAS_UV + _TEXCOORD_0 = texCoords; + #endif + + pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0); + gl_Position = u_MVPMatrix * positions; + } +`,mq=` +#pragma vscode_glsllint_stage: frag +#if (__VERSION__ < 300) + #define fragmentColor gl_FragColor +#else + out vec4 fragmentColor; +#endif + + void main(void) { + vec3 pos = pbr_vPosition; + fragmentColor = pbr_filterColor(vec4(1.0)); + } +`;function VR(t,e){let{id:r,geometry:i,material:n,vertexCount:s,materialOptions:o,modelOptions:a}=e,A=ah(t,n,i.attributes,o);le.info(4,"createGLTFModel defines: ",A.defines)();let h=[],g={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},_={id:r,geometry:i,topology:i.topology,vertexCount:s,modules:[W3],vs:kR(t,gq),fs:kR(t,mq),...a,bindings:{...A.bindings,...a.bindings},defines:{...A.defines,...a.defines},parameters:{...g,...A.parameters,...a.parameters},uniforms:{...A.uniforms,...a.uniforms}},x=new Qe(t,_);return new Ao({managedResources:h,model:x})}function kR(t,e){return`#version 300 es +${e}`}var _q={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},Qp=class{device;options;gltf;constructor(e,r={}){this.device=e,this.options={..._q,...r}}instantiate(e){return this.gltf=e,(e.scenes||[]).map(i=>this.createScene(i))}createAnimator(){return Array.isArray(this.gltf.animations)?new Yp(this.gltf):null}createScene(e){let i=(e.nodes||[]).map(s=>this.createNode(s));return new ys({id:e.name||e.id,children:i})}createNode(e){if(!e._node){let i=(e.children||[]).map(s=>this.createNode(s));e.mesh&&i.push(this.createMesh(e.mesh));let n=new ys({id:e.name||e.id,children:i});if(e.matrix)n.setMatrix(e.matrix);else{if(n.matrix.identity(),e.translation&&n.matrix.translate(e.translation),e.rotation){let s=new Fe().fromQuaternion(e.rotation);n.matrix.multiplyRight(s)}e.scale&&n.matrix.scale(e.scale)}e._node=n}return e._node}createMesh(e){if(!e._mesh){let i=(e.primitives||[]).map((s,o)=>this.createPrimitive(s,o,e)),n=new ys({id:e.name||e.id,children:i});e._mesh=n}return e._mesh}createPrimitive(e,r,i){let n=e.name||`${i.name||i.id}-primitive-${r}`,s=yq(e.mode||4),o=e.indices?e.indices.count:this.getVertexCount(e.attributes),a=VR(this.device,{id:n,geometry:this.createGeometry(n,e,s),material:e.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});return a.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],a}getVertexCount(e){throw new Error("getVertexCount not implemented")}createGeometry(e,r,i){let n={};for(let[s,o]of Object.entries(r.attributes)){let{components:a,size:A,value:h}=o;n[s]={size:A??a,value:h}}return new mt({id:e,topology:i,indices:r.indices.value,attributes:n})}createBuffer(e,r){e.bufferView||(e.bufferView={});let{bufferView:i}=e;return i.lumaBuffers||(i.lumaBuffers={}),i.lumaBuffers[r]||(i.lumaBuffers[r]=this.device.createBuffer({id:`from-${i.id}`,data:i.data||e.value})),i.lumaBuffers[r]}createSampler(e){return e}needsPOT(){return!1}},Fs;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(Fs||(Fs={}));function yq(t){switch(t){case Fs.POINTS:return"point-list";case Fs.LINES:return"line-list";case Fs.LINE_STRIP:return"line-strip";case Fs.LINE_LOOP:return"line-loop-webgl";case Fs.TRIANGLES:return"triangle-list";case Fs.TRIANGLE_STRIP:return"triangle-strip";case Fs.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(t)}}function j3(t,e,r){let i=new Qp(t,r),n=i.instantiate(e),s=i.createAnimator();return{scenes:n,animator:s}}var X3={};dr(X3,{decode:()=>Rq,name:()=>Iq});function _r(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var qp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Kp={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var xq=1.33,zR=["SCALAR","VEC2","VEC3","VEC4"],bq=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Tq=new Map(bq),Eq={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vq={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Sq={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Jp(t){return zR[t-1]||zR[0]}function Rl(t){let e=Tq.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function Bl(t,e){let r=Sq[t.componentType],i=Eq[t.type],n=vq[t.componentType],s=t.count*i,o=t.count*i*n;_r(o>=0&&o<=e.byteLength);let a=Kp[t.componentType],A=qp[t.type];return{ArrayType:r,length:s,byteLength:o,componentByteSize:a,numberOfComponentsInElement:A}}function ch(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let i=e.map(o=>o.bufferView);r=r.filter(o=>!i.includes(o));let n=r.reduce((o,a)=>o+a.byteLength,0),s=e.reduce((o,a)=>{let{width:A,height:h}=a.image;return o+A*h},0);return n+Math.ceil(4*s*xq)}function HR(t,e,r){let i=t.bufferViews[r];_r(i);let n=i.buffer,s=e[n];_r(s);let o=(i.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,o,i.byteLength)}function GR(t,e,r){let i=typeof r=="number"?t.accessors?.[r]:r;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let n=t.bufferViews?.[i.bufferView||0];if(!n)throw new Error(`No gltf buffer view for accessor ${n}`);let{arrayBuffer:s,byteOffset:o}=e[n.buffer],a=(o||0)+(i.byteOffset||0)+(n.byteOffset||0),{ArrayType:A,length:h,componentByteSize:g,numberOfComponentsInElement:_}=Bl(i,n),x=g*_,T=n.byteStride||x;if(typeof n.byteStride>"u"||n.byteStride===x)return new A(s,a,h);let v=new A(h);for(let S=0;Sn===e),i=this.getRequiredExtensions().find(n=>n===e);return typeof r=="string"||typeof i=="string"}getExtension(e){let r=this.getUsedExtensions().find(n=>n===e),i=this.json.extensions||{};return r?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(i=>i===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let i=this.json[e]&&this.json[e][r];if(!i)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return i}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,i=this.gltf.buffers[r];_r(i);let n=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return GR(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),n=this.getBuffer(r.buffer).data,s=r.byteOffset||0;return new Uint8Array(n,s,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,i){return e.extensions=e.extensions||{},e.extensions[r]=i,this.registerUsedExtension(r),this}setObjectExtension(e,r,i){let n=e.extensions||{};n[r]=i}removeObjectExtension(e,r){let i=e?.extensions||{};if(i[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let n=this.json.extensionsRemoved;n.includes(r)||n.push(r)}delete i[r]}addExtension(e,r={}){return _r(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return _r(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:i}=e;this.json.nodes=this.json.nodes||[];let n={mesh:r};return i&&(n.matrix=i),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:i,material:n,mode:s=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:s}]};if(i){let A=this._addIndices(i);a.primitives[0].indices=A}return Number.isFinite(n)&&(a.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let i={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(i),this.json.meshes.length-1}addImage(e,r){let i=$o(e),n=r||i?.mimeType,o={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(o),this.json.images.length-1}addBufferView(e,r=0,i=this.byteLength){let n=e.byteLength;_r(Number.isFinite(n)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let s={buffer:r,byteOffset:i,byteLength:n};return this.byteLength+=qs(n,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(s),this.json.bufferViews.length-1}addAccessor(e,r){let i={bufferView:e,type:Jp(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let i=this.addBufferView(e),n={min:r.min,max:r.max};(!n.min||!n.max)&&(n=this._getAccessorMinMax(e,r.size));let s={size:r.size,componentType:Rl(e),count:Math.round(e.length/r.size),min:n.min,max:n.max};return this.addAccessor(i,Object.assign(s,r))}addTexture(e){let{imageIndex:r}=e,i={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let e=this.byteLength,r=new ArrayBuffer(e),i=new Uint8Array(r),n=0;for(let s of this.sourceBuffers||[])n=$m(s,i,n);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r]}_removeStringFromArray(e,r){let i=!0;for(;i;){let n=e.indexOf(r);n>-1?e.splice(n,1):i=!1}}_addAttributes(e={}){let r={};for(let i in e){let n=e[i],s=this._getGltfAttributeName(i),o=this.addBinaryBuffer(n.value,n);r[s]=o}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let i={min:null,max:null};if(e.lengthx===g);_===-1&&(_=i.push(g)-1),s.push(_)}let o=new Uint32Array(s),a=t.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,A=t.addBufferView(o,a,0),h=t.addAccessor(A,{size:1,componentType:Rl(o),count:o.length});n.attributes[e]=h}function Mq(t,e,r,i,n=[0]){let s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},o=r[i],a=r[i+1],A=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(A=4);let h=Pq(o,a,t,A),g=0;for(let _ of n){let x=typeof _=="number"?Object.values(s)[_]:s[_],T=h+x.offset,v=OA(t);if(v.data.length<=T)throw new Error(`${v.data.length} <= ${T}`);let S=v.data[T];g|=S<i)break;let h=a/n,g=A/n;s.push(t.slice(h,h+g))}return s}function eg(t,e,r){let i=[];for(let n=0;nLq,name:()=>Fq});var Y3="EXT_structural_metadata",Fq=Y3;async function Lq(t,e){let r=new Pt(t);Nq(r,e)}function Nq(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Y3);r&&(e.gltf?.loadImages&&Dq(t,r),Uq(t,r))}function Dq(t,e){let r=e.propertyTextures,i=t.gltf.json;if(r&&i.meshes)for(let n of i.meshes)for(let s of n.primitives)Vq(t,r,s,e)}function Uq(t,e){let r=e.schema;if(!r)return;let i=r.classes,n=e.propertyTables;if(i&&n)for(let s in i){let o=kq(n,s);o&&Hq(t,r,o)}}function kq(t,e){for(let r of t)if(r.class===e)return r;return null}function Vq(t,e,r,i){if(!e)return;let s=r.extensions?.[Y3]?.propertyTextures;if(s)for(let o of s){let a=e[o];zq(t,a,r,i)}}function zq(t,e,r,i){if(!e.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);let n=e.class;for(let s in e.properties){let o=`${n}_${s}`,a=e.properties?.[s];if(!a)continue;a.data||(a.data=[]);let A=a.data,h=Ll(t,a,r);h!==null&&(Zp(t,o,h,A,r),a.data=A,i.dataAttributeNames.push(o))}}function Hq(t,e,r){let i=e.classes?.[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let s in i.properties){let o=i.properties[s],a=r.properties?.[s];if(a){let A=Gq(t,e,o,n,a);a.data=A}}}function Gq(t,e,r,i,n){let s=[],o=n.values,a=t.getTypedArrayForBufferView(o),A=Wq(t,r,n,i),h=jq(t,n,i);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{s=Xq(r,i,a,A);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{s=tg(i,a,A,h);break}case"ENUM":{s=Yq(e,r,i,a,A);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return s}function Wq(t,e,r,i){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?Ol(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",i):null}function jq(t,e,r){return typeof e.stringOffsets<"u"?Ol(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function Xq(t,e,r,i){let n=t.array,s=t.count,o=lh(t.type,t.componentType),a=r.byteLength/o,A;return t.componentType?A=Fl(r,t.type,t.componentType,a):A=r,n?i?$p(A,e,i,r.length,o):s?eg(A,e,s):[]:A}function Yq(t,e,r,i,n){let s=e.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let o=t.enums?.[s];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);let a=o.valueType||"UINT16",A=lh(e.type,a),h=i.byteLength/A,g=Fl(i,e.type,a,h);if(g||(g=i),e.array){if(n)return Qq({valuesData:g,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:i.length,elementSize:A,enumEntry:o});let _=e.count;return _?qq(g,r,_,o):[]}return Q3(g,0,r,o)}function Qq(t){let{valuesData:e,numberOfElements:r,arrayOffsets:i,valuesDataBytesLength:n,elementSize:s,enumEntry:o}=t,a=[];for(let A=0;An)break;let _=h/s,x=g/s,T=Q3(e,_,x,o);a.push(T)}return a}function qq(t,e,r,i){let n=[];for(let s=0;sZq,name:()=>Jq});var QR="EXT_feature_metadata",Jq=QR;async function Zq(t,e){let r=new Pt(t);$q(r,e)}function $q(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(QR);r&&(e.gltf?.loadImages&&eK(t,r),tK(t,r))}function eK(t,e){let r=e.schema;if(!r)return;let i=r.classes,{featureTextures:n}=e;if(i&&n)for(let s in i){let o=i[s],a=iK(n,s);a&&sK(t,a,o)}}function tK(t,e){let r=e.schema;if(!r)return;let i=r.classes,n=e.featureTables;if(i&&n)for(let s in i){let o=rK(n,s);o&&nK(t,r,o)}}function rK(t,e){for(let r in t){let i=t[r];if(i.class===e)return i}return null}function iK(t,e){for(let r in t){let i=t[r];if(i.class===e)return i}return null}function nK(t,e,r){if(!r.class)return;let i=e.classes?.[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let s in i.properties){let o=i.properties[s],a=r.properties?.[s];if(a){let A=oK(t,e,o,n,a);a.data=A}}}function sK(t,e,r){let i=e.class;for(let n in r.properties){let s=e?.properties?.[n];if(s){let o=uK(t,s,i);s.data=o}}}function oK(t,e,r,i,n){let s=[],o=n.bufferView,a=t.getTypedArrayForBufferView(o),A=aK(t,r,n,i),h=cK(t,r,n,i);return r.type==="STRING"||r.componentType==="STRING"?s=tg(i,a,A,h):lK(r)&&(s=AK(r,i,a,A)),s}function aK(t,e,r,i){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Ol(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",i):null}function cK(t,e,r,i){return typeof r.stringOffsetBufferView<"u"?Ol(t,r.stringOffsetBufferView,r.offsetType||"UINT32",i):null}function lK(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function AK(t,e,r,i){let n=t.type==="ARRAY",s=t.componentCount,o="SCALAR",a=t.componentType||t.type,A=lh(o,a),h=r.byteLength/A,g=Fl(r,o,a,h);return n?i?$p(g,e,i,r.length,A):s?eg(g,e,s):[]:g}function uK(t,e,r){let i=t.gltf.json;if(!i.meshes)return[];let n=[];for(let s of i.meshes)for(let o of s.primitives)fK(t,r,e,n,o);return n}function fK(t,e,r,i,n){let s={channels:r.channels,...r.texture},o=Ll(t,s,n);o&&Zp(t,e,o,i,n)}var qR="4.2.1";var Nl=!0,KR=1735152710,$3=12,rg=8,hK=1313821514,dK=5130562,pK=0,gK=0,mK=1;function _K(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function JR(t,e=0,r={}){let i=new DataView(t),{magic:n=KR}=r,s=i.getUint32(e,!1);return s===n||s===KR}function ZR(t,e,r=0,i={}){let n=new DataView(e),s=_K(n,r+0),o=n.getUint32(r+4,Nl),a=n.getUint32(r+8,Nl);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:s,version:o,json:{},binChunks:[]}),r+=$3,t.version){case 1:return yK(t,n,r);case 2:return xK(t,n,r,i={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function yK(t,e,r){at(t.header.byteLength>$3+rg);let i=e.getUint32(r+0,Nl),n=e.getUint32(r+4,Nl);return r+=rg,at(n===pK),J3(t,e,r,i),r+=i,r+=Z3(t,e,r,t.header.byteLength),r}function xK(t,e,r,i){return at(t.header.byteLength>$3+rg),bK(t,e,r,i),r+t.header.byteLength}function bK(t,e,r,i){for(;r+8<=t.header.byteLength;){let n=e.getUint32(r+0,Nl),s=e.getUint32(r+4,Nl);switch(r+=rg,s){case hK:J3(t,e,r,n);break;case dK:Z3(t,e,r,n);break;case gK:i.strict||J3(t,e,r,n);break;case mK:i.strict||Z3(t,e,r,n);break;default:break}r+=qs(n,4)}return r}function J3(t,e,r,i){let n=new Uint8Array(e.buffer,r,i),o=new TextDecoder("utf8").decode(n);return t.json=JSON.parse(o),qs(i,4)}function Z3(t,e,r,i){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:i,arrayBuffer:e.buffer}),qs(i,4)}function ex(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let i=e.baseUri||e.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${t}`);return i.substr(0,i.lastIndexOf("/")+1)+t}var rx={};dr(rx,{decode:()=>OK,name:()=>BK});var TK="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",EK="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",vK=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),SK=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),wK={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},CK={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function $R(t,e,r,i,n,s="NONE"){let o=await MK();RK(o,o.exports[CK[n]],t,e,r,i,o.exports[wK[s||"NONE"]])}var tx;async function MK(){return tx||(tx=PK()),tx}async function PK(){let t=TK;WebAssembly.validate(vK)&&(t=EK,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(IK(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function IK(t){let e=new Uint8Array(t.length);for(let i=0;i96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let i=0;iLK,preprocess:()=>NK});var Dl="EXT_texture_webp",LK=Dl;function NK(t,e){let r=new Pt(t);if(!b1("image/webp")){if(r.getRequiredExtensions().includes(Dl))throw new Error(`gltf: Required extension ${Dl} not supported by browser`);return}let{json:i}=r;for(let n of i.textures||[]){let s=r.getObjectExtension(n,Dl);s&&(n.source=s.source),r.removeObjectExtension(n,Dl)}r.removeExtension(Dl)}var nx={};dr(nx,{name:()=>DK,preprocess:()=>UK});var ng="KHR_texture_basisu",DK=ng;function UK(t,e){let r=new Pt(t),{json:i}=r;for(let n of i.textures||[]){let s=r.getObjectExtension(n,ng);s&&(n.source=s.source,r.removeObjectExtension(n,ng))}r.removeExtension(ng)}var lx={};dr(lx,{decode:()=>eJ,encode:()=>tJ,name:()=>ZK,preprocess:()=>$K});var eB="4.2.1";var tB={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:eB,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function iB(t,e,r){let i=nB(e.metadata),n=[],s=kK(e.attributes);for(let o in t){let a=t[o],A=rB(o,a,s[o]);n.push(A)}if(r){let o=rB("indices",r);n.push(o)}return{fields:n,metadata:i}}function kK(t){let e={};for(let r in t){let i=t[r];e[i.name||"undefined"]=i}return e}function rB(t,e,r){let i=r?nB(r.metadata):void 0;return p1(t,e,i)}function nB(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var sB={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},VK={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},zK=4,Ah=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let n=this.decoder.GetEncodedGeometryType(i),s=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let o;switch(n){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(i,s);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(i,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!o.ok()||!s.ptr){let x=`DRACO decompression failed: ${o.error_msg()}`;throw new Error(x)}let a=this._getDracoLoaderData(s,n,r),A=this._getMeshData(s,a,r),h=us(A.attributes),g=iB(A.attributes,a,A.indices);return{loader:"draco",loaderData:a,header:{vertexCount:s.num_points(),boundingBox:h},...A,schema:g}}finally{this.draco.destroy(i),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,r,i){let n=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,i);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:s}}_getDracoAttributes(e,r){let i={};for(let n=0;nthis.decoder[o]).includes(n)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits(),range:o.range(),min_values:new Float32Array([1,2,3]).map(a=>o.min_value(a))}}finally{this.draco.destroy(o)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:i=[]}=r,n=e.attribute_type();if(i.map(o=>this.decoder[o]).includes(n)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits()}}finally{this.draco.destroy(o)}}return null}};function HK(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function GK(t){let e=t.size(),r=new Int32Array(e);for(let i=0;i({draco:r})):ax||=YK(t),await ax}async function YK(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await Ln(ox[mi.FALLBACK_DECODER],"draco",t,mi.FALLBACK_DECODER);break;case"wasm":default:[e,r]=await Promise.all([await Ln(ox[mi.DECODER],"draco",t,mi.DECODER),await Ln(ox[mi.DECODER_WASM],"draco",t,mi.DECODER_WASM)])}return e=e||globalThis.DracoDecoderModule,await QK(e,r)}function QK(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(i=>{t({...r,onModuleLoaded:n=>i({draco:n})})})}var sg={...tB,parse:qK};async function qK(t,e){let{draco:r}=await oB(e),i=new Ah(r);try{return i.parseSync(t,e?.draco)}finally{i.destroy()}}function aB(t){let e={};for(let r in t){let i=t[r];if(r!=="indices"){let n=cx(i);e[r]=n}}return e}function cx(t){let{buffer:e,size:r,count:i}=KK(t);return{value:e,size:r,byteOffset:0,count:i,type:Jp(r),componentType:Rl(e)}}function KK(t){let e=t,r=1,i=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=JK(e,Float32Array)),i=e.length/r),{buffer:e,size:r,count:i}}function JK(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var Ro="KHR_draco_mesh_compression",ZK=Ro;function $K(t,e,r){let i=new Pt(t);for(let n of cB(i))i.getObjectExtension(n,Ro)}async function eJ(t,e,r){if(!e?.gltf?.decompressMeshes)return;let i=new Pt(t),n=[];for(let s of cB(i))i.getObjectExtension(s,Ro)&&n.push(rJ(i,s,e,r));await Promise.all(n),i.removeExtension(Ro)}function tJ(t,e={}){let r=new Pt(t);for(let i of r.json.meshes||[])iJ(i,e),r.addRequiredExtension(Ro)}async function rJ(t,e,r,i){let n=t.getObjectExtension(e,Ro);if(!n)return;let s=t.getTypedArrayForBufferView(n.bufferView),o=qo(s.buffer,s.byteOffset),a={...r};delete a["3d-tiles"];let A=await Ti(o,sg,a,i),h=aB(A.attributes);for(let[g,_]of Object.entries(h))if(g in e.attributes){let x=e.attributes[g],T=t.getAccessor(x);T?.min&&T?.max&&(_.min=T.min,_.max=T.max)}e.attributes=h,A.indices&&(e.indices=cx(A.indices)),t.removeObjectExtension(e,Ro),nJ(e)}function iJ(t,e,r=4,i,n){if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let s=i.DracoWriter.encodeSync({attributes:t}),o=n?.parseSync?.({attributes:t}),a=i._addFauxAttributes(o.attributes),A=i.addBufferView(s);return{primitives:[{attributes:a,mode:r,extensions:{[Ro]:{bufferView:A,attributes:a}}}]}}function nJ(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*cB(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var Ax={};dr(Ax,{decode:()=>cJ,name:()=>sJ});var ag="KHR_texture_transform",sJ=ag,og=new X,oJ=new wt,aJ=new wt;async function cJ(t,e){if(!new Pt(t).hasExtension(ag)||!e.gltf?.loadBuffers)return;let n=t.json.materials||[];for(let s=0;so===i&&a===n)!==-1)){let o=pJ(r);return i!==n&&(t.texCoord=n),e.push([i,n]),{originalTexCoord:i,texCoord:n,matrix:o}}return null}function fJ(t,e,r){let{originalTexCoord:i,texCoord:n,matrix:s}=r,o=e.attributes[`TEXCOORD_${i}`];if(Number.isFinite(o)){let a=t.json.accessors?.[o];if(a&&a.bufferView){let A=t.json.bufferViews?.[a.bufferView];if(A){let{arrayBuffer:h,byteOffset:g}=t.buffers[A.buffer],_=(g||0)+(a.byteOffset||0)+(A.byteOffset||0),{ArrayType:x,length:T}=Bl(a,A),v=Kp[a.componentType],S=qp[a.type],C=A.byteStride||v*S,M=new Float32Array(T);for(let R=0;RmJ,encode:()=>_J,name:()=>gJ});var $a="KHR_lights_punctual",gJ=$a;async function mJ(t){let e=new Pt(t),{json:r}=e,i=e.getExtension($a);i&&(e.json.lights=i.lights,e.removeExtension($a));for(let n of r.nodes||[]){let s=e.getObjectExtension(n,$a);s&&(n.light=s.light),e.removeObjectExtension(n,$a)}}async function _J(t){let e=new Pt(t),{json:r}=e;if(r.lights){let i=e.addExtension($a);_r(!i.lights),i.lights=r.lights,delete r.lights}if(e.json.lights){for(let i of e.json.lights){let n=i.node;e.addObjectExtension(n,$a,i)}delete e.json.lights}}var fx={};dr(fx,{decode:()=>xJ,encode:()=>bJ,name:()=>yJ});var uh="KHR_materials_unlit",yJ=uh;async function xJ(t){let e=new Pt(t),{json:r}=e;for(let i of r.materials||[])i.extensions&&i.extensions.KHR_materials_unlit&&(i.unlit=!0),e.removeObjectExtension(i,uh);e.removeExtension(uh)}function bJ(t){let e=new Pt(t),{json:r}=e;if(e.materials)for(let i of r.materials||[])i.unlit&&(delete i.unlit,e.addObjectExtension(i,uh,{}),e.addExtension(uh))}var hx={};dr(hx,{decode:()=>EJ,encode:()=>vJ,name:()=>TJ});var fh="KHR_techniques_webgl",TJ=fh;async function EJ(t){let e=new Pt(t),{json:r}=e,i=e.getExtension(fh);if(i){let n=SJ(i,e);for(let s of r.materials||[]){let o=e.getObjectExtension(s,fh);o&&(s.technique=Object.assign({},o,n[o.technique]),s.technique.values=wJ(s.technique,e)),e.removeObjectExtension(s,fh)}e.removeExtension(fh)}}async function vJ(t,e){}function SJ(t,e){let{programs:r=[],shaders:i=[],techniques:n=[]}=t,s=new TextDecoder;return i.forEach(o=>{if(Number.isFinite(o.bufferView))o.code=s.decode(e.getTypedArrayForBufferView(o.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(o=>{o.fragmentShader=i[o.fragmentShader],o.vertexShader=i[o.vertexShader]}),n.forEach(o=>{o.program=r[o.program]}),n}function wJ(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(i=>{t.uniforms[i].value&&!(i in r)&&(r[i]=t.uniforms[i].value)}),Object.keys(r).forEach(i=>{typeof r[i]=="object"&&r[i].index!==void 0&&(r[i].texture=e.getTexture(r[i].index))}),r}var lB=[q3,X3,rx,ix,nx,lx,ux,fx,hx,Ax,K3];function AB(t,e={},r){let i=lB.filter(n=>fB(n.name,e));for(let n of i)n.preprocess?.(t,e,r)}async function uB(t,e={},r){let i=lB.filter(n=>fB(n.name,e));for(let n of i)await n.decode?.(t,e,r)}function fB(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var dx="KHR_binary_glTF";function hB(t){let e=new Pt(t),{json:r}=e;for(let i of r.images||[]){let n=e.getObjectExtension(i,dx);n&&Object.assign(i,n),e.removeObjectExtension(i,dx)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(dx)}var dB={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},MJ={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},px=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${i.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),hB(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in dB)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let i=e[r];if(!(!i||Array.isArray(i))){e[r]=[];for(let n in i){let s=i[n];s.id=s.id||n;let o=e[r].length;e[r].push(s),this.idToIndexMap[r][n]=o}}}_convertObjectIdsToArrayIndices(e){for(let r in dB)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:i,indices:n,material:s}=r;for(let o in i)i[o]=this._convertIdToIndex(i[o],"accessor");n&&(r.indices=this._convertIdToIndex(n,"accessor")),s&&(r.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let i of e[r])for(let n in i){let s=i[n],o=this._convertIdToIndex(s,n);i[n]=o}}_convertIdToIndex(e,r){let i=MJ[r];if(i in this.idToIndexMap){let n=this.idToIndexMap[i][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return n}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let i=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,n=e.textures.findIndex(s=>s.id===i);n!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:n})}}};function pB(t,e={}){return new px().normalize(t,e)}async function gB(t,e,r=0,i,n){return PJ(t,e,r,i),pB(t,{normalize:i?.gltf?.normalize}),AB(t,i,n),i?.gltf?.loadBuffers&&t.json.buffers&&await IJ(t,i,n),i?.gltf?.loadImages&&await RJ(t,i,n),await uB(t,i,n),t}function PJ(t,e,r,i){if(i.uri&&(t.baseUri=i.uri),e instanceof ArrayBuffer&&!JR(e,r,i)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=Km(e);else if(e instanceof ArrayBuffer){let o={};r=ZR(o,e,r,i.glb),_r(o.type==="glTF",`Invalid GLB magic string ${o.type}`),t._glb=o,t.json=o.json}else _r(!1,"GLTF: must be ArrayBuffer or string");let n=t.json.buffers||[];if(t.buffers=new Array(n.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:o}=t._glb;t.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}let s=t.json.images||[];t.images=new Array(s.length).fill({})}async function IJ(t,e,r){let i=t.json.buffers||[];for(let n=0;nthis._resolveBufferView(n,s))),e.images&&(i.images=e.images.map((n,s)=>this._resolveImage(n,s))),e.samplers&&(i.samplers=e.samplers.map((n,s)=>this._resolveSampler(n,s))),e.textures&&(i.textures=e.textures.map((n,s)=>this._resolveTexture(n,s))),e.accessors&&(i.accessors=e.accessors.map((n,s)=>this._resolveAccessor(n,s))),e.materials&&(i.materials=e.materials.map((n,s)=>this._resolveMaterial(n,s))),e.meshes&&(i.meshes=e.meshes.map((n,s)=>this._resolveMesh(n,s))),e.nodes&&(i.nodes=e.nodes.map((n,s)=>this._resolveNode(n,s)),i.nodes=i.nodes.map((n,s)=>this._resolveNodeChildren(n))),e.skins&&(i.skins=e.skins.map((n,s)=>this._resolveSkin(n,s))),e.scenes&&(i.scenes=e.scenes.map((n,s)=>this._resolveScene(n,s))),typeof this.json.scene=="number"&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let i=e&&e[r];return i||console.warn(`glTF file error: Could not find ${e}[${r}]`),i}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(i=>this.getNode(i))}}_resolveNode(e,r){let i={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(i.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(i.camera=this.getCamera(e.camera)),e.skin!==void 0&&(i.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(i.mesh=e.meshes.reduce((n,s)=>{let o=this.getMesh(s);return n.id=o.id,n.primitives=n.primitives.concat(o.primitives),n},{primitives:[]})),i}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let i=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:i}}_resolveMesh(e,r){let i={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(i.primitives=e.primitives.map(n=>{let s={...n,attributes:{},indices:void 0,material:void 0},o=n.attributes;for(let a in o)s.attributes[a]=this.getAccessor(o[a]);return n.indices!==void 0&&(s.indices=this.getAccessor(n.indices)),n.material!==void 0&&(s.material=this.getMaterial(n.material)),s})),i}_resolveMaterial(e,r){let i={...e,id:e.id||`material-${r}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};let n=i.pbrMetallicRoughness;n.baseColorTexture&&(n.baseColorTexture={...n.baseColorTexture},n.baseColorTexture.texture=this.getTexture(n.baseColorTexture.index)),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture={...n.metallicRoughnessTexture},n.metallicRoughnessTexture.texture=this.getTexture(n.metallicRoughnessTexture.index))}return i}_resolveAccessor(e,r){let i=VJ(e.componentType),n=zJ(e.type),s=i*n,o={...e,id:e.id||`accessor-${r}`,bytesPerComponent:i,components:n,bytesPerElement:s,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(o.bufferView=this.getBufferView(e.bufferView)),o.bufferView){let a=o.bufferView.buffer,{ArrayType:A,byteLength:h}=Bl(o,o.bufferView),g=(o.bufferView.byteOffset||0)+(o.byteOffset||0)+a.byteOffset,_=a.arrayBuffer.slice(g,g+h);o.bufferView.byteStride&&(_=this._getValueFromInterleavedBuffer(a,g,o.bufferView.byteStride,o.bytesPerElement,o.count)),o.value=new A(_)}return o}_getValueFromInterleavedBuffer(e,r,i,n,s){let o=new Uint8Array(s*n);for(let a=0;a{r.traverse(i=>{Object.values(i.model.uniforms).forEach(n=>{n.loaded===!1&&e.push(n)})})}),await HJ(()=>e.some(r=>!r.loaded))}async function HJ(t){for(;t();)await new Promise(e=>requestAnimationFrame(e))}var _B=`#version 300 es +#define SHADER_NAME scenegraph-layer-vertex-shader +in vec3 instancePositions; +in vec3 instancePositions64Low; +in vec4 instanceColors; +in vec3 instancePickingColors; +in vec3 instanceModelMatrixCol0; +in vec3 instanceModelMatrixCol1; +in vec3 instanceModelMatrixCol2; +in vec3 instanceTranslation; +uniform float sizeScale; +uniform float sizeMinPixels; +uniform float sizeMaxPixels; +uniform mat4 sceneModelMatrix; +uniform bool composeModelMatrix; +in vec3 positions; +#ifdef HAS_UV +in vec2 texCoords; +#endif +#ifdef MODULE_PBR +#ifdef HAS_NORMALS +in vec3 normals; +#endif +#endif +out vec4 vColor; +#ifndef MODULE_PBR +#ifdef HAS_UV +out vec2 vTEXCOORD_0; +#endif +#endif +void main(void) { +#if defined(HAS_UV) && !defined(MODULE_PBR) +vTEXCOORD_0 = texCoords; +geometry.uv = texCoords; +#endif +geometry.worldPosition = instancePositions; +geometry.pickingColor = instancePickingColors; +mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); +vec3 normal = vec3(0.0, 0.0, 1.0); +#ifdef MODULE_PBR +#ifdef HAS_NORMALS +normal = instanceModelMatrix * (sceneModelMatrix * vec4(normals, 0.0)).xyz; +#endif +#endif +float originalSize = project_size_to_pixel(sizeScale); +float clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels); +vec3 pos = (instanceModelMatrix * (sceneModelMatrix * vec4(positions, 1.0)).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation; +if(composeModelMatrix) { +DECKGL_FILTER_SIZE(pos, geometry); +geometry.normal = project_normal(normal); +geometry.worldPosition += pos; +gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +} +else { +pos = project_size(pos); +DECKGL_FILTER_SIZE(pos, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position); +geometry.normal = project_normal(normal); +} +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +#ifdef MODULE_PBR +pbr_vPosition = geometry.position.xyz; +#ifdef HAS_NORMALS +pbr_vNormal = geometry.normal; +#endif +#ifdef HAS_UV +pbr_vUV = texCoords; +#else +pbr_vUV = vec2(0., 0.); +#endif +geometry.uv = pbr_vUV; +#endif +vColor = instanceColors; +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var yB=`#version 300 es +#define SHADER_NAME scenegraph-layer-fragment-shader +uniform float opacity; +in vec4 vColor; +out vec4 fragColor; +#ifndef MODULE_PBR +#if defined(HAS_UV) && defined(HAS_BASECOLORMAP) +in vec2 vTEXCOORD_0; +uniform sampler2D u_BaseColorSampler; +#endif +#endif +void main(void) { +#ifdef MODULE_PBR +fragColor = vColor * pbr_filterColor(vec4(0)); +geometry.uv = pbr_vUV; +#else +#if defined(HAS_UV) && defined(HAS_BASECOLORMAP) +fragColor = vColor * texture(u_BaseColorSampler, vTEXCOORD_0); +geometry.uv = vTEXCOORD_0; +#else +fragColor = vColor; +#endif +#endif +fragColor.a *= opacity; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var xB=[255,255,255,255],GJ={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?typeof t.scene=="object"?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:xB},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[Ls]},Ul=class extends ht{static{this.defaultProps=GJ}static{this.layerName="ScenegraphLayer"}getShaders(){let e=[xt,Mt];return this.props._lighting==="pbr"&&e.push(O3),super.getShaders({vs:_B,fs:yB,modules:e})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:xB,transition:!0},instanceModelMatrix:Hp})}updateState(e){super.updateState(e);let{props:r,oldProps:i}=e;r.scenegraph!==i.scenegraph?this._updateScenegraph():r._animations!==i._animations&&this._applyAnimationsProp(this.state.animator,r._animations)}finalizeState(e){super.finalizeState(e),this.state.scenegraph?.destroy()}get isLoaded(){return!!(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let e=this.props,{device:r}=this.context,i=null;if(e.scenegraph instanceof Wn)i={scenes:[e.scenegraph]};else if(e.scenegraph&&typeof e.scenegraph=="object"){let a=e.scenegraph,A=a.json?ec(a):a,h=j3(r,A,this._getModelOptions());i={gltf:A,...h},mB(h).then(()=>{this.setNeedsRedraw()}).catch(g=>{this.raiseError(g,"loading glTF")})}let n={layer:this,device:this.context.device},s=e.getScene(i,n),o=e.getAnimator(i,n);if(s instanceof ys){this.state.scenegraph?.destroy(),this._applyAnimationsProp(o,e._animations);let a=[];s.traverse(A=>{A instanceof Ao&&a.push(A.model)}),this.setState({scenegraph:s,animator:o,models:a}),this.getAttributeManager().invalidateAll()}else s!==null&&me.warn("invalid scenegraph:",s)()}_applyAnimationsProp(e,r){if(!e||!r)return;let i=e.getAnimations();Object.keys(r).sort().forEach(n=>{let s=r[n];if(n==="*")i.forEach(o=>{Object.assign(o,s)});else if(Number.isFinite(Number(n))){let o=Number(n);o>=0&&oa===n);o?Object.assign(o,s):me.warn(`animation ${n} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:e}=this.props,r;return e&&(typeof e=="function"?r=e({gl:this.context.gl,layer:this}):r=e),{imageBasedLightingEnvironment:r,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(e.timeline.getTime()),this.setNeedsRedraw());let{viewport:r,renderPass:i}=this.context,{sizeScale:n,sizeMinPixels:s,sizeMaxPixels:o,opacity:a,coordinateSystem:A}=this.props,h=this.getNumInstances();this.state.scenegraph.traverse((g,{worldMatrix:_})=>{if(g instanceof Ao){let{model:x}=g;x.setInstanceCount(h),x.setUniforms({sizeScale:n,opacity:a,sizeMinPixels:s,sizeMaxPixels:o,composeModelMatrix:Gp(r,A),sceneModelMatrix:_,u_Camera:x.uniforms.project_uCameraPosition}),x.draw(i)}})}};var bB=`#version 300 es +#define SHADER_NAME simple-mesh-layer-vs +uniform float sizeScale; +uniform bool composeModelMatrix; +uniform bool pickFeatureIds; +in vec3 positions; +in vec3 normals; +in vec3 colors; +in vec2 texCoords; +in vec4 uvRegions; +in vec3 featureIdsPickingColors; +in vec4 instanceColors; +in vec3 instancePickingColors; +in vec3 instanceModelMatrixCol0; +in vec3 instanceModelMatrixCol1; +in vec3 instanceModelMatrixCol2; +out vec2 vTexCoord; +out vec3 cameraPosition; +out vec3 normals_commonspace; +out vec4 position_commonspace; +out vec4 vColor; +vec2 applyUVRegion(vec2 uv) { +#ifdef HAS_UV_REGIONS +return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy; +#else +return uv; +#endif +} +void main(void) { +vec2 uv = applyUVRegion(texCoords); +geometry.uv = uv; +if (pickFeatureIds) { +geometry.pickingColor = featureIdsPickingColors; +} else { +geometry.pickingColor = instancePickingColors; +} +mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); +vTexCoord = uv; +cameraPosition = project_uCameraPosition; +vColor = vec4(colors * instanceColors.rgb, instanceColors.a); +vec3 pos = (instanceModelMatrix * positions) * sizeScale; +vec3 projectedPosition = project_position(positions); +position_commonspace = vec4(projectedPosition, 1.0); +gl_Position = project_common_position_to_clipspace(position_commonspace); +geometry.position = position_commonspace; +normals_commonspace = project_normal(instanceModelMatrix * normals); +geometry.normal = normals_commonspace; +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +#ifdef MODULE_PBR +pbr_vPosition = geometry.position.xyz; +#ifdef HAS_NORMALS +pbr_vNormal = geometry.normal; +#endif +#ifdef HAS_UV +pbr_vUV = uv; +#else +pbr_vUV = vec2(0., 0.); +#endif +geometry.uv = pbr_vUV; +#endif +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var TB=`#version 300 es +#define SHADER_NAME simple-mesh-layer-fs +precision highp float; +uniform bool hasTexture; +uniform sampler2D sampler; +uniform bool flatShading; +uniform float opacity; +in vec2 vTexCoord; +in vec3 cameraPosition; +in vec3 normals_commonspace; +in vec4 position_commonspace; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +#ifdef MODULE_PBR +fragColor = vColor * pbr_filterColor(vec4(0)); +geometry.uv = pbr_vUV; +fragColor.a *= opacity; +#else +geometry.uv = vTexCoord; +vec3 normal; +if (flatShading) { +normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); +} else { +normal = normals_commonspace; +} +vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor; +vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); +fragColor = vec4(lightColor, color.a * opacity); +#endif +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;function WJ(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var jJ={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},hh=class extends Os{static{this.layerName="MeshLayer"}static{this.defaultProps=jJ}getShaders(){let e=super.getShaders();return e.modules.push(_2),{...e,vs:bB,fs:TB}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:i}=e;r.pbrMaterial!==i.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:!!r}),super.draw(e))}getModel(e){let{id:r,pbrMaterial:i}=this.props,n=this.parseMaterial(i,e);this.setState({parsedPBRMaterial:n});let s=this.getShaders();return WJ(e.attributes),new Qe(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...s.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:i}=this.props,n=this.parseMaterial(e,i);this.setState({parsedPBRMaterial:n}),r.setBindings(n.bindings),r.setUniforms(n.uniforms)}}parseMaterial(e,r){let i=!!(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return ah(this.context.device,{unlit:i,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,i=new Uint8ClampedArray(r.length*e.size),n=[];for(let s=0;sr.destroy()),this.setState({parsedPBRMaterial:null})}};var Ns=6356752314245179e-9,XJ={radii:[6378137,6378137,Ns],radiiSquared:[6378137*6378137,6378137*6378137,Ns*Ns],oneOverRadii:[1/6378137,1/6378137,1/Ns],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Ns*Ns)],maximumRadius:Math.max(6378137,6378137,Ns),centerToleranceSquared:.1};function cg(t){return t}var bRe=new X;function YJ(t,e=[],r=cg){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function EB(t,e=[]){return YJ(t,e,Ut._cartographicRadians?cg:C_)}function QJ(t,e,r=cg){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function vB(t,e){return QJ(t,e,Ut._cartographicRadians?cg:M_)}var SB=1e-14,qJ=new X,wB={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},mx={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},dh={east:new X,north:new X,up:new X,west:new X,south:new X,down:new X},KJ=new X,JJ=new X,ZJ=new X;function _x(t,e,r,i,n,s){let o=wB[e]&&wB[e][r];Mr(o&&(!i||i===o));let a,A,h,g=qJ.copy(n);if(lr(g.x,0,SB)&&lr(g.y,0,SB)){let x=Math.sign(g.z);a=KJ.fromArray(mx[e]),e!=="east"&&e!=="west"&&a.scale(x),A=JJ.fromArray(mx[r]),r!=="east"&&r!=="west"&&A.scale(x),h=ZJ.fromArray(mx[i]),i!=="east"&&i!=="west"&&h.scale(x)}else{let{up:x,east:T,north:v}=dh;T.set(-g.y,g.x,0).normalize(),t.geodeticSurfaceNormal(g,x),v.copy(x).cross(T);let{down:S,west:C,south:M}=dh;S.copy(x).scale(-1),C.copy(T).scale(-1),M.copy(v).scale(-1),a=dh[e],A=dh[r],h=dh[i]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=A.x,s[5]=A.y,s[6]=A.z,s[7]=0,s[8]=h.x,s[9]=h.y,s[10]=h.z,s[11]=0,s[12]=g.x,s[13]=g.y,s[14]=g.z,s[15]=1,s}var kl=new X,$J=new X,eZ=new X;function CB(t,e,r=[]){let{oneOverRadii:i,oneOverRadiiSquared:n,centerToleranceSquared:s}=e;kl.from(t);let o=kl.x,a=kl.y,A=kl.z,h=i.x,g=i.y,_=i.z,x=o*o*h*h,T=a*a*g*g,v=A*A*_*_,S=x+T+v,C=Math.sqrt(1/S);if(!Number.isFinite(C))return;let M=$J;if(M.copy(t).scale(C),Snn.EPSILON12);return kl.scale([Y,H,L]).to(r)}var lg=new X,MB=new X,iZ=new X,bn=new X,nZ=new X,Ag=new X,lt=class{constructor(e=0,r=0,i=0){this.centerToleranceSquared=nn.EPSILON1,Mr(e>=0),Mr(r>=0),Mr(i>=0),this.radii=new X(e,r,i),this.radiiSquared=new X(e*e,r*r,i*i),this.radiiToTheFourth=new X(e*e*e*e,r*r*r*r,i*i*i*i),this.oneOverRadii=new X(e===0?0:1/e,r===0?0:1/r,i===0?0:1/i),this.oneOverRadiiSquared=new X(e===0?0:1/(e*e),r===0?0:1/(r*r),i===0?0:1/(i*i)),this.minimumRadius=Math.min(e,r,i),this.maximumRadius=Math.max(e,r,i),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||!!(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let i=MB,n=iZ,[,,s]=e;this.geodeticSurfaceNormalCartographic(e,i),n.copy(this.radiiSquared).scale(i);let o=Math.sqrt(i.dot(n));return n.scale(1/o),i.scale(s),n.add(i),n.to(r)}cartesianToCartographic(e,r=[0,0,0]){Ag.from(e);let i=this.scaleToGeodeticSurface(Ag,bn);if(!i)return;let n=this.geodeticSurfaceNormal(i,MB),s=nZ;s.copy(Ag).subtract(i);let o=Math.atan2(n.y,n.x),a=Math.asin(n.z),A=Math.sign(Lr.dot(s,Ag))*Lr.length(s);return vB([o,a,A],r)}eastNorthUpToFixedFrame(e,r=new Fe){return _x(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,i,n,s=new Fe){return _x(this,e,r,i,n,s)}geocentricSurfaceNormal(e,r=[0,0,0]){return lg.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let i=EB(e),n=i[0],s=i[1],o=Math.cos(s);return lg.set(o*Math.cos(n),o*Math.sin(n),Math.sin(s)).normalize(),lg.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return lg.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return CB(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){bn.from(e);let i=bn.x,n=bn.y,s=bn.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(i*i*o.x+n*n*o.y+s*s*o.z);return bn.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return bn.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return bn.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,i=[0,0,0]){Mr(lr(this.radii.x,this.radii.y,nn.EPSILON15)),Mr(this.radii.z>0),bn.from(e);let n=bn.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-r))return bn.set(0,0,n).to(i)}};lt.WGS84=new lt(6378137,6378137,Ns);var ug=class{item;previous;next;constructor(e,r,i){this.item=e,this.previous=r,this.next=i}};var fg=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new ug(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let i=e.next;e.next=r,this.tail===e?this.tail=r:i.previous=r,r.next=i,r.previous=e,++this._length}};var hg=class{_list;_sentinel;_trimTiles;constructor(){this._list=new fg,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,i){r._cacheNode||(r._cacheNode=this._list.add(r),i&&i(e,r))}unloadTile(e,r,i){let n=r._cacheNode;n&&(this._list.remove(n),r._cacheNode=null,i&&i(e,r))}unloadTiles(e,r){let i=this._trimTiles;this._trimTiles=!1;let n=this._list,s=e.maximumMemoryUsage*1024*1024,o=this._sentinel,a=n.head;for(;a!==o&&(e.gpuMemoryUsageInBytes>s||i);){let A=a.item;a=a.next,this.unloadTile(e,A,r)}}trim(){this._trimTiles=!0}};function PB(t,e){at(t),at(e);let{rtcCenter:r,gltfUpAxis:i}=e,{computedTransform:n,boundingVolume:{center:s}}=t,o=new Fe(n);switch(r&&o.translate(r),i){case"Z":break;case"Y":let _=new Fe().rotateX(Math.PI/2);o=o.multiplyRight(_);break;case"X":let x=new Fe().rotateY(-Math.PI/2);o=o.multiplyRight(x);break;default:break}e.isQuantized&&o.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new X(s);e.cartesianModelMatrix=o,e.cartesianOrigin=a;let A=lt.WGS84.cartesianToCartographic(a,new X),g=lt.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=g.multiplyRight(o),e.cartographicOrigin=A,e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var IB=new X,yx=new X,xx=new ii([new Yr,new Yr,new Yr,new Yr,new Yr,new Yr]);function BB(t,e){let{cameraDirection:r,cameraUp:i,height:n}=t,{metersPerUnit:s}=t.distanceScales,o=dg(t,t.center),a=lt.WGS84.eastNorthUpToFixedFrame(o),A=t.unprojectPosition(t.cameraPosition),h=lt.WGS84.cartographicToCartesian(A,new X),g=new X(a.transformAsVector(new X(r).scale(s))).normalize(),_=new X(a.transformAsVector(new X(i).scale(s))).normalize();sZ(t);let x=t.constructor,{longitude:T,latitude:v,width:S,bearing:C,zoom:M}=t,R=new x({longitude:T,latitude:v,height:n,width:S,bearing:C,zoom:M,pitch:0});return{camera:{position:h,direction:g,up:_},viewport:t,topDownViewport:R,height:n,cullingVolume:xx,frameNumber:e,sseDenominator:1.15}}function OB(t,e,r){if(r===0||t.length<=r)return[t,[]];let i=[],{longitude:n,latitude:s}=e.viewport;for(let[h,g]of t.entries()){let[_,x]=g.header.mbs,T=Math.abs(n-_),v=Math.abs(s-x),S=Math.sqrt(v*v+T*T);i.push([h,S])}let o=i.sort((h,g)=>h[1]-g[1]),a=[];for(let h=0;h0?o.normalize():o=new X(0,1,0);let a=o.clone().cross(s);for(let A of[o,a,s]){pg.copy(A).scale(i);for(let h=0;h<2;h++)Kr.copy(r),Kr.add(pg),WB(e,Kr),pg.negate()}return e}function GB(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function WB(t,e){lt.WGS84.cartesianToCartographic(e,Kr),t[0][0]=Math.min(t[0][0],Kr[0]),t[0][1]=Math.min(t[0][1],Kr[1]),t[0][2]=Math.min(t[0][2],Kr[2]),t[1][0]=Math.max(t[1][0],Kr[0]),t[1][1]=Math.max(t[1][1],Kr[1]),t[1][2]=Math.max(t[1][2],Kr[2])}var aBe=new X,cBe=new X,lBe=new Fe,ABe=new X,uBe=new X,fBe=new X;function pZ(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function gZ(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,i=t.dynamicScreenSpaceErrorFactor;return pZ(e,r)*i}return 0}function jB(t,e,r){let i=t.tileset,n=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?n:t.lodMetricValue;if(s===0)return 0;let o=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:A}=e,{viewDistanceScale:h}=i.options,g=s*a*(h||1)/(o*A);return g-=gZ(i,o),g}var Ex=new X,XB=new X,Bo=new X,YB=new X,mZ=new X,vx=new Fe,QB=new Fe;function qB(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*Sx(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function Sx(t,e){let{topDownViewport:r}=e,i=t.header.mbs[1],n=t.header.mbs[0],s=t.header.mbs[2],o=t.header.mbs[3],a=[...t.boundingVolume.center],A=r.unprojectPosition(r.cameraPosition);lt.WGS84.cartographicToCartesian(A,Ex),XB.copy(Ex).subtract(a).normalize(),lt.WGS84.eastNorthUpToFixedFrame(a,vx),QB.copy(vx).invert(),Bo.copy(Ex).transform(QB);let h=Math.sqrt(Bo[0]*Bo[0]+Bo[1]*Bo[1]),g=h*h/Bo[2];YB.copy([Bo[0],Bo[1],g]);let x=YB.transform(vx).subtract(a).normalize(),v=XB.cross(x).normalize().scale(o).add(a),S=lt.WGS84.cartesianToCartographic(v),C=r.project([n,i,s]),M=r.project(S);return mZ.copy(C).subtract(M).magnitude()}function KB(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var ph=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return at(e=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){at(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){at(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var _Z={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},is=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new ph;_emptyTraversalStack=new ph;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={..._Z,...e}}traverse(e,r,i){this.root=e,this.options={...this.options,...i},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let i=this._traversalStack;for(e._selectionDepth=1,i.push(e);i.length>0;){let s=i.pop(),o=!1;this.canTraverse(s,r)&&(this.updateChildTiles(s,r),o=this.updateAndPushChildren(s,r,i,s.hasRenderContent?s._selectionDepth+1:s._selectionDepth));let a=s.parent,A=!!(!a||a._shouldRefine),h=!o;s.hasRenderContent?s.refine===qr.ADD?(this.loadTile(s,r),this.selectTile(s,r)):s.refine===qr.REPLACE&&(this.loadTile(s,r),h&&this.selectTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),h&&this.selectTile(s,r)),this.touchTile(s,r),s._shouldRefine=o&&A}let n=new Date().getTime();(this.traversalFinished(r)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let i=e.children;for(let n of i)this.updateTile(n,r)}updateAndPushChildren(e,r,i,n){let{loadSiblings:s,skipLevelOfDetail:o}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let A=e.refine===qr.REPLACE&&e.hasRenderContent&&!o,h=!1,g=!0;for(let _ of a)if(_._selectionDepth=n,_.isVisibleAndInRequestVolume?(i.find(_)&&i.delete(_),i.push(_),h=!0):(A||s)&&(this.loadTile(_,r),this.touchTile(_,r)),A){let x;if(_._inRequestVolume?_.hasRenderContent?x=_.contentAvailable:x=this.executeEmptyTraversal(_,r):x=!1,g=g&&x,!g)return!1}return h||(g=!1),g}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r,i=!1,n=!1){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:!n&&!e.isVisibleAndInRequestVolume?!1:this.shouldRefine(e,r,i):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,i=!1){let n=e._screenSpaceError;return i&&(n=e.getScreenSpaceError(r,!0)),n>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let i=[];if(this.options.viewportTraversersMap)for(let n in this.options.viewportTraversersMap)this.options.viewportTraversersMap[n]===r.viewport.id&&i.push(n);else i.push(r.viewport.id);e.updateVisibility(r,i)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let i=!1;for(let n of e.children)n.updateVisibility(r),i=i||n.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(e,r){let i=!0,n=this._emptyTraversalStack;for(n.push(e);n.length>0;){let s=n.pop(),o=!s.hasRenderContent&&this.canTraverse(s,r,!1,!1),a=!s.hasRenderContent&&s.children.length===0;if(!o&&!s.contentAvailable&&!a&&(i=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),o){let A=s.children;for(let h of A)n.push(h)}}return i}};var JB=new X;function yZ(t){return t!=null}var rc=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=ni.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new Fe;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new is({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new Fe;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(e,r,i,n=""){this.header=r,this.tileset=e,this.id=n||r.id,this.url=r.url,this.parent=i,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===ni.READY||this.hasEmptyContent}get contentAvailable(){return!!(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===ni.UNLOADED}get contentExpired(){return this.contentState===ni.EXPIRED}get contentFailed(){return this.contentState===ni.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=zB(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case Rr.I3S:return Sx(this,e);case Rr.TILES3D:return jB(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,i=this.refine===qr.ADD||r;if(i&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===ni.UNLOADED)return-1;let n=this.parent,o=n&&(!i||this._screenSpaceError===0||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-o,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=ni.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=ni.UNLOADED,!1;try{let i=this.tileset.getTileUrl(this.contentUrl),n=this.tileset.loader,s={...this.tileset.loadOptions,[n.id]:{...this.tileset.loadOptions[n.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(n.id)}};return this.content=await Cr(i,n,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=ni.READY,this._onContentLoaded(),!0}catch(i){throw this.contentState=ni.FAILED,i}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=ni.UNLOADED,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let i=this.parent,n=i?i._visibilityPlaneMask:ii.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let s=i?i.computedTransform:this.tileset.modelMatrix;this._updateTransform(s)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==ii.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:i}=e,{boundingVolume:n}=this;return i.computeVisibilityWithPlaneMask(n,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return JB.subVectors(r.center,e.position),e.direction.dot(JB)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(yZ(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=ni.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new Fe(e.transform):new Fe;let r=this.parent,i=this.tileset,n=r&&r.computedTransform?r.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new Fe(n).multiplyRight(this.transform);let s=r&&r._initialTransform?r._initialTransform.clone():new Fe;this._initialTransform=new Fe(s).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=ni.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ii.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||qr.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=gg(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=gg(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=gg(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new Fe){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return KB(this.tileset.tileset)}}};var mg=class extends is{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let i=e.children.length>0;if(e.hasTilesetContent&&i){let o=e.children[0];this.updateTileVisibility(o,r),e._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let n=e.refine===qr.REPLACE,s=e._optimChildrenWithinParent===NB.USE_OPTIMIZATION;if(n&&s&&i&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:i}=e;return!i||i.hasTilesetContent||i.refine!==qr.ADD?!1:!this.shouldRefine(e,r,!0)}};var _g=class{frameNumberMap=new Map;register(e,r){let i=this.frameNumberMap.get(e)||new Map,n=i.get(r)||0;i.set(r,n+1),this.frameNumberMap.set(e,i)}deregister(e,r){let i=this.frameNumberMap.get(e);if(!i)return;let n=i.get(r)||1;i.set(r,n-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var wx={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},yg=class{_statusMap;pendingTilesRegister=new _g;constructor(){this._statusMap={}}add(e,r,i,n){if(!this._statusMap[r]){let{frameNumber:s,viewport:{id:o}}=n;this._statusMap[r]={request:e,callback:i,key:r,frameState:n,status:wx.REQUESTED},this.pendingTilesRegister.register(o,s),e().then(a=>{this._statusMap[r].status=wx.COMPLETED;let{frameNumber:A,viewport:{id:h}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(h,A),this._statusMap[r].callback(a,n)}).catch(a=>{this._statusMap[r].status=wx.ERROR;let{frameNumber:A,viewport:{id:h}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(h,A),i(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:i,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,i);let{frameNumber:s,viewport:{id:o}}=r;this.pendingTilesRegister.register(o,s),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var xg=class extends is{_tileManager;constructor(e){super(e),this._tileManager=new yg}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=qB(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let i=e.header.children||[],n=e.children,s=e.tileset;for(let o of i){let a=`${o.id}-${r.viewport.id}`,A=n&&n.find(h=>h.id===a);if(A)A&&this.updateTile(A,r);else{let h=()=>this._loadTile(o.id,s);this._tileManager.find(a)?this._tileManager.update(a,r):(s.tileset.nodePages&&(h=()=>s.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(h,a,_=>this._onTileLoad(_,e,a),r))}}return!1}async _loadTile(e,r){let{loader:i}=r,n=r.getTileUrl(`${r.url}/nodes/${e}`),s={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await Cr(n,i,s)}_onTileLoad(e,r,i){let n=new rc(r.tileset,e,r,i);r.children.push(n);let s=this._tileManager.find(n.id).frameState;this.updateTile(n,s),this._frameNumber===s.frameNumber&&(this.traversalFinished(s)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,s)}};var xZ={description:"",ellipsoid:lt.WGS84,modelMatrix:new Fe,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},bg="Tiles In Tileset(s)",Cx="Tiles In Memory",ZB="Tiles In View",$B="Tiles To Render",e6="Tiles Loaded",Mx="Tiles Loading",t6="Tiles Unloaded",r6="Failed Tile Loads",i6="Points/Vertices",Px="Tile Memory Use",n6="Maximum Screen Space Error",gh=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new hg;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...xZ,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Ei.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Ks({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Gr({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let i=e;return this.queryParams.length&&(i=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),i}hasExtension(e){return this._extensionsUsed.indexOf(e)>-1}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytesthis._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let i=[];for(let n of r){let s=n.id;this._needTraverse(s)?i.push(s):this.traverseCounter--}for(let n of r){let s=n.id;if(this.roots[s]||(this.roots[s]=this._initializeTileHeaders(this.tileset,null)),!i.includes(s))continue;let o=BB(n,this._frameNumber);this._traverser.traverse(this.roots[s],o,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let i=this.frameStateData[r],n=Object.values(this._traverser.selectedTiles),[s,o]=OB(n,e,this.options.maximumTilesSelected);i.selectedTiles=s;for(let a of o)a.unselect();i._requestedTiles=Object.values(this._traverser.requestedTiles),i._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let e in this.frameStateData){let r=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let i=new Set(e.map(o=>o.id)),n=new Set(r.map(o=>o.id)),s=e.filter(o=>!n.has(o.id)).length>0;return s=s||r.filter(o=>!i.has(o.id)).length>0,s}_loadTiles(){for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let i of this.selectedTiles)i.contentAvailable&&i.content&&(e++,i.content.pointCount?r+=i.content.pointCount:r+=i.content.vertexCount);this.stats.get(ZB).count=this.selectedTiles.length,this.stats.get($B).count=e,this.stats.get(i6).count=r,this.stats.get(n6).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===Rr.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===Rr.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===Rr.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:i,xmax:n,ymin:s,ymax:o,zmin:a,zmax:A}=e;this.cartographicCenter=new X(i+(n-i)/2,s+(o-s)/2,a+(A-a)/2),this.cartesianCenter=new X,lt.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Tx(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[i,n,s,o]=r;this.cartographicCenter=new X(i+(s-i)/2,n+(o-n)/2,0),this.cartesianCenter=new X,lt.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=LB(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new X,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new X,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new X,lt.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new X(0,0,-lt.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=FB(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(bg),this.stats.get(Mx),this.stats.get(Cx),this.stats.get(ZB),this.stats.get($B),this.stats.get(e6),this.stats.get(t6),this.stats.get(r6),this.stats.get(i6),this.stats.get(Px,"memory"),this.stats.get(n6)}_initializeTileHeaders(e,r){let i=new rc(this,e.root,r);if(r&&(r.children.push(i),i.depth=r.depth+1),this.type===Rr.TILES3D){let n=[];for(n.push(i);n.length>0;){let s=n.pop();this.stats.get(bg).incrementCount();let o=s.header.children||[];for(let a of o){let A=new rc(this,a,s);if(A.contentUrl?.includes("?session=")){let g=new URL(A.contentUrl).searchParams.get("session");g&&(this._queryParams.session=g)}s.children.push(A),A.depth=s.depth+1,n.push(A)}}}return i}_initializeTraverser(){let e;switch(this.type){case Rr.TILES3D:e=mg;break;case Rr.I3S:e=xg;break;default:e=is}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(i){this._onTileLoadError(e,i instanceof Error?i:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(r6).incrementCount();let i=r.message||r.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${i}`),this.options.onTileError(e,i,n)}_onTileLoad(e,r){if(r){if(this.type===Rr.I3S){let i=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(bg).reset(),this.stats.get(bg).addCount(i)}e&&e.content&&PB(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===Rr.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===Rr.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(Mx).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Mx).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(e6).incrementCount(),this.stats.get(Cx).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Px).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(Cx).decrementCount(),this.stats.get(t6).incrementCount(),this.stats.get(Px).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let i of r.children)e.push(i);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,i=[];for(i.push(r);i.length>0;){e=i.pop();for(let n of e.children)i.push(n);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),i=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...i}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};var Tg="4.2.1";var ic={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},l6e=Object.keys(ic);function Ix(t,e,r){at(t instanceof ArrayBuffer);let i=new TextDecoder("utf8"),n=new Uint8Array(t,e,r);return i.decode(n)}function s6(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var bZ={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ar={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},rt={...bZ,...ar};var Rx={[ar.DOUBLE]:Float64Array,[ar.FLOAT]:Float32Array,[ar.UNSIGNED_SHORT]:Uint16Array,[ar.UNSIGNED_INT]:Uint32Array,[ar.UNSIGNED_BYTE]:Uint8Array,[ar.BYTE]:Int8Array,[ar.SHORT]:Int16Array,[ar.INT]:Int32Array},TZ={DOUBLE:ar.DOUBLE,FLOAT:ar.FLOAT,UNSIGNED_SHORT:ar.UNSIGNED_SHORT,UNSIGNED_INT:ar.UNSIGNED_INT,UNSIGNED_BYTE:ar.UNSIGNED_BYTE,BYTE:ar.BYTE,SHORT:ar.SHORT,INT:ar.INT},Bx="Failed to convert GL type",Tn=class t{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in Rx)if(Rx[r]===e)return r;throw new Error(Bx)}static fromName(e){let r=TZ[e];if(!r)throw new Error(Bx);return r}static getArrayType(e){switch(e){case ar.UNSIGNED_SHORT_5_6_5:case ar.UNSIGNED_SHORT_4_4_4_4:case ar.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=Rx[e];if(!r)throw new Error(Bx);return r}}static getByteSize(e){return t.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return!!t.getArrayType(e)}static createTypedArray(e,r,i=0,n){n===void 0&&(n=(r.byteLength-i)/t.getByteSize(e));let s=t.getArrayType(e);return new s(r,i,n)}};function o6(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function Ox(t,e=[0,0,0]){let r=t>>11&31,i=t>>5&63,n=t&31;return e[0]=r<<3,e[1]=i<<2,e[2]=n<<3,e}var x6e=1/256;var b6e=new Aa,T6e=new X,E6e=new Aa,v6e=new Aa,S6e=new Uint8Array(1);function a6(t,e=255){return ei(t,0,e)/e*2-1}function c6(t){return t<0?-1:1}function l6(t,e,r,i){if(o6(i),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(i.x=a6(t,r),i.y=a6(e,r),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){let n=i.x;i.x=(1-Math.abs(i.y))*c6(n),i.y=(1-Math.abs(n))*c6(i.y)}return i.normalize()}function Fx(t,e,r){return l6(t,e,255,r)}var Us=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return!!this.json[e]}getGlobalProperty(e,r=rt.UNSIGNED_INT,i=1){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,r,i,1,n.byteOffset):n}getPropertyArray(e,r,i){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(r=Tn.fromName(n.componentType)),this._getTypedArrayFromBinary(e,r,i,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,r,n)}getProperty(e,r,i,n,s){let o=this.json[e];if(!o)return o;let a=this.getPropertyArray(e,r,i);if(i===1)return a[n];for(let A=0;At[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},SZ={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function A6(t,e,r,i){let{componentType:n}=t;at(t.componentType);let s=typeof n=="string"?Tn.fromName(n):n,o=EZ[t.type],a=vZ[t.type],A=SZ[t.type];return r+=t.byteOffset,{values:Tn.createTypedArray(s,e,r,o*i),type:s,size:o,unpacker:a,packer:A}}var ns=t=>t!==void 0;function u6(t,e,r){if(!e)return null;let i=t.getExtension("3DTILES_batch_table_hierarchy"),n=e.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=n,i=n),i?wZ(i,r):null}function wZ(t,e){let r,i,n,s=t.instancesLength,o=t.classes,a=t.classIds,A=t.parentCounts,h=t.parentIds,g=s;ns(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,n=getBinaryAccessor(a),a=n.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,s));let _;if(ns(A))for(ns(A.byteOffset)&&(A.componentType=defaultValue(A.componentType,GL.UNSIGNED_SHORT),A.type=AttributeType.SCALAR,n=getBinaryAccessor(A),A=n.createArrayBufferView(e.buffer,e.byteOffset+A.byteOffset,s)),_=new Uint16Array(s),g=0,r=0;r0?CZ(t,e,r):MZ(t,e,r)}function CZ(t,e,r){let i=t.classIds,n=t.parentCounts,s=t.parentIds,o=t.parentIndexes,a=i.length,A=scratchVisited;A.length=Math.max(A.length,a);let h=++marker,g=scratchStack;for(g.length=0,g.push(e);g.length>0;){if(e=g.pop(),A[e]===h)continue;A[e]=h;let _=r(t,e);if(ns(_))return _;let x=n[e],T=o[e];for(let v=0;vt,IZ={HIERARCHY:!0,extensions:!0,extras:!0},nc=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,i,n={}){at(i>=0),this.json=e||{},this.binary=r,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(let s in this.json)IZ[s]||(this._properties[s]=this.json[s]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=u6(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),at(typeof r=="string",r),this._hierarchy){let i=zl(this._hierarchy,e,(n,s)=>{let o=n.classIds[s];return n.classes[o].name===r});return _i(i)}return!1}isExactClass(e,r){return at(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),at(typeof r=="string",r),_i(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=_i(r)?r:[],r.length=0;let i=Object.keys(this._properties);return r.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),at(typeof r=="string",r),this._binaryProperties){let n=this._binaryProperties[r];if(_i(n))return this._getBinaryProperty(n,e)}let i=this._properties[r];if(_i(i))return Eg(i[e],!0);if(this._hierarchy){let n=this._getHierarchyProperty(e,r);if(_i(n))return n}}setProperty(e,r,i){let n=this.featureCount;if(this._checkBatchId(e),at(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(o){this._setBinaryProperty(o,e,i);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,i))return;let s=this._properties[r];_i(s)||(this._properties[r]=new Array(n),s=this._properties[r]),s[e]=Eg(i,!0)}_checkBatchId(e){if(!(e>=0&&e{let o=n.classIds[s],a=n.classes[o].instances;return _i(a[r])});return _i(i)}_getPropertyNamesInHierarchy(e,r){zl(this._hierarchy,e,(i,n)=>{let s=i.classIds[n],o=i.classes[s].instances;for(let a in o)o.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return zl(this._hierarchy,e,(i,n)=>{let s=i.classIds[n],o=i.classes[s],a=i.classIndexes[n],A=o.instances[r];return _i(A)?_i(A.typedArray)?this._getBinaryProperty(A,a):Eg(A[a],!0):null})}_setHierarchyProperty(e,r,i,n){let s=zl(this._hierarchy,r,(o,a)=>{let A=o.classIds[a],h=o.classes[A],g=o.classIndexes[a],_=h.instances[i];return _i(_)?(at(a===r,`Inherited property "${i}" is read-only.`),_i(_.typedArray)?this._setBinaryProperty(_,g,n):_[g]=Eg(n,!0),!0):!1});return _i(s)}};function Oo(t,e,r=0){let i=new DataView(e);if(t.magic=i.getUint32(r,!0),r+=4,t.version=i.getUint32(r,!0),r+=4,t.byteLength=i.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var Hl=4,h6="b3dm tile in legacy format.";function Gl(t,e,r){let i=new DataView(e),n;t.header=t.header||{};let s=i.getUint32(r,!0);r+=Hl;let o=i.getUint32(r,!0);r+=Hl;let a=i.getUint32(r,!0);r+=Hl;let A=i.getUint32(r,!0);return r+=Hl,a>=570425344?(r-=Hl*2,n=s,a=o,A=0,s=0,o=0,console.warn(h6)):A>=570425344&&(r-=Hl,n=a,a=s,A=o,s=0,o=0,console.warn(h6)),t.header.featureTableJsonByteLength=s,t.header.featureTableBinaryByteLength=o,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=A,t.header.batchLength=n,r}function Wl(t,e,r,i){return r=RZ(t,e,r,i),r=BZ(t,e,r,i),r}function RZ(t,e,r,i){let{featureTableJsonByteLength:n,featureTableBinaryByteLength:s,batchLength:o}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:o||0},n&&n>0){let a=Ix(e,r,n);t.featureTableJson=JSON.parse(a)}return r+=n||0,t.featureTableBinary=new Uint8Array(e,r,s),r+=s||0,r}function BZ(t,e,r,i){let{batchTableJsonByteLength:n,batchTableBinaryByteLength:s}=t.header||{};if(n&&n>0){let o=Ix(e,r,n);t.batchTableJson=JSON.parse(o),r+=n,s&&s>0&&(t.batchTableBinary=new Uint8Array(e,r,s),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=s)}return r}function Lx(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:i,isRGB565:n,pointCount:s=0}=t;if(i&&r){let o=new Uint8ClampedArray(s*3);for(let a=0;a_*255);o[a*3]=g[0],o[a*3+1]=g[1],o[a*3+2]=g[2]}return{type:rt.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}if(e&&n){let o=new Uint8ClampedArray(s*3);for(let a=0;a12;){let a={shape:"tile3d"};t.tiles.push(a),r=await s(e,r,i,n,a)}return r}async function b6(t,e,r,i){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!i)return e.byteLength;let n=await Ti(e,Ls,r,i);t.gltf=ec(n),t.gpuMemoryUsageInBytes=ch(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function Nx(t,e=0,r,i,n={shape:"tile3d"}){switch(n.byteOffset=e,n.type=s6(t,e),n.type){case ic.COMPOSITE:return await x6(n,t,e,r,i,Nx);case ic.BATCHED_3D_MODEL:return await _6(n,t,e,r,i);case ic.GLTF:return await b6(n,t,r,i);case ic.INSTANCED_3D_MODEL:return await y6(n,t,e,r,i);case ic.POINT_CLOUD:return await m6(n,t,e,r,i);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}async function Dx(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let s=T6(t.slice(8,16)),o=new Uint8Array(t,24,s),A=new TextDecoder("utf8").decode(o),h=JSON.parse(A),g=T6(t.slice(16,24)),_=new ArrayBuffer(0);if(g&&(_=t.slice(24+s)),await Cg(h,h.tileAvailability,_,r),Array.isArray(h.contentAvailability))for(let x of h.contentAvailability)await Cg(h,x,_,r);else await Cg(h,h.contentAvailability,_,r);return await Cg(h,h.childSubtreeAvailability,_,r),h}async function Cg(t,e,r,i){let n=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof n!="number")return;let s=t.bufferViews[n],o=t.buffers[s.buffer];if(!i?.baseUrl)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(o.uri){let A=`${i?.baseUrl||""}/${o.uri}`,g=await(await i.fetch(A)).arrayBuffer();e.explicitBitstream=new Uint8Array(g,s.byteOffset,s.byteLength);return}let a=t.buffers.slice(0,s.buffer).reduce((A,h)=>A+h.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+o.byteLength),s.byteOffset,s.byteLength)}function T6(t){let e=new DataView(t),r=e.getUint32(0,!0),i=e.getUint32(4,!0);return r+2**32*i}var Mg={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Tg,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:Dx,options:{}};var Qi=null;try{Qi=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Wt(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Wt.prototype.__isLong__;Object.defineProperty(Wt.prototype,"__isLong__",{value:!0});function Jr(t){return(t&&t.__isLong__)===!0}function E6(t){var e=Math.clz32(t&-t);return t?31-e:e}Wt.isLong=Jr;var v6={},S6={};function sc(t,e){var r,i,n;return e?(t>>>=0,(n=0<=t&&t<256)&&(i=S6[t],i)?i:(r=Tt(t,0,!0),n&&(S6[t]=r),r)):(t|=0,(n=-128<=t&&t<128)&&(i=v6[t],i)?i:(r=Tt(t,t<0?-1:0,!1),n&&(v6[t]=r),r))}Wt.fromInt=sc;function qi(t,e){if(isNaN(t))return e?ks:En;if(e){if(t<0)return ks;if(t>=P6)return B6}else{if(t<=-C6)return yi;if(t+1>=C6)return R6}return t<0?qi(-t,e).neg():Tt(t%Xl|0,t/Xl|0,e)}Wt.fromNumber=qi;function Tt(t,e,r){return new Wt(t,e,r)}Wt.fromBits=Tt;var Pg=Math.pow;function kx(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?ks:En;if(r=r||10,r<2||360)throw Error("interior hyphen");if(i===0)return kx(t.substring(1),e,r).neg();for(var n=qi(Pg(r,8)),s=En,o=0;o>>0:this.low};xe.toNumber=function(){return this.unsigned?(this.high>>>0)*Xl+(this.low>>>0):this.high*Xl+(this.low>>>0)};xe.toString=function(e){if(e=e||10,e<2||36>>0,g=h.toString(e);if(o=A,o.isZero())return g+a;for(;g.length<6;)g="0"+g;a=""+g+a}};xe.getHighBits=function(){return this.high};xe.getHighBitsUnsigned=function(){return this.high>>>0};xe.getLowBits=function(){return this.low};xe.getLowBitsUnsigned=function(){return this.low>>>0};xe.getNumBitsAbs=function(){if(this.isNegative())return this.eq(yi)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<=0};xe.isOdd=function(){return(this.low&1)===1};xe.isEven=function(){return(this.low&1)===0};xe.equals=function(e){return Jr(e)||(e=vn(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};xe.eq=xe.equals;xe.notEquals=function(e){return!this.eq(e)};xe.neq=xe.notEquals;xe.ne=xe.notEquals;xe.lessThan=function(e){return this.comp(e)<0};xe.lt=xe.lessThan;xe.lessThanOrEqual=function(e){return this.comp(e)<=0};xe.lte=xe.lessThanOrEqual;xe.le=xe.lessThanOrEqual;xe.greaterThan=function(e){return this.comp(e)>0};xe.gt=xe.greaterThan;xe.greaterThanOrEqual=function(e){return this.comp(e)>=0};xe.gte=xe.greaterThanOrEqual;xe.ge=xe.greaterThanOrEqual;xe.compare=function(e){if(Jr(e)||(e=vn(e)),this.eq(e))return 0;var r=this.isNegative(),i=e.isNegative();return r&&!i?-1:!r&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};xe.comp=xe.compare;xe.negate=function(){return!this.unsigned&&this.eq(yi)?yi:this.not().add(jl)};xe.neg=xe.negate;xe.add=function(e){Jr(e)||(e=vn(e));var r=this.high>>>16,i=this.high&65535,n=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,A=e.low>>>16,h=e.low&65535,g=0,_=0,x=0,T=0;return T+=s+h,x+=T>>>16,T&=65535,x+=n+A,_+=x>>>16,x&=65535,_+=i+a,g+=_>>>16,_&=65535,g+=r+o,g&=65535,Tt(x<<16|T,g<<16|_,this.unsigned)};xe.subtract=function(e){return Jr(e)||(e=vn(e)),this.add(e.neg())};xe.sub=xe.subtract;xe.multiply=function(e){if(this.isZero())return this;if(Jr(e)||(e=vn(e)),Qi){var r=Qi.mul(this.low,this.high,e.low,e.high);return Tt(r,Qi.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?ks:En;if(this.eq(yi))return e.isOdd()?yi:En;if(e.eq(yi))return this.isOdd()?yi:En;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(M6)&&e.lt(M6))return qi(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,n=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,A=e.high&65535,h=e.low>>>16,g=e.low&65535,_=0,x=0,T=0,v=0;return v+=o*g,T+=v>>>16,v&=65535,T+=s*g,x+=T>>>16,T&=65535,T+=o*h,x+=T>>>16,T&=65535,x+=n*g,_+=x>>>16,x&=65535,x+=s*h,_+=x>>>16,x&=65535,x+=o*A,_+=x>>>16,x&=65535,_+=i*g+n*h+s*A+o*a,_&=65535,Tt(T<<16|v,_<<16|x,this.unsigned)};xe.mul=xe.multiply;xe.divide=function(e){if(Jr(e)||(e=vn(e)),e.isZero())throw Error("division by zero");if(Qi){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?Qi.div_u:Qi.div_s)(this.low,this.high,e.low,e.high);return Tt(r,Qi.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ks:En;var i,n,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ks;if(e.gt(this.shru(1)))return I6;s=ks}else{if(this.eq(yi)){if(e.eq(jl)||e.eq(Ux))return yi;if(e.eq(yi))return jl;var o=this.shr(1);return i=o.div(e).shl(1),i.eq(En)?e.isNegative()?jl:Ux:(n=this.sub(e.mul(i)),s=i.add(n.div(e)),s)}else if(e.eq(yi))return this.unsigned?ks:En;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=En}for(n=this;n.gte(e);){i=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(i)/Math.LN2),A=a<=48?1:Pg(2,a-48),h=qi(i),g=h.mul(e);g.isNegative()||g.gt(n);)i-=A,h=qi(i,this.unsigned),g=h.mul(e);h.isZero()&&(h=jl),s=s.add(h),n=n.sub(g)}return s};xe.div=xe.divide;xe.modulo=function(e){if(Jr(e)||(e=vn(e)),Qi){var r=(this.unsigned?Qi.rem_u:Qi.rem_s)(this.low,this.high,e.low,e.high);return Tt(r,Qi.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};xe.mod=xe.modulo;xe.rem=xe.modulo;xe.not=function(){return Tt(~this.low,~this.high,this.unsigned)};xe.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};xe.clz=xe.countLeadingZeros;xe.countTrailingZeros=function(){return this.low?E6(this.low):E6(this.high)+32};xe.ctz=xe.countTrailingZeros;xe.and=function(e){return Jr(e)||(e=vn(e)),Tt(this.low&e.low,this.high&e.high,this.unsigned)};xe.or=function(e){return Jr(e)||(e=vn(e)),Tt(this.low|e.low,this.high|e.high,this.unsigned)};xe.xor=function(e){return Jr(e)||(e=vn(e)),Tt(this.low^e.low,this.high^e.high,this.unsigned)};xe.shiftLeft=function(e){return Jr(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Tt(this.low<>>32-e,this.unsigned):Tt(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):Tt(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};xe.shr=xe.shiftRight;xe.shiftRightUnsigned=function(e){return Jr(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Tt(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?Tt(this.high,0,this.unsigned):Tt(this.high>>>e-32,0,this.unsigned)};xe.shru=xe.shiftRightUnsigned;xe.shr_u=xe.shiftRightUnsigned;xe.rotateLeft=function(e){var r;return Jr(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Tt(this.high,this.low,this.unsigned):e<32?(r=32-e,Tt(this.low<>>r,this.high<>>r,this.unsigned)):(e-=32,r=32-e,Tt(this.high<>>r,this.low<>>r,this.unsigned))};xe.rotl=xe.rotateLeft;xe.rotateRight=function(e){var r;return Jr(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Tt(this.high,this.low,this.unsigned):e<32?(r=32-e,Tt(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,r=32-e,Tt(this.low<>>e,this.high<>>e,this.unsigned))};xe.rotr=xe.rotateRight;xe.toSigned=function(){return this.unsigned?Tt(this.low,this.high,!1):this};xe.toUnsigned=function(){return this.unsigned?this:Tt(this.low,this.high,!0)};xe.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};xe.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};xe.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Wt.fromBytes=function(e,r,i){return i?Wt.fromBytesLE(e,r):Wt.fromBytesBE(e,r)};Wt.fromBytesLE=function(e,r){return new Wt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Wt.fromBytesBE=function(e,r){return new Wt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var Yl=Wt;var YZ=16;function mh(t){t==="X"&&(t="");let e=t.padEnd(YZ,"0");return Yl.fromString(e,!0,16)}function Vx(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let i=e;e*=4;let s=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-i-s.length).join("0")+s}function zx(t,e){let r=QZ(t).shiftRightUnsigned(2);return t.add(Yl.fromNumber(2*e+1-4).multiply(r))}function QZ(t){return t.and(t.not().add(1))}var qZ=3,KZ=30,JZ=2*KZ+1,O6=180/Math.PI;function L6(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),i=e[1],n=i.length,s=0,o=[0,0];for(let a=n-1;a>=0;a--){s=n-a;let A=i[a],h=0,g=0;A==="1"?g=1:A==="2"?(h=1,g=1):A==="3"&&(h=1);let _=Math.pow(2,s-1);ZZ(_,o,h,g),o[0]+=_*h,o[1]+=_*g}if(r%2===1){let a=o[0];o[0]=o[1],o[1]=a}return{face:r,ij:o,level:s}}function N6(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function Gx(t){return[F6(t[0]),F6(t[1])]}function Wx(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function jx([t,e,r]){let i=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*O6,i*O6]}function ZZ(t,e,r,i){if(i===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function D6(t){let e=Hx(t.ij,t.level,[.5,.5]),r=Gx(e),i=Wx(t.face,r);return jx(i)}var $Z=100;function Xx(t){let{face:e,ij:r,level:i}=t,n=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil($Z*Math.pow(2,-i))),o=new Float64Array(4*s*2+2),a=0,A=0;for(let h=0;h<4;h++){let g=n[h].slice(0),_=n[h+1],x=(_[0]-g[0])/s,T=(_[1]-g[1])/s;for(let v=0;v89.999&&(R[0]=A);let B=R[0]-A;R[0]+=B>180?-360:B<-180?360:0,o[a++]=R[0],o[a++]=R[1],A=R[0]}}return o[a++]=o[0],o[a++]=o[1],o}function Ql(t){let e=e$(t);return L6(e)}function e$(t){if(t.indexOf("/")>0)return t;let e=mh(t);return N6(e)}function Yx(t){let e=Ql(t);return D6(e)}function k6(t){let e;if(t.face===2||t.face===5){let r=null,i=0;for(let n=0;n<4;n++){let s=`${t.face}/${n}`,o=Ql(s),a=Xx(o);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,i),i+=a.length}e=U6(r)}else{let r=Xx(t);e=U6(r)}return e}function U6(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let i=0;ii-n),r.sort((i,n)=>i-n),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function Qx(t,e){let r=e?.minimumHeight||0,i=e?.maximumHeight||0,n=Ql(t),s=k6(n),o=s.west,a=s.south,A=s.east,h=s.north,g=[];return g.push(new X(o,h,r)),g.push(new X(A,h,r)),g.push(new X(A,a,r)),g.push(new X(o,a,r)),g.push(new X(o,h,i)),g.push(new X(A,h,i)),g.push(new X(A,a,i)),g.push(new X(o,a,i)),g}function Ig(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},i=Qx(e,r),n=Yx(e),s=n[0],o=n[1],a=lt.WGS84.cartographicToCartesian([s,o,r.maximumHeight]),A=new X(a[0],a[1],a[2]);i.push(A);let h=eh(i);return[...h.center,...h.halfAxes]}var t$=4,r$=8,i$={QUADTREE:t$,OCTREE:r$};function n$(t,e,r){if(t?.box){let i=mh(t.s2VolumeInfo.token),n=zx(i,e),s=Vx(n),o={...t.s2VolumeInfo};switch(o.token=s,r){case"OCTREE":let h=t.s2VolumeInfo,g=h.maximumHeight-h.minimumHeight,_=g/2,x=h.minimumHeight+g/2;h.minimumHeight=x-_,h.maximumHeight=x+_;break;default:break}return{box:Ig(o),s2VolumeInfo:o}}}async function Kx(t){let{implicitOptions:e,parentData:r={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,s2VolumeBox:n,loaderOptions:s}=t,{subtree:o,level:a=0,globalData:A={level:0,mortonIndex:0,x:0,y:0,z:0}}=t,{subdivisionScheme:h,subtreeLevels:g,maximumLevel:_,contentUrlTemplate:x,subtreesUriTemplate:T,basePath:v}=e,S={children:[],lodMetricValue:0,contentUrl:""};if(!_)return km.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${x} won't be loaded...`),S;let C=a+A.level;if(C>_)return S;let M=i$[h],R=Math.log2(M),B=i&1,k=i>>1&1,Q=i>>2&1,$=(M**a-1)/(M-1),re=oc(r.mortonIndex,i,R),Y=$+re,H=oc(r.x,B,1),L=oc(r.y,k,1),ae=oc(r.z,Q,1),fe=!1;a>=g&&(fe=qx(o.childSubtreeAvailability,re));let he=oc(A.x,H,a),ye=oc(A.y,L,a),Ne=oc(A.z,ae,a);if(fe){let At=`${v}/${T}`,De=Rg(At,C,he,ye,Ne);o=await Cr(De,Mg,s),A={mortonIndex:re,x:H,y:L,z:ae,level:a},re=0,Y=0,H=0,L=0,ae=0,a=0}if(!qx(o.tileAvailability,Y))return S;qx(o.contentAvailability,Y)&&(S.contentUrl=Rg(x,C,he,ye,Ne));let et=a+1,st={mortonIndex:re,x:H,y:L,z:ae};for(let At=0;At1&&km.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?!!r.constant:r.explicitBitstream?c$(e,r.explicitBitstream):!1}function s$(t,e,r,i,n){let{basePath:s,refine:o,getRefine:a,lodMetricType:A,getTileType:h,rootLodMetricValue:g,rootBoundingVolume:_}=i,x=t.contentUrl&&t.contentUrl.replace(`${s}/`,""),T=g/2**e,v=n?.box?{box:n.box}:_,S=o$(e,v,r);return{children:t.children,contentUrl:t.contentUrl,content:{uri:x},id:t.contentUrl,refine:a(o),type:h(t),lodMetricType:A,lodMetricValue:T,geometricError:T,transform:t.transform,boundingVolume:S}}function o$(t,e,r){if(e.region){let{childTileX:i,childTileY:n,childTileZ:s}=r,[o,a,A,h,g,_]=e.region,x=2**t,T=(A-o)/x,v=(h-a)/x,S=(_-g)/x,[C,M]=[o+T*i,o+T*(i+1)],[R,B]=[a+v*n,a+v*(n+1)],[k,Q]=[g+S*s,g+S*(s+1)];return{region:[C,R,M,B,k,Q]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}function oc(t,e,r){return(t<s[o])}function a$(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function c$(t,e){let r=Math.floor(t/8),i=t%8;return(e[r]>>i&1)===1}function Zx(t,e=""){if(!e)return Yi.EMPTY;let i=e.split("?")[0].split(".").pop();switch(i){case"pnts":return Yi.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Yi.SCENEGRAPH;default:return i||Yi.EMPTY}}function $x(t){switch(t){case"REPLACE":case"replace":return qr.REPLACE;case"ADD":case"add":return qr.ADD;default:return t}}function Jx(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let i=new URL(t,`${e}/`);return decodeURI(i.toString())}else if(t.startsWith("/"))return t;return Ei.resolve(e,t)}function V6(t,e){if(!t)return null;let r;if(t.content){let n=t.content.uri||t.content?.url;typeof n<"u"&&(r=Jx(n,e))}return{...t,id:r,contentUrl:r,lodMetricType:Ds.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Zx(t,r),refine:$x(t.refine)}}async function G6(t,e,r){let i=null,n=H6(t.root);n&&t.root?i=await z6(t.root,t,e,n,r):i=V6(t.root,e);let s=[];for(s.push(i);s.length>0;){let o=s.pop()||{},a=o.children||[],A=[];for(let h of a){let g=H6(h),_;g?_=await z6(h,t,e,g,r):_=V6(h,e),_&&(A.push(_),s.push(_))}o.children=A}return i}async function z6(t,e,r,i,n){let{subdivisionScheme:s,maximumLevel:o,availableLevels:a,subtreeLevels:A,subtrees:{uri:h}}=i,g=Rg(h,0,0,0,0),_=Jx(g,r),x=await Cr(_,Mg,n),T=t.content?.uri,v=T?Jx(T,r):"",S=e?.root?.refine,C=t.geometricError,M=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(M){let Q={box:Ig(M),s2VolumeInfo:M};t.boundingVolume=Q}let R=t.boundingVolume,B={contentUrlTemplate:v,subtreesUriTemplate:h,subdivisionScheme:s,subtreeLevels:A,maximumLevel:Number.isFinite(a)?a-1:o,refine:S,basePath:r,lodMetricType:Ds.GEOMETRIC_ERROR,rootLodMetricValue:C,rootBoundingVolume:R,getTileType:Zx,getRefine:$x};return await l$(t,r,x,B,n)}async function l$(t,e,r,i,n){if(!t)return null;let{children:s,contentUrl:o}=await Kx({subtree:r,implicitOptions:i,loaderOptions:n}),a,A=null;return o&&(a=o,A={uri:o.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:Ds.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:Zx(t,a),refine:$x(t.refine),content:A||t.content,children:s}}function H6(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var Bg={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Tg,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:A$,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function A$(t,e={},r){let i=e["3d-tiles"]||{},n;return i.isTileset==="auto"?n=r?.url&&r.url.indexOf(".json")!==-1:n=i.isTileset,n?u$(t,e,r):f$(t,e,r)}async function u$(t,e,r){let i=JSON.parse(new TextDecoder().decode(t)),n=r?.url||"",s=h$(n),o=await G6(i,s,e||{});return{...i,shape:"tileset3d",loader:Bg,url:n,queryString:r?.queryString||"",basePath:s,root:o||i.root,type:Rr.TILES3D,lodMetricType:Ds.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0}}async function f$(t,e,r){let i={content:{shape:"tile3d",featureIds:null}};return await Nx(t,0,e,r,i.content),i.content}function h$(t){return Ei.dirname(t)}var W6=[0],d$={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Bg,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},_h=class extends Gt{static{this.defaultProps=d$}static{this.layerName="Tile3DLayer"}initializeState(){"onTileLoadFail"in this.props&&me.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return!!(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:i}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),i.viewportChanged){let{activeViewports:n}=this.state;Object.keys(n).length&&(this._updateTileset(n),this.state.lastUpdatedViewports=n,this.state.activeViewports={})}if(i.propsChanged){let{layerMap:n}=this.state;for(let s in n)n[s].needsUpdate=!0}}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:i}=this.state;this.internalState.viewport=e,r[e.id]=e;let n=i?.[e.id];(!n||!e.equals(n))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let i=r&&r.props.tile;return e.picked&&(e.object=i),e.sourceTile=i,e}filterSubLayer({layer:e,viewport:r}){let{tile:i}=e.props,{id:n}=r;return i.selected&&i.viewportIds.includes(n)}_updateAutoHighlight(e){let r=e.sourceTile,i=this.state.layerMap[r?.id];i&&i.layer&&i.layer.updateAutoHighlight(e)}async _loadTileset(e){let{loadOptions:r={}}=this.props,i=this.props.loader||this.props.loaders,n=Array.isArray(i)?i[0]:i,s={loadOptions:{...r}},o=e;if(n.preload){let h=await n.preload(e,r);h.url&&(o=h.url),h.headers&&(s.loadOptions.fetch={...s.loadOptions.fetch,headers:h.headers}),Object.assign(s,h)}let a=await Cr(o,n,s.loadOptions),A=new gh(a,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...s});this.setState({tileset3d:A,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(A)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:i}=this.context,n=Object.keys(e).length;!i||!n||!r||r.selectTiles(Object.values(e)).then(s=>{this.state.frameNumber!==s&&this.setState({frameNumber:s})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case Yi.POINTCLOUD:return this._makePointCloudLayer(e,r);case Yi.SCENEGRAPH:return this._make3DModelLayer(e);case Yi.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:i,pointCount:n,constantRGBA:s,cartographicOrigin:o,modelMatrix:a}=e.content,{positions:A,normals:h,colors:g}=i;if(!A)return null;let _=r&&r.props.data||{header:{vertexCount:n},attributes:{POSITION:A,NORMAL:h,COLOR_0:g}},{pointSize:x,getPointColor:T}=this.props,v=this.getSubLayerClass("pointcloud",Oa);return new v({pointSize:x},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:_,coordinateSystem:Oe.METER_OFFSETS,coordinateOrigin:o,modelMatrix:a,getColor:s||T,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:i,cartographicOrigin:n,modelMatrix:s}=e.content,o=this.getSubLayerClass("scenegraph",Ul);return new o({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:i||W6,scenegraph:r,coordinateSystem:Oe.METER_OFFSETS,coordinateOrigin:n,modelMatrix:s,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(e,r){let i=e.content,{attributes:n,indices:s,modelMatrix:o,cartographicOrigin:a,coordinateSystem:A=Oe.METER_OFFSETS,material:h,featureIds:g}=i,{_getMeshColor:_}=this.props,x=r&&r.props.mesh||new mt({topology:"triangle-list",attributes:p$(n),indices:s}),T=this.getSubLayerClass("mesh",hh);return new T(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:x,data:W6,getColor:_(e),pbrMaterial:h,modelMatrix:o,coordinateOrigin:a,coordinateSystem:A,featureIds:g,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(i=>{let n=r[i.id]=r[i.id]||{tile:i},{layer:s}=n;return i.selected&&(s?n.needsUpdate&&(s=this._getSubLayer(i,s),n.needsUpdate=!1):s=this._getSubLayer(i)),n.layer=s,s}).filter(Boolean):null}};function p$(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var g$=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function eb(t){return t>>1^-(t&1)}function m$(t){let e=0,r={};for(let[i,n]of g$){let s=n===8?t.getFloat64:t.getFloat32;r[i]=s.call(t,e,!0),e+=n}return{header:r,headerEndPosition:e}}function _$(t,e){let r=e,i=3,n=t.getUint32(r,!0),s=new Uint16Array(n*i);r+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,a=n*o,A=r,h=A+a,g=h+a,_=0,x=0,T=0;for(let v=0;v65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;i%o!==0&&(i+=o-i%o);let a=t.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let A=a*3,h=yh(t.buffer,i,A,o);return i+=A*o,{triangleIndicesEndPosition:i,triangleIndices:h}}function x$(t,e,r){let i=r,n=3,o=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let A=yh(t.buffer,i,a,o,!1);i+=a*o;let h=t.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let g=yh(t.buffer,i,h,o,!1);i+=h*o;let _=t.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let x=yh(t.buffer,i,_,o,!1);i+=_*o;let T=t.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let v=yh(t.buffer,i,T,o,!1);return i+=T*o,{edgeIndicesEndPosition:i,westIndices:A,southIndices:g,eastIndices:x,northIndices:v}}function b$(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function T$(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function E$(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let i=e;for(;iMath.min(...n)-Math.min(...s)||Math.max(...n)-Math.max(...s));let r=[],i=0;for(;ie[3*i+1]-e[3*n+1]),t.eastIndices.sort((i,n)=>e[3*n+1]-e[3*i+1]),t.southIndices.sort((i,n)=>e[3*n]-e[3*i]),t.northIndices.sort((i,n)=>e[3*i]-e[3*n]);let r=[];for(let i in t){let n=t[i];for(let s=0;s>=1)>1;){let x=s+a>>1,T=o+A>>1;n&1?(a=s,A=o,s=h,o=g):(s=a,o=A,a=h,A=g),h=x,g=T}let _=i*4;this.coords[_+0]=s,this.coords[_+1]=o,this.coords[_+2]=a,this.coords[_+3]=A}}createTile(e){return new ib(e,this)}},ib=class{constructor(e,r){let i=r.gridSize;if(e.length!==i*i)throw new Error(`Expected terrain data of length ${i*i} (${i} x ${i}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:i,gridSize:n}=this.martini,{terrain:s,errors:o}=this;for(let a=e-1;a>=0;a--){let A=a*4,h=i[A+0],g=i[A+1],_=i[A+2],x=i[A+3],T=h+_>>1,v=g+x>>1,S=T+v-g,C=v+h-T,M=(s[g*n+h]+s[x*n+_])/2,R=v*n+T,B=Math.abs(M-s[R]);if(o[R]=Math.max(o[R],B),a>1)*n+(h+S>>1),Q=(x+C>>1)*n+(_+S>>1);o[R]=Math.max(o[R],o[k],o[Q])}}}getMesh(e=0){let{gridSize:r,indices:i}=this.martini,{errors:n}=this,s=0,o=0,a=r-1;i.fill(0);function A(T,v,S,C,M,R){let B=T+S>>1,k=v+C>>1;Math.abs(T-M)+Math.abs(v-R)>1&&n[k*r+B]>e?(A(M,R,T,v,B,k),A(S,C,M,R,B,k)):(i[v*r+T]=i[v*r+T]||++s,i[C*r+S]=i[C*r+S]||++s,i[R*r+M]=i[R*r+M]||++s,o++)}A(0,0,a,a,a,0),A(a,a,0,0,0,a);let h=new Uint16Array(s*2),g=new Uint32Array(o*3),_=0;function x(T,v,S,C,M,R){let B=T+S>>1,k=v+C>>1;if(Math.abs(T-M)+Math.abs(v-R)>1&&n[k*r+B]>e)x(M,R,T,v,B,k),x(S,C,M,R,B,k);else{let Q=i[v*r+T]-1,$=i[C*r+S]-1,re=i[R*r+M]-1;h[2*Q]=T,h[2*Q+1]=v,h[2*$]=S,h[2*$+1]=C,h[2*re]=M,h[2*re+1]=R,g[_++]=Q,g[_++]=$,g[_++]=re}}return x(0,0,a,a,a,0),x(a,a,0,0,0,a),{vertices:h,triangles:g}}};var bh=class{constructor(e,r,i=r){this.data=e,this.width=r,this.height=i,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let n=r-1,s=i-1,o=this._addPoint(0,0),a=this._addPoint(n,0),A=this._addPoint(0,s),h=this._addPoint(n,s),g=this._addTriangle(h,o,A,-1,-1,-1);this._addTriangle(o,h,a,g,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r=0&&nt>=0&&it>=0){et=!0;let At=$*Ne+re*nt+Y*it,De=Math.abs(At-this.heightAt(st,he));fe+=De*De,De>H&&(H=De,L=st,ae=he)}else if(et)break;Ne+=M,nt+=B,it+=S}x+=R,T+=k,v+=C}(L===e&&ae===r||L===i&&ae===n||L===s&&ae===o)&&(H=0),this._candidates[2*a]=L,this._candidates[2*a+1]=ae,this._rms[a]=fe,this._queuePush(a,H,fe)}_step(){let e=this._queuePop(),r=e*3+0,i=e*3+1,n=e*3+2,s=this.triangles[r],o=this.triangles[i],a=this.triangles[n],A=this.coords[2*s],h=this.coords[2*s+1],g=this.coords[2*o],_=this.coords[2*o+1],x=this.coords[2*a],T=this.coords[2*a+1],v=this._candidates[2*e],S=this._candidates[2*e+1],C=this._addPoint(v,S);if(cc(A,h,g,_,v,S)===0)this._handleCollinear(C,r);else if(cc(g,_,x,T,v,S)===0)this._handleCollinear(C,i);else if(cc(x,T,A,h,v,S)===0)this._handleCollinear(C,n);else{let M=this._halfedges[r],R=this._halfedges[i],B=this._halfedges[n],k=this._addTriangle(s,o,C,M,-1,-1,r),Q=this._addTriangle(o,a,C,R,-1,k+1),$=this._addTriangle(a,s,C,B,k+2,Q+1);this._legalize(k),this._legalize(Q),this._legalize($)}}_addPoint(e,r){let i=this.coords.length>>1;return this.coords.push(e,r),i}_addTriangle(e,r,i,n,s,o,a=this.triangles.length){let A=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=i,this._halfedges[a+0]=n,this._halfedges[a+1]=s,this._halfedges[a+2]=o,n>=0&&(this._halfedges[n]=a+0),s>=0&&(this._halfedges[s]=a+1),o>=0&&(this._halfedges[o]=a+2),this._candidates[2*A+0]=0,this._candidates[2*A+1]=0,this._queueIndices[A]=-1,this._rms[A]=0,this._pending[this._pendingLen++]=A,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let i=e-e%3,n=r-r%3,s=i+(e+1)%3,o=i+(e+2)%3,a=n+(r+2)%3,A=n+(r+1)%3,h=this.triangles[o],g=this.triangles[e],_=this.triangles[s],x=this.triangles[a],T=this.coords;if(!P$(T[2*h],T[2*h+1],T[2*g],T[2*g+1],T[2*_],T[2*_+1],T[2*x],T[2*x+1]))return;let v=this._halfedges[s],S=this._halfedges[o],C=this._halfedges[a],M=this._halfedges[A];this._queueRemove(i/3),this._queueRemove(n/3);let R=this._addTriangle(h,x,_,-1,C,v,i),B=this._addTriangle(x,h,g,R,S,M,n);this._legalize(R+1),this._legalize(B+2)}_handleCollinear(e,r){let i=r-r%3,n=i+(r+1)%3,s=i+(r+2)%3,o=this.triangles[s],a=this.triangles[r],A=this.triangles[n],h=this._halfedges[n],g=this._halfedges[s],_=this._halfedges[r];if(_<0){let $=this._addTriangle(e,o,a,-1,g,-1,i),re=this._addTriangle(o,e,A,$,-1,h);this._legalize($+1),this._legalize(re+2);return}let x=_-_%3,T=x+(_+2)%3,v=x+(_+1)%3,S=this.triangles[T],C=this._halfedges[T],M=this._halfedges[v];this._queueRemove(x/3);let R=this._addTriangle(o,a,e,g,-1,-1,i),B=this._addTriangle(a,S,e,M,-1,R+1,x),k=this._addTriangle(S,A,e,C,-1,B+1),Q=this._addTriangle(A,o,e,h,R+2,k+1);this._legalize(R),this._legalize(B),this._legalize(k),this._legalize(Q)}_queuePush(e,r,i){let n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(r),this._rmsSum+=i,this._queueUp(n)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let n=this._pending.indexOf(e);if(n!==-1)this._pending[n]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let i=this._queue.length-1;i!==r&&(this._queueSwap(r,i),this._queueDown(r,i)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let i=this._queue[e],n=this._queue[r];this._queue[e]=n,this._queue[r]=i,this._queueIndices[i]=r,this._queueIndices[n]=e;let s=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=s}_queueUp(e){let r=e;for(;;){let i=r-1>>1;if(i===r||!this._queueLess(r,i))break;this._queueSwap(i,r),r=i}}_queueDown(e,r){let i=e;for(;;){let n=2*i+1;if(n>=r||n<0)break;let s=n+1,o=n;if(se}};function cc(t,e,r,i,n,s){return(r-n)*(e-s)-(i-s)*(t-n)}function P$(t,e,r,i,n,s,o,a){let A=t-o,h=e-a,g=r-o,_=i-a,x=n-o,T=s-a,v=A*A+h*h,S=g*g+_*_,C=x*x+T*T;return A*(_*C-S*T)-h*(g*C-S*x)+v*(g*T-_*x)<0}function Y6(t,e){let{meshMaxError:r,bounds:i,elevationDecoder:n}=e,{data:s,width:o,height:a}=t,A,h;switch(e.tesselator){case"martini":A=Fg(s,o,a,n,e.tesselator),h=j6(r,o,A);break;case"delatin":A=Fg(s,o,a,n,e.tesselator),h=X6(r,o,a,A);break;default:o===a&&!(a&o-1)?(A=Fg(s,o,a,n,"martini"),h=j6(r,o,A)):(A=Fg(s,o,a,n,"delatin"),h=X6(r,o,a,A));break}let{vertices:g}=h,{triangles:_}=h,x=I$(g,A,o,a,i),T=us(x);if(e.skirtHeight){let{attributes:v,triangles:S}=Og(x,_,e.skirtHeight);x=v,_=S}return{loaderData:{header:{}},header:{vertexCount:_.length,boundingBox:T},mode:4,indices:{value:Uint32Array.from(_),size:1},attributes:x}}function j6(t,e,r){let i=e+1,s=new xh(i).createTile(r),{vertices:o,triangles:a}=s.getMesh(t);return{vertices:o,triangles:a}}function X6(t,e,r,i){let n=new bh(i,e+1,r+1);n.run(t);let{coords:s,triangles:o}=n;return{vertices:s,triangles:o}}function Fg(t,e,r,i,n){let{rScaler:s,bScaler:o,gScaler:a,offset:A}=i,h=new Float32Array((e+1)*(r+1));for(let g=0,_=0;_rb(t,e?.["quantized-mesh"]),parse:async(t,e)=>rb(t,e?.["quantized-mesh"])};var q6=[1],O$={...rs.defaultProps,elevationData:Po,texture:{...Po,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[Ng]};function K6(t){return Array.isArray(t)?t.join(";"):t||""}var Th=class extends Gt{static{this.defaultProps=O$}static{this.layerName="TerrainLayer"}updateState({props:e,oldProps:r}){let i=e.elevationData!==r.elevationData;if(i){let{elevationData:s}=e,o=s&&(Array.isArray(s)||s.includes("{x}")&&s.includes("{y}"));this.setState({isTiled:o})}let n=i||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&n){let s=this.loadTerrain(e);this.setState({terrain:s})}e.workerUrl&&me.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:i,meshMaxError:n,signal:s}){if(!e)return null;let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?n*2:0,...o?.terrain,bounds:r,meshMaxError:n,elevationDecoder:i}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:o,signal:s})}getTiledTerrainData(e){let{elevationData:r,fetch:i,texture:n,elevationDecoder:s,meshMaxError:o}=this.props,{viewport:a}=this.context,A=ts(r,e),h=n&&ts(n,e),{signal:g}=e,_=[0,0],x=[0,0];if(a.isGeospatial){let C=e.bbox;_=a.projectFlat([C.west,C.south]),x=a.projectFlat([C.east,C.north])}else{let C=e.bbox;_=[C.left,C.bottom],x=[C.right,C.top]}let T=[_[0],_[1],x[0],x[1]],v=this.loadTerrain({elevationData:A,bounds:T,elevationDecoder:s,meshMaxError:o,signal:g}),S=h?i(h,{propName:"texture",layer:this,loaders:[],signal:g}).catch(C=>null):Promise.resolve(null);return Promise.all([v,S])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",Os),{color:i,wireframe:n,material:s}=this.props,{data:o}=e;if(!o)return null;let[a,A]=o;return new r(e,{data:q6,mesh:a,texture:A,_instanced:!1,coordinateSystem:Oe.CARTESIAN,getPosition:h=>[0,0,0],getColor:i,wireframe:n,material:s})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,i=e.map(o=>o.content).filter(Boolean).map(o=>o[0].header.boundingBox.map(A=>A[2]));if(i.length===0)return;let n=Math.min(...i.map(o=>o[0])),s=Math.max(...i.map(o=>o[1]));(!r||nr[1])&&this.setState({zRange:[n,s]})}renderLayers(){let{color:e,material:r,elevationData:i,texture:n,wireframe:s,meshMaxError:o,elevationDecoder:a,tileSize:A,maxZoom:h,minZoom:g,extent:_,maxRequests:x,onTileLoad:T,onTileUnload:v,onTileError:S,maxCacheSize:C,maxCacheByteSize:M,refinementStrategy:R}=this.props;if(this.state.isTiled)return new rs(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:K6(i),texture:K6(n),meshMaxError:o,elevationDecoder:a}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:A,maxZoom:h,minZoom:g,extent:_,maxRequests:x,onTileLoad:T,onTileUnload:v,onTileError:S,maxCacheSize:C,maxCacheByteSize:M,refinementStrategy:R});if(!i)return null;let B=this.getSubLayerClass("mesh",Os);return new B(this.getSubLayerProps({id:"mesh"}),{data:q6,mesh:this.state.terrain,texture:n,_instanced:!1,getPosition:k=>[0,0,0],getColor:e,material:r,wireframe:s})}};var F$={clipBounds:[0,0,1,1],clipByInstance:void 0},J6=` +uniform vec4 clip_bounds; +bool clip_isInBounds(vec2 position) { +return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3]; +} +`,L$={name:"clip-vs",vs:J6},N$={"vs:#decl":` +out float clip_isVisible; +`,"vs:DECKGL_FILTER_GL_POSITION":` +clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy)); +`,"fs:#decl":` +in float clip_isVisible; +`,"fs:DECKGL_FILTER_COLOR":` +if (clip_isVisible < 0.5) discard; +`},D$={name:"clip-fs",fs:J6},U$={"vs:#decl":` +out vec2 clip_commonPosition; +`,"vs:DECKGL_FILTER_GL_POSITION":` +clip_commonPosition = geometry.position.xy; +`,"fs:#decl":` +in vec2 clip_commonPosition; +`,"fs:DECKGL_FILTER_COLOR":` +if (!clip_isInBounds(clip_commonPosition)) discard; +`},ql=class extends Zc{static{this.defaultProps=F$}static{this.extensionName="ClipExtension"}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=!!this.props.clipByInstance),this.state.clipByInstance=e,e?{modules:[L$],inject:N$}:{modules:[D$],inject:U$}}draw({uniforms:e}){let{clipBounds:r}=this.props;if(this.state.clipByInstance)e.clip_bounds=r;else{let i=this.projectPosition([r[0],r[1],0]),n=this.projectPosition([r[2],r[3],0]);e.clip_bounds=[Math.min(i[0],n[0]),Math.min(i[1],n[1]),Math.max(i[0],n[0]),Math.max(i[1],n[1])]}}};function ob(t,e,r){let i=k$(t),n=Object.keys(i).filter(s=>i[s]!==Array);return V$(t,{propArrayTypes:i,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function k$(t){let e={};for(let r of t)if(r.properties)for(let i in r.properties){let n=r.properties[i];e[i]=X$(n,e[i])}return e}function V$(t,e,r){let{pointPositionsCount:i,pointFeaturesCount:n,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:A,polygonObjectsCount:h,polygonRingsCount:g,polygonFeaturesCount:_,propArrayTypes:x,coordLength:T}=e,{numericPropKeys:v=[],PositionDataType:S=Float32Array,triangulate:C=!0}=r,M=t[0]&&"id"in t[0],R=t.length>65535?Uint32Array:Uint16Array,B={type:"Point",positions:new S(i*T),globalFeatureIds:new R(i),featureIds:n>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},k={type:"LineString",pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new S(s*T),globalFeatureIds:new R(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},Q={type:"Polygon",polygonIndices:A>65535?new Uint32Array(h+1):new Uint16Array(h+1),primitivePolygonIndices:A>65535?new Uint32Array(g+1):new Uint16Array(g+1),positions:new S(A*T),globalFeatureIds:new R(A),featureIds:_>65535?new Uint32Array(A):new Uint16Array(A),numericProps:{},properties:[],fields:[]};C&&(Q.triangles=[]);for(let re of[B,k,Q])for(let Y of v){let H=x[Y];re.numericProps[Y]=new H(re.positions.length/T)}k.pathIndices[o]=s,Q.polygonIndices[h]=A,Q.primitivePolygonIndices[g]=A;let $={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let re of t){let Y=re.geometry,H=re.properties||{};switch(Y.type){case"Point":z$(Y,B,$,T,H),B.properties.push(sb(H,v)),M&&B.fields.push({id:re.id}),$.pointFeature++;break;case"LineString":H$(Y,k,$,T,H),k.properties.push(sb(H,v)),M&&k.fields.push({id:re.id}),$.lineFeature++;break;case"Polygon":G$(Y,Q,$,T,H),Q.properties.push(sb(H,v)),M&&Q.fields.push({id:re.id}),$.polygonFeature++;break;default:throw new Error("Invalid geometry type")}$.feature++}return j$(B,k,Q,T)}function z$(t,e,r,i,n){e.positions.set(t.data,r.pointPosition*i);let s=t.data.length/i;ab(e,n,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function H$(t,e,r,i,n){e.positions.set(t.data,r.linePosition*i);let s=t.data.length/i;ab(e,n,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let o=0,a=t.indices.length;o(x-h)/s),_=wy(A,g,s,e);for(let x=0,T=_.length;xA>=e&&A<=r),s=t.primitivePolygonIndices.value.filter(A=>A>=e&&A<=r);if(!(n.length>2)){let A=[];for(let h=0;ha>=e&&a<=r);if(!(n.length>2))return{type:"LineString",coordinates:Ug(i,n[0],n[1])};let o=[];for(let a=0;a1?{type:"MultiPoint",coordinates:n}:{type:"Point",coordinates:n[0]}}function Ug(t,e,r){e=e||0,r=r||t.value.length/t.size;let i=[];for(let n=e;n>3}if(n--,i===1||i===2)s+=e.readSVarint(),o+=e.readSVarint(),i===1&&(A&&a.push(A),A=[]),A&&A.push([s,o]);else if(i===7)A&&A.push(A[0].slice());else throw new Error(`unknown command ${i}`)}return A&&a.push(A),a}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,i=1,n=0,s=0,o=0,a=1/0,A=-1/0,h=1/0,g=-1/0;for(;e.pos>3}if(n--,i===1||i===2)s+=e.readSVarint(),o+=e.readSVarint(),sA&&(A=s),og&&(g=o);else if(i!==7)throw new Error(`unknown command ${i}`)}return[a,h,A,g]}_toGeoJSON(e){let r=this.loadGeometry(),i=t.types[this.type],n,s;switch(this.type){case 1:let a=[];for(n=0;n=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new Hg(this._pbf,r,this.extent,this._keys,this._values)}};function yee(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(xee(r)))}function xee(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}var Wg=class{layers;constructor(e,r){this.layers=e.readFields(bee,{},r)}};function bee(t,e,r){if(t===3&&r){let i=new Gg(r,r.readVarint()+r.pos);i.length&&e&&(e[i.name]=i)}}function A8(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[xo(t.data)]],indices:[t.indices]};let i=[],n=[],s=[],o=[],a,A=0;for(let h,g=0,_;g>3),jg--,lc===1||lc===2)ub+=e.readSVarint(),fb+=e.readSVarint(),lc===1&&r.push(Eh),i.push(ub,fb),Eh+=2;else if(lc===7){if(Eh>0){let n=r[r.length-1];i.push(i[n],i[n+1]),Eh+=2}}else throw new Error(`unknown command ${lc}`);return{data:i,indices:r}}_toBinaryCoordinates(e){let r=this.loadGeometry(),i;e(r.data,this);let n=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=r.indices.length,i={type:"Point",...r};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=r.indices.length,this._geometryInfo.linePositionsCount+=r.data.length/n,i={type:"LineString",...r};break;case 3:i=A8(r),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=i.indices.length;for(let o of i.indices)this._geometryInfo.polygonRingsCount+=o.length;this._geometryInfo.polygonPositionsCount+=i.data.length/n;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let s={type:"Feature",geometry:i,properties:this.properties};return this.id!==null&&(s.id=this.id),s}toBinaryCoordinates(e){if(typeof e=="function")return this._toBinaryCoordinates(e);let{x:r,y:i,z:n}=e,s=this.extent*Math.pow(2,n),o=this.extent*r,a=this.extent*i;return this._toBinaryCoordinates(A=>u8(A,o,a,s))}};var Yg=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Eee,this,r),this.length=this._features.length}feature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let i=this._pbf.readVarint()+this._pbf.pos;return new Xg(this._pbf,i,this.extent,this._keys,this._values,r)}};function Eee(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(vee(r)))}function vee(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}var Qg=class{layers;constructor(e,r){this.layers=e.readFields(See,{},r)}};function See(t,e,r){if(t===3&&r){let i=new Yg(r,r.readVarint()+r.pos);i.length&&e&&(e[i.name]=i)}}function pb(t,e){let r=Cee(e),i=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:hb(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:d8(t,r)};case"geojson":return d8(t,r);case"binary-geometry":return hb(t,r);case"binary":return hb(t,r);default:throw new Error(i||"undefined shape")}}function hb(t,e){let[r,i]=wee(t,e),n=ob(r,i);return n.byteLength=t.byteLength,n}function wee(t,e){let r=[],i={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,i];let n=new Qg(new db.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(o=>{let a=n.layers[o];if(a)for(let A=0;A{let o=i.layers[s];if(o)for(let a=0;apb(t,e),parseSync:pb,binary:!0};var Fee={Point:p8,MultiPoint:Lee,LineString:g8,MultiLineString:Nee,Polygon:m8,MultiPolygon:Dee};function p8([t,e],[r,i],n){let s=Fr(r[0],i[0],t),o=Fr(r[1],i[1],e);return n.unprojectFlat([s,o])}function gb(t,e,r){return t.map(i=>p8(i,e,r))}function Lee(t,e,r){return gb(t,e,r)}function g8(t,e,r){return gb(t,e,r)}function Nee(t,e,r){return t.map(i=>g8(i,e,r))}function m8(t,e,r){return t.map(i=>gb(i,e,r))}function Dee(t,e,r){return t.map(i=>m8(i,e,r))}function _8(t,e,r){let i=r.projectFlat([e.west,e.north]),n=r.projectFlat([e.east,e.south]),s=[i,n];return{...t,coordinates:Fee[t.type](t.coordinates,s,r)}}var Uee=["points","lines","polygons"];function mb(t,e,r,i){for(let n of Uee){let s=t[n]&&kee(t[n],e,r,i);if(s>=0)return s}return-1}function kee(t,e,r,i){let n=t.featureIds.value;if(!n.length)return-1;let s=0,o=n[n.length-1]+1;if(i){let A=Vee(t,i);if(A)s=A[0],o=A[1]+1;else return-1}let a=-1;if(e in t.numericProps){let A=t.numericProps[e].value.findIndex((h,g)=>h===r&&n[g]>=s&&n[g]=0?t.globalFeatureIds.value[A]:-1}else e?a=y8(t.properties,A=>A[e]===r,s,o):t.fields&&(a=y8(t.fields,A=>A.id===r,s,o));return a>=0?zee(t,a):-1}function Vee(t,e){if(!t.__layers){let r={},{properties:i}=t;for(let n=0;ni&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(n)||r.maxzoom{let x=yb(_,s)===g,T=A||x8(_)===i;return x&&T}):a&&n?mb(a,s,g,A?"":i):-1}_pickObjects(e){let{deck:r,viewport:i}=this.context,n=i.width,s=i.height,o=i.x,a=i.y,A=[this.id];return r.pickObjects({x:o,y:a,width:n,height:s,layerIds:A,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),i=new Set,n=[];for(let s of r){let o=yb(s.object,this.props.uniqueIdProperty);o===void 0?n.push(s.object):i.has(o)||(i.add(o),n.push(s.object))}return n}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(i=>{i.hasOwnProperty(e)||Object.defineProperty(i,e,{get:()=>{if(!i.content)return null;if(this.state.binary&&Array.isArray(i.content)&&!i.content.length)return[];let{bbox:n}=i;if(i._contentWGS84===void 0&&S3(n)){let s=this.state.binary?kg(i.content):i.content;i._contentWGS84=s.map(o=>T8(o,n,this.context.viewport))}return i._contentWGS84}})})}};function yb(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function x8(t){return t.properties?.layerName||null}function b8(t){return t!=null&&t!==""}function T8(t,e,r){let i={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(i.geometry,"coordinates",{get:()=>_8(t.geometry,e,r).coordinates}),i}var E8="0123456789bcdefghjkmnpqrstuvwxyz",v8={};for(let t=0;t=0;_--){let x=a>>_&1;e?(o=(n+s)/2,x===1?s=o:n=o):(o=(r+i)/2,x===1?i=o:r=o),e=!e}}return[i,s,r,n]}function S8(t){let[e,r,i,n]=Yee(t);return[n,i,n,e,r,e,r,i,n,i]}var Qee={getGeohash:{type:"accessor",value:t=>t.geohash}},Sh=class extends Pi{static{this.layerName="GeohashLayer"}static{this.defaultProps=Qee}indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(i,n)=>S8(r(i,n))}}};import Kg from"https://esm.sh/@mapbox/mapbox-gl-draw@1.4.3";Kg.constants.classes.CONTROL_BASE="maplibregl-ctrl";Kg.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-";Kg.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var w8=Kg;var qee=Object.prototype.toString,$l=Array.isArray||function(e){return qee.call(e)==="[object Array]"};function Tb(t){return typeof t=="function"}function Kee(t){return $l(t)?"array":typeof t}function bb(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function C8(t,e){return t!=null&&typeof t=="object"&&e in t}function Jee(t,e){return t!=null&&typeof t!="object"&&t.hasOwnProperty&&t.hasOwnProperty(e)}var Zee=RegExp.prototype.test;function $ee(t,e){return Zee.call(t,e)}var ete=/\S/;function tte(t){return!$ee(ete,t)}var rte={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function ite(t){return String(t).replace(/[&<>"'`=\/]/g,function(r){return rte[r]})}var nte=/\s*/,ste=/\s+/,M8=/\s*=/,ote=/\s*\}/,ate=/#|\^|\/|>|\{|&|=|!/;function cte(t,e){if(!t)return[];var r=!1,i=[],n=[],s=[],o=!1,a=!1,A="",h=0;function g(){if(o&&!a)for(;s.length;)delete n[s.pop()];else s=[];o=!1,a=!1}var _,x,T;function v(Y){if(typeof Y=="string"&&(Y=Y.split(ste,2)),!$l(Y)||Y.length!==2)throw new Error("Invalid tags: "+Y);_=new RegExp(bb(Y[0])+"\\s*"),x=new RegExp("\\s*"+bb(Y[1])),T=new RegExp("\\s*"+bb("}"+Y[1]))}v(e||Ki.tags);for(var S=new Ch(t),C,M,R,B,k,Q;!S.eos();){if(C=S.pos,R=S.scanUntil(_),R)for(var $=0,re=R.length;$"?k=[M,R,C,S.pos,A,h,r]:k=[M,R,C,S.pos],h++,n.push(k),M==="#"||M==="^")i.push(k);else if(M==="/"){if(Q=i.pop(),!Q)throw new Error('Unopened section "'+R+'" at '+C);if(Q[1]!==R)throw new Error('Unclosed section "'+Q[1]+'" at '+C)}else M==="name"||M==="{"||M==="&"?a=!0:M==="="&&v(R)}if(g(),Q=i.pop(),Q)throw new Error('Unclosed section "'+Q[1]+'" at '+S.pos);return Ate(lte(n))}function lte(t){for(var e=[],r,i,n=0,s=t.length;n0?i[i.length-1][4]:e;break;default:r.push(n)}return e}function Ch(t){this.string=t,this.tail=t,this.pos=0}Ch.prototype.eos=function(){return this.tail===""};Ch.prototype.scan=function(e){var r=this.tail.match(e);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};Ch.prototype.scanUntil=function(e){var r=this.tail.search(e),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function Zl(t,e){this.view=t,this.cache={".":this.view},this.parent=e}Zl.prototype.push=function(e){return new Zl(e,this)};Zl.prototype.lookup=function(e){var r=this.cache,i;if(r.hasOwnProperty(e))i=r[e];else{for(var n=this,s,o,a,A=!1;n;){if(e.indexOf(".")>0)for(s=n.view,o=e.split("."),a=0;s!=null&&a"?h=this.renderPartial(a,r,i,s):A==="&"?h=this.unescapedValue(a,r):A==="name"?h=this.escapedValue(a,r,s):A==="text"&&(h=this.rawValue(a)),h!==void 0&&(o+=h);return o};si.prototype.renderSection=function(e,r,i,n,s){var o=this,a="",A=r.lookup(e[1]);function h(x){return o.render(x,r,i,s)}if(A){if($l(A))for(var g=0,_=A.length;g<_;++g)a+=this.renderTokens(e[4],r.push(A[g]),i,n,s);else if(typeof A=="object"||typeof A=="string"||typeof A=="number")a+=this.renderTokens(e[4],r.push(A),i,n,s);else if(Tb(A)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");A=A.call(r.view,n.slice(e[3],e[5]),h),A!=null&&(a+=A)}else a+=this.renderTokens(e[4],r,i,n,s);return a}};si.prototype.renderInverted=function(e,r,i,n,s){var o=r.lookup(e[1]);if(!o||$l(o)&&o.length===0)return this.renderTokens(e[4],r,i,n,s)};si.prototype.indentPartial=function(e,r,i){for(var n=r.replace(/[^ \t]/g,""),s=e.split(` +`),o=0;o0||!i)&&(s[o]=n+s[o]);return s.join(` +`)};si.prototype.renderPartial=function(e,r,i,n){if(i){var s=this.getConfigTags(n),o=Tb(i)?i(e[1]):i[e[1]];if(o!=null){var a=e[6],A=e[5],h=e[4],g=o;A==0&&h&&(g=this.indentPartial(o,h,a));var _=this.parse(g,s);return this.renderTokens(_,r,i,g,n)}}};si.prototype.unescapedValue=function(e,r){var i=r.lookup(e[1]);if(i!=null)return i};si.prototype.escapedValue=function(e,r,i){var n=this.getConfigEscape(i)||Ki.escape,s=r.lookup(e[1]);if(s!=null)return typeof s=="number"&&n===Ki.escape?String(s):n(s)};si.prototype.rawValue=function(e){return e[1]};si.prototype.getConfigTags=function(e){return $l(e)?e:e&&typeof e=="object"?e.tags:void 0};si.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!$l(e))return e.escape};var Ki={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(t){wh.templateCache=t},get templateCache(){return wh.templateCache}},wh=new si;Ki.clearCache=function(){return wh.clearCache()};Ki.parse=function(e,r){return wh.parse(e,r)};Ki.render=function(e,r,i,n){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Kee(e)+'" was given as the first argument for mustache#render(template, view, partials)');return wh.render(e,r,i,n)};Ki.escape=ite;Ki.Scanner=Ch;Ki.Context=Zl;Ki.Writer=si;var Eb=Ki;function vb(t,e,r){return r!==null?Eb.render(r,t.properties):e===null?Object.keys(t.properties).map(n=>`${n}: ${t.properties[n]}`).join("
"):t.properties[e]}function Sb(t){let e={background:"white",color:"black","border-radius":"3px"};return({layer:r,object:i})=>{if(i){let n=typeof t=="object"?t[r.id]:t;return n&&{html:Eb.render(n,i),style:e}}return null}}var ute=new sl({configuration:new Jn({layers:xb})});function I8(t,e){let[r,i]=e;console.log(r,i),t[r](...i)}function P8(t){return t.map(e=>ute.convert(Object.assign(e,{onHover:({object:r})=>console.log(r)})))}function R8(t,e){let r=null,i=null;return{addTooltip:function(n,s=null,o=null){let a={closeButton:!1,closeOnClick:!1},A=new t.Popup(a);e.on("mousemove",n,h=>{let g=h.features[0],_=vb(g,s,o);A.setLngLat(h.lngLat).setHTML(_).addTo(e)}),e.on("mouseleave",n,()=>{A.remove()})},addControl:function(n,s,o){e.addControl(new t[n](s),o)},addPopup:function(n,s=null,o=null){let a={closeButton:!1},A=new t.Popup(a);e.on("click",n,h=>{let g=h.features[0],_=vb(g,s,o);A.setLngLat(h.lngLat).setHTML(_).addTo(e)})},addMarker:function({lngLat:n,popup:s,options:o}){let a=new t.Marker(o).setLngLat(n);if(s){let A=new t.Popup(s.options).setHTML(s.text);a.setPopup(A)}a.addTo(e)},setSourceData:function(n,s){e.getSource(n).setData(s)},addDeckOverlay:function(n,s=null){let o=P8(n);r=new el({interleaved:!0,layers:o,getTooltip:s?Sb(s):null}),e.addControl(r)},setDeckLayers:function(n,s=null){console.log("Updating Deck.GL layers");let o=P8(n);r.setProps({layers:o,getTooltip:s?Sb(s):null})},addMapboxDraw(n,s,o=null){i=new w8(n),e.addControl(i,s),o&&i.add(o)},getMapboxDraw:function(){return i}}}var hte=new fte;eA.addProtocol("pmtiles",hte.tile);eA.LayerSwitcherControl=_A;eA.InfoBoxControl=mA;function dte(t){let e="pymaplibregl",r=document.createElement("div");return r.id=e,r.style.height=t.get("height"),r}function wb(t,e){let r={center:e.getCenter(),zoom:e.getZoom(),bounds:e.getBounds(),bearing:e.getBearing(),pitch:e.getPitch()};t.set("view_state",r),t.save_changes()}function pte(t,e){let r=new eA.Map(t);return r.on("mouseover",()=>{r.getCanvas().style.cursor="pointer"}),r.on("mouseout",()=>{r.getCanvas().style.cursor=""}),r.on("click",i=>{e.set("clicked",i.lngLat),e.save_changes()}),r.on("zoomend",i=>{wb(e,r)}),r.on("moveend",i=>{wb(e,r)}),r.once("load",()=>{r.resize(),wb(e,r)}),r.on("draw.selectionchange",i=>{let n=i.features;console.log("selection changed",n),e.set("draw_features_selected",n),e.save_changes()}),r}function gte({model:t,el:e}){console.log("maplibregl",eA.version);let r=dte(t),i=Object.assign({container:r},t.get("map_options"));console.log(i);let n=pte(i,t),s=R8(eA,n),o=["draw.create","draw.update","draw.delete","draw.render"];for(let h in o)n.on(o[h],g=>{let _=s.getMapboxDraw();console.log("features",_.getAll()),t.set("draw_feature_collection_all",_.getAll()),t.save_changes()});let a=h=>{h.forEach(g=>{if(Object.keys(s).includes(g[0])){console.log("internal call",g);let[_,x]=g;s[_](...x);return}I8(n,g)})},A=t.get("calls");n.on("load",()=>{console.log("init calls",A),a(A),t.set("_rendered",!0),t.save_changes()}),t.on("msg:custom",h=>{console.log("custom msg",h),a(h.calls)}),e.appendChild(r)}var PNe={render:gte};export{PNe as default}; /*! Bundled license information: hammerjs/hammer.js: @@ -2473,6 +3796,37 @@ hammerjs/hammer.js: * Copyright (c) 2016 Jorik Tangelder; * Licensed under the MIT license *) +long/dist/long.js: + (** + * @license long.js (c) 2013 Daniel Wirtz + * Released under the Apache License, Version 2.0 + * see: https://github.com/dcodeIO/long.js for details + *) + +ieee754/index.js: + (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) + +long/index.js: + (** + * @license + * Copyright 2009 The Closure Library Authors + * Copyright 2020 Daniel Wirtz / The long.js Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + *) + mustache/mustache.mjs: (*! * mustache.js - Logic-less {{mustache}} templates with JavaScript diff --git a/package-lock.json b/package-lock.json index 81bd319b..98d7bb4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "pymaplibregl", - "version": "0.2.1", + "version": "0.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pymaplibregl", - "version": "0.2.1", + "version": "0.2.5", "license": "MIT", "dependencies": { "@deck.gl/aggregation-layers": "^9.0.16", + "@deck.gl/geo-layers": "^9.0.16", "@deck.gl/json": "^9.0.16", "@deck.gl/layers": "^9.0.16", "@deck.gl/mapbox": "^9.0.16", @@ -62,6 +63,73 @@ "mjolnir.js": "^2.7.0" } }, + "node_modules/@deck.gl/extensions": { + "version": "9.0.23", + "resolved": "https://registry.npmjs.org/@deck.gl/extensions/-/extensions-9.0.23.tgz", + "integrity": "sha512-ZgHhqEj4g1beae4pjAdqH27bV6tG/I19PmmgNa1EoP2IstmCIaJRdCOmIw/33bmFWyx+lg7HHs4GCv+Hf/wdsg==", + "peer": true, + "dependencies": { + "@luma.gl/constants": "^9.0.15", + "@luma.gl/shadertools": "^9.0.15", + "@math.gl/core": "^4.0.0" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, + "node_modules/@deck.gl/extensions/node_modules/@luma.gl/constants": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/@luma.gl/constants/-/constants-9.0.15.tgz", + "integrity": "sha512-gcvQmd5Nl0rnU/lXq2Rj214Mjc2XnyBJlfcQfRUGBngvcN4AtQvVtZVUveW6wCZA6JysB0ntvi4ovZm4GhJ/lw==", + "peer": true + }, + "node_modules/@deck.gl/extensions/node_modules/@luma.gl/shadertools": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/@luma.gl/shadertools/-/shadertools-9.0.15.tgz", + "integrity": "sha512-U/W1Vh7HXlhw3T6edUMcLFPSO6OVlDZKPx8v6kSkJtjny37aFZaVeRupUgYfjsSxK1aEc5uTAN1w7+3lJMhUIg==", + "peer": true, + "dependencies": { + "@math.gl/core": "^4.0.0", + "@math.gl/types": "^4.0.0" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, + "node_modules/@deck.gl/geo-layers": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/geo-layers/-/geo-layers-9.0.16.tgz", + "integrity": "sha512-fsa/qqbbz8sdeQI/x4unTRvxNIS+gkcJf2ZIuUFakDxzic9fg9FnVijepI612+BlbvO3Ce5ubzl9Oqds6Ece9g==", + "dependencies": { + "@loaders.gl/3d-tiles": "^4.2.0", + "@loaders.gl/gis": "^4.2.0", + "@loaders.gl/loader-utils": "^4.2.0", + "@loaders.gl/mvt": "^4.2.0", + "@loaders.gl/schema": "^4.2.0", + "@loaders.gl/terrain": "^4.2.0", + "@loaders.gl/tiles": "^4.2.0", + "@loaders.gl/wms": "^4.2.0", + "@luma.gl/gltf": "^9.0.14", + "@luma.gl/shadertools": "^9.0.14", + "@math.gl/core": "^4.0.0", + "@math.gl/culling": "^4.0.0", + "@math.gl/web-mercator": "^4.0.0", + "@types/geojson": "^7946.0.8", + "h3-js": "^4.1.0", + "long": "^3.2.0" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@deck.gl/extensions": "^9.0.0", + "@deck.gl/layers": "^9.0.0", + "@deck.gl/mesh-layers": "^9.0.0", + "@loaders.gl/core": "^4.2.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, "node_modules/@deck.gl/json": { "version": "9.0.16", "resolved": "https://registry.npmjs.org/@deck.gl/json/-/json-9.0.16.tgz", @@ -106,6 +174,35 @@ "@luma.gl/core": "^9.0.0" } }, + "node_modules/@deck.gl/mesh-layers": { + "version": "9.0.23", + "resolved": "https://registry.npmjs.org/@deck.gl/mesh-layers/-/mesh-layers-9.0.23.tgz", + "integrity": "sha512-fT/LQT/ngQPOYMiZPS8t4MidLlUHRP9+YpoTzej0ZUAYrX0tdPCF2IZ7uuSNM3MMlpFzFUB3vUfHTz3vfF5cBA==", + "peer": true, + "dependencies": { + "@loaders.gl/gltf": "^4.2.0", + "@luma.gl/gltf": "^9.0.15", + "@luma.gl/shadertools": "^9.0.15" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, + "node_modules/@deck.gl/mesh-layers/node_modules/@luma.gl/shadertools": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/@luma.gl/shadertools/-/shadertools-9.0.15.tgz", + "integrity": "sha512-U/W1Vh7HXlhw3T6edUMcLFPSO6OVlDZKPx8v6kSkJtjny37aFZaVeRupUgYfjsSxK1aEc5uTAN1w7+3lJMhUIg==", + "peer": true, + "dependencies": { + "@math.gl/core": "^4.0.0", + "@math.gl/types": "^4.0.0" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.19.10", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.10.tgz", @@ -474,6 +571,63 @@ "node": ">=12" } }, + "node_modules/@loaders.gl/3d-tiles": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/3d-tiles/-/3d-tiles-4.2.2.tgz", + "integrity": "sha512-op7KelDjEahz+ViFmavJdHw10n6lRZeTefC/cVYVQ1Jfvb8T+55KaOOXGoZODo14/B8Z53FnyPGVqR68dBYARw==", + "dependencies": { + "@loaders.gl/compression": "4.2.2", + "@loaders.gl/crypto": "4.2.2", + "@loaders.gl/draco": "4.2.2", + "@loaders.gl/gltf": "4.2.2", + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/math": "4.2.2", + "@loaders.gl/tiles": "4.2.2", + "@loaders.gl/zip": "4.2.2", + "@math.gl/core": "^4.0.1", + "@math.gl/culling": "^4.0.1", + "@math.gl/geospatial": "^4.0.1", + "@probe.gl/log": "^4.0.4", + "long": "^5.2.1" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/3d-tiles/node_modules/long": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", + "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" + }, + "node_modules/@loaders.gl/compression": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/compression/-/compression-4.2.2.tgz", + "integrity": "sha512-dBFjMe4zLhE4NXfVsPkhs267/55qnxgP/AIhksOKTx30gQxCtcty6RWhfWGnluTnbAEXID2Uq/vfp1HYH7ZYCg==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "@types/brotli": "^1.3.0", + "@types/pako": "^1.0.1", + "fflate": "0.7.4", + "lzo-wasm": "^0.0.4", + "pako": "1.0.11", + "snappyjs": "^0.6.1" + }, + "optionalDependencies": { + "brotli": "^1.3.2", + "lz4js": "^0.2.0", + "zstd-codec": "^0.1" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/compression/node_modules/fflate": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.4.tgz", + "integrity": "sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==" + }, "node_modules/@loaders.gl/core": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@loaders.gl/core/-/core-4.2.2.tgz", @@ -486,6 +640,64 @@ "@probe.gl/log": "^4.0.2" } }, + "node_modules/@loaders.gl/crypto": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/crypto/-/crypto-4.2.2.tgz", + "integrity": "sha512-0rbpHX8784wkcTb8+gjkzAxdA4p2CH3W5xxzdvpG4r37jVQwKYrh2NJxeF+xGIuuxlEaxD8x4kcyadKgCVtspA==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "@types/crypto-js": "^4.0.2" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/draco": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/draco/-/draco-4.2.2.tgz", + "integrity": "sha512-WM7Zw6+04QzqlXjUYibR63Zi4I2iuBaDR41Rguur1s+ns2faiHDyEvuFlKtArTChFPQ8Xzf+6MNt7JeR8kpZTA==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "draco3d": "1.5.7" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/gis": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/gis/-/gis-4.2.2.tgz", + "integrity": "sha512-s9kD6yLMKn8+jAhDFDVWBeeKcDkJHFrscTnVWveGBfnC7IYT4gD6lQeHRIfXrJKs0LWmKPrAS8grTq7Ull8V6Q==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@mapbox/vector-tile": "^1.3.1", + "@math.gl/polygon": "^4.0.0", + "pbf": "^3.2.1" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/gltf": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/gltf/-/gltf-4.2.2.tgz", + "integrity": "sha512-AK90PnRoaZ1jw/QWkg6TEJG8Yxd/QefxwlbMRJvtgk7QafsYo8dMm0e7EYgyOms0wDOcPflm5LHkIoqViRp/ww==", + "dependencies": { + "@loaders.gl/draco": "4.2.2", + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/textures": "4.2.2", + "@math.gl/core": "^4.0.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, "node_modules/@loaders.gl/images": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@loaders.gl/images/-/images-4.2.2.tgz", @@ -510,6 +722,35 @@ "@loaders.gl/core": "^4.0.0" } }, + "node_modules/@loaders.gl/math": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/math/-/math-4.2.2.tgz", + "integrity": "sha512-nfiNNxXobhdKJILlHDWvm92SMEMMh1XAsb4BYvRIHyTzw4KzflFMS6C62v8ctAW6P8pQKyRvuos9LcRyroty1A==", + "dependencies": { + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@math.gl/core": "^4.0.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/mvt": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/mvt/-/mvt-4.2.2.tgz", + "integrity": "sha512-KglhYp1rwIs6h6AtrmKjrEYWxcX6xhlG3c3pTIFJwfA5nMBa+cmzD19vBRo1po9hzWKq4oqqhi7JL0ovH6GAqw==", + "dependencies": { + "@loaders.gl/gis": "4.2.2", + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@math.gl/polygon": "^4.0.0", + "pbf": "^3.2.1" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, "node_modules/@loaders.gl/schema": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@loaders.gl/schema/-/schema-4.2.2.tgz", @@ -521,6 +762,70 @@ "@loaders.gl/core": "^4.0.0" } }, + "node_modules/@loaders.gl/terrain": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/terrain/-/terrain-4.2.2.tgz", + "integrity": "sha512-M5wDS20y0TTq9giCONLOWSIznD9H4JxfU1wicyEGUOa8U2u0Fdau5TObr//fOcT+Tvemkvcn01Oxj8acJWIsGw==", + "dependencies": { + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@mapbox/martini": "^0.2.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/textures": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/textures/-/textures-4.2.2.tgz", + "integrity": "sha512-UlxCCi7VbCloj4VCzSULASgGVA059jglQYLc3kIHclvGoMcx3MJi0hID0MEQ6IhdO9Zyn4F42doVPrriNDVJFQ==", + "dependencies": { + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "@math.gl/types": "^4.0.1", + "ktx-parse": "^0.0.4", + "texture-compressor": "^1.0.2" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/tiles": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/tiles/-/tiles-4.2.2.tgz", + "integrity": "sha512-mozBA1FOrOFXa0lBxrRvHoRxsSb9T8D6ZfFIpbVR1z0zEWKm+NgRQzO8yS4IJD/CPFOn/r31SolZII6yXnzWbg==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/math": "4.2.2", + "@math.gl/core": "^4.0.0", + "@math.gl/culling": "^4.0.0", + "@math.gl/geospatial": "^4.0.0", + "@math.gl/web-mercator": "^4.0.0", + "@probe.gl/stats": "^4.0.2" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/wms": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/wms/-/wms-4.2.2.tgz", + "integrity": "sha512-MoZqOgebyXsElfNbjX/el4jA9Rypusq7Z+cJ1tiP2yBTepuLkPBpXLeuUgt/v0MOqGoUWrkUY8I811ijkZYyjA==", + "dependencies": { + "@loaders.gl/images": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/xml": "4.2.2", + "@turf/rewind": "^5.1.5", + "deep-strict-equal": "^0.2.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, "node_modules/@loaders.gl/worker-utils": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@loaders.gl/worker-utils/-/worker-utils-4.2.2.tgz", @@ -529,6 +834,34 @@ "@loaders.gl/core": "^4.0.0" } }, + "node_modules/@loaders.gl/xml": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/xml/-/xml-4.2.2.tgz", + "integrity": "sha512-ADikkGCwkS6d2IwFPomVAZfTNEHC6xXqDFbzfhYThsG3ptPpeosjJmn4GdI4dyazTsQnKIeiqV/RLS4CvJgxzw==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "fast-xml-parser": "^4.2.5" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/zip": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/zip/-/zip-4.2.2.tgz", + "integrity": "sha512-8wuhWrmGFUb9X7i1E9ObhqyiYuwQj6x0ttzujXE6o83T8TI1i88fySttMe0LSV2aIrTLo8A5n6MOf2LPSefPYg==", + "dependencies": { + "@loaders.gl/compression": "4.2.2", + "@loaders.gl/crypto": "4.2.2", + "@loaders.gl/loader-utils": "4.2.2", + "jszip": "^3.1.5", + "md5": "^2.3.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, "node_modules/@luma.gl/constants": { "version": "9.0.14", "resolved": "https://registry.npmjs.org/@luma.gl/constants/-/constants-9.0.14.tgz", @@ -562,6 +895,33 @@ "@luma.gl/core": "^9.0.0" } }, + "node_modules/@luma.gl/gltf": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/@luma.gl/gltf/-/gltf-9.0.15.tgz", + "integrity": "sha512-gZsWzpYd+oj8W8Gsrr+Iq8Q05zSTyzbAHgmDvDFati4d7X++jnCUZL00KB4wwheQ755MXHU+//+10b5L1Nev1Q==", + "dependencies": { + "@loaders.gl/textures": "^4.2.0", + "@luma.gl/shadertools": "9.0.15", + "@math.gl/core": "^4.0.0" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.2.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, + "node_modules/@luma.gl/gltf/node_modules/@luma.gl/shadertools": { + "version": "9.0.15", + "resolved": "https://registry.npmjs.org/@luma.gl/shadertools/-/shadertools-9.0.15.tgz", + "integrity": "sha512-U/W1Vh7HXlhw3T6edUMcLFPSO6OVlDZKPx8v6kSkJtjny37aFZaVeRupUgYfjsSxK1aEc5uTAN1w7+3lJMhUIg==", + "dependencies": { + "@math.gl/core": "^4.0.0", + "@math.gl/types": "^4.0.0" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, "node_modules/@luma.gl/shadertools": { "version": "9.0.14", "resolved": "https://registry.npmjs.org/@luma.gl/shadertools/-/shadertools-9.0.14.tgz", @@ -587,11 +947,29 @@ "@luma.gl/core": "^9.0.0" } }, + "node_modules/@mapbox/martini": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@mapbox/martini/-/martini-0.2.0.tgz", + "integrity": "sha512-7hFhtkb0KTLEls+TRw/rWayq5EeHtTaErgm/NskVoXmtgAQu/9D299aeyj6mzAR/6XUnYRp2lU+4IcrYRFjVsQ==" + }, + "node_modules/@mapbox/point-geometry": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", + "integrity": "sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ==" + }, "node_modules/@mapbox/tiny-sdf": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.6.tgz", "integrity": "sha512-qMqa27TLw+ZQz5Jk+RcwZGH7BQf5G/TrutJhspsca/3SHwmgKQ1iq+d3Jxz5oysPVYTGP6aXxCo5Lk9Er6YBAA==" }, + "node_modules/@mapbox/vector-tile": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz", + "integrity": "sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw==", + "dependencies": { + "@mapbox/point-geometry": "~0.1.0" + } + }, "node_modules/@math.gl/core": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@math.gl/core/-/core-4.0.1.tgz", @@ -600,6 +978,22 @@ "@math.gl/types": "4.0.1" } }, + "node_modules/@math.gl/culling": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/culling/-/culling-4.0.1.tgz", + "integrity": "sha512-lv83sMKp0n1HjORhuNtWgX9ylYyj+/zHEPF0xxRXZvcpurB85fhgFLhvR81KLjmSbhQmFgzl0fZe7Ei3WxEP5Q==", + "dependencies": { + "@math.gl/core": "4.0.1" + } + }, + "node_modules/@math.gl/geospatial": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/geospatial/-/geospatial-4.0.1.tgz", + "integrity": "sha512-FfTUMk8uRlBa4W3dMSFwPjRgdEBnOeVjBr3mcGqb3lHA/PPMvKuE+o7OJfA61Wj6ItuZqCEZHbLbA3WRAENoqQ==", + "dependencies": { + "@math.gl/core": "4.0.1" + } + }, "node_modules/@math.gl/polygon": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@math.gl/polygon/-/polygon-4.0.1.tgz", @@ -627,14 +1021,12 @@ "node_modules/@probe.gl/env": { "version": "4.0.9", "resolved": "https://registry.npmjs.org/@probe.gl/env/-/env-4.0.9.tgz", - "integrity": "sha512-AOmVMD0/j78mX+k4+qX7ZhE0sY9H+EaJgIO6trik0BwV6VcrwxTGCGFAeuRsIGhETDnye06tkLXccYatYxAYwQ==", - "peer": true + "integrity": "sha512-AOmVMD0/j78mX+k4+qX7ZhE0sY9H+EaJgIO6trik0BwV6VcrwxTGCGFAeuRsIGhETDnye06tkLXccYatYxAYwQ==" }, "node_modules/@probe.gl/log": { "version": "4.0.9", "resolved": "https://registry.npmjs.org/@probe.gl/log/-/log-4.0.9.tgz", "integrity": "sha512-ebuZaodSRE9aC+3bVC7cKRHT8garXeT1jTbj1R5tQRqQYc9iGeT3iemVOHx5bN9Q6gAs/0j54iPI+1DvWMAW4A==", - "peer": true, "dependencies": { "@probe.gl/env": "4.0.9" } @@ -644,6 +1036,69 @@ "resolved": "https://registry.npmjs.org/@probe.gl/stats/-/stats-4.0.9.tgz", "integrity": "sha512-Q9Xt/sJUQaMsbjRKjOscv2t7wXIymTrOEJ4a3da4FTCn7bkKvcdxdyFAQySCrtPxE+YZ5I5lXpWPgv9BwmpE1g==" }, + "node_modules/@turf/boolean-clockwise": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@turf/boolean-clockwise/-/boolean-clockwise-5.1.5.tgz", + "integrity": "sha512-FqbmEEOJ4rU4/2t7FKx0HUWmjFEVqR+NJrFP7ymGSjja2SQ7Q91nnBihGuT+yuHHl6ElMjQ3ttsB/eTmyCycxA==", + "dependencies": { + "@turf/helpers": "^5.1.5", + "@turf/invariant": "^5.1.5" + } + }, + "node_modules/@turf/clone": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@turf/clone/-/clone-5.1.5.tgz", + "integrity": "sha512-//pITsQ8xUdcQ9pVb4JqXiSqG4dos5Q9N4sYFoWghX21tfOV2dhc5TGqYOhnHrQS7RiKQL1vQ48kIK34gQ5oRg==", + "dependencies": { + "@turf/helpers": "^5.1.5" + } + }, + "node_modules/@turf/helpers": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-5.1.5.tgz", + "integrity": "sha512-/lF+JR+qNDHZ8bF9d+Cp58nxtZWJ3sqFe6n3u3Vpj+/0cqkjk4nXKYBSY0azm+GIYB5mWKxUXvuP/m0ZnKj1bw==" + }, + "node_modules/@turf/invariant": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@turf/invariant/-/invariant-5.2.0.tgz", + "integrity": "sha512-28RCBGvCYsajVkw2EydpzLdcYyhSA77LovuOvgCJplJWaNVyJYH6BOR3HR9w50MEkPqb/Vc/jdo6I6ermlRtQA==", + "dependencies": { + "@turf/helpers": "^5.1.5" + } + }, + "node_modules/@turf/meta": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@turf/meta/-/meta-5.2.0.tgz", + "integrity": "sha512-ZjQ3Ii62X9FjnK4hhdsbT+64AYRpaI8XMBMcyftEOGSmPMUVnkbvuv3C9geuElAXfQU7Zk1oWGOcrGOD9zr78Q==", + "dependencies": { + "@turf/helpers": "^5.1.5" + } + }, + "node_modules/@turf/rewind": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@turf/rewind/-/rewind-5.1.5.tgz", + "integrity": "sha512-Gdem7JXNu+G4hMllQHXRFRihJl3+pNl7qY+l4qhQFxq+hiU1cQoVFnyoleIqWKIrdK/i2YubaSwc3SCM7N5mMw==", + "dependencies": { + "@turf/boolean-clockwise": "^5.1.5", + "@turf/clone": "^5.1.5", + "@turf/helpers": "^5.1.5", + "@turf/invariant": "^5.1.5", + "@turf/meta": "^5.1.5" + } + }, + "node_modules/@types/brotli": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@types/brotli/-/brotli-1.3.4.tgz", + "integrity": "sha512-cKYjgaS2DMdCKF7R0F5cgx1nfBYObN2ihIuPGQ4/dlIY6RpV7OWNwe9L8V4tTVKL2eZqOkNM9FM/rgTvLf4oXw==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/crypto-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz", + "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==" + }, "node_modules/@types/geojson": { "version": "7946.0.14", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", @@ -663,17 +1118,124 @@ "@types/geojson": "*" } }, + "node_modules/@types/node": { + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/offscreencanvas": { "version": "2019.7.3", "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==", "peer": true }, + "node_modules/@types/pako": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/pako/-/pako-1.0.7.tgz", + "integrity": "sha512-YBtzT2ztNF6R/9+UXj2wTGFnC9NklAnASt3sC0h2m1bbH7G6FyBIkt4AN8ThZpNfxUo1b2iMVO0UawiJymEt8A==" + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "optional": true + }, + "node_modules/brotli": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/brotli/-/brotli-1.3.3.tgz", + "integrity": "sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==", + "optional": true, + "dependencies": { + "base64-js": "^1.1.2" + } + }, + "node_modules/buf-compare": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buf-compare/-/buf-compare-1.0.1.tgz", + "integrity": "sha512-Bvx4xH00qweepGc43xFvMs5BKASXTbHaHm6+kDYIK9p/4iFwjATQkmPKHQSgJZzKbAymhztRbXUf1Nqhzl73/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, + "node_modules/core-assert": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/core-assert/-/core-assert-0.2.1.tgz", + "integrity": "sha512-IG97qShIP+nrJCXMCgkNZgH7jZQ4n8RpPyPeXX++T6avR/KhLhgLiHKoEn5Rc1KjfycSfA9DMa6m+4C4eguHhw==", + "dependencies": { + "buf-compare": "^1.0.0", + "is-error": "^2.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, "node_modules/d3-hexbin": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/d3-hexbin/-/d3-hexbin-0.2.2.tgz", "integrity": "sha512-KS3fUT2ReD4RlGCjvCEm1RgMtp2NFZumdMu4DBzQK8AZv3fXRM6Xm8I4fSU07UXvH4xxg03NwWKWdvxfS/yc4w==" }, + "node_modules/deep-strict-equal": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/deep-strict-equal/-/deep-strict-equal-0.2.0.tgz", + "integrity": "sha512-3daSWyvZ/zwJvuMGlzG1O+Ow0YSadGfb3jsh9xoCutv2tWyB9dA4YvR9L9/fSdDZa2dByYQe+TqapSGUrjnkoA==", + "dependencies": { + "core-assert": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/draco3d": { + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/draco3d/-/draco3d-1.5.7.tgz", + "integrity": "sha512-m6WCKt/erDXcw+70IJXnG7M3awwQPAsZvJGX5zY7beBqpELw6RDGkYVU0W43AFxye4pDZ5i2Lbyc/NNGqwjUVQ==" + }, "node_modules/earcut": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", @@ -726,6 +1288,27 @@ "jsep": "^0.3.0" } }, + "node_modules/fast-xml-parser": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.0.tgz", + "integrity": "sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/fflate": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", @@ -737,6 +1320,16 @@ "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA==", "peer": true }, + "node_modules/h3-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/h3-js/-/h3-js-4.1.0.tgz", + "integrity": "sha512-LQhmMl1dRQQjMXPzJc7MpZ/CqPOWWuAvVEoVJM9n/s7vHypj+c3Pd5rLQCkAsOgAoAYKbNCsYFE++LF7MvSfCQ==", + "engines": { + "node": ">=4", + "npm": ">=3", + "yarn": ">=1.3.0" + } + }, "node_modules/hammerjs": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz", @@ -746,6 +1339,61 @@ "node": ">=0.8.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/image-size": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.7.5.tgz", + "integrity": "sha512-Hiyv+mXHfFEP7LzUL/llg9RwFxxY+o9N3JVLIeG5E7iFIFAalxvRU9UZthBdYDEVnzHMgjnKJPPpay5BWf1g9g==", + "bin": { + "image-size": "bin/image-size.js" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "node_modules/is-error": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-error/-/is-error-2.2.2.tgz", + "integrity": "sha512-IOQqts/aHWbiisY5DuPJQ0gcbvaLFCa7fBa9xoLfxBZvQ+ZI/Zh9xoI7Gk+G64N0FdK4AbibytHht2tWgpJWLg==" + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/jsep": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/jsep/-/jsep-0.3.5.tgz", @@ -754,6 +1402,59 @@ "node": ">= 6.0.0" } }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/ktx-parse": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/ktx-parse/-/ktx-parse-0.0.4.tgz", + "integrity": "sha512-LY3nrmfXl+wZZdPxgJ3ZmLvG+wkOZZP3/dr4RbQj1Pk3Qwz44esOOSFFVQJcNWpXAtiNIC66WgXufX/SYgYz6A==" + }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dependencies": { + "immediate": "~3.0.5" + } + }, + "node_modules/long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha512-ZYvPPOMqUwPoDsbJaR10iQJYnMuZhRTvHYl62ErLIEX7RgFlziSBUUvrt3OVfc47QlHHpzPZYP17g3Fv7oeJkg==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/lz4js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/lz4js/-/lz4js-0.2.0.tgz", + "integrity": "sha512-gY2Ia9Lm7Ep8qMiuGRhvUq0Q7qUereeldZPP1PMEJxPtEWHJLqw9pgX68oHajBH0nzJK4MaZEA/YNV3jT8u8Bg==", + "optional": true + }, + "node_modules/lzo-wasm": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/lzo-wasm/-/lzo-wasm-0.0.4.tgz", + "integrity": "sha512-VKlnoJRFrB8SdJhlVKvW5vI1gGwcZ+mvChEXcSX6r2xDNc/Q2FD9esfBmGCuPZdrJ1feO+YcVFd2PTk0c137Gw==" + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "node_modules/mjolnir.js": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/mjolnir.js/-/mjolnir.js-2.7.3.tgz", @@ -776,6 +1477,23 @@ "mustache": "bin/mustache" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, + "node_modules/pbf": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.3.0.tgz", + "integrity": "sha512-XDF38WCH3z5OV/OVa8GKUNtLAyneuzbCisx7QUCF8Q6Nutx0WnJrQe5O+kOtBlLfRNUws98Y58Lblp+NJG5T4Q==", + "dependencies": { + "ieee754": "^1.1.12", + "resolve-protobuf-schema": "^2.1.0" + }, + "bin": { + "pbf": "bin/pbf" + } + }, "node_modules/pmtiles": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.0.6.tgz", @@ -799,6 +1517,99 @@ "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "node_modules/protocol-buffers-schema": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz", + "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/resolve-protobuf-schema": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz", + "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==", + "dependencies": { + "protocol-buffers-schema": "^3.3.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + }, + "node_modules/snappyjs": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/snappyjs/-/snappyjs-0.6.1.tgz", + "integrity": "sha512-YIK6I2lsH072UE0aOFxxY1dPDCS43I5ktqHpeAsuLNYWkE5pGxRGWfDM4/vSUfNzXjC1Ivzt3qx31PCLmc9yqg==" + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, + "node_modules/texture-compressor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/texture-compressor/-/texture-compressor-1.0.2.tgz", + "integrity": "sha512-dStVgoaQ11mA5htJ+RzZ51ZxIZqNOgWKAIvtjLrW1AliQQLCmrDqNzQZ8Jh91YealQ95DXt4MEduLzJmbs6lig==", + "dependencies": { + "argparse": "^1.0.10", + "image-size": "^0.7.4" + }, + "bin": { + "texture-compressor": "bin/texture-compressor.js" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/zstd-codec": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/zstd-codec/-/zstd-codec-0.1.4.tgz", + "integrity": "sha512-KYnWoFWgGtWyQEKNnUcb3u8ZtKO8dn5d8u+oGpxPlopqsPyv60U8suDyfk7Z7UtAO6Sk5i1aVcAs9RbaB1n36A==", + "optional": true } } } diff --git a/package.json b/package.json index 1b686cab..57841f73 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ }, "dependencies": { "@deck.gl/aggregation-layers": "^9.0.16", + "@deck.gl/geo-layers": "^9.0.16", "@deck.gl/json": "^9.0.16", "@deck.gl/layers": "^9.0.16", "@deck.gl/mapbox": "^9.0.16", diff --git a/srcjs/deck-layers.js b/srcjs/deck-layers.js index b0dd40de..1b643b62 100644 --- a/srcjs/deck-layers.js +++ b/srcjs/deck-layers.js @@ -1,2 +1,3 @@ export * from "@deck.gl/layers"; export * from "@deck.gl/aggregation-layers"; +export * from "@deck.gl/geo-layers";