/*!
 * Mini Tokyo 3D v4.0.0
 * https://minitokyo3d.com
 * (c) 2019-2026 Akihiko Kusanagi
 * Released under the MIT license
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mt3d={})}(this,function(e){"use strict";var t="undefined"!=typeof document?document.currentScript:null;function i(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(e)}const n="https://api.odpt.org/api/v4/",r="https://api-challenge.odpt.org/api/v4/",s={standingDuration:6e4,minStandingDuration:3e4,minBusStandingDuration:15e3,refreshInterval:6e4,refreshTimeout:1e4,realtimeCheckInterval:15e3,maxSpeedKMPH:80,accelerationKMPHPS:3,get maxSpeed(){return s.maxSpeedKMPH/36e5},get acceleration(){return s.accelerationKMPHPS/36e8},get maxAccelerationTime(){return s.maxSpeed/s.acceleration},get maxAccDistance(){return s.maxAccelerationTime*s.maxSpeed/2},maxFlightSpeedKMPH:500,flightAccelerationKMPHPS:12,get maxFlightSpeed(){return s.maxFlightSpeedKMPH/36e5},get flightAcceleration(){return s.flightAccelerationKMPHPS/36e8},maxBusSpeedKMPH:30,busAccelerationKMPHPS:3,get maxBusSpeed(){return s.maxBusSpeedKMPH/36e5},get busAcceleration(){return s.busAccelerationKMPHPS/36e8},get maxBusAccelerationTime(){return s.maxBusSpeed/s.busAcceleration},get maxBusAccDistance(){return s.maxBusAccelerationTime*s.maxBusSpeed/2},minDelay:25e3,minFlightInterval:9e4,transitionDuration:300,fadeDuration:1e3,defaultCenter:[139.767,35.6814],defaultZoom:14,defaultBearing:0,defaultPitch:60,defaultEcoFrameRate:1,defaultViewMode:"ground",defaultTrackingMode:"position",defaultClockMode:"realtime",defaultTimezone:"Asia/Tokyo",defaultEcoMode:"normal",odptHosts:{"api.odpt.org":"odpt","api-challenge.odpt.org":"challenge"},dataUrl:"https://minitokyo3d.com/data",dataSources:[{id:"odpt",trainUrl:`${n}odpt:Train?odpt:operator=${["Toei"].map(e=>`odpt.Operator:${e}`).join(",")}`,trainInfoUrl:`${n}odpt:TrainInformation?odpt:operator=${["TWR","TokyoMetro","Toei","YokohamaMunicipal","MIR","TamaMonorail"].map(e=>`odpt.Operator:${e}`).join(",")}`},{id:"challenge",trainUrl:`${r}odpt:Train?odpt:operator=${["Keikyu","Tobu"].map(e=>`odpt.Operator:${e}`).join(",")}`,trainInfoUrl:`${r}odpt:TrainInformation?odpt:operator=${["jre-is","Tokyu","Keikyu","Tobu","Seibu","Keio"].map(e=>`odpt.Operator:${e}`).join(",")}`,expiresAt:"2027-03-13T00:00:00+09:00"},{id:"mt3d",trainUrl:"https://mini-tokyo.appspot.com/tid",trainInfoUrl:"https://mini-tokyo.appspot.com/traininfo",flightUrl:"https://mini-tokyo.appspot.com/flight",atisUrl:"https://mini-tokyo.appspot.com/atisinfo"}],searchUrl:"https://search.minitokyo3d.com/api/v1/routes",lastStaticUpdate:"2026-05-28 15:00:00",customAttribution:'<a href="https://github.com/nagix/mini-tokyo-3d">© Akihiko Kusanagi</a>',copyright:"© 2019-2026 Akihiko Kusanagi",shareUrl:"https://minitokyo3d.com",events:["boxzoomcancel","boxzoomend","boxzoomstart","click","contextmenu","dblclick","drag","dragend","dragstart","error","load","mousedown","mousemove","mouseout","mouseover","mouseup","move","moveend","movestart","pitch","pitchend","pitchstart","resize","rotate","rotateend","rotatestart","touchcancel","touchend","touchmove","touchstart","wheel","zoom","zoomend","zoomstart"],langs:["de","en","es","fr","ja","ko","ne","pt-BR","th","zh-Hans","zh-Hant"]};var o=Uint8Array,a=Uint16Array,l=Int32Array,c=new o([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),u=new o([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),h=new o([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=function(e,t){for(var i=new a(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new l(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},p=d(c,2),f=p.b,m=p.r;f[28]=258,m[258]=28;for(var g=d(u,0).b,_=new a(32768),y=0;y<32768;++y){var v=(43690&y)>>1|(21845&y)<<1;_[y]=((65280&(v=(61680&(v=(52428&v)>>2|(13107&v)<<2))>>4|(3855&v)<<4))>>8|(255&v)<<8)>>1}var x=function(e,t,i){for(var n=e.length,r=0,s=new a(t);r<n;++r)e[r]&&++s[e[r]-1];var o,l=new a(t);for(r=1;r<t;++r)l[r]=l[r-1]+s[r-1]<<1;if(i){o=new a(1<<t);var c=15-t;for(r=0;r<n;++r)if(e[r])for(var u=r<<4|e[r],h=t-e[r],d=l[e[r]-1]++<<h,p=d|(1<<h)-1;d<=p;++d)o[_[d]>>c]=u}else for(o=new a(n),r=0;r<n;++r)e[r]&&(o[r]=_[l[e[r]-1]++]>>15-e[r]);return o},b=new o(288);for(y=0;y<144;++y)b[y]=8;for(y=144;y<256;++y)b[y]=9;for(y=256;y<280;++y)b[y]=7;for(y=280;y<288;++y)b[y]=8;var w=new o(32);for(y=0;y<32;++y)w[y]=5;var T=x(b,9,1),S=x(w,5,1),E=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},A=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},M=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},I=function(e){return(e+7)/8|0},C=function(e,t,i){return(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length),new o(e.subarray(t,i))},P=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],L=function(e,t,i){var n=new Error(t||P[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,L),!i)throw n;return n},R=new o(0),O=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var i=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:i?i.length:0},this.o=new o(32768),this.p=new o(0),i&&this.o.set(i)}return e.prototype.e=function(e){if(this.ondata||L(5),this.d&&L(4),this.p.length){if(e.length){var t=new o(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,i=function(e,t,i,n){var r=e.length;if(!r||t.f&&!t.l)return i||new o(0);var s=!i,a=s||2!=t.i,l=t.i;s&&(i=new o(3*r));var d=function(e){var t=i.length;if(e>t){var n=new o(Math.max(2*t,e));n.set(i),i=n}},p=t.f||0,m=t.p||0,_=t.b||0,y=t.l,v=t.d,b=t.m,w=t.n,P=8*r;do{if(!y){p=A(e,m,1);var R=A(e,m+1,3);if(m+=3,!R){var O=e[(H=I(m)+4)-4]|e[H-3]<<8,D=H+O;if(D>r){l&&L(0);break}a&&d(_+O),i.set(e.subarray(H,D),_),t.b=_+=O,t.p=m=8*D,t.f=p;continue}if(1==R)y=T,v=S,b=9,w=5;else if(2==R){var B=A(e,m,31)+257,F=A(e,m+10,15)+4,N=B+A(e,m+5,31)+1;m+=14;for(var k=new o(N),z=new o(19),U=0;U<F;++U)z[h[U]]=A(e,m+3*U,7);m+=3*F;var V=E(z),j=(1<<V)-1,G=x(z,V,1);for(U=0;U<N;){var H,W=G[A(e,m,j)];if(m+=15&W,(H=W>>4)<16)k[U++]=H;else{var q=0,X=0;for(16==H?(X=3+A(e,m,3),m+=2,q=k[U-1]):17==H?(X=3+A(e,m,7),m+=3):18==H&&(X=11+A(e,m,127),m+=7);X--;)k[U++]=q}}var $=k.subarray(0,B),Z=k.subarray(B);b=E($),w=E(Z),y=x($,b,1),v=x(Z,w,1)}else L(1);if(m>P){l&&L(0);break}}a&&d(_+131072);for(var Y=(1<<b)-1,J=(1<<w)-1,K=m;;K=m){var Q=(q=y[M(e,m)&Y])>>4;if((m+=15&q)>P){l&&L(0);break}if(q||L(2),Q<256)i[_++]=Q;else{if(256==Q){K=m,y=null;break}var ee=Q-254;Q>264&&(ee=A(e,m,(1<<(ne=c[U=Q-257]))-1)+f[U],m+=ne);var te=v[M(e,m)&J],ie=te>>4;if(te||L(3),m+=15&te,Z=g[ie],ie>3){var ne=u[ie];Z+=M(e,m)&(1<<ne)-1,m+=ne}if(m>P){l&&L(0);break}a&&d(_+131072);var re=_+ee;if(_<Z){var se=0-Z,oe=Math.min(Z,re);for(se+_<0&&L(3);_<oe;++_)i[_]=n[se+_]}for(;_<re;++_)i[_]=i[_-Z]}}t.l=y,t.p=K,t.b=_,t.f=p,y&&(p=1,t.m=b,t.d=v,t.n=w)}while(!p);return _!=i.length&&s?C(i,0,_):i.subarray(0,_)}(this.p,this.s,this.o);this.ondata(C(i,t,this.s.b),this.d),this.o=C(i,this.s.b-32768),this.s.b=this.o.length,this.p=C(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),D=function(){function e(e,t){this.v=1,this.r=0,O.call(this,e,t)}return e.prototype.push=function(e,t){if(O.prototype.e.call(this,e),this.r+=e.length,this.v){var i=this.p.subarray(this.v-1),n=i.length>3?function(e){31==e[0]&&139==e[1]&&8==e[2]||L(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(i):4;if(n>i.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-i.length);this.p=i.subarray(n),this.v=0}O.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=I(this.s.p)+9,this.s={i:0},this.o=new o(0),this.push(new o(0),t)):t&&O.prototype.c.call(this,t)},e}(),B="undefined"!=typeof TextDecoder&&new TextDecoder,F=0;try{B.decode(R,{stream:!0}),F=1}catch(LG){}var N=function(){function e(e){this.ondata=e,F?this.t=new TextDecoder:this.p=R}return e.prototype.push=function(e,t){if(this.ondata||L(5),t=!!t,this.t)return this.ondata(this.t.decode(e,{stream:!0}),t),void(t&&(this.t.decode().length&&L(8),this.t=null));this.p||L(4);var i=new o(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length);var n=function(e){for(var t="",i=0;;){var n=e[i++],r=(n>127)+(n>223)+(n>239);if(i+r>e.length)return{s:t,r:C(e,i-1)};r?3==r?(n=((15&n)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=String.fromCharCode(1&r?(31&n)<<6|63&e[i++]:(15&n)<<12|(63&e[i++])<<6|63&e[i++]):t+=String.fromCharCode(n)}}(i),r=n.s,s=n.r;t?(s.length&&L(8),this.p=null):this.p=s,this.ondata(r,t)},e}();let k=!1;function z(){return k}function U(e){return new URL(e,"undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("mini-tokyo-3d.min.js",document.baseURI).href).href}function V(e){return fetch(e).then(t=>{if(e.endsWith(".gz")){let e="";const i=t.body.getReader(),n=new N(t=>{e+=t}),r=new D((e,t)=>{n.push(e,t)});return i.read().then(function t({done:n,value:s}){return n?(r.push(new Uint8Array(0),!0),JSON.parse(e)):(r.push(s),i.read().then(t))})}return t.json()})}function j(e,t,i){return e*(1-i)+t*i}function G(e,t,i){return Math.min(Math.max(e,t),i)}function H(e,t){let i,n;if(!Array.isArray(e)&&"string"!=typeof e)return!1;if(!Array.isArray(t))return-1!==e.indexOf(t);for(i=0,n=t.length;i<n;i++)if(-1===e.indexOf(t[i]))return!1;return!0}function W(e){return e.normalize("NFD").replace(/\(.*\)|<.*>|〈.*〉|[\u0300-\u036F]/g,"")}function q(e,t){return void 0===e?t:e}function X(e){return`${("0"+(Math.floor(e/36e5)+3)%24).slice(-2)}:${("0"+Math.floor(e/6e4)%60).slice(-2)}`}function $(e){return 6e4*((+e.substring(0,2)+21)%24*60+ +e.substring(3,5))}function Z(e){return"string"==typeof e?e.replace(/.*:/,""):Array.isArray(e)?e.map(Z):e}function Y(){const e=performance.now()%1500/1500*2;return e<1?e:2-e}function J(e){return.2126*e.r+.7152*e.g+.0722*e.b}function K(e){const t=parseInt(e.replace("#",""),16);return[Math.floor(t/65536)%256,Math.floor(t/256)%256,t%256]}function Q(e,t,i){const n=document.createElement(e);for(const e of Object.keys(t))try{n[e]=t[e]}catch(i){n.setAttribute(e,t[e])}return i&&i.appendChild(n),n}function ee(e,t){const i=Q("div",{className:"notification",innerHTML:t},e);setTimeout(()=>{i.style.opacity=0},1e3),setTimeout(()=>{e.removeChild(i)},2e3)}function te(e){if(!H(s.langs,e)){const t=window.navigator;e=t.languages&&t.languages[0]||t.language||t.userLanguage||t.browserLanguage||""}return function(e){return H(s.langs.map(e=>e.replace("pt-BR","pt")),e=e.match(/^zh-(Hant|TW|HK|MO)/)?"zh-Hant":e.match(/^zh/)?"zh-Hans":e.substring(0,2))?e:void 0}(e)||"en"}"undefined"!=typeof window&&window.addEventListener("touchstart",()=>{k=!0},{once:!0});var ie="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var re,se={exports:{}};function oe(){return re||(re=1,function(e){e.exports=function(){let e,t,i;function n(n,r){if(e)if(t){const n={};e(void 0,n),i=r(n),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob(["self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+e+")(undefined, sharedChunk); ("+t+")(undefined, sharedChunk); self.onerror = null;"],{type:"text/javascript"})))}else t=r;else e=r}return n(["require","exports"],function(e,t){var i=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i*s-r*n;return o?(e[0]=s*(o=1/o),e[1]=-n*o,e[2]=-r*o,e[3]=i*o,e):null}function s(){var e=new n(9);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function o(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=o*u-a*c,e[1]=r*c-n*u,e[2]=n*a-r*o,e[3]=a*l-s*u,e[4]=i*u-r*l,e[5]=r*s-i*a,e[6]=s*c-o*l,e[7]=n*l-i*c,e[8]=i*o-n*s,e}function a(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1],f=i[2],m=i[3],g=i[4],_=i[5],y=i[6],v=i[7],x=i[8];return e[0]=d*n+p*o+f*c,e[1]=d*r+p*a+f*u,e[2]=d*s+p*l+f*h,e[3]=m*n+g*o+_*c,e[4]=m*r+g*a+_*u,e[5]=m*s+g*l+_*h,e[6]=y*n+v*o+x*c,e[7]=y*r+v*a+x*u,e[8]=y*s+v*l+x*h,e}function l(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function c(e){var t=new n(16);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 u(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function h(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*a-n*o,v=i*l-r*o,x=i*c-s*o,b=n*l-r*a,w=n*c-s*a,T=r*c-s*l,S=u*m-h*f,E=u*g-d*f,A=u*_-p*f,M=h*g-d*m,I=h*_-p*m,C=d*_-p*g,P=y*C-v*I+x*M+b*A-w*E+T*S;return P?(e[0]=(a*C-l*I+c*M)*(P=1/P),e[1]=(r*I-n*C-s*M)*P,e[2]=(m*T-g*w+_*b)*P,e[3]=(d*w-h*T-p*b)*P,e[4]=(l*A-o*C-c*E)*P,e[5]=(i*C-r*A+s*E)*P,e[6]=(g*x-f*T-_*v)*P,e[7]=(u*T-d*x+p*v)*P,e[8]=(o*I-a*A+c*S)*P,e[9]=(n*A-i*I-s*S)*P,e[10]=(f*w-m*x+_*y)*P,e[11]=(h*x-u*w-p*y)*P,e[12]=(a*E-o*M-l*S)*P,e[13]=(i*M-n*E+r*S)*P,e[14]=(m*v-f*b-g*y)*P,e[15]=(u*b-h*v+d*y)*P,e):null}function d(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*n+x*a+b*h+w*m,e[1]=v*r+x*l+b*d+w*g,e[2]=v*s+x*c+b*p+w*_,e[3]=v*o+x*u+b*f+w*y,e[4]=(v=i[4])*n+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=v*r+x*l+b*d+w*g,e[6]=v*s+x*c+b*p+w*_,e[7]=v*o+x*u+b*f+w*y,e[8]=(v=i[8])*n+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=v*r+x*l+b*d+w*g,e[10]=v*s+x*c+b*p+w*_,e[11]=v*o+x*u+b*f+w*y,e[12]=(v=i[12])*n+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=v*r+x*l+b*d+w*g,e[14]=v*s+x*c+b*p+w*_,e[15]=v*o+x*u+b*f+w*y,e}function p(e,t,i){var n,r,s,o,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=s*m+c*g+p*_+t[14],e[15]=o*m+u*g+f*_+t[15]),e}function f(e,t,i){var n=i[0],r=i[1],s=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function m(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[4],o=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*r+c*n,e[5]=o*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-s*n,e[9]=u*r-o*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function g(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*r-c*n,e[1]=o*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=s*n+c*r,e[9]=o*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e}function _(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=s*r+c*n,e[1]=o*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-s*n,e[5]=u*r-o*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}function y(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function v(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function x(e,t,n){var r,s,o,a=n[0],l=n[1],c=n[2],u=Math.sqrt(a*a+l*l+c*c);return u<i?null:(a*=u=1/u,l*=u,c*=u,r=Math.sin(t),s=Math.cos(t),e[0]=a*a*(o=1-s)+s,e[1]=l*a*o+c*r,e[2]=c*a*o-l*r,e[3]=0,e[4]=a*l*o-c*r,e[5]=l*l*o+s,e[6]=c*l*o+a*r,e[7]=0,e[8]=a*c*o+l*r,e[9]=l*c*o-a*r,e[10]=c*c*o+s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function b(e,t){var i=t[0],n=t[1],r=t[2],s=t[4],o=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(i*i+n*n+r*r),e[1]=Math.sqrt(s*s+o*o+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}function w(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i+i,a=n+n,l=r+r,c=i*o,u=n*o,h=n*a,d=r*o,p=r*a,f=r*l,m=s*o,g=s*a,_=s*l;return e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}var T=d;function S(){var e=new n(3);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function E(e){var t=new n(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function A(e){var t=e[0],i=e[1],n=e[2];return Math.sqrt(t*t+i*i+n*n)}function M(e,t,i){var r=new n(3);return r[0]=e,r[1]=t,r[2]=i,r}function I(e,t,i,n){return e[0]=t,e[1]=i,e[2]=n,e}function C(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function P(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function L(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function R(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function O(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function D(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function B(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e}function F(e,t){var i=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return Math.sqrt(i*i+n*n+r*r)}function N(e,t){var i=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return i*i+n*n+r*r}function k(e){var t=e[0],i=e[1],n=e[2];return t*t+i*i+n*n}function z(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function U(e,t){var i=t[0],n=t[1],r=t[2],s=i*i+n*n+r*r;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function V(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function j(e,t,i){var n=t[0],r=t[1],s=t[2],o=i[0],a=i[1],l=i[2];return e[0]=r*l-s*a,e[1]=s*o-n*l,e[2]=n*a-r*o,e}function G(e,t,i,n){var r=t[0],s=t[1],o=t[2];return e[0]=r+n*(i[0]-r),e[1]=s+n*(i[1]-s),e[2]=o+n*(i[2]-o),e}function H(e,t,i){var n=t[0],r=t[1],s=t[2],o=i[3]*n+i[7]*r+i[11]*s+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*s+i[12])/(o=o||1),e[1]=(i[1]*n+i[5]*r+i[9]*s+i[13])/o,e[2]=(i[2]*n+i[6]*r+i[10]*s+i[14])/o,e}function W(e,t,i){var n=t[0],r=t[1],s=t[2];return e[0]=n*i[0]+r*i[3]+s*i[6],e[1]=n*i[1]+r*i[4]+s*i[7],e[2]=n*i[2]+r*i[5]+s*i[8],e}function q(e,t,i){var n=i[0],r=i[1],s=i[2],o=i[3],a=t[0],l=t[1],c=t[2],u=r*c-s*l,h=s*a-n*c,d=n*l-r*a;return e[0]=a+o*(u+=u)+r*(d+=d)-s*(h+=h),e[1]=l+o*h+s*u-n*d,e[2]=c+o*d+n*h-r*u,e}function X(e){return e[0]=0,e[1]=0,e[2]=0,e}function $(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var Z=P,Y=L,J=A;function K(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Q(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function ee(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i*i+n*n+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=n*o,e[2]=r*o,e[3]=s*o,e}function te(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*s+i[12]*o,e[1]=i[1]*n+i[5]*r+i[9]*s+i[13]*o,e[2]=i[2]*n+i[6]*r+i[10]*s+i[14]*o,e[3]=i[3]*n+i[7]*r+i[11]*s+i[15]*o,e}function ie(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ne(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function re(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+o*a,e[1]=r*l+s*a,e[2]=s*l-r*a,e[3]=o*l-n*a,e}function se(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l-s*a,e[1]=r*l+o*a,e[2]=s*l+n*a,e[3]=o*l-r*a,e}S(),K();var oe,ae,le,ce=ee,ue=(oe=S(),ae=M(1,0,0),le=M(0,1,0),function(e,t,i){var n=V(t,i);return n<-.999999?(j(oe,ae,t),J(oe)<1e-6&&j(oe,le,t),U(oe,oe),function(e,t,i){i*=.5;var n=Math.sin(i);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i)}(e,oe,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(j(oe,t,i),e[0]=oe[0],e[1]=oe[1],e[2]=oe[2],e[3]=1+n,ce(e,e))});function he(){var e=new n(2);return n!=Float32Array&&(e[0]=0,e[1]=0),e}function de(e,t){var i=new n(2);return i[0]=e,i[1]=t,i}function pe(e,t,i){return e[0]=t,e[1]=i,e}function fe(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function me(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function ge(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function _e(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function ye(e,t){var i=t[0],n=t[1],r=i*i+n*n;return r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e}function ve(e,t){return e[0]*t[0]+e[1]*t[1]}ie(),ie(),s();var xe,be,we=me;function Te(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}he();var Se=function(){if(be)return xe;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return be=1,xe=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)<t)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=r/s}var o=0,a=1;for(i=e,n=0;n<20&&(r=this.sampleCurveX(i),!(Math.abs(r-e)<t));n++)e>r?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},xe}(),Ee=Te(Se);function Ae(e,t){this.x=e,this.y=t}function Me(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Me(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!Me(e[i],t[i]))return!1;return!0}return e===t}Ae.prototype={clone(){return new Ae(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ae},Ae.convert=function(e){if(e instanceof Ae)return e;if(Array.isArray(e))return new Ae(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ae(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ie=Math.PI/180,Ce=180/Math.PI,Pe=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Le=/\b(iPad|iPhone|iPod)\b/,Re=/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/;function Oe(e){return e*Ie}function De(e){return e*Ce}const Be=[[0,0],[1,0],[1,1],[0,1]];function Fe(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Ne(e,t,i,n){const r=new Ee(e,t,i,n);return function(e){return r.solve(e)}}const ke=Ne(.25,.1,.25,1);function ze(e,t,i){return Math.min(i,Math.max(t,e))}function Ue(e,t,i){return(i=ze((i-e)/(t-e),0,1))*i*(3-2*i)}function Ve(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function je(e,t,i){if(!e.length)return i(null,[]);let n=e.length;const r=new Array(e.length);let s=null;e.forEach((e,o)=>{t(e,(e,t)=>{e&&(s=e),r[o]=t,0===--n&&i(s,r)})})}function Ge(e,t){const i={};for(let n=0;n<t.length;n++){const r=t[n];r in e&&(i[r]=e[r])}return i}let He=1;function We(){return He++}function qe(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function Xe(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function $e(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function Ze(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function Ye(e){return Array.isArray(e)?e.map(Ye):"object"==typeof e&&e?$e(e,Ye):e}function Je(e,t){for(let i=0;i<e.length;i++)if(t.includes(e[i]))return!0;return!1}const Ke={};function Qe(e){Ke[e]||(Ke[e]=!0)}function et(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function tt(e){let t=0;for(let i,n,r=0,s=e.length,o=s-1;r<s;o=r++)i=e[r],n=e[o],t+=(n.x-i.x)*(i.y+n.y);return t}function it([e,t,i]){const n=Oe(t+90),r=Oe(i);return{x:e*Math.cos(n)*Math.sin(r),y:e*Math.sin(n)*Math.sin(r),z:e*Math.cos(r),azimuthal:t,polar:i}}function nt(e){return("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function rt(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const s=n||r;return t[i]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let st,ot=null;function at(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function lt(e,t,i,n){for(;t<i;){const r=t+i>>1;e[r]<n?t=r+1:i=r}return t}function ct(e,t,i,n){for(;t<i;){const r=t+i>>1;e[r]<=n?t=r+1:i=r}return t}function ut(e){return e>0?1/(1.001-e):1+e}function ht(e){return e>0?1-1/(1.001-e):-e}function dt(e,t,i){return(e-t.min)*(i.max-i.min)/(t.max-t.min)+i.min}const pt={API_URL:"https://api.mapbox.com",API_URL_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i,API_TILEJSON_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i,API_SPRITE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i,API_FONTS_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i,API_STYLE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i,API_CDN_URL_REGEX:/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i,get EVENTS_URL(){if(!pt.API_URL)return null;try{const e=new URL(pt.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function ft(){return new URL(pt.DRACO_URL,pt.API_URL).href}function mt(){if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(void 0===st){if("object"!=typeof WebAssembly)return!1;const e=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]);st=WebAssembly.validate(e)}return st}()?pt.MESHOPT_SIMD_URL:pt.MESHOPT_URL,pt.API_URL).href}function gt(){return new URL(pt.BUILDING_GEN_URL,pt.API_URL).href}function _t(e){return pt.API_URL_REGEX.test(e)}function yt(e){return pt.API_SPRITE_REGEX.test(e)}let vt,xt,bt,wt,Tt,St;function Et(){return null==vt&&(vt=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),vt}const At={requestIdleCallback:e=>{if("undefined"!=typeof requestIdleCallback)return requestIdleCallback(e);setTimeout(()=>e({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>void 0!==wt?wt:performance.now(),setNow(e){wt=e},restoreNow(){wt=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:n}=e;Tt||(Tt=document.createElement("canvas"));const r=Tt.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>Tt.width||n>Tt.height)&&(Tt.width=i,Tt.height=n),r.clearRect(-t,-t,i+2*t,n+2*t),r.drawImage(e,0,0,i,n),r.getImageData(-t,-t,i+2*t,n+2*t)},resolveURL:e=>(xt||(xt=document.createElement("a")),xt.href=e,xt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==bt&&(bt=window.matchMedia("(prefers-reduced-motion: reduce)")),bt.matches)},hasCanvasFingerprintNoise(){if(void 0!==St)return St;if(!Et())return St=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n<e.width;++n)t.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,t.fillRect(n,0,1,1);const n=t.getImageData(0,0,e.width,e.height);i=0;for(let e=0;e<n.data.length;++e)if(e%4!=3&&i++!==n.data[e])return St=!0,!0;return St=!1,!1}};function Mt(e,t){const i=e.indexOf("?");if(i<0)return`${e}?${new URLSearchParams(t).toString()}`;const n=new URLSearchParams(e.slice(i));for(const e in t)n.set(e,t[e]);return`${e.slice(0,i)}?${n.toString()}`}function It(e,t={persistentParams:[]}){const i=e.indexOf("?");if(i<0)return e;const n=new URLSearchParams,r=new URLSearchParams(e.slice(i));for(const e of t.persistentParams){const t=r.get(e);t&&n.set(e,t)}const s=n.toString();return`${e.slice(0,i)}${s.length>0?`?${s}`:""}`}const Ct="mapbox-tiles";let Pt=500,Lt=50;const Rt=["language","worldview","jobid"];let Ot;function Dt(){try{return caches}catch(e){}}function Bt(){const e=Dt();e&&null==Ot&&(Ot=e.open(Ct))}let Ft=1/0;const Nt={supported:!1,testSupport:function(e){!Ut&&zt&&(Vt?Gt(e):kt=e)}};let kt,zt,Ut=!1,Vt=!1;const jt="undefined"!=typeof self?self:{};function Gt(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,zt),e.isContextLost())return;Nt.supported=!0}catch(e){}e.deleteTexture(t),Ut=!0}jt.document&&(zt=jt.document.createElement("img"),zt.onload=function(){kt&&Gt(kt),kt=null,Vt=!0},zt.onerror=function(){Ut=!0,kt=null},zt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ht={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Ht);class Wt extends Error{constructor(e,t,i){401===t&&_t(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function qt(e){return"object"==typeof e&&null!==e&&"status"in e&&404===e.status}const Xt=nt()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,$t=/^\w+:/,Zt=/[\r\n]+/,Yt=function(e,t){return(i=e.url).startsWith("file:")||Xt().startsWith("file:")&&!$t.test(i)?function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let n=i.response;if("json"===e.type)try{n=JSON.parse(i.response)}catch(e){return t(e)}const r=new Headers;i.getAllResponseHeaders().trim().split(Zt).forEach(e=>{const t=e.split(": "),i=t.shift(),n=t.join(": ");r.append(i,n)}),t(null,n,r)}else t(new Wt(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,t):function(e,t){const i=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Xt(),referrerPolicy:e.referrerPolicy,signal:i.signal});let r=!1,s=!1;const o=(a=n.url).indexOf("sku=")>0&&_t(a);var a;"json"===e.type&&n.headers.set("Accept","application/json");const l=(i,r,a)=>{if(s)return;if(i&&"SecurityError"!==i.message&&Qe(i.toString()),r&&a)return c(r);const l=Date.now();fetch(n).then(i=>{if(i.ok){const e=o?i.clone():null;return c(i,e,l)}return t(new Wt(i.statusText,i.status,e.url))}).catch(i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))})},c=(i,o,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then(e=>{s||(o&&a&&function(e,t,i){if(Bt(),null==Ot)return;const n=rt(t.headers.get("cache-control")||"");if(n["no-store"])return;const r={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>r.headers.set(t,e)),n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const s=r.headers.get("expires");if(!s)return;if(new Date(s).getTime()-i<42e4)return;let o=It(e.url,{persistentParams:Rt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;r.status=200,o=Mt(o,{range:t})}const a=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,r);var l;Bt(),null!=Ot&&Ot.then(e=>e.put(o,a)).catch(e=>Qe(e.message))}(n,o,a),r=!0,t(null,e,i.headers))}).catch(e=>{s||t(new Error(e.message))})};return o?function(e,t){if(Bt(),null==Ot)return t(null);Ot.then(i=>{let n=It(e.url,{persistentParams:Rt});const r=e.headers.get("Range");r&&(n=Mt(n,{range:r})),i.match(n).then(e=>{const r=function(e){if(!e)return!1;const t=new Date(e.headers.get("expires")||0),i=rt(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!i["no-cache"]}(e);i.delete(n).catch(t),r&&i.put(n,e.clone()).catch(t),t(null,e,r)}).catch(t)}).catch(t)}(n,l):l(null,null),{cancel:()=>{s=!0,r||i.abort()}}}(e,t);var i},Jt=function(e,t){return Yt(Object.assign(e,{type:"json"}),t)},Kt=function(e,t){return Yt(Object.assign(e,{type:"arrayBuffer"}),t)};function Qt(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let ei,ti;ei=[],ti=0;const ii=function(e,t){if(Nt.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),ti>=pt.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return ei.push(i),i}ti++;let i=!1;const n=()=>{if(!i)for(i=!0,ti--;ei.length&&ti<pt.MAX_PARALLEL_IMAGE_REQUESTS;){const e=ei.shift(),{requestParameters:t,callback:i,cancelled:n}=e;n||(e.cancel=ii(t,i).cancel)}},r=Kt(e,(e,i,r)=>{n(),e?t(e):i&&function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(i,(e,i)=>t(e,i,r))});return{cancel:()=>{r.cancel(),n()}}};var ni,ri,si,oi={exports:{}},ai={exports:{}},li={exports:{}},ci=function(){if(si)return oi.exports;si=1;var e=(ni||(ni=1,ai.exports=function(e,t){var i,n,r,s,o,a,l,c;for(n=e.length-(i=3&e.length),r=t,o=3432918353,a=461845907,c=0;c<n;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,r=27492+(65535&(s=5*(65535&(r=(r^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+(((s>>>16)+58964&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ai.exports),t=(ri||(ri=1,li.exports=function(e,t){for(var i,n=e.length,r=t^n,s=0;n>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(s)|(255&e.charCodeAt(++s))<<8|(255&e.charCodeAt(++s))<<16|(255&e.charCodeAt(++s))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:r^=(255&e.charCodeAt(s+2))<<16;case 2:r^=(255&e.charCodeAt(s+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(s)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),li.exports);return oi.exports=e,oi.exports.murmur3=e,oi.exports.murmur2=t,oi.exports}(),ui=Te(ci);class hi{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class di extends hi{constructor(e,t={}){super("error",Object.assign({error:e},t))}}function pi(e,t,i){i[e]&&i[e].includes(t)||(i[e]=i[e]||[],i[e].push(t))}function fi(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class mi{on(e,t){return this._listeners=this._listeners||{},pi(e,t,this._listeners),this}off(e,t){return fi(e,t,this._listeners),fi(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pi(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t)})}fire(e,t){const i="string"==typeof e?new hi(e,t):e,n=i.type;if(this.listens(n)){i.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)fi(n,e,this._oneTimeListeners),e.call(this,i);const r=this._eventedParent;if(r){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(i,e),r.fire(i)}}return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class gi{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new gi(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,i]=e.split("");return new gi({name:t,iconsetId:i})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return gi.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var _i,yi={},vi=function(){if(_i)return yi;_i=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function i(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function r(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{yi.parseCSSColor=function(s){var o,a=s.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),d=1;switch(u){case"rgba":if(4!==h.length)return null;d=n(h.pop());case"rgb":return 3!==h.length?null:[i(h[0]),i(h[1]),i(h[2]),d];case"hsla":if(4!==h.length)return null;d=n(h.pop());case"hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[t(255*r(_,g,p+1/3)),t(255*r(_,g,p)),t(255*r(_,g,p-1/3)),d];default:return null}}return null}}catch(e){}return yi}();function xi(e,t,i){return e*(1-i)+t*i}class bi{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n}static parse(e){if(!e)return;if(e instanceof bi)return e;if("string"!=typeof e)return;const t=vi.parseCSSColor(e);return t?new bi(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const{r:e,g:t,b:i,a:n}=this;return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*i)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:i,b:n,a:r}=this;return new Ti(e,t,i,n,r)}toPremultipliedRenderColor(e){const{r:t,g:i,b:n,a:r}=this;return new Si(e,t*r,i*r,n*r,r)}clone(){return new bi(this.r,this.g,this.b,this.a)}}class wi{constructor(e,t,i,n,r,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,o=s*s;this.premultiplied?(t=0===r?0:t/r*(s-1),i=0===r?0:i/r*(s-1),n=0===r?0:n/r*(s-1)):(t*=s-1,i*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),i=Math.max(0,Math.min(s-1,i)),n=Math.max(0,Math.min(s-1,n));const a=Math.floor(t),l=Math.floor(i),c=Math.floor(n),u=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(n),p=t-a,f=i-l,m=n-c,g=e.image.data,_=4*(a+l*o+c*s),y=4*(a+l*o+d*s),v=4*(a+h*o+c*s),x=4*(a+h*o+d*s),b=4*(u+l*o+c*s),w=4*(u+l*o+d*s),T=4*(u+h*o+c*s),S=4*(u+h*o+d*s);this.r=xi(xi(xi(g[_],g[y],m),xi(g[v],g[x],m),f),xi(xi(g[b],g[w],m),xi(g[T],g[S],m),f),p)/255*(this.premultiplied?r:1),this.g=xi(xi(xi(g[_+1],g[y+1],m),xi(g[v+1],g[x+1],m),f),xi(xi(g[b+1],g[w+1],m),xi(g[T+1],g[S+1],m),f),p)/255*(this.premultiplied?r:1),this.b=xi(xi(xi(g[_+2],g[y+2],m),xi(g[v+2],g[x+2],m),f),xi(xi(g[b+2],g[w+2],m),xi(g[T+2],g[S+2],m),f),p)/255*(this.premultiplied?r:1),this.a=r}else this.r=t,this.g=i,this.b=n,this.a=r}toArray(){const{r:e,g:t,b:i,a:n}=this;return[255*e,255*t,255*i,n]}toHslaArray(){let{r:e,g:t,b:i,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];const r=1/n;e*=r,t*=r,i*=r}const r=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),o=Math.min(Math.max(i,0),1),a=Math.min(r,s,o),l=Math.max(r,s,o),c=l-a,u=.5*(a+l);if(0===c)return[0,0,100*u,n];const h=u>.5?c/(2-l-a):c/(l+a);let d;switch(l){case r:d=60*((s-o)/c+(s<o?6:0));break;case s:d=60*((o-r)/c+2);break;default:d=60*((r-s)/c+4)}return[d,100*h,100*u,n]}toArray01(){const{r:e,g:t,b:i,a:n}=this;return[e,t,i,n]}toArray01Scaled(e){const{r:t,g:i,b:n}=this;return[t*e,i*e,n*e]}toArray01Linear(){const{r:e,g:t,b:i,a:n}=this;return[Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(i,2.2),n]}}class Ti extends wi{constructor(e,t,i,n,r){super(e,t,i,n,r,!1)}}class Si extends wi{constructor(e,t,i,n,r){super(e,t,i,n,r,!0)}}function Ei(e,t,i){return e.map((e,n)=>xi(e,t[n],i))}bi.black=new bi(0,0,0,1),bi.white=new bi(1,1,1,1),bi.transparent=new bi(0,0,0,0),bi.red=new bi(1,0,0,1),bi.blue=new bi(0,0,1,1);var Ai=Object.freeze({__proto__:null,array:Ei,color:function(e,t,i){return new bi(xi(e.r,t.r,i),xi(e.g,t.g,i),xi(e.b,t.b,i),xi(e.a,t.a,i))},number:xi});class Mi extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Ii{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Ii(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Ci={kind:"null"},Pi={kind:"number"},Li={kind:"string"},Ri={kind:"boolean"},Oi={kind:"color"},Di={kind:"object"},Bi={kind:"value"},Fi={kind:"collator"},Ni={kind:"formatted"},ki={kind:"resolvedImage"};function zi(e,t){return{kind:"array",itemType:e,N:t}}function Ui(e){if("array"===e.kind){const t=Ui(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Vi=[Ci,Pi,Li,Ri,Oi,Ni,Di,zi(Bi),ki];function ji(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ji(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Vi)if(!ji(e,t))return null}return`Expected ${Ui(e)} but found ${Ui(t)} instead.`}function Gi(e,t){return t.some(t=>t.kind===e.kind)}function Hi(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Wi(e,t){return"array"===e.kind&&"array"===t.kind?e.N===t.N&&Wi(e.itemType,t.itemType):e.kind===t.kind}class qi{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Xi{constructor(e,t,i,n,r){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r}}class $i{constructor(e){this.sections=e}static fromString(e){return new $i([new Xi(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof $i?e:$i.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const i=t.image.getPrimary().id.toString();e.push(["image",i]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(i)}return e}}class Zi{constructor(e,t={}){this.id=gi.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1}toString(){return JSON.stringify(this)}static parse(e){let t,i,n,r;try{({id:t,params:i,sx:n,sy:r}=JSON.parse(e)||{})}catch(e){return null}return t?new Zi(t,{params:i,sx:n,sy:r}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class Yi{constructor(e,t,i,n,r=!1){this.primaryId=gi.from(e),this.primaryOptions=t,i&&(this.secondaryId=gi.from(i)),this.secondaryOptions=n,this.available=r}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Zi(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Zi(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?Yi.build({name:e}):e}static build(e,t,i,n){return!e||"object"==typeof e&&!("name"in e)?null:new Yi(e,i,t,n)}}function Ji(e,t,i,n){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ki(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof bi)return!0;if(e instanceof qi)return!0;if(e instanceof $i)return!0;if(e instanceof Yi)return!0;if(Array.isArray(e)){for(const t of e)if(!Ki(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ki(e[t]))return!1;return!0}return!1}function Qi(e){if(null===e)return Ci;if("string"==typeof e)return Li;if("boolean"==typeof e)return Ri;if("number"==typeof e)return Pi;if(e instanceof bi)return Oi;if(e instanceof qi)return Fi;if(e instanceof $i)return Ni;if(e instanceof Yi)return ki;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Qi(t);if(i){if(i===e)continue;i=Bi;break}i=e}return zi(i||Bi,t)}return Di}function en(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof $i||e instanceof Yi||e instanceof bi?e.toString():JSON.stringify(e)}class tn{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ki(e[1]))return t.error("invalid value");const i=e[1];let n=Qi(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new tn(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof bi?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof $i?this.value.serialize():this.value}}class nn{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const rn={string:Li,number:Pi,boolean:Ri,object:Di};class sn{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,n=1;const r=e[0];if("array"===r){let r,s;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in rn)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=rn[i],n++}else r=Bi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++}i=zi(r,s)}else i=rn[r];const s=[];for(;n<e.length;n++){const i=t.parse(e[n],n,Bi);if(!i)return null;s.push(i)}return new sn(i,s)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!ji(this.type,Qi(i)))return i;if(t===this.args.length-1)throw new nn(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Ui(Qi(i))} but was expected to be of type ${Ui(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n)}}return t.concat(this.args.map(e=>e.serialize()))}}class on{constructor(e){this.type=Ni,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const s=e[i];if(r&&"object"==typeof s&&!Array.isArray(s)){r=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],i,"font-scale",Pi),!e))return null;let o=null;if(s["text-font"]&&(o=t.parseObjectValue(s["text-font"],i,"text-font",zi(Li)),!o))return null;let a=null;if(s["text-color"]&&(a=t.parseObjectValue(s["text-color"],i,"text-color",Oi),!a))return null;const l=n.at(-1);l.scale=e,l.font=o,l.textColor=a}else{const s=t.parse(e[i],i,Bi);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new on(n)}evaluate(e){return new $i(this.sections.map(t=>{const i=t.content.evaluate(e);return Wi(Qi(i),ki)?new Xi("",i,null,null,null):new Xi(en(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class an{constructor(e,t,i,n){this._imageWarnHistory={},this.type=ki,this.namePrimary=e,this.nameSecondary=t,i&&(this.paramsPrimary=i.params,this.iconsetIdPrimary=i.iconset?i.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let i=1;const n=[];function r(){if(i<e.length){const r=t.parse(e[i],i++,Li);return r?(n.push({image:r,options:{}}),!0):(t.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function s(){if(i<e.length){const s=e[i];if(null===(r=s)||"object"!=typeof r||Array.isArray(r))return!0;const o=s.params,a=s.iconset,l=t.concat(i);if(!o&&!a)return i++,!0;if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const e={},t=l.concat(void 0,"params");for(const i in o){if(!i)return t.error("Image parameter name should be non-empty"),!1;const n=t.concat(void 0,i).parse(o[i],void 0,Oi,void 0,{typeAnnotation:"coerce"});if(!n)return!1;e[i]=n}n.at(-1).options.params=e}if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!a.id)return l.error('Image options "iconset" should have an "id" property'),!1;n.at(-1).options.iconset=a}return i++,!0}var r;return!0}for(let e=0;e<2;e++)if(!r()||!s())return;return new an(n[0].image,n[1]?n[1].image:void 0,n[0].options,n[1]?n[1].options:void 0)}evaluateParams(e,t){const i={};if(t){for(const n in t)if(t[n])try{i[n]=t[n].evaluate(e)}catch(e){continue}if(0!==Object.keys(i).length)return{params:i}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},i=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,n=Yi.build(t,i,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(n&&e.availableImages){const t=n.getPrimary().id;if(n.available=e.availableImages.some(e=>gi.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>gi.isEqual(e,t)))}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t])}outputDefined(){return!1}serializeOptions(e,t){const i={};if(t&&(i.iconset={id:t}),e){i.params={};for(const t in e)e[t]&&(i.params[t]=e[t].serialize())}return Object.keys(i).length>0?i:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t)}return e}}function ln(e){return un(e)?"string":hn(e)?"number":dn(e)?"boolean":Array.isArray(e)?"array":null===e?"null":cn(e)?"object":typeof e}function cn(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function un(e){return"string"==typeof e||e instanceof String}function hn(e){return"number"==typeof e||e instanceof Number}function dn(e){return"boolean"==typeof e||e instanceof Boolean}const pn={"to-boolean":Ri,"to-color":Oi,"to-number":Pi,"to-string":Li};class fn{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],n=[];let r=Ci;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);r=zi(t.expectedType.itemType,i)}else{if(!(i>0&&Ki(e[1][0])))return null;r=zi(Qi(e[1][0]),i)}for(let s=0;s<i;s++){const i=e[1][s];let o;if(Array.isArray(i))o=t.parse(i,void 0,r.itemType);else{const e=ln(i);if(e!==r.itemType.kind)return t.error(`Expected ${r.itemType.kind} but found ${e}.`);o=t.registry.literal.parse(["literal",void 0===i?null:i],t)}if(!o)return null;n.push(o)}}else{if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");r=pn[i];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,Bi);if(!r)return null;n.push(r)}}return new fn(r,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const n of this.args){if(t=n.evaluate(e),i=null,t instanceof bi)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ji(t[0],t[1],t[2],t[3]),!i))return new bi(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new nn(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new nn(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?$i.fromString(en(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Yi.build(en(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):en(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new on([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new an(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const mn=["Unknown","Point","LineString","Polygon"];class gn{constructor(e,t,i){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=i}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?mn[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=bi.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class _n{constructor(e,t,i,n,r){this.name=e,this.type=t,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(e){if(!this._evaluate){const e=_n.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const i=e[0],n=_n.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=[];let a=null,l=-1;for(const[n,c]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;o.push(n),l++,null===a?a=new Fr(t.registry,t.path,null,t.scope,[],t._scope,t.options,t.iconImageUseTheme):a.errors.length=0;const s=[];let u=!1;for(let t=1;t<e.length;t++){const i=e[t],r=Array.isArray(n)?n[t-1]:n.type,o=a.parse(i,1+s.length,r);if(!o){u=!0;break}s.push(o)}if(!u)if(Array.isArray(n)&&n.length!==s.length)a.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(n)?n[e]:n.type;a.checkSubtype(t,s[e].type,e+1)}if(0===a.errors.length)return new _n(i,r,c,s,l)}}if(1===o.length)t.errors.push(...a.errors);else{const i=(o.length?o:s.map(([e])=>e)).map(yn).join(" | "),n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],1+n.length);if(!r)return null;n.push(Ui(r.type))}t.error(`Expected arguments of type ${i}, but found (${n.join(", ")}) instead.`)}return null}static register(e,t){_n.definitions=t;for(const i in t)e[i]=_n}}function yn(e){return Array.isArray(e)?`(${e.map(Ui).join(", ")})`:`(${Ui(e.type)}...)`}class vn{constructor(e,t,i){this.type=Fi,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument."),null;const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object."),null;const n=void 0===i["case-sensitive"]?t.parse(!1,1,Ri):t.parseObjectValue(i["case-sensitive"],1,"case-sensitive",Ri);if(!n)return null;const r=void 0===i["diacritic-sensitive"]?t.parse(!1,1,Ri):t.parseObjectValue(i["diacritic-sensitive"],1,"diacritic-sensitive",Ri);if(!r)return null;let s=null;return i.locale&&(s=t.parseObjectValue(i.locale,1,"locale",Li),!s)?null:new vn(n,r,s)}evaluate(e){return new qi(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function xn(e,t,i=0,n=e.length-1,r=wn){for(;n>i;){if(n-i>600){const s=n-i+1,o=t-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);xn(e,t,Math.max(i,Math.floor(t-o*l/s+c)),Math.min(n,Math.floor(t+(s-o)*l/s+c)),r)}const s=e[t];let o=i,a=n;for(bn(e,i,t),r(e[n],s)>0&&bn(e,i,n);o<a;){for(bn(e,o,a),o++,a--;r(e[o],s)<0;)o++;for(;r(e[a],s)>0;)a--}0===r(e[i],s)?bn(e,i,a):(a++,bn(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function bn(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function wn(e,t){return e<t?-1:e>t?1:0}function Tn(e){let t=0;for(let i,n,r=0,s=e.length,o=s-1;r<s;o=r++)i=e[r],n=e[o],t+=(n.x-i.x)*(i.y+n.y);return t}function Sn(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function En(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function An(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],s=e[0]-i[0],o=e[1]-i[1];return n*o-s*r===0&&n*s<=0&&r*o<=0}function Mn(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function In(e,t,i=!1){let n=!1;for(let r=0,s=t.length;r<s;r++){const s=t[r];for(let t=0,r=s.length,o=r-1;t<r;o=t++){const r=s[o],a=s[t];if(An(e,r,a))return i;Mn(e,r,a)&&(n=!n)}}return n}function Cn(e,t,i,n){const r=n[0]-i[0],s=n[1]-i[1],o=(e[0]-i[0])*s-r*(e[1]-i[1]),a=(t[0]-i[0])*s-r*(t[1]-i[1]);return o>0&&a<0||o<0&&a>0}function Pn(e,t,i,n){return 0!==(r=[n[0]-i[0],n[1]-i[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*s[0]&&!(!Cn(e,t,i,n)||!Cn(i,n,e,t));var r,s}function Ln(e){const t=new Ae(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Ae(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),i.x<n.x&&(i.x=n.x),i.y<n.y&&(i.y=n.y);return{min:t,max:i}}const Rn=8192;function On(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Rn),Math.round(n*r*Rn)]}function Dn(e,t){for(let i=0;i<t.length;i++)if(In(e,t[i]))return!0;return!1}function Bn(e,t,i){for(const n of i)for(let i=0,r=n.length,s=r-1;i<r;s=i++)if(Pn(e,t,n[s],n[i]))return!0;return!1}function Fn(e,t){for(let i=0;i<e.length;++i)if(!In(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(Bn(e[i],e[i+1],t))return!1;return!0}function Nn(e,t){for(let i=0;i<t.length;i++)if(Fn(e,t[i]))return!0;return!1}function kn(e,t,i){const n=[];for(let r=0;r<e.length;r++){const s=[];for(let n=0;n<e[r].length;n++){const o=On(e[r][n],i);Sn(t,o),s.push(o)}n.push(s)}return n}function zn(e,t,i){const n=[];for(let r=0;r<e.length;r++){const s=kn(e[r],t,i);n.push(s)}return n}function Un(e,t,i,n){if(e[0]<i[0]||e[0]>i[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Sn(t,e)}function Vn(e,t,i,n){const r=Math.pow(2,n.z)*Rn,s=[n.x*Rn,n.y*Rn],o=[];if(!e)return o;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];Un(n,t,i,r),o.push(n)}return o}function jn(e,t,i,n){const r=Math.pow(2,n.z)*Rn,s=[n.x*Rn,n.y*Rn],o=[];if(!e)return o;for(const i of e){const e=[];for(const n of i){const i=[n.x+s[0],n.y+s[1]];Sn(t,i),e.push(i)}o.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of o)for(const n of e)Un(n,t,i,r)}var a;return o}class Gn{constructor(e,t){this.type=Ri,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ki(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Gn(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Gn(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Gn(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return!1;if("Polygon"===t.type){const s=kn(t.coordinates,n,r),o=Vn(e.geometry(),i,n,r);if(!En(i,n))return!1;for(const e of o)if(!In(e,s))return!1}if("MultiPolygon"===t.type){const s=zn(t.coordinates,n,r),o=Vn(e.geometry(),i,n,r);if(!En(i,n))return!1;for(const e of o)if(!Dn(e,s))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return!1;if("Polygon"===t.type){const s=kn(t.coordinates,n,r),o=jn(e.geometry(),i,n,r);if(!En(i,n))return!1;for(const e of o)if(!Fn(e,s))return!1}if("MultiPolygon"===t.type){const s=zn(t.coordinates,n,r),o=jn(e.geometry(),i,n,r);if(!En(i,n))return!1;for(const e of o)if(!Nn(e,s))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const Hn={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},Wn=1/298.257223563,qn=Wn*(2-Wn),Xn=Math.PI/180;class $n{static fromTile(e,t,i){const n=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),r=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Xn;return new $n(r,i)}static get units(){return Hn}constructor(e,t){if(void 0===e)throw new Error("No latitude given.");if(t&&!Hn[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys(Hn).join(", ")}`);const i=6378.137*Xn*(t?Hn[t]:1),n=Math.cos(e*Xn),r=1/(1-qn*(1-n*n)),s=Math.sqrt(r);this.kx=i*s*n,this.ky=i*s*r*(1-qn)}distance(e,t){const i=Jn(e[0]-t[0])*this.kx,n=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+n*n)}bearing(e,t){const i=Jn(t[0]-e[0])*this.kx;return Math.atan2(i,(t[1]-e[1])*this.ky)/Xn}destination(e,t,i){const n=i*Xn;return this.offset(e,Math.sin(n)*t,Math.cos(n)*t)}offset(e,t,i){return[e[0]+t/this.kx,e[1]+i/this.ky]}lineDistance(e){let t=0;for(let i=0;i<e.length-1;i++)t+=this.distance(e[i],e[i+1]);return t}area(e){let t=0;for(let i=0;i<e.length;i++){const n=e[i];for(let e=0,r=n.length,s=r-1;e<r;s=e++)t+=Jn(n[e][0]-n[s][0])*(n[e][1]+n[s][1])*(i?-1:1)}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let i=0;if(t<=0)return e[0];for(let n=0;n<e.length-1;n++){const r=e[n],s=e[n+1],o=this.distance(r,s);if(i+=o,i>t)return Yn(r,s,(t-(i-o))/o)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[n,r]=t,s=Jn(i[0]-n)*this.kx,o=(i[1]-r)*this.ky;if(0!==s||0!==o){const t=(Jn(e[0]-n)*this.kx*s+(e[1]-r)*this.ky*o)/(s*s+o*o);t>1?(n=i[0],r=i[1]):t>0&&(n+=s/this.kx*t,r+=o/this.ky*t)}return s=Jn(e[0]-n)*this.kx,o=(e[1]-r)*this.ky,Math.sqrt(s*s+o*o)}pointOnLine(e,t){let i=1/0,n=e[0][0],r=e[0][1],s=0,o=0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],u=Jn(e[a+1][0]-l)*this.kx,h=(e[a+1][1]-c)*this.ky,d=0;0===u&&0===h||(d=(Jn(t[0]-l)*this.kx*u+(t[1]-c)*this.ky*h)/(u*u+h*h),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=Jn(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p<i&&(i=p,n=l,r=c,s=a,o=d)}return{point:[n,r],index:s,t:Math.max(0,Math.min(1,o))}}lineSlice(e,t,i){let n=this.pointOnLine(i,e),r=this.pointOnLine(i,t);if(n.index>r.index||n.index===r.index&&n.t>r.t){const e=n;n=r,r=e}const s=[n.point],o=n.index+1,a=r.index;!Zn(i[o],s[0])&&o<=a&&s.push(i[o]);for(let e=o+1;e<=a;e++)s.push(i[e]);return Zn(i[a],r.point)||s.push(r.point),s}lineSliceAlong(e,t,i){let n=0;const r=[];for(let s=0;s<i.length-1;s++){const o=i[s],a=i[s+1],l=this.distance(o,a);if(n+=l,n>e&&0===r.length&&r.push(Yn(o,a,(e-(n-l))/l)),n>=t)return r.push(Yn(o,a,(t-(n-l))/l)),r;n>e&&r.push(a)}return r}bufferPoint(e,t){const i=t/this.ky,n=t/this.kx;return[e[0]-n,e[1]-i,e[0]+n,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,n=t/this.kx;return[e[0]-n,e[1]-i,e[2]+n,e[3]+i]}insideBBox(e,t){return Jn(e[0]-t[0])>=0&&Jn(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Zn(e,t){return e[0]===t[0]&&e[1]===t[1]}function Yn(e,t,i){const n=Jn(t[0]-e[0]);return[e[0]+n*i,e[1]+(t[1]-e[1])*i]}function Jn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class Kn{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,s=t[r];if(i(n,s)>=0)break;t[e]=s,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1);const s=n+1;if(s<this.length&&i(t[s],t[n])<0&&(n=s),i(t[n],r)>=0)break;t[e]=t[n],e=n}t[e]=r}}var Qn=8192;function er(e,t){return t.dist-e.dist}function tr(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function ir(e){return e[1]-e[0]+1}function nr(e,t){return e[1]>=e[0]&&e[1]<t}function rr(e,t){if(e[0]>e[1])return[null,null];const i=ir(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return[e,null];const t=Math.floor(i/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function sr(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!nr(t,e.length))return i;for(let n=t[0];n<=t[1];++n)Sn(i,e[n]);return i}function or(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;i<e.length;++i)for(let n=0;n<e[i].length;++n)Sn(t,e[i][n]);return t}function ar(e,t,i){if(tr(e)||tr(t))return NaN;let n=0,r=0;return e[2]<t[0]&&(n=t[0]-e[2]),e[0]>t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]<t[1]&&(r=t[1]-e[3]),i.distance([0,0],[n,r])}function lr(e){return 360*e-180}function cr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ur(e,t,i=8192){const n=Math.pow(2,t.z),r=(e.y/i+t.y)/n;return[lr((e.x/i+t.x)/n),cr(r)]}function hr(e,t){const i=[];for(let n=0;n<e.length;++n)i.push(ur(e[n],t));return i}function dr(e,t,i){const n=i.pointOnLine(t,e).point;return i.distance(e,n)}function pr(e,t,i,n,r){const s=i.slice(n[0],n[1]+1);let o=1/0;for(let i=t[0];i<=t[1];++i)if(0===(o=Math.min(o,dr(e[i],s,r))))return 0;return o}function fr(e,t,i,n,r){const s=Math.min(r.pointToSegmentDistance(e,i,n),r.pointToSegmentDistance(t,i,n)),o=Math.min(r.pointToSegmentDistance(i,e,t),r.pointToSegmentDistance(n,e,t));return Math.min(s,o)}function mr(e,t,i,n,r){if(!nr(t,e.length)||!nr(n,i.length))return NaN;let s=1/0;for(let o=t[0];o<t[1];++o)for(let t=n[0];t<n[1];++t){if(Pn(e[o],e[o+1],i[t],i[t+1]))return 0;s=Math.min(s,fr(e[o],e[o+1],i[t],i[t+1],r))}return s}function gr(e,t,i,n,r){if(!nr(t,e.length)||!nr(n,i.length))return NaN;let s=1/0;for(let o=t[0];o<=t[1];++o)for(let t=n[0];t<=n[1];++t)if(0===(s=Math.min(s,r.distance(e[o],i[t]))))return s;return s}function _r(e,t,i){if(In(e,t,!0))return 0;let n=1/0;for(const r of t){const t=r.length;if(t<2)return NaN;if(r[0]!==r[t-1]&&0===(n=Math.min(n,i.pointToSegmentDistance(e,r[t-1],r[0]))))return n;if(0===(n=Math.min(n,dr(e,r,i))))return n}return n}function yr(e,t,i,n){if(!nr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(In(e[n],i,!0))return 0;let r=1/0;for(let s=t[0];s<t[1];++s)for(const t of i)for(let i=0,o=t.length,a=o-1;i<o;a=i++){if(Pn(e[s],e[s+1],t[a],t[i]))return 0;r=Math.min(r,fr(e[s],e[s+1],t[a],t[i],n))}return r}function vr(e,t){for(const i of e)for(let e=0;e<=i.length-1;++e)if(In(i[e],t,!0))return!0;return!1}function xr(e,t,i,n=1/0){const r=or(e),s=or(t);if(n!==1/0&&ar(r,s,i)>=n)return n;if(En(r,s)){if(vr(e,t))return 0}else if(vr(t,e))return 0;let o=n;for(const n of e)for(let e=0,r=n.length,s=r-1;e<r;s=e++)for(const r of t)for(let t=0,a=r.length,l=a-1;t<a;l=t++){if(Pn(n[s],n[e],r[l],r[t]))return 0;o=Math.min(o,fr(n[s],n[e],r[l],r[t],i))}return o}function br(e,t,i,n,r,s,o){if(null===s||null===o)return;const a=ar(sr(n,s),sr(r,o),i);a<t&&e.push({dist:a,range1:s,range2:o})}function wr(e,t,i,n,r=1/0){let s=Math.min(n.distance(e[0],i[0][0]),r);if(0===s)return s;const o=new Kn([{dist:0,range1:[0,e.length-1],range2:[0,0]}],er),a=t?50:100,l=or(i);for(;o.length;){const r=o.pop();if(r.dist>=s)continue;const c=r.range1;if(ir(c)<=a){if(!nr(c,e.length))return NaN;if(t){const t=yr(e,c,i,n);if(0===(s=Math.min(s,t)))return s}else for(let t=c[0];t<=c[1];++t){const r=_r(e[t],i,n);if(0===(s=Math.min(s,r)))return s}}else{const i=rr(c,t);if(null!==i[0]){const t=ar(sr(e,i[0]),l,n);t<s&&o.push({dist:t,range1:i[0],range2:[0,0]})}if(null!==i[1]){const t=ar(sr(e,i[1]),l,n);t<s&&o.push({dist:t,range1:i[1],range2:[0,0]})}}}return s}function Tr(e,t,i,n,r,s=1/0){let o=Math.min(s,r.distance(e[0],i[0]));if(0===o)return o;const a=new Kn([{dist:0,range1:[0,e.length-1],range2:[0,i.length-1]}],er),l=t?50:100,c=n?50:100;for(;a.length;){const s=a.pop();if(s.dist>=o)continue;const u=s.range1,h=s.range2;if(ir(u)<=l&&ir(h)<=c){if(!nr(u,e.length)||!nr(h,i.length))return NaN;if(t&&n?o=Math.min(o,mr(e,u,i,h,r)):t||n?t&&!n?o=Math.min(o,pr(i,h,e,u,r)):!t&&n&&(o=Math.min(o,pr(e,u,i,h,r))):o=Math.min(o,gr(e,u,i,h,r)),0===o)return o}else{const s=rr(u,t),l=rr(h,n);br(a,o,r,e,i,s[0],l[0]),br(a,o,r,e,i,s[0],l[1]),br(a,o,r,e,i,s[1],l[0]),br(a,o,r,e,i,s[1],l[1])}}return o}function Sr(e,t,i,n,r=1/0){let s=r;const o=sr(e,[0,e.length-1]);for(const r of i)if(!(s!==1/0&&ar(o,sr(r,[0,r.length-1]),n)>=s)&&(s=Math.min(s,Tr(e,t,r,!0,n,s)),0===s))return s;return s}function Er(e,t,i,n,r=1/0){let s=r;const o=sr(e,[0,e.length-1]);for(const r of i){if(s!==1/0&&ar(o,or(r),n)>=s)continue;const i=wr(e,t,r,n,s);if(isNaN(i))return i;if(0===(s=Math.min(s,i)))return s}return s}function Ar(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Mr{constructor(e,t){this.type=Pi,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Ki(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e<t.features.length;++e)if(Ar(t.features[e].geometry.type))return new Mr(t,t.features[e].geometry)}else if("Feature"===t.type){if(Ar(t.geometry.type))return new Mr(t,t.geometry)}else if(Ar(t.type))return new Mr(t,t)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),i=e.canonicalID();if(null!=t&&null!=i){if("Point"===e.geometryType())return function(e,t,i){const n=[];for(const i of e)for(const e of i)n.push(ur(e,t));const r=new $n(n[0][1],"meters");return"Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type?Tr(n,!1,"Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r):"MultiLineString"===i.type?Sr(n,!1,i.coordinates,r):"Polygon"===i.type||"MultiPolygon"===i.type?Er(n,!1,"Polygon"===i.type?[i.coordinates]:i.coordinates,r):null}(t,i,this.geometries);if("LineString"===e.geometryType())return function(e,t,i){const n=[];for(const i of e){const e=[];for(const n of i)e.push(ur(n,t));n.push(e)}const r=new $n(n[0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return Sr("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n,r);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const s=Sr(i.coordinates[t],!0,n,r,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}if("Polygon"===i.type||"MultiPolygon"===i.type){let e=1/0;for(let t=0;t<n.length;t++){const s=Er(n[t],!0,"Polygon"===i.type?[i.coordinates]:i.coordinates,r,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}return null}(t,i,this.geometries);if("Polygon"===e.geometryType())return function(e,t,i){const n=[];for(const i of function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let s=0;s<t;s++){const t=Tn(e[s]);0!==t&&(e[s].area=Math.abs(t),void 0===r&&(r=t<0),r===t<0?(n&&i.push(n),n=[e[s]]):n.push(e[s]))}return n&&i.push(n),i}(e)){const e=[];for(let n=0;n<i.length;++n)e.push(hr(i[n],t));n.push(e)}const r=new $n(n[0][0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return Er("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n,r);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const s=Er(i.coordinates[t],!0,n,r,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}return"Polygon"===i.type||"MultiPolygon"===i.type?function(e,t,i){let n=1/0;for(const r of e)for(const e of t){const t=xr(r,e,i,n);if(isNaN(t))return t;if(0===(n=Math.min(n,t)))return n}return n}("Polygon"===i.type?[i.coordinates]:i.coordinates,n,r):null}(t,i,this.geometries)}return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Ir(e){if(e instanceof _n){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(e.name.startsWith("filter-"))return!1}if(e instanceof Gn)return!1;if(e instanceof Mr)return!1;if(e instanceof Dr)return e.featureConstant;let t=!0;return e.eachChild(e=>{t&&!Ir(e)&&(t=!1)}),t}function Cr(e){if(e instanceof _n&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Cr(e)&&(t=!1)}),t}function Pr(e,t){if(e instanceof _n&&t.includes(e.name))return!1;let i=!0;return e.eachChild(e=>{i&&!Pr(e,t)&&(i=!1)}),i}function Lr(e,t,i){return[e,t,i].filter(Boolean).join("")}function Rr(e,t){switch(e){case"string":return en(t);case"number":return+t;case"boolean":return!!t;case"color":return bi.parse(t);case"formatted":return $i.fromString(en(t));case"resolvedImage":return Yi.build(en(t))}return t}function Or(e,t,i,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&e<t&&(e=t),void 0!==i&&e>i&&(e=i),e}class Dr{constructor(e,t,i,n=!1){this.type=e,this.key=t,this.scope=i,this.featureConstant=n}static parse(e,t){let i=t.expectedType;if(null==i&&(i=Bi),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof tn))return t.error("Key name of 'config' expression must be a string literal.");let r,s=!0;const o=en(n.value);if(e.length>=3){const i=t.parse(e[2],2);if(!(i instanceof tn))return t.error("Scope of 'config' expression must be a string literal.");r=en(i.value)}if(t.options){const e=Lr(o,r,t._scope),i=t.options.get(e);i&&(s=Ir(i.value||i.default))}return new Dr(i,o,r,s)}evaluate(e){const t=Lr(this.key,this.scope,e.scope),i=e.getConfig(t);if(!i)return null;const{type:n,value:r,values:s,minValue:o,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let u=c;if(r){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),u=r.evaluate(e),e.scope=t}return n&&(u=Rr(n,u)),void 0===u||void 0===o&&void 0===a&&void 0===l||("number"==typeof u?u=Or(u,o,a,l):Array.isArray(u)&&(u=u.map(e=>"number"==typeof e?Or(e,o,a,l):e))),void 0!==r&&void 0!==u&&s&&!s.includes(u)&&(u=c,n&&(u=Rr(n,u))),(n&&n!==this.type||void 0!==u&&!Wi(Qi(u),this.type))&&(u=Rr(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Br{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Br(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Fr{constructor(e,t=[],i,n=new Ii,r=[],s,o,a){this.registry=e,this.path=t,this.scope=n,this.errors=r,this.expectedType=i,this._scope=s,this.options=o,this.iconImageUseTheme=a}get key(){if(void 0===this._key){const e=this.path;let t="";for(let i=0;i<e.length;i++){const n=e[i];t+="string"==typeof n?`['${n}']`:`[${n}]`}this._key=t}return this._key}parse(e,t,i,n,r={}){return t||i?this.concat(t,null,i,n)._parse(e,r):this._parse(e,r)}parseObjectValue(e,t,i,n,r,s={}){return this.concat(t,i,n,r)._parse(e,s)}_parse(e,t){function i(e,t,i){return"assert"===i?new sn(t,[e]):"coerce"===i?new fn(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof e[0]?this.registry[e[0]]:void 0;if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"coerce");else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof tn)&&"resolvedImage"!==r.type.kind&&Nr(r)){const t=new gn(this._scope,this.options,this.iconImageUseTheme);try{r=new tn(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return fn.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i,n){let r="number"==typeof e?this.path.concat(e):this.path;r="string"==typeof t?r.concat(t):r;const s=n?this.scope.concat(n):this.scope;return new Fr(this.registry,r,i||null,s,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Mi(i,e))}checkSubtype(e,t,i){const n=ji(e,t);return n&&this.error(n,..."number"==typeof i?[i]:[]),n}}function Nr(e){if(e instanceof Br)return Nr(e.boundExpression);if(e instanceof _n&&"error"===e.name)return!1;if(e instanceof vn)return!1;if(e instanceof Gn)return!1;if(e instanceof Mr)return!1;if(e instanceof Dr)return!1;const t=e instanceof fn||e instanceof sn;let i=!0;return e.eachChild(e=>{i=t?i&&Nr(e):i&&e instanceof tn}),!!i&&Ir(e)&&Pr(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function kr(e,t){const i=e.length-1;let n,r,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),n=e[a],r=e[a+1],n<=t){if(a===i||t<r)return a;s=a+1}else{if(!(n>t))throw new nn("Input is not a number.");o=a-1}return 0}class zr{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Pi);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i<e.length;i+=2){const s=1===i?-1/0:e[i],o=e[i+1],a=i,l=i+1;if("number"!=typeof s)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(n.length&&n.at(-1)[0]>=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(o,l,r);if(!c)return null;r=r||c.type,n.push([s,c])}return new zr(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[kr(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Ur=.95047,Vr=1.08883,jr=4/29,Gr=6/29,Hr=3*Gr*Gr,Wr=Gr*Gr*Gr,qr=Math.PI/180,Xr=180/Math.PI;function $r(e){return e>Wr?Math.pow(e,1/3):e/Hr+jr}function Zr(e){return e>Gr?e*e*e:Hr*(e-jr)}function Yr(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Jr(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Kr(e){const t=Jr(e.r),i=Jr(e.g),n=Jr(e.b),r=$r((.4124564*t+.3575761*i+.1804375*n)/Ur),s=$r((.2126729*t+.7151522*i+.072175*n)/1);return{l:116*s-16,a:500*(r-s),b:200*(s-$r((.0193339*t+.119192*i+.9503041*n)/Vr)),alpha:e.a}}function Qr(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Zr(t),i=Ur*Zr(i),n=Vr*Zr(n),new bi(Yr(3.2404542*i-1.5371385*t-.4985314*n),Yr(-.969266*i+1.8760108*t+.041556*n),Yr(.0556434*i-.2040259*t+1.0572252*n),e.alpha)}function es(e,t,i){const n=t-e;return e+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const ts={forward:Kr,reverse:Qr,interpolate:function(e,t,i){return{l:xi(e.l,t.l,i),a:xi(e.a,t.a,i),b:xi(e.b,t.b,i),alpha:xi(e.alpha,t.alpha,i)}}},is={forward:function(e){const{l:t,a:i,b:n}=Kr(e),r=Math.atan2(n,i)*Xr;return{h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*qr,i=e.c;return Qr({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:es(e.h,t.h,i),c:xi(e.c,t.c,i),l:xi(e.l,t.l,i),alpha:xi(e.alpha,t.alpha,i)}}};var ns=Object.freeze({__proto__:null,hcl:is,lab:ts});class rs{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=ss(t,e.base,i,n);else if("linear"===e.name)r=ss(t,1,i,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;r=new Ee(s[0],s[1],s[2],s[3]).solve(ss(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(r=t.parse(r,2,Pi),!r)return null;const o=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Oi:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<s.length;e+=2){const i=s[e],n=s[e+1],r=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',r);if(o.length&&o.at(-1)[0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,o.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new rs(a,i,n,r,o):t.error(`Type ${Ui(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const s=kr(t,n),o=rs.interpolationFactor(this.interpolation,n,t[s],t[s+1]),a=i[s].evaluate(e),l=i[s+1].evaluate(e);return"interpolate"===this.operator?Ai[this.type.kind.toLowerCase()](a,l,o):"interpolate-hcl"===this.operator?is.reverse(is.interpolate(is.forward(a),is.forward(l),o)):ts.reverse(ts.interpolate(ts.forward(a),ts.forward(l),o))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function ss(e,t,i,n){const r=n-i,s=e-i;return 0===r?0:1===t?s/r:(Math.pow(t,s)-1)/(Math.pow(t,r)-1)}class os{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument."),null;let i=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}const s=n&&r.some(e=>ji(n,e.type));return new os(s?Bi:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(e),i&&i instanceof Yi&&!i.available&&(t||(t=i),i=null,n===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const as=/[^a-zA-Z0-9_]/;class ls{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let n=1;n<e.length-1;n+=2){const r=e[n];if("string"!=typeof r)return t.error(`Expected string, but found ${typeof r} instead.`,n);if(as.test(r))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const s=t.parse(e[n+1],n+1);if(!s)return null;i.push([r,s])}const n=t.parse(e.at(-1),e.length-1,t.expectedType,i);return n?new ls(i,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}class cs{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Pi),n=t.parse(e[2],2,zi(t.expectedType||Bi));return i&&n?new cs(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new nn("Array index out of bounds: negative index");if(t>=i.length)throw new nn("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new nn("Array index must be an integer. Use at-interpolated for fractional indices");return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class us{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Pi),n=t.parse(e[2],2,zi(t.expectedType||Bi));return i&&n?new us(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new nn(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new nn(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t===Math.floor(t))return i[t];const n=Math.floor(t),r=Math.ceil(t),s=i[n],o=i[r];if("number"!=typeof s||"number"!=typeof o)throw new nn(`Cannot interpolate between non-number values at index ${t}.`);const a=t-n;return s*(1-a)+o*a}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class hs{constructor(e,t){this.type=Ri,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const i=t.parse(e[1],1,Bi),n=t.parse(e[2],2,Bi);return i&&n?Gi(i.type,[Ri,Li,Pi,Ci,Bi])?new hs(i,n):(t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ui(i.type)} instead`),null):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Hi(t,["boolean","string","number","null"]))throw new nn(`Expected first argument to be of type boolean, string, number or null, but found ${Ui(Qi(t))} instead.`);if(!Hi(i,["string","array"]))throw new nn(`Expected second argument to be of type array or string, but found ${Ui(Qi(i))} instead.`);return i.includes(t)}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ds{constructor(e,t,i){this.type=Pi,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const i=t.parse(e[1],1,Bi),n=t.parse(e[2],2,Bi);if(!i||!n)return null;if(!Gi(i.type,[Ri,Li,Pi,Ci,Bi]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ui(i.type)} instead`),null;if(4===e.length){const r=t.parse(e[3],3,Pi);return r?new ds(i,n,r):null}return new ds(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Hi(t,["boolean","string","number","null"]))throw new nn(`Expected first argument to be of type boolean, string, number or null, but found ${Ui(Qi(t))} instead.`);if(!Hi(i,["string","array"]))throw new nn(`Expected second argument to be of type array or string, but found ${Ui(Qi(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return i.indexOf(t,n)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class ps{constructor(e,t,i,n,r,s){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,this.otherwise=s}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},s=[];for(let o=2;o<e.length-1;o+=2){let a=e[o];const l=e[o+1];Array.isArray(a)||(a=[a]);const c=t.concat(o);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Qi(e)))return null}else i=Qi(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=s.length}const u=t.parse(l,o,n);if(!u)return null;n=n||u.type,s.push(u)}const o=t.parse(e[1],1,Bi);if(!o)return null;const a=t.parse(e.at(-1),e.length-1,n);return a?"value"!==o.type.kind&&t.concat(1).checkSubtype(i,o.type)?null:new ps(i,n,o,r,s,a):null}evaluate(e){const t=this.input.evaluate(e);return(Wi(Qi(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const r=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of i)e.push(1===n.length?r(n[0]):n.map(r)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class fs{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;r<e.length-1;r+=2){const s=t.parse(e[r],r,Ri);if(!s)return null;const o=t.parse(e[r+1],r+1,i);if(!o)return null;n.push([s,o]),i=i||o.type}const r=t.parse(e.at(-1),e.length-1,i);return r?new fs(i,n,r):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class ms{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const i=t.parse(e[1],1,Bi),n=t.parse(e[2],2,Pi);if(!i||!n)return null;if(!Gi(i.type,[zi(Bi),Li,Bi]))return t.error(`Expected first argument to be of type array or string, but found ${Ui(i.type)} instead`),null;if(4===e.length){const r=t.parse(e[3],3,Pi);return r?new ms(i.type,i,n,r):null}return new ms(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Hi(t,["string","array"]))throw new nn(`Expected first argument to be of type array or string, but found ${Ui(Qi(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(i,n)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class gs{constructor(e,t){this.type=zi(Li),this.str=e,this.delimiter=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Li),n=t.parse(e[2],2,Li);return i&&n?new gs(i,n):void 0}evaluate(e){const t=this.str.evaluate(e),i=this.delimiter.evaluate(e);return t.split(i)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function _s(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function ys(e,t,i,n){return 0===n.compare(t,i)}function vs(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Ri,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let s=t.parse(e[1],1,Bi);if(!s)return null;if(!_s(i,s.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ui(s.type)}'.`);let o=t.parse(e[2],2,Bi);if(!o)return null;if(!_s(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ui(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${Ui(s.type)}' and '${Ui(o.type)}'.`);n&&("value"===s.type.kind&&"value"!==o.type.kind?s=new sn(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new sn(s.type,[o])));let a=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Fi),!a)return null}return new r(s,o,a)}evaluate(r){const s=this.lhs.evaluate(r),o=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Qi(s),i=Qi(o);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new nn(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Qi(s),i=Qi(o);if("string"!==e.kind||"string"!==i.kind)return t(r,s,o)}return this.collator?i(r,s,o,this.collator.evaluate(r)):t(r,s,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const xs=vs("==",function(e,t,i){return t===i},ys),bs=vs("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!ys(0,t,i,n)}),ws=vs("<",function(e,t,i){return t<i},function(e,t,i,n){return n.compare(t,i)<0}),Ts=vs(">",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),Ss=vs("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Es=vs(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class As{constructor(e,t,i,n,r,s){this.type=Li,this.number=e,this.locale=t,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Pi);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parseObjectValue(n.locale,2,"locale",Li),!r))return null;let s=null;if(n.currency&&(s=t.parseObjectValue(n.currency,2,"currency",Li),!s))return null;let o=null;if(n.unit&&(o=t.parseObjectValue(n.unit,2,"unit",Li),!o))return null;let a=null;if(n["min-fraction-digits"]&&(a=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Pi),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Pi),!l)?null:new As(i,r,s,o,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Ms{constructor(e){this.type=Pi,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?(t.error(`Expected argument of type string or array, but found ${Ui(i.type)} instead.`),null):new Ms(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new nn(`Expected value to be of type string or array, but found ${Ui(Qi(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function Is(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Cs={"==":xs,"!=":bs,">":Ts,"<":ws,">=":Es,"<=":Ss,array:sn,at:cs,"at-interpolated":us,boolean:sn,case:fs,coalesce:os,collator:vn,format:on,image:an,in:hs,"index-of":ds,interpolate:rs,"interpolate-hcl":rs,"interpolate-lab":rs,length:Ms,let:ls,literal:tn,match:ps,number:sn,"number-format":As,object:sn,slice:ms,step:zr,string:sn,"to-boolean":fn,"to-color":fn,"to-number":fn,"to-string":fn,var:Br,within:Gn,distance:Mr,config:Dr,split:gs};function Ps(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const s=r?r.evaluate(e):1,o=Ji(t,i,n,s);if(o)throw new nn(o);return new bi(t/255,i/255,n/255,s)}function Ls(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const s=r?r.evaluate(e):1,o=function(e,t,i,n){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,n,s);if(o)throw new nn(o);const a=`hsla(${t}, ${i}%, ${n}%, ${s})`,l=bi.parse(a);if(!l)throw new nn(`Failed to parse HSLA color: ${a}`);return l}function Rs(e,t){return e in t}function Os(e,t){const i=t[e];return void 0===i?null:i}function Ds(e){return{type:e}}function Bs(e){if(e instanceof Dr)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...Bs(e)])}),t}function Fs(e){if(e instanceof _n&&"is-active-floor"===e.name)return!0;let t=!1;return e.eachChild(e=>{!t&&Fs(e)&&(t=!0)}),t}function Ns(e){return{result:"success",value:e}}function ks(e){return{result:"error",value:e}}function zs(e,t){return!!e&&!!e.parameters&&e.parameters.includes(t)}function Us(e){return"data-driven"===e["property-type"]}function Vs(e){return zs(e.expression,"measure-light")}function js(e){return zs(e.expression,"zoom")}function Gs(e){return!!e.expression&&e.expression.interpolated}function Hs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ws(e){return e}function qs(e,t){const i="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],r=n||!(n||void 0!==e.property),s=e.type||(Gs(t)?"exponential":"interval");if(i&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],bi.parse(e[1])])),e.default=bi.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!ns[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let o,a,l;if("exponential"===s)o=Ys;else if("interval"===s)o=Zs;else if("categorical"===s){o=$s,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=Js}if(n){const i={},n=[];for(let t=0;t<e.stops.length;t++){const r=e.stops[t],s=r[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:e.type,property:e.property,default:e.default,stops:[]},n.push(s)),i[s].stops.push([r[0].value,r[1]])}const r=[];for(const e of n)r.push([i[e].zoom,qs(i[e],t)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:rs.interpolationFactor.bind(void 0,s),zoomStops:r.map(e=>e[0]),evaluate:({zoom:i},n)=>Ys({stops:r,base:e.base},t,i).evaluate(i,n)}}if(r){const i="exponential"===s?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:rs.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>o(e,t,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Xs(e.default,t.default):o(e,t,r,a,l)}}}function Xs(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function $s(e,t,i,n,r){return Xs(typeof i===r?n[i]:void 0,e.default,t.default)}function Zs(e,t,i){if(!hn(i))return Xs(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const r=kr(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Ys(e,t,i){const n=void 0!==e.base?e.base:1;if(!hn(i))return Xs(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const s=kr(e.stops.map(e=>e[0]),i),o=function(e,t,i,n){const r=n-i,s=e-i;return 0===r?0:1===t?s/r:(Math.pow(t,s)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[s][0],e.stops[s+1][0]),a=e.stops[s][1],l=e.stops[s+1][1];let c=Ai[t.type]||Ws;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=ns[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),o))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,o)}}:c(a,l,o)}function Js(e,t,i){return"color"===t.type?i=bi.parse(i):"formatted"===t.type?i=$i.fromString(i.toString()):"resolvedImage"===t.type?i=Yi.build(i.toString()):ln(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Xs(i,e.default,t.default)}_n.register(Cs,{error:[{kind:"error"},[Li],(e,[t])=>{throw new nn(t.evaluate(e))}],typeof:[Li,[Bi],(e,[t])=>Ui(Qi(t.evaluate(e)))],"to-rgba":[zi(Pi,4),[Oi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[zi(Pi,4),[Oi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Oi,[Pi,Pi,Pi],Ps],rgba:[Oi,[Pi,Pi,Pi,Pi],Ps],hsl:[Oi,[Pi,Pi,Pi],Ls],hsla:[Oi,[Pi,Pi,Pi,Pi],Ls],has:{type:Ri,overloads:[[[Li],(e,[t])=>Rs(t.evaluate(e),e.properties())],[[Li,Di],(e,[t,i])=>Rs(t.evaluate(e),i.evaluate(e))]]},get:{type:Bi,overloads:[[[Li],(e,[t])=>Os(t.evaluate(e),e.properties())],[[Li,Di],(e,[t,i])=>Os(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Bi,[Li],(e,[t])=>Os(t.evaluate(e),e.featureState||{})],properties:[Di,[],e=>e.properties()],"geometry-type":[Li,[],e=>e.geometryType()],worldview:[Li,[],e=>e.globals.worldview||""],"is-active-floor":[Ri,Ds(Li),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return!1;if(0===t.length)return!0;const i=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return i.has(n)})}],id:[Bi,[],e=>e.id()],zoom:[Pi,[],e=>e.globals.zoom],pitch:[Pi,[],e=>e.globals.pitch||0],"distance-from-center":[Pi,[],e=>e.distanceFromCenter()],"measure-light":[Pi,[Li],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Pi,[],e=>e.globals.heatmapDensity||0],"line-progress":[Pi,[],e=>e.globals.lineProgress||0],"raster-value":[Pi,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Pi,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Pi,[],e=>e.globals.skyRadialProgress||0],accumulated:[Bi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Pi,Ds(Pi),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[Pi,Ds(Pi),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:Pi,overloads:[[[Pi,Pi],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Pi],(e,[t])=>-t.evaluate(e)]]},"/":[Pi,[Pi,Pi],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Pi,[Pi,Pi],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Pi,[],()=>Math.LN2],pi:[Pi,[],()=>Math.PI],e:[Pi,[],()=>Math.E],"^":[Pi,[Pi,Pi],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Pi,[Pi],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Pi,[Pi],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Pi,[Pi],(e,[t])=>Math.log(t.evaluate(e))],log2:[Pi,[Pi],(e,[t])=>Math.log2(t.evaluate(e))],sin:[Pi,[Pi],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Pi,[Pi],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Pi,[Pi],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Pi,[Pi],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Pi,[Pi],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Pi,[Pi],(e,[t])=>Math.atan(t.evaluate(e))],min:[Pi,Ds(Pi),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Pi,Ds(Pi),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Pi,[Pi],(e,[t])=>Math.abs(t.evaluate(e))],round:[Pi,[Pi],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Pi,[Pi],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Pi,[Pi],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Ri,[Li,Bi],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Ri,[Bi],(e,[t])=>e.id()===t.value],"filter-type-==":[Ri,[Li],(e,[t])=>e.geometryType()===t.value],"filter-<":[Ri,[Li,Bi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<r}],"filter-id-<":[Ri,[Bi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<n}],"filter->":[Ri,[Li,Bi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Ri,[Bi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Ri,[Li,Bi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Ri,[Bi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Ri,[Li,Bi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Ri,[Bi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Ri,[Bi],(e,[t])=>t.value in e.properties()],"filter-has-id":[Ri,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Ri,[zi(Li)],(e,[t])=>t.value.includes(e.geometryType())],"filter-id-in":[Ri,[zi(Bi)],(e,[t])=>t.value.includes(e.id())],"filter-in-small":[Ri,[Li,zi(Bi)],(e,[t,i])=>i.value.includes(e.properties()[t.value])],"filter-in-large":[Ri,[Li,zi(Bi)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Ri,overloads:[[[Ri,Ri],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Ds(Ri),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Ri,overloads:[[[Ri,Ri],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Ds(Ri),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Ri,[Ri],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Ri,[Li],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Li,[Li],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Li,[Li],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Li,Ds(Bi),(e,t)=>t.map(t=>en(t.evaluate(e))).join("")],"resolved-locale":[Li,[Fi],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Pi,[Pi,Pi,Bi],(e,t)=>{const[i,n,r]=t.map(t=>t.evaluate(e));if(i>n)return i;if(i===n)return i;let s;if("string"==typeof r)s=function(e){let t=0;if(0===e.length)return t;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return t}(r);else{if("number"!=typeof r)throw new nn(`Invalid seed input: ${r}`);s=r}return i+Is(s)()*(n-i)}]});class Ks{constructor(e,t,i,n,r){this.expression=e,this._warningHistory={},this._scope=i,this._options=n,this._iconImageUseTheme=r,this._evaluator=new gn(i,n,r),this._defaultValue=t?function(e){return"color"===e.type&&(Hs(e.default)||Array.isArray(e.default))?new bi(0,0,0,0):"color"===e.type?bi.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this.configDependencies=Bs(e),this.isIndoorDependent=Fs(e)}evaluateWithoutErrorHandling(e,t,i,n,r,s,o,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,s,o,a,l){this._evaluator||(this._evaluator=new gn(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null,this._evaluator.iconImageUseTheme=l||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new nn(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0),this._defaultValue}}}function Qs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Cs}function eo(e,t,i,n,r){const s=new Fr(Cs,[],t?function(e){const t={color:Oi,string:Li,number:Pi,enum:Li,boolean:Ri,formatted:Ni,resolvedImage:ki};return"array"===e.type?zi(t[e.value]||Bi,e.length):t[e.type]}(t):void 0,void 0,void 0,i,n,r),o=s.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?Ns(new Ks(o,t,i,n,r)):ks(s.errors)}class to{constructor(e,t,i,n){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!Cr(t.expression),this.configDependencies=Bs(t.expression),this.isIndoorDependent=Fs(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,s)}evaluate(e,t,i,n,r,s,o){return this._styleExpression.evaluate(e,t,i,n,r,s,void 0,void 0,o)}}class io{constructor(e,t,i,n,r,s){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Cr(t.expression),this.isIndoorDependent=Fs(t.expression),this.isLightConstant=r,this.isLineProgressConstant=s,this.configDependencies=Bs(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,s)}evaluate(e,t,i,n,r,s){return this._styleExpression.evaluate(e,t,i,n,r,s)}interpolationFactor(e,t,i){return this.interpolationType?rs.interpolationFactor(this.interpolationType,e,t,i):0}}function no(e,t,i,n,r){if("error"===(e=eo(e,t,i,n,r)).result)return e;const s=e.value.expression,o=Ir(s);if(!o&&!Us(t))return ks([new Mi("","data expressions not supported")]);const a=Pr(s,["zoom","pitch","distance-from-center"]);if(!a&&!js(t))return ks([new Mi("","zoom expressions not supported")]);const l=Pr(s,["measure-light"]);if(!l&&!Vs(t))return ks([new Mi("","measure-light expression not supported")]);const c=Pr(s,["line-progress"]);if(!c&&!function(e){return zs(e.expression,"line-progress")}(t))return ks([new Mi("","line-progress expression not supported")]);const u=t.expression&&t.expression.relaxZoomRestriction,h=so(s);return h||a||u?h instanceof Mi?ks([h]):h instanceof rs&&!Gs(t)?ks([new Mi("",'"interpolate" expressions cannot be used with this property')]):Ns(h?new io(o&&c?"camera":"composite",e.value,h.labels,h instanceof rs?h.interpolation:void 0,l,c):new to(o&&c?"constant":"source",e.value,l,c)):ks([new Mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ro{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,qs(this._parameters,this._specification))}static deserialize(e){return new ro(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function so(e){let t=null;if(e instanceof ls)t=so(e.result);else if(e instanceof os){for(const i of e.args)if(t=so(i),t)break}else(e instanceof zr||e instanceof rs)&&e.input instanceof _n&&"zoom"===e.input.name&&(t=e);return t instanceof Mi||e.eachChild(e=>{const i=so(e);i instanceof Mi?t=i:t&&i&&t!==i&&(t=new Mi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}class oo{constructor(e,t,i){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const t=new Int32Array(e);this.width=t[0],this.height=t[1],this.xCellCount=t[2],this.yCellCount=t[3],this.boxUid=t[4],this.circleUid=t[5];const i=this.xCellCount*this.yCellCount,n=[];for(let e=0;e<i;e++){const i=t[6+e],r=t[6+e+1];n.push(i===r?null:t.subarray(i,r))}const r=t[6+i],s=[];for(let e=0;e<i;e++){const i=t[r+e],n=t[r+e+1];s.push(i===n?null:t.subarray(i,n))}let o=t[r+i];this.boxCells=n,this.circleCells=s,this.boxKeys=t.subarray(o,o+this.boxUid),o+=this.boxUid,this.circleKeys=t.subarray(o,o+this.circleUid),o+=this.circleUid,this.bboxes=t.subarray(o,o+4*this.boxUid),o+=4*this.boxUid,this.circles=t.subarray(o,o+3*this.circleUid)}else{this.width=e,this.height=t,this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);const n=this.xCellCount*this.yCellCount,r=[],s=[];for(let e=0;e<n;e++)r.push([]),s.push([]);this.boxCells=r,this.circleCells=s,this.boxKeys=[],this.circleKeys=[],this.bboxes=[],this.circles=[],this.boxUid=0,this.circleUid=0}this.xScale=this.xCellCount/this.width,this.yScale=this.yCellCount/this.height}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,n,r){const s=this.boxUid++,o=this._xCell(t),a=this._yCell(i),l=this._xCell(n),c=this._yCell(r);for(let e=o;e<=l;e++)for(let t=a;t<=c;t++)this.boxCells[this.xCellCount*t+e].push(s);this.boxKeys.push(e),this.bboxes.push(t,i,n,r)}insertCircle(e,t,i,n){const r=this.circleUid++,s=this._xCell(t-n),o=this._yCell(i-n),a=this._xCell(t+n),l=this._yCell(i+n);for(let e=s;e<=a;e++)for(let t=o;t<=l;t++)this.circleCells[this.xCellCount*t+e].push(r);this.circleKeys.push(e),this.circles.push(t,i,n)}query(e,t,i,n,r){const s=[];if(i<0||e>this.width||n<0||t>this.height)return s;const o=this._nextGen(),{boxCells:a,circleCells:l,boxKeys:c,circleKeys:u,bboxes:h,circles:d,boxSeen:p,circleSeen:f,xCellCount:m}=this,g=this._xCell(e),_=this._yCell(t),y=this._xCell(i),v=this._yCell(n);for(let x=g;x<=y;x++)for(let g=_;g<=v;g++){const _=m*g+x,y=a[_];if(y)for(let a=0;a<y.length;a++){const l=y[a];if(p[l]===o)continue;p[l]=o;const u=4*l,d=h[u],f=h[u+1],m=h[u+2],g=h[u+3];e<=m&&t<=g&&i>=d&&n>=f&&(!r||r(c[l]))&&s.push({key:c[l],x1:d,y1:f,x2:m,y2:g})}const v=l[_];if(v)for(let a=0;a<v.length;a++){const l=v[a];if(f[l]===o)continue;f[l]=o;const c=3*l,h=d[c],p=d[c+1],m=d[c+2];!this._circleAndRectCollide(h,p,m,e,t,i,n)||r&&!r(u[l])||s.push({key:u[l],x1:h-m,y1:p-m,x2:h+m,y2:p+m})}}return s}queryKeys(e,t,i,n,r){const s=[];if(i<0||e>this.width||n<0||t>this.height)return s;const o=this._nextGen(),{boxCells:a,boxKeys:l,bboxes:c,boxSeen:u,xCellCount:h,xScale:d,yScale:p}=this,f=this._xCell(e),m=this._yCell(t),g=this._xCell(i),_=this._yCell(n);for(let y=f;y<=g;y++)for(let f=m;f<=_;f++){if(r&&!r(y/d,f/p,(y+1)/d,(f+1)/p))continue;const m=a[h*f+y];if(m)for(let a=0;a<m.length;a++){const h=m[a];if(u[h]===o)continue;u[h]=o;const d=4*h,p=c[d],f=c[d+1],g=c[d+2],_=c[d+3];(r?r(p,f,g,_):e<=g&&t<=_&&i>=p&&n>=f)&&s.push(l[h])}}return s}hitTest(e,t,i,n,r){if(i<0||e>this.width||n<0||t>this.height)return!1;const s=this._nextGen(),{boxCells:o,circleCells:a,boxKeys:l,circleKeys:c,bboxes:u,circles:h,boxSeen:d,circleSeen:p,xCellCount:f}=this,m=this._xCell(e),g=this._yCell(t),_=this._xCell(i),y=this._yCell(n);for(let v=m;v<=_;v++)for(let m=g;m<=y;m++){const g=f*m+v,_=o[g];if(_)for(let o=0;o<_.length;o++){const a=_[o];if(d[a]===s)continue;d[a]=s;const c=4*a;if(e<=u[c+2]&&t<=u[c+3]&&i>=u[c]&&n>=u[c+1]&&(!r||r(l[a])))return!0}const y=a[g];if(y)for(let o=0;o<y.length;o++){const a=y[o];if(p[a]===s)continue;p[a]=s;const l=3*a;if(this._circleAndRectCollide(h[l],h[l+1],h[l+2],e,t,i,n)&&(!r||r(c[a])))return!0}}return!1}hitTestCircle(e,t,i,n){const r=e-i,s=t-i,o=e+i,a=t+i;if(o<0||r>this.width||a<0||s>this.height)return!1;const l=this._nextGen(),{boxCells:c,circleCells:u,boxKeys:h,circleKeys:d,bboxes:p,circles:f,boxSeen:m,circleSeen:g,xCellCount:_}=this,y=this._xCell(r),v=this._yCell(s),x=this._xCell(o),b=this._yCell(a);for(let r=y;r<=x;r++)for(let s=v;s<=b;s++){const o=_*s+r,a=c[o];if(a)for(let r=0;r<a.length;r++){const s=a[r];if(m[s]===l)continue;m[s]=l;const o=4*s;if(this._circleAndRectCollide(e,t,i,p[o],p[o+1],p[o+2],p[o+3])&&(!n||n(h[s])))return!0}const y=u[o];if(y)for(let r=0;r<y.length;r++){const s=y[r];if(g[s]===l)continue;g[s]=l;const o=3*s;if(this._circlesCollide(f[o],f[o+1],f[o+2],e,t,i)&&(!n||n(d[s])))return!0}}return!1}static serialize(e,t){const i=e.toArrayBuffer();return t&&t.add(i),{buffer:i}}static deserialize(e){return new oo(e.buffer)}toArrayBuffer(){const e=this.xCellCount*this.yCellCount;let t=0,i=0;for(let n=0;n<e;n++)t+=this.boxCells[n].length,i+=this.circleCells[n].length;const n=new Int32Array(6+(e+1)+t+(e+1)+i+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);n[0]=this.width,n[1]=this.height,n[2]=this.xCellCount,n[3]=this.yCellCount,n[4]=this.boxUid,n[5]=this.circleUid;let r=6+(e+1);for(let t=0;t<e;t++){n[6+t]=r;const e=this.boxCells[t];n.set(e,r),r+=e.length}n[6+e]=r;const s=r;r+=e+1;for(let t=0;t<e;t++){n[s+t]=r;const e=this.circleCells[t];n.set(e,r),r+=e.length}return n[s+e]=r,n.set(this.boxKeys,r),r+=this.boxUid,n.set(this.circleKeys,r),r+=this.circleUid,n.set(this.bboxes,r),r+=4*this.boxUid,n.set(this.circles,r),n.buffer}_xCell(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_yCell(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_nextGen(){return this.boxSeen.length<this.boxUid&&(this.boxSeen=new Uint32Array(this.boxUid)),this.circleSeen.length<this.circleUid&&(this.circleSeen=new Uint32Array(this.circleUid)),this.generation=this.generation+1>>>0,0===this.generation&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}_circlesCollide(e,t,i,n,r,s){const o=n-e,a=r-t,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(e,t,i,n,r,s,o){const a=(s-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(o-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const ao={};function lo(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),ao[t]={klass:e,omit:i.omit||[]}}lo(Object,"Object"),lo(oo,"Grid"),delete Ae.prototype.constructor,lo(bi,"Color"),lo(Error,"Error"),lo($i,"Formatted"),lo(Xi,"FormattedSection"),lo(Wt,"AJAXError"),lo(Yi,"ResolvedImage"),lo(ro,"StylePropertyFunction"),lo(Ks,"StyleExpression",{omit:["_evaluator"]}),lo(gi,"ImageId"),lo(Zi,"ImageVariant"),lo(io,"ZoomDependentExpression"),lo(to,"ZoomConstantExpression"),lo(_n,"CompoundExpression",{omit:["_evaluate"]});for(const e in Cs)ao[Cs[e]._classRegistryKey]||lo(Cs[e],`Expression${e}`);function co(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function uo(e,t){if(null===e)return null;const i=typeof e;if("object"!==i)return"bigint"===i?{$name:"BigInt",value:e.toString()}:e;if(Array.isArray(e)){const i=e.length,n=[];n.length=i;for(let r=0;r<i;r++)n[r]=uo(e[r],t);return n}if(ArrayBuffer.isView(e))return t&&t.add(e.buffer),e;if(co(e)||e instanceof ImageBitmap)return t&&t.add(e),e;if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(e instanceof Map){const i={$name:"Map",entries:[]};for(const[n,r]of e.entries())i.entries.push(uo(n),uo(r,t));return i}if(e instanceof Set){const t={$name:"Set"};let i=0;for(const n of e.values())t[++i]=uo(n);return t}if(e instanceof Date||e instanceof RegExp||e instanceof Boolean||e instanceof Number||e instanceof String)return e;const n=e.constructor,r=n._classRegistryKey;if(!r)throw new Error(`Can't serialize object of unregistered class "${n.name}".`);const s=n.serialize?n.serialize(e,t):{};if(!n.serialize){const i=ao[r].omit,n=e;for(const e in n)Object.hasOwn(n,e)&&(i.includes(e)||(s[e]=uo(n[e],t)));e instanceof Error&&(s.message=e.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(s.$name=r),s}function ho(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e)){for(let t=0;t<e.length;t++)e[t]=ho(e[t]);return e}if(ArrayBuffer.isView(e)||co(e)||e instanceof ImageBitmap||e instanceof ImageData||e instanceof Date||e instanceof RegExp||e instanceof Boolean||e instanceof Number||e instanceof String)return e;const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],i=new Map;for(let e=0;e<t.length;e+=2)i.set(ho(t[e]),ho(t[e+1]));return i}if("Set"===t){const t=new Set;for(const i in e)"$name"!==i&&t.add(ho(e[i]));return t}if("BigInt"===t)return BigInt(e.value);const{klass:i}=ao[t];if(!i)throw new Error(`Can't deserialize unregistered class "${t}".`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const t in e)"$name"!==t&&(n[t]=ho(e[t]));return n}const po=e=>e>=1536&&e<=1791,fo=e=>e>=1872&&e<=1919,mo=e=>e>=2208&&e<=2303,go=e=>e>=11904&&e<=12031,_o=e=>e>=12032&&e<=12255,yo=e=>e>=12272&&e<=12287,vo=e=>e>=12288&&e<=12351,xo=e=>e>=12352&&e<=12447,bo=e=>e>=12448&&e<=12543,wo=e=>e>=12544&&e<=12591,To=e=>e>=12704&&e<=12735,So=e=>e>=12736&&e<=12783,Eo=e=>e>=12784&&e<=12799,Ao=e=>e>=12800&&e<=13055,Mo=e=>e>=13056&&e<=13311,Io=e=>e>=13312&&e<=19903,Co=e=>e>=19968&&e<=40959,Po=e=>e>=40960&&e<=42127,Lo=e=>e>=42128&&e<=42191,Ro=e=>e>=44032&&e<=55215,Oo=e=>e>=63744&&e<=64255,Do=e=>e>=64336&&e<=65023,Bo=e=>e>=65040&&e<=65055,Fo=e=>e>=65072&&e<=65103,No=e=>e>=65104&&e<=65135,ko=e=>e>=65136&&e<=65279,zo=e=>e>=65280&&e<=65519;function Uo(e){for(const t of e)if(Ho(t.charCodeAt(0)))return!0;return!1}function Vo(e){for(const t of e)if(!jo(t.charCodeAt(0)))return!1;return!0}function jo(e){return!(po(e)||fo(e)||mo(e)||Do(e)||ko(e))}function Go(e){return!(e<11904||!(To(e)||wo(e)||Fo(e)||Oo(e)||Mo(e)||go(e)||So(e)||vo(e)||Io(e)||Co(e)||Ao(e)||zo(e)||xo(e)||yo(e)||_o(e)||Eo(e)||bo(e)||Bo(e)||Lo(e)||Po(e)))}function Ho(e){return!(746!==e&&747!==e&&(e<4352||!(To(e)||wo(e)||Fo(e)&&!(e>=65097&&e<=65103)||Oo(e)||Mo(e)||go(e)||So(e)||!(!vo(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Io(e)||Co(e)||Ao(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||Ro(e)||xo(e)||yo(e)||(e=>e>=12688&&e<=12703)(e)||_o(e)||Eo(e)||bo(e)&&12540!==e||!(!zo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!No(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||Bo(e)||(e=>e>=19904&&e<=19967)(e)||Po(e)||Lo(e))))}function Wo(e){return 12312===e||12313===e||12316===e||12540===e||12448===e}function qo(e){return!(Ho(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||vo(e)||bo(e)||(e=>e>=57344&&e<=63743)(e)||Fo(e)||No(e)||zo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Xo(e){return po(e)||fo(e)||mo(e)||Do(e)||ko(e)}function $o(e){return e>=1424&&e<=2303||Do(e)||ko(e)}function Zo(e,t){return!(!t&&$o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Yo(e){for(const t of e)if($o(t.charCodeAt(0)))return!0;return!1}const Jo={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Ko=null,Qo=Jo.unavailable,ea=null;const ta=function(e){e&&(Qo=Jo.error),Ko&&Ko(e)};function ia(){na.fire(new hi("pluginStateChange",{pluginStatus:Qo,pluginURL:ea}))}const na=new mi,ra=function(){return Qo},sa=function(){if(Qo!==Jo.deferred||!ea)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Qo=Jo.loading,ia(),ea&&Kt({url:ea},e=>{e?ta(e):(Qo=Jo.loaded,ia())})},oa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Qo===Jo.loaded||null!=oa.applyArabicShaping,isLoading:()=>Qo===Jo.loading,setState(e){Qo=e.pluginStatus,ea=e.pluginURL},isParsing:()=>Qo===Jo.parsing,isParsed:()=>Qo===Jo.parsed,getPluginURL:()=>ea},aa=function(){oa.isLoading()||oa.isLoaded()||"deferred"!==ra()||sa()};class la{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!Zo(i.charCodeAt(0),t))return!1;return!0}(e,oa.isLoaded())}}class ca{constructor(e,t,i,n,r){this.property=e,this.value=t,this.expression=function(e,t,i,n,r){if(Hs(e))return new ro(e,t);if(Qs(e)||Array.isArray(e)&&e.length>0){const s=no(e,t,i,n,r);if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));return s.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=bi.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i,n,r)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i,n){return this.property.possiblyEvaluate(this,e,t,i,n)}}class ua{constructor(e,t,i,n){this.property=e,this.value=new ca(e,void 0,t,i,n)}transitioned(e,t){return new da(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new da(this.property,this.value,null,{},0)}}class ha{constructor(e,t,i,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Ye(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new ua(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new ca(this._values[e].property,null===t?void 0:Ye(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent())}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,n)}else Object.hasOwn(i,t)&&this.setValue(t,n)}}getTransition(e){return Ye(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new ua(this._values[e].property)),this._values[e].transition=Ye(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n)}return e}transitioned(e,t){const i=new pa(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new pa(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class da{constructor(e,t,i,n,r){const s=n.delay||0,o=n.duration||0;r=r||0,this.property=e,this.value=t,this.begin=r+s,this.end=this.begin+o,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),s=this.prior;if(s){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n<this.begin)return s.possiblyEvaluate(e,t,i);{const o=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(e,t,i),r,Fe(o))}}return r}}class pa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const n=new ga(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class fa{constructor(e,t,i,n){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Ye(this._values[e].value)}setValue(e,t){this._values[e]=new ca(this._values[e].property,null===t?void 0:Ye(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent())}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i,n){const r=new ga(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(e,t,i,n);return r}isIndoorDependent(){return this._isIndoorDependent}}class ma{constructor(e,t,i,n){this.property=e,this.value=t,this.parameters=i,this.iconImageUseTheme=n}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,n,r){return this.property.evaluate(this.value,this.parameters,e,t,i,n,this.iconImageUseTheme,r)}}class ga{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class _a{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const n=Ai[this.specification.type];return n?n(e,t,i):e}}class ya{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,n,r){return"constant"===e.expression.kind||"camera"===e.expression.kind?new ma(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,n,void 0,r)},t):new ma(this,e.expression,t,r)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new ma(this,{kind:"constant",value:void 0},e.parameters);const n=Ai[this.specification.type];return n?new ma(this,{kind:"constant",value:n(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,n,r,s,o,a){return"constant"===e.kind?e.value:e.evaluate(t,i,n,r,s,a,o)}}class va{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class xa{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new la(0,{});for(const i in e){const n=e[i],r=n.specification;r&&r.overridable&&this.overridableProperties.push(i);const s=this.defaultPropertyValues[i]=new ca(n,void 0),o=this.defaultTransitionablePropertyValues[i]=new ua(n);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=s.possiblyEvaluate(t)}}}lo(ya,"DataDrivenProperty"),lo(_a,"DataConstantProperty"),lo(va,"ColorRampProperty");var ba=JSON.parse('{"$version":8,"$root":{"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","line-progress"]},"transition":true,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function wa(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ta(e){if(Array.isArray(e))return e.map(Ta);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ta(e[i]);return t}return wa(e)}function Sa(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Sa(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Ea(e,t="",i=null,n="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Sa(e)||(e=Ra(e));const r=e;let s=!0;try{s=function(e){if(!Ia(e))return e;let t=Ta(e);return Ma(t),t=Aa(t),t}(r)}catch(e){}let o=null,a=null;if("background"!==n&&"sky"!==n&&"slot"!==n){a=ba[`filter_${n}`];const e=eo(s,a,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));o=(t,i,n)=>e.value.evaluate(t,i,{},n)}let l=null,c=null;if(s!==r){const e=eo(r,a,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,i,n,r,s)=>e.value.evaluate(t,i,{},n,void 0,void 0,r,s),c=!Ir(e.value.expression)}return{filter:o,dynamicFilter:l||void 0,needGeometry:La(s),needFeature:!!c}}function Aa(e){if(!Array.isArray(e))return e;const t=function(e){if(Ca.has(e[0]))for(let t=1;t<e.length;t++)if(Ia(e[t]))return!0;return e}(e);return!0===t?t:t.map(e=>Aa(e))}function Ma(e){let t=!1;const i=[];if("case"===e[0]){for(let n=1;n<e.length-1;n+=2)t=t||Ia(e[n]),i.push(e[n+1]);i.push(e.at(-1))}else if("match"===e[0]){t=t||Ia(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e.at(-1))}else if("step"===e[0]){t=t||Ia(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Ma(e[t])}function Ia(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Ia(e[t]))return!0;return!1}const Ca=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Pa(e,t){return e<t?-1:e>t?1:0}function La(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(La(e[t]))return!0;return!1}function Ra(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?Oa(e[1],e[2],"=="):"!="===t?Fa(Oa(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Oa(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Ra))):"all"===t?["all"].concat(e.slice(1).map(Ra)):"none"===t?["all"].concat(e.slice(1).map(Ra).map(Fa)):"in"===t?Da(e[1],e.slice(2)):"!in"===t?Fa(Da(e[1],e.slice(2))):"has"===t?Ba(e[1]):"!has"!==t||Fa(Ba(e[1]));var i}function Oa(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function Da(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(Pa)]]:["filter-in-small",e,["literal",t]]}}function Ba(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Fa(e){return["!",e]}const Na="";function ka(e,t){return t?`${e}${Na}${t}`:e}function za(e){const t=e.indexOf(Na);return t>=0?e.slice(t+1):""}let Ua;const Va=()=>Ua||(Ua=new xa({"icon-size":new ya(ba.layout_symbol["icon-size"]),"icon-image":new ya(ba.layout_symbol["icon-image"]),"icon-rotate":new ya(ba.layout_symbol["icon-rotate"]),"icon-offset":new ya(ba.layout_symbol["icon-offset"]),"text-size":new ya(ba.layout_symbol["text-size"]),"text-rotate":new ya(ba.layout_symbol["text-rotate"]),"text-offset":new ya(ba.layout_symbol["text-offset"])}));let ja;const Ga=()=>ja||(ja=new xa({"icon-opacity":new ya(ba.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ya(ba.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ya(ba.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ya(ba.paint_symbol["text-emissive-strength"]),"icon-color":new ya(ba.paint_symbol["icon-color"]),"icon-halo-color":new ya(ba.paint_symbol["icon-halo-color"]),"icon-halo-width":new ya(ba.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ya(ba.paint_symbol["icon-halo-blur"]),"icon-translate":new ya(ba.paint_symbol["icon-translate"]),"text-opacity":new ya(ba.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ya(ba.paint_symbol["text-occlusion-opacity"]),"text-color":new ya(ba.paint_symbol["text-color"],{runtimeType:Oi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ya(ba.paint_symbol["text-halo-color"]),"text-halo-width":new ya(ba.paint_symbol["text-halo-width"]),"text-halo-blur":new ya(ba.paint_symbol["text-halo-blur"]),"text-translate":new ya(ba.paint_symbol["text-translate"]),"symbol-z-offset":new ya(ba.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}));class Ha{constructor(e,t,i,n,r,s){this._conditionSpec=e,this._propertiesSpec=i;const o=eo(e,ba.appearance.condition);if("success"===o.result&&(this.condition=o.value),this.name=t,i){this.layoutProperties=new ga(Va()),this.unevaluatedLayout=new fa(Va(),n,r,s),this.paintProperties=new ga(Ga()),this.unevaluatedPaint=new fa(Ga(),n,r,"");for(const e in i)e in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(e,i[e]):e in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(e,i[e])}}isActive(e){return!(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,i){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,i)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""))}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},i=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},n=Object.assign({},t,i);return Object.keys(n).length>0&&(e.properties=n),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),i=this.hasLayoutProperty("icon-offset"),n=this.hasLayoutProperty("icon-rotate");return e||t||i||n}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),i=this.hasLayoutProperty("text-rotate");return e||t||i}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[e].value}hasPaintProperty(e){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[e].value}}const Wa="-transition",qa=new Set(["fill","line","background","hillshade","raster"]);class Xa extends mi{constructor(e,t,i,n,r,s){if(super(),this.id=e.id,this.fqid=ka(this.id,i),this.type=e.type,this.scope=i,this.lut=n,this.options=r,this.iconImageUseTheme=s,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const t=eo(this.filter,ba[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new fa(t.layout,this.scope,r,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new ha(t.paint,this.scope,r);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ga(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&qa.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new Ha(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(Wa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const i=this._transitionablePaint,n=i._properties.properties;if(e.endsWith(Wa)){const r=e.slice(0,-11);return n[r]&&i.setTransition(r,t||void 0),!1}if(!n[e])return!1;const r=i._values[e],s=r.value.isDataDriven(),o=r.value;i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=e.endsWith("pattern")||"line-dasharray"===e;return l||s||c||this._handleOverridablePaintPropertyUpdate(e,o,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),Ze(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ma&&Us(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!Cr(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=Ea(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,i){return{}}queryRadius(e){}queryIntersectsFeature(e,t,i,n,r,s,o,a,l,c){}}const $a={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Za{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Ya=new ArrayBuffer(0);class Ja{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=Ya),t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this._reallocCount++,this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}reserveForAdditional(e){this.reserve(this.length+e)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ka(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=$a[e.type].BYTES_PER_ELEMENT,s=i=Qa(i,Math.max(t,r)),o=e.components||1;return n=Math.max(n,r),i+=r*o,{name:e.name,type:e.type,components:o,offset:s}}),size:Qa(i,Math.max(n,t)),alignment:t}}function Qa(e,t){return Math.ceil(e/t)*t}class el extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}el.prototype.bytesPerElement=4,lo(el,"StructArrayLayout2i4");class tl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}tl.prototype.bytesPerElement=6,lo(tl,"StructArrayLayout3i6");class il extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,e}}il.prototype.bytesPerElement=8,lo(il,"StructArrayLayout2i2ui8");class nl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}nl.prototype.bytesPerElement=4,lo(nl,"StructArrayLayout1f4");class rl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e,s=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.float32[s+1]=n,e}}rl.prototype.bytesPerElement=8,lo(rl,"StructArrayLayout2i1f8");class sl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}sl.prototype.bytesPerElement=8,lo(sl,"StructArrayLayout3i8");class ol extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,e}}ol.prototype.bytesPerElement=8,lo(ol,"StructArrayLayout4i8");class al extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r)}emplace(e,t,i,n,r,s){const o=5*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,this.int16[o+4]=s,e}}al.prototype.bytesPerElement=10,lo(al,"StructArrayLayout5i10");class ll extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,s,o)}emplace(e,t,i,n,r,s,o,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=s,this.uint8[c+7]=o,this.float32[u+2]=a,e}}ll.prototype.bytesPerElement=12,lo(ll,"StructArrayLayout2i4ub1f12");class cl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}cl.prototype.bytesPerElement=12,lo(cl,"StructArrayLayout3f12");class ul extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r)}emplace(e,t,i,n,r,s){const o=6*e,a=3*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,this.float32[a+2]=s,e}}ul.prototype.bytesPerElement=12,lo(ul,"StructArrayLayout4ui1f12");class hl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const s=4*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,e}}hl.prototype.bytesPerElement=8,lo(hl,"StructArrayLayout4ui8");class dl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r,s)}emplace(e,t,i,n,r,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=s,this.int16[a+5]=o,e}}dl.prototype.bytesPerElement=12,lo(dl,"StructArrayLayout6i12");class pl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,s,o,a,l,c,u,h)}emplace(e,t,i,n,r,s,o,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=s,this.uint16[p+5]=o,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}pl.prototype.bytesPerElement=24,lo(pl,"StructArrayLayout4i4ui4i24");class fl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r,s)}emplace(e,t,i,n,r,s,o){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=s,this.float32[l+4]=o,e}}fl.prototype.bytesPerElement=20,lo(fl,"StructArrayLayout3i3f20");class ml extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,e}}ml.prototype.bytesPerElement=16,lo(ml,"StructArrayLayout4f16");class gl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}gl.prototype.bytesPerElement=4,lo(gl,"StructArrayLayout1ul4");class _l extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}_l.prototype.bytesPerElement=4,lo(_l,"StructArrayLayout2ui4");class yl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,n,r,s,o,a,l,c,u,h,d)}emplace(e,t,i,n,r,s,o,a,l,c,u,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=s,this.float32[m+3]=o,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}yl.prototype.bytesPerElement=40,lo(yl,"StructArrayLayout5i4f1i1ul2ui40");class vl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,s,o)}emplace(e,t,i,n,r,s,o,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=s,this.int16[l+6]=o,this.int16[l+7]=a,e}}vl.prototype.bytesPerElement=16,lo(vl,"StructArrayLayout3i2i2i16");class xl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r)}emplace(e,t,i,n,r,s){const o=4*e,a=8*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.int16[a+6]=r,this.int16[a+7]=s,e}}xl.prototype.bytesPerElement=16,lo(xl,"StructArrayLayout2f1f2i16");class bl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r,s)}emplace(e,t,i,n,r,s,o){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=s,this.float32[l+4]=o,e}}bl.prototype.bytesPerElement=20,lo(bl,"StructArrayLayout2ub4f20");class wl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}wl.prototype.bytesPerElement=6,lo(wl,"StructArrayLayout3ui6");class Tl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x)}emplace(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b){const w=30*e,T=15*e,S=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=s,this.uint16[w+8]=o,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=g,this.uint8[S+49]=_,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,e}}Tl.prototype.bytesPerElement=60,lo(Tl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Sl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E,A,M,I,C,P,L,R){const O=this.length;return this.resize(O+1),this.emplace(O,e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E,A,M,I,C,P,L,R)}emplace(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E,A,M,I,C,P,L,R,O){const D=20*e,B=40*e,F=80*e;return this.float32[D+0]=t,this.float32[D+1]=i,this.int16[B+4]=n,this.int16[B+5]=r,this.int16[B+6]=s,this.int16[B+7]=o,this.int16[B+8]=a,this.int16[B+9]=l,this.int16[B+10]=c,this.int16[B+11]=u,this.int16[B+12]=h,this.uint16[B+13]=d,this.uint16[B+14]=p,this.uint16[B+15]=f,this.uint16[B+16]=m,this.uint16[B+17]=g,this.uint16[B+18]=_,this.uint16[B+19]=y,this.uint16[B+20]=v,this.uint16[B+21]=x,this.uint16[B+22]=b,this.uint16[B+23]=w,this.uint16[B+24]=T,this.uint16[B+25]=S,this.uint16[B+26]=E,this.uint16[B+27]=A,this.uint32[D+14]=M,this.float32[D+15]=I,this.float32[D+16]=C,this.float32[D+17]=P,this.float32[D+18]=L,this.uint8[F+76]=R,this.uint16[B+39]=O,e}}Sl.prototype.bytesPerElement=80,lo(Sl,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class El extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r,s)}emplace(e,t,i,n,r,s,o){const a=6*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=n,this.float32[a+3]=r,this.float32[a+4]=s,this.float32[a+5]=o,e}}El.prototype.bytesPerElement=24,lo(El,"StructArrayLayout6f24");class Al extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r)}emplace(e,t,i,n,r,s){const o=5*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,this.float32[o+4]=s,e}}Al.prototype.bytesPerElement=20,lo(Al,"StructArrayLayout5f20");class Ml extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,s,o)}emplace(e,t,i,n,r,s,o,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=s,this.float32[l+5]=o,this.float32[l+6]=a,e}}Ml.prototype.bytesPerElement=28,lo(Ml,"StructArrayLayout7f28");class Il extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,n,r,s,o,a,l,c,u)}emplace(e,t,i,n,r,s,o,a,l,c,u,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=i,this.float32[d+2]=n,this.float32[d+3]=r,this.float32[d+4]=s,this.float32[d+5]=o,this.float32[d+6]=a,this.float32[d+7]=l,this.float32[d+8]=c,this.float32[d+9]=u,this.float32[d+10]=h,e}}Il.prototype.bytesPerElement=44,lo(Il,"StructArrayLayout11f44");class Cl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,s,o,a,l)}emplace(e,t,i,n,r,s,o,a,l,c){const u=9*e;return this.float32[u+0]=t,this.float32[u+1]=i,this.float32[u+2]=n,this.float32[u+3]=r,this.float32[u+4]=s,this.float32[u+5]=o,this.float32[u+6]=a,this.float32[u+7]=l,this.float32[u+8]=c,e}}Cl.prototype.bytesPerElement=36,lo(Cl,"StructArrayLayout9f36");class Pl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}Pl.prototype.bytesPerElement=8,lo(Pl,"StructArrayLayout2f8");class Ll extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const s=6*e;return this.uint32[3*e+0]=t,this.uint16[s+2]=i,this.uint16[s+3]=n,this.uint16[s+4]=r,e}}Ll.prototype.bytesPerElement=12,lo(Ll,"StructArrayLayout1ul3ui12");class Rl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Rl.prototype.bytesPerElement=2,lo(Rl,"StructArrayLayout1ui2");class Ol extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m)}emplace(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g){const _=16*e;return this.float32[_+0]=t,this.float32[_+1]=i,this.float32[_+2]=n,this.float32[_+3]=r,this.float32[_+4]=s,this.float32[_+5]=o,this.float32[_+6]=a,this.float32[_+7]=l,this.float32[_+8]=c,this.float32[_+9]=u,this.float32[_+10]=h,this.float32[_+11]=d,this.float32[_+12]=p,this.float32[_+13]=f,this.float32[_+14]=m,this.float32[_+15]=g,e}}Ol.prototype.bytesPerElement=64,lo(Ol,"StructArrayLayout16f64");class Dl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,s,o)}emplace(e,t,i,n,r,s,o,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=s,this.float32[c+3]=o,this.float32[c+4]=a,e}}Dl.prototype.bytesPerElement=20,lo(Dl,"StructArrayLayout4ui3f20");class Bl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}Bl.prototype.bytesPerElement=2,lo(Bl,"StructArrayLayout1i2");class Fl extends Ja{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}Fl.prototype.bytesPerElement=1,lo(Fl,"StructArrayLayout1ub1");class Nl extends Za{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Nl.prototype.size=40;class kl extends yl{get(e){return new Nl(this,e)}}lo(kl,"CollisionBoxArray");class zl extends Za{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}zl.prototype.size=60;class Ul extends Tl{get(e){return new zl(this,e)}}lo(Ul,"PlacedSymbolArray");class Vl extends Za{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}Vl.prototype.size=80;class jl extends Sl{get(e){return new Vl(this,e)}}lo(jl,"SymbolInstanceArray");class Gl extends nl{getoffsetX(e){return this.float32[1*e+0]}}lo(Gl,"GlyphOffsetArray");class Hl extends el{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}lo(Hl,"SymbolLineVertexArray");class Wl extends Za{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Wl.prototype.size=12;class ql extends Ll{get(e){return new Wl(this,e)}}lo(ql,"FeatureIndexArray");class Xl extends _l{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}lo(Xl,"FillExtrusionCentroidArray");class $l extends Za{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}$l.prototype.size=6;class Zl extends tl{get(e){return new $l(this,e)}}lo(Zl,"FillExtrusionWallArray");const Yl=Ka([{name:"a_pos",components:2,type:"Int16"}],4),Jl=Ka([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Kl=Ka([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Ql{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,n,r){let s=this.segments.at(-1);return e>Ql.MAX_VERTEX_ARRAY_LENGTH&&Qe(`Max vertices per segment is ${Ql.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>Ql.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n||void 0!==r&&s&&void 0!==s.batchIndex&&s.batchIndex!==r)&&(s={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(s.sortKey=n),void 0!==r&&(s.batchIndex=r),this.segments.push(s)),s}prepareSegment(e,t,i,n,r){return this._prepareSegment(e,t.length,i.length,n,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,n){return new Ql([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function ec(e,t){return 256*(e=ze(Math.floor(e),0,255))+ze(Math.floor(t),0,255)}Ql.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,lo(Ql,"SegmentVector");const tc=Ka([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ic=Ka([{name:"a_pattern_b",components:4,type:"Uint16"}]),nc=Ka([{name:"a_dash",components:4,type:"Uint16"}]);class rc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(sc(e)),this.positions.push(t,i,n)}eachPosition(e,t){const i=sc(e);let n=0,r=this.ids.length-1;for(;n<r;){const e=n+r>>1;this.ids[e]>=i?r=e:n=e+1}for(;this.ids[n]===i;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return oc(i,n,0,i.length-1),t&&(t.add(i.buffer),t.add(n.buffer)),{ids:i,positions:n}}static deserialize(e){const t=new rc;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function sc(e){const t=+e;return Number.isSafeInteger(t)?t:ui(String(e))}function oc(e,t,i,n){for(;i<n;){const r=e[i+n>>1];let s=i-1,o=n+1;for(;;){do{s++}while(e[s]<r);do{o--}while(e[o]>r);if(s>=o)break;ac(e,s,o),ac(t,3*s,3*o),ac(t,3*s+1,3*o+1),ac(t,3*s+2,3*o+2)}o-i<n-o?(oc(e,t,i,o),i=o+1):(oc(e,t,o+1,n),n=o)}}function ac(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}lo(rc,"FeaturePositionMap");class lc{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,i){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class cc extends lc{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class uc extends lc{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class hc extends lc{constructor(e){super(e),this.current=[0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class dc extends lc{constructor(e){super(e),this.current=[0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class pc extends lc{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4ui(this.location,i[0],i[1],i[2],i[3])))}}class fc extends lc{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class mc extends lc{constructor(e){super(e),this.current=bi.transparent.toPremultipliedRenderColor(null)}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}class gc extends lc{constructor(e){super(e),this.current=new Float32Array(16)}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;if(i[12]!==n[12]||i[0]!==n[0])return n.set(i),void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix4fv(this.location,!1,n);break}}}class _c extends lc{constructor(e){super(e),this.current=new Float32Array(4)}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<4;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix2fv(this.location,!1,n);break}}}function yc(e){return[ec(255*e.r,255*e.g),ec(255*e.b,255*e.a)]}function vc(e,t,i,n,r,s,o,a){return!!e&&("composite"===e.kind||"source"===e.kind?"none"===e.evaluate(new la(0,{brightness:s,worldview:a}),t,i,r,n,o):"none"===e.value)}class xc{constructor(e,t,i,n){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i,this.context=n}setUniform(e,t,i,n,r){const s=n.constantOr(this.value);t.set(e,r,s instanceof bi?s.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):s)}getBinding(e,t){return"color"===this.type?new mc(e):new uc(e)}}class bc{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern}setUniform(e,t,i,n,r){let s=null;"u_pattern"!==r&&"u_dash"!==r||(s=this.pattern),"u_pattern_b"===r&&(s=this.patternTransition),"u_pixel_ratio"===r&&(s=this.pixelRatio),s&&t.set(e,r,s)}getBinding(e,t){return"u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new pc(e):new uc(e)}}class wc{constructor(e,t,i,n){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i,n,r,s,o,a){const l=this.paintVertexArray.length,c="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new la(0,{brightness:s,worldview:a}),t,{},r,n,o):"constant"===this.expression.kind&&this.expression.value,u=vc(this.lutExpression,t,{},n,r,s,o,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c,u?null:this.context.lut)}updatePaintArray(e,t,i,n,r,s,o,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:o,worldview:a},i,n,void 0,r):"constant"===this.expression.kind&&this.expression.value,c=vc(this.lutExpression,i,n,r,void 0,o,void 0,a);this._setPaintValue(e,t,l,c?null:this.context.lut)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=yc(i.toPremultipliedRenderColor(n));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Tc{constructor(e,t,i,n,r,s){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,t,i,n,r,s,o,a){const l=this.expression.evaluate(new la(this.context.zoom,{brightness:s,worldview:a}),t,{},r,n,o),c=this.expression.evaluate(new la(this.context.zoom+1,{brightness:s,worldview:a}),t,{},r,n,o),u=vc(this.lutExpression,t,{},n,r,s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,c,u?null:this.context.lut)}updatePaintArray(e,t,i,n,r,s,o,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:o,worldview:a},i,n,void 0,r),c=this.expression.evaluate({zoom:this.context.zoom+1,brightness:o,worldview:a},i,n,void 0,r),u=vc(this.lutExpression,i,n,r,void 0,o,void 0,a);this._setPaintValue(e,t,l,c,u?null:this.context.lut)}_setPaintValue(e,t,i,n,r){if("color"===this.type){const s=yc(i.toPremultipliedRenderColor(r)),o=yc(n.toPremultipliedRenderColor(r));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,s[0],s[1],o[0],o[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i,n);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,i,n,r){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,o=ze(this.expression.interpolationFactor(s,this.context.zoom,this.context.zoom+1),0,1);t.set(e,r,o)}getBinding(e,t){return new uc(e)}}class Sc{constructor(e,t,i,n,r){this.expression=e,this.layerId=r,this.paintVertexAttributes=("array"===i?nc:tc).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new n,this.paintTransitionVertexArray=new hl}populatePaintArray(e,t,i,n){const r=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,n,r,s,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],s)}_setPaintValues(e,t,i,n){if(!n||!i)return;const r=n[i[0]],s=n[i[1]];if(r){if(r){const{tl:i,br:n,pixelRatio:s}=r;for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i[0],i[1],n[0],n[1],s)}if(s){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:i,br:n}=s;for(let r=e;r<t;r++)this.paintTransitionVertexArray.emplace(r,i[0],i[1],n[0],n[1])}}}upload(e){const t=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,t)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,ic.members,t))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class Ec{constructor(e,t,i=()=>!0){this.binders={},this._buffers=[],this.context=t;const n=[],r=e;for(const s in e.paint._values){const o=r.paint.get(s);if(s.endsWith("-use-theme"))continue;if(!i(s))continue;if(!(o instanceof ma&&Us(o.property.specification)))continue;const a=Ic(s,e.type),l=o.value,c=o.property.specification.type,u=!!o.property.useIntegerZoom,h="line-dasharray"===s||s.endsWith("pattern"),d=r.paint.get(`${s}-use-theme`),p="line-dasharray"===s&&"constant"!==r.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||h){const t=Lc(s,c,"source");this.binders[s]=h?new Sc(l,a,c,t,e.id):new wc(l,a,c,t),n.push(`/a_${s}`)}else{const e=Lc(s,c,"composite");this.binders[s]=new Tc(l,a,c,u,t,e),n.push(`/z_${s}`)}else this.binders[s]=h?new bc(l.value,a):new xc(l.value,a,c,t),n.push(`/u_${s}`);d&&(this.binders[s].lutExpression=d.value)}this.cacheKey=n.sort().join("")}updateExpressions(e){const t=e;for(const e in this.binders){const i=this.binders[e];if(i instanceof wc||i instanceof Tc||i instanceof Sc){const n=t.paint.get(e);i.expression=n.value}}}getMaxValue(e){const t=this.binders[e];return t instanceof wc||t instanceof Tc?t.maxValue:0}populatePaintArrays(e,t,i,n,r,s,o,a){for(const l in this.binders){const c=this.binders[l];c.context=this.context,(c instanceof wc||c instanceof Tc||c instanceof Sc)&&c.populatePaintArray(e,t,i,n,r,s,o,a)}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof bc&&n.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof Sc?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,i,n,r,s,o,a,l,c){let u=!1;const h=Object.keys(e),d=0!==h.length&&!a,p=d?h:t.uniqueIds;this.context.lut=r.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof wc||h instanceof Tc||h instanceof Sc)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=r.paint.get(a);h.expression=f.value;for(const i of p){const r=e[i.toString()];t.eachPosition(i,(e,t,i)=>{const a=n.feature(e);h.updatePaintArray(t,i,a,r,s,o,l,c)})}if(!d)for(const t of i.uniqueIds){const r=e[t.toString()];i.eachPosition(t,(e,t,i)=>{const a=n.feature(e);h.updatePaintArray(t,i,a,r,s,o,l,c)})}u=!0}}return u}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof xc||i instanceof bc)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof xc||n instanceof bc||n instanceof Tc)for(const r of n.uniformNames)t.push({name:r,property:i,binding:n.getBinding(e,r)})}return t}setUniforms(e,t,i,n,r){for(const{name:t,property:s,binding:o}of i)this.binders[s].setUniform(e,o,r,n.get(s),t)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof wc||t instanceof Tc||t instanceof Sc)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof Sc&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof wc||i instanceof Tc||i instanceof Sc)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof wc||t instanceof Tc||t instanceof Sc)&&t.destroy()}}}class Ac{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ec(n,t,i);this.needsUpload=!1,this._featureMap=new rc,this._featureMapWithoutIds=new rc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,n,r,s,o,a,l){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,s,o,a,l);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n,r,s,o,a){for(const l of i)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,r,s,o||0,a)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}updateExpressions(e){const t=new Set;for(const i of e){const e=this.programConfigurations[i.id];e&&(e.updateExpressions(i),t.add(i.id))}for(const e in this.programConfigurations)t.has(e)||delete this.programConfigurations[e]}}const Mc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function Ic(e,t){return Mc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Cc={"line-pattern":{source:ul,composite:ul},"fill-pattern":{source:ul,composite:ul},"fill-extrusion-pattern":{source:ul,composite:ul},"line-dasharray":{source:hl,composite:hl}},Pc={color:{source:Pl,composite:ml},number:{source:nl,composite:Pl}};function Lc(e,t,i){const n=Cc[e];return n&&n[i]||Pc[t][i]}lo(xc,"ConstantBinder"),lo(bc,"PatternConstantBinder"),lo(wc,"SourceExpressionBinder",{omit:["expression"]}),lo(Sc,"PatternCompositeBinder",{omit:["expression"]}),lo(Tc,"CompositeExpressionBinder",{omit:["expression"]}),lo(Ec,"ProgramConfiguration",{omit:["_buffers"]}),lo(Ac,"ProgramConfigurationSet");const Rc=Qn/Math.PI/2,Oc=64,Dc=[Oc,32,16],Bc=-Rc,Fc=Rc;function Nc(e,t,i,n=Rc){return i=Oe(i),[e*Math.sin(i)*n,-t*n,e*Math.cos(i)*n]}function kc(e,t,i){return Nc(Math.cos(Oe(e)),Math.sin(Oe(e)),t,i)}const zc=6371008.8,Uc=2*Math.PI*zc;class Vc{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Vc(Ve(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return zc*Math.acos(Math.min(r,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new jc({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return kc(this.lat,this.lng,Rc+e*Rc/zc)}static convert(e){if(e instanceof Vc)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Vc(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Vc(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class jc{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof Vc?new Vc(e.lng,e.lat):Vc.convert(e),this}setSouthWest(e){return this._sw=e instanceof Vc?new Vc(e.lng,e.lat):Vc.convert(e),this}extend(e){const t=this._sw,i=this._ne;let n,r;if(e instanceof Vc)n=e,r=e;else{if(!(e instanceof jc))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(jc.convert(e)):this.extend(Vc.convert(e)):"object"==typeof e&&null!==e&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(Vc.convert(e)):this;if(n=e._sw,r=e._ne,!n||!r)return this}return t||i?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new Vc(n.lng,n.lat),this._ne=new Vc(r.lng,r.lat)),this}getCenter(){return new Vc((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Vc(this.getWest(),this.getNorth())}getSouthEast(){return new Vc(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=Vc.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}static convert(e){if(e)return e instanceof jc?e:new jc(e)}}function Gc(e){return Uc*Math.cos(e*Math.PI/180)}function Hc(e){return(180+e)/360}function Wc(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function qc(e,t){return e/Gc(t)}function Xc(e){return 360*e-180}function $c(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Zc(e,t){return e*Gc($c(t))}const Yc=85.051129;function Jc(e){return Math.cos(Oe(ze(e,-85.051129,Yc)))}function Kc(e,t){const i=ze(t,0,25.5),n=Math.pow(2,i);return Jc(e)*Uc/(512*n)}function Qc(e){return 1/Math.cos(e*Math.PI/180)}function eu(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Qn)/(1<<e.z)*2));return 80150034*i/(i*i+1)/Qn/(1<<e.z)}class tu{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=Vc.convert(e);return new tu(Hc(i.lng),Wc(i.lat),qc(t,i.lat))}toLngLat(){return new Vc(Xc(this.x),$c(this.y))}toAltitude(){return Zc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Uc*Qc($c(this.y))}}function iu(e,t,i,n,r,s,o,a,l){const c=(t+n)/2,u=(i+r)/2,h=new Ae(c,u);a(h),function(e,t,i,n,r,s){const o=i-r,a=n-s;return Math.abs((n-t)*o-(i-e)*a)/Math.hypot(o,a)}(h.x,h.y,s.x,s.y,o.x,o.y)>=l?(iu(e,t,i,c,u,s,h,a,l),iu(e,c,u,n,r,h,o,a,l)):e.push(o)}function nu(e,t,i){let n=e[0],r=n.x,s=n.y;t(n);const o=[n];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:u}=l;t(l),iu(o,r,s,c,u,n,l,t,i),r=c,s=u,n=l}return o}function ru(e,t,i,n){if(n(t,i)){const r=t.add(i)._mult(.5);ru(e,t,r,n),ru(e,r,i,n)}else e.push(i)}function su(e,t){let i=e[0];const n=[i];for(let r=1;r<e.length;r++){const s=e[r];ru(n,i,s,t),i=s}return n}const ou=Math.pow(2,14)-1,au=-ou-1;function lu(e,t){const i=Math.round(e.x*t),n=Math.round(e.y*t);return e.x=ze(i,au,ou),e.y=ze(n,au,ou),(i<e.x||i>e.x+1||n<e.y||n>e.y+1)&&Qe("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function cu(e,t,i){const n=e.loadGeometry(),r=e.extent,s=Qn/r;if(t&&i&&i.projection.isReprojectedInTileSpace){const s=1<<t.z,{scale:o,x:a,y:l,projection:c}=i,u=e=>{const i=Xc((t.x+e.x/r)/s),n=$c((t.y+e.y/r)/s),u=c.project(i,n);e.x=(u.x*o-a)*r,e.y=(u.y*o-l)*r};for(let t=0;t<n.length;t++)if(1!==e.type)n[t]=nu(n[t],u,1);else{const e=[];for(const i of n[t])i.x<0||i.x>=r||i.y<0||i.y>=r||(u(i),e.push(i));n[t]=e}}for(const e of n)for(const t of e)lu(t,s);return n}function uu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?cu(e):[]}}class hu{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(du,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let n,r=1,s=0,o=0,a=0;for(;e.pos<t;){if(s<=0){const t=e.readVarint();r=7&t,s=t>>3}if(s--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(n&&i.push(n),n=[]),n&&n.push(new Ae(o,a));else{if(7!==r)throw new Error(`unknown command ${r}`);n&&n.push(n[0].clone())}}return n&&i.push(n),i}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,s=0,o=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos<t;){if(n<=0){const t=e.readVarint();i=7&t,n=t>>3}if(n--,1===i||2===i)r+=e.readSVarint(),s+=e.readSVarint(),r<o&&(o=r),r>a&&(a=r),s<l&&(l=s),s>c&&(c=s);else if(7!==i)throw new Error(`unknown command ${i}`)}return[o,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,s=this.extent*t,o=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of o)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=o.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let s=0;s<t;s++){const t=pu(e[s]);0!==t&&(void 0===r&&(r=t<0),r===t<0?(n&&i.push(n),n=[e[s]]):n&&n.push(e[s]))}return n&&i.push(n),i}(o),t=[];for(const i of e)t.push(i.map(l));c=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}const u={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(u.id=this.id),u}}function du(e,t,i){1===e?t.id=i.readVarint():2===e?function(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[i]=n}}(i,t):3===e?t.type=i.readVarint():4===e&&(t._geometry=i.pos)}function pu(e){let t=0;for(let i,n,r=0,s=e.length,o=s-1;r<s;o=r++)i=e[r],n=e[o],t+=(n.x-i.x)*(i.y+n.y);return t}hu.types=["Unknown","Point","LineString","Polygon"];class fu{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(mu,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new hu(this._pbf,t,this.extent,this._keys,this._values)}}function mu(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class gu{constructor(e,t){this.layers=e.readFields(_u,{},t)}}function _u(e,t,i){if(3===e){const e=new fu(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const yu="3d_elevation_id",vu="level";class xu{constructor(){this._valid=!1}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,i){return this.get(e,!0,t,i)}optional(e,t,i){return this.get(e,!1,t,i)}success(){return this._valid}get(e,t,i,n){const r=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==r&&!Number.isNaN(r)?i(n?n(r):r):t&&(this._valid=!1),this}}class bu{constructor(e,t){this.featureFunc=e,this.vertexFunc=t}parseFeature(e,t,i){return this.featureFunc(e,t,i)}parseVertex(e,t,i){return this.vertexFunc(e,t,i)}}const wu=new bu((e,t,i)=>e.reset(t).require(yu,e=>{i.id=e}).optional("fixed_height_relative",e=>{i.constantHeight=e},Su.decodeRelativeHeight).geometry(e=>{i.bounds=e},Ln).success(),(e,t,i)=>e.reset(t).require(yu,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height_relative",e=>{i.height=e},Su.decodeRelativeHeight).geometry(e=>{i.position=e},Su.getPoint).success()),Tu=new bu((e,t,i)=>e.reset(t).require(yu,e=>{i.id=e}).optional("fixed_height",e=>{i.constantHeight=e},Su.decodeMetricHeight).geometry(e=>{i.bounds=e},Ln).success(),(e,t,i)=>e.reset(t).require(yu,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height",e=>{i.height=e},Su.decodeMetricHeight).geometry(e=>{i.position=e},Su.getPoint).success());class Su{static getPoint(e){return de(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?Tu:void 0:wu}static parse(e){const t=[],i=[],n=e.length,r=new xu;for(let s=0;s<n;s++){const n=e.feature(s),o=n.properties.version,a=Su.getVersionSchema(o);if(void 0===a){Qe(`Unknown elevation feature version number ${o||"(unknown)"}`);continue}const l=n.properties.type;if(!l)continue;const c=hu.types[n.type];if("Point"===c&&"curve_point"===l){const e={};a.parseVertex(r,n,e)&&t.push(e)}else if("Polygon"===c&&"curve_meta"===l){const e={};a.parseFeature(r,n,e)&&i.push(e)}}return{vertices:t,features:i}}}class Eu{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const n=ve(t,this.dir);if(Math.abs(n)<1e-6)return!1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,!0}}class Au{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const n=V(t,this.dir);if(Math.abs(n)<1e-6)return!1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,i[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],r=e[1],s=e[2],o=t[0],a=t[1],l=t[2];return Math.abs(n-o)<=i*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=i*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(s-l)<=i*Math.max(1,Math.abs(s),Math.abs(l))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[r,s,o]=this.dir,a=this.pos[0]-e[0],l=this.pos[1]-e[1],c=this.pos[2]-e[2],u=r*r+s*s+o*o,h=2*(a*r+l*s+c*o),d=h*h-4*u*(a*a+l*l+c*c-t*t);if(d<0){const e=Math.max(-h/2,0),i=a+r*e,u=l+s*e,d=c+o*e,p=Math.hypot(i,u,d);return n[0]=i*t/p,n[1]=u*t/p,n[2]=d*t/p,!1}{const e=(-h-Math.sqrt(d))/(2*u);if(e<0){const e=Math.hypot(a,l,c);return n[0]=a*t/e,n[1]=l*t/e,n[2]=c*t/e,!1}return n[0]=a+r*e,n[1]=l+s*e,n[2]=c+o*e,!0}}}class Mu{constructor(e,t,i,n,r){this.TL=e,this.TR=t,this.BR=i,this.BL=n,this.horizon=r}static fromInvProjectionMatrix(e,t,i){const n=[-1,1,1],r=[1,1,1],s=[1,-1,1],o=[-1,-1,1],a=H(n,n,e),l=H(r,r,e),c=H(s,s,e),u=H(o,o,e);return new Mu(a,l,c,u,t/i)}}function Iu(e,t,i,n){const r=t[0],s=t[1],o=t[2],a=i[0],l=i[1],c=i[2];let u=1/0,h=-1/0;for(let t=0;t<e.length;t++){const i=e[t],n=(i[0]-r)*a+(i[1]-s)*l+(i[2]-o)*c;n<u&&(u=n),n>h&&(h=n)}return n[0]=u,n[1]=h,n}function Cu(e,t){let i=!0;for(let n=0;n<e.planes.length;n++){const r=e.planes[n];let s=0;for(let e=0;e<t.length;e++)s+=+(V(r,t[e])+r[3]>=0);if(0===s)return 0;s!==t.length&&(i=!1)}return i?2:1}const Pu=[0,0];function Lu(e,t){for(const i of e.projections){const n=Iu(t,e.points[0],i.axis,Pu);if(i.projection[1]<n[0]||i.projection[0]>n[1])return 0}return 1}function Ru(e,t){const i=t[0],n=t[1],r=t[2],s=t[3];for(let t=0;t<e.length;t++){const o=e[t];if(i*o[0]+n*o[1]+r*o[2]+s>=0)return!0}return!1}class Ou{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=Du.fromPoints(this.points),this.projections=[],this.frustumEdges=[Z([],this.points[2],this.points[3]),Z([],this.points[0],this.points[3]),Z([],this.points[4],this.points[0]),Z([],this.points[5],this.points[1]),Z([],this.points[6],this.points[2]),Z([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Iu(this.points,this.points[0],t,[0,0])}),this.projections.push({axis:i,projection:Iu(this.points,this.points[0],i,[0,0])})}}static fromInvProjectionMatrix(e,t,i,n){const r=Math.pow(2,i),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(i=>{const s=te([],i,e),o=1/s[3]/t*r;return(a=s)[0]=(l=s)[0]*(c=[o,o,n?1/s[3]:o,o])[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a;var a,l,c}),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=U([],j([],Z([],s[e[0]],s[e[1]]),Z([],s[e[2]],s[e[1]]))),i=-V(t,s[e[1]]);return t.concat(i)}),a=[];for(let e=0;e<s.length;e++)a.push([s[e][0],s[e][1],s[e][2]]);return new Ou(a,o)}intersectsPrecise(e,t,i){for(let i=0;i<t.length;i++)if(!Ru(e,t[i]))return 0;for(let t=0;t<this.planes.length;t++)if(!Ru(e,this.planes[t]))return 0;const n=this.points,r=n[0][0],s=n[0][1],o=n[0][2];for(const t of i)for(const i of this.frustumEdges){const a=t[1]*i[2]-t[2]*i[1],l=t[2]*i[0]-t[0]*i[2],c=t[0]*i[1]-t[1]*i[0];if(0===a&&0===l&&0===c)continue;let u=1/0,h=-1/0;for(let e=0;e<n.length;e++){const t=n[e],i=(t[0]-r)*a+(t[1]-s)*l+(t[2]-o)*c;i<u&&(u=i),i>h&&(h=i)}let d=1/0,p=-1/0;for(let t=0;t<e.length;t++){const i=e[t],n=(i[0]-r)*a+(i[1]-s)*l+(i[2]-o)*c;n<d&&(d=n),n>p&&(p=n)}if(u>p||d>h)return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(V([t[0],t[1],t[2]],e)+i<0)return!1}return!0}}class Du{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const n of e)R(t,t,n),O(i,i,n);return new Du(t,i)}static fromTileIdAndHeight(e,t,i){const n=1<<e.canonical.z,r=e.canonical.x,s=e.canonical.y;return new Du([r/n,s/n,t],[(r+1)/n,(s+1)/n,i])}static applyTransform(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)H(i[e],i[e],t);return Du.fromPoints(i)}static applyTransformFast(e,t){const i=[t[12],t[13],t[14]],n=[...i];for(let r=0;r<3;r++)for(let s=0;s<3;s++){const o=t[4*s+r],a=o*e.min[s],l=o*e.max[s];i[r]+=Math.min(a,l),n[r]+=Math.max(a,l)}return new Du(i,n)}static projectAabbCorners(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)H(i[e],i[e],t);return i}constructor(e,t){this.min=e,this.max=t,this.center=D([],C([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=E(this.min),n=E(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],n[e]=t[e]?this.center[e]:this.max[e];return n[2]=this.max[2],new Du(i,n)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Cu(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Cu(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?Lu(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Lu(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}lo(Du,"Aabb");class Bu{constructor(e,t){this.feature=e,this.metersToTile=t,this.index=0}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,i=t[1],n=-t[0],r=(e.extent+1)*this.metersToTile;return[new Ae(Math.trunc(e.position[0]+i*r),Math.trunc(e.position[1]+n*r)),new Ae(Math.trunc(e.position[0]-i*r),Math.trunc(e.position[1]-n*r))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class Fu{constructor(e,t,i,n,r,s){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[he(),he(),he(),he(),he(),he(),he()],this.id=e,this.heightRange={min:i,max:i},this.safeArea=t,this.constantHeight=i,null==this.constantHeight&&(null!=this.constantHeight||0!==n.length)){this.vertices=n,this.edges=r,this.edges=this.edges.filter(e=>{return e.a<this.vertices.length&&e.b<this.vertices.length&&!((t=this.vertices[e.a].position)[0]===(i=this.vertices[e.b].position)[0]&&t[1]===i[1]);var t,i}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const e of this.vertices)this.vertexProps.push({dir:de(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,e.height),this.heightRange.max=Math.max(this.heightRange.max,e.height);for(const e of this.edges){const t=this.vertices[e.a].position,i=this.vertices[e.b].position,n=me(he(),i,t),r=_e(n),s=ge(he(),n,1/r);this.edgeProps.push({vec:n,dir:s,len:r});const o=this.vertexProps[e.a].dir,a=this.vertexProps[e.b].dir;fe(o,o,s),fe(a,a,s)}for(const e of this.vertexProps)0===e.dir[0]&&0===e.dir[1]||ye(e.dir,e.dir);this.tessellate(s)}}pointElevation(e){if(null!=this.constantHeight)return this.constantHeight;const t=this.getClosestEdge(e);if(null==t)return 0;const[i,n]=t;return xi(this.vertices[this.edges[i].a].height,this.vertices[this.edges[i].b].height,n)}computeSlopeNormal(e,t){const i=this.getClosestEdge(e);if(!i)return M(0,0,1);const n=i[0],r=this.edges[n],s=this.edgeProps[n].vec,o=M(s[0],s[1],(this.vertices[r.b].height-this.vertices[r.a].height)*t),a=M(o[1],-o[0],0);j(a,a,o);const l=A(a);return l>0?D(a,a,1/l):I(a,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,i=Number.POSITIVE_INFINITY,n=0;const[r,s,o,a,l,c,u]=this._tmpVec2;pe(u,e.x,e.y);const h=new Eu(u,null);for(let e=0;e<this.edges.length;e++){const d=this.edges[e],p=this.edgeProps[e].dir;h.dir=p;const f=this.vertices[d.a].position,m=this.vertices[d.b].position,g=h.intersectsPlane(f,this.vertexProps[d.a].dir,r),_=h.intersectsPlane(m,this.vertexProps[d.b].dir,s);if(!g||!_)continue;me(o,s,r),me(a,u,r);const y=ve(o,o),v=y>0?ve(a,o)/y:0,x=ze(v,0,1),b=Math.abs((v-x)*this.edgeProps[e].len);me(l,u,f),pe(c,p[1],-p[0]);const w=b+Math.abs(ve(l,c));w<i&&(t=e,i=w,n=x)}return[t,n]}tessellate(e){const t=S(),i=S(),n=S(),r=S();for(let s=this.edges.length-1;s>=0;--s){const o=this.edges[s].a,a=this.edges[s].b,{position:l,height:c,extent:u}=this.vertices[o],{position:h,height:d,extent:p}=this.vertices[a],f=this.vertexProps[o].dir,m=this.vertexProps[a].dir;if(I(t,l[0]/e,l[1]/e,c),I(i,h[0]/e,h[1]/e,d),I(n,f[1],-f[0],0),D(n,n,u),I(r,m[1],-m[0],0),D(r,r,p),this.distSqLines(M(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),M(i[0]-.5*r[0],i[1]-.5*r[1],i[2]-.5*r[2]),M(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),M(i[0]+.5*r[0],i[1]+.5*r[1],i[2]+.5*r[2]))<=.0025000000000000005)continue;const g=this.vertices.length,_=fe(he(),l,h);this.vertices.push({position:ge(_,_,.5),height:.5*(c+d),extent:.5*(u+p)});const y=fe(he(),f,m);this.vertexProps.push({dir:ye(y,y)}),this.edges.splice(s,1),this.edgeProps.splice(s,1),this.edges.push({a:o,b:g}),this.edges.push({a:g,b:a});const v=me(he(),this.vertices[g].position,l),x=_e(v),b={vec:v,dir:ge(he(),v,1/x),len:x};this.edgeProps.push(b),this.edgeProps.push(b)}}distSqLines(e,t,i,n){const r=P(S(),t,e),s=P(S(),n,i),o=P(S(),e,i),a=V(r,r),l=V(r,s),c=V(r,o),u=V(s,s),h=V(s,o),d=a*u-l*l;if(0===d)return N(G(r,i,n,V(o,s)/V(s,s)),e);const p=(a*h-l*c)/d;return N(G(r,e,t,(l*h-c*u)/d),G(s,i,n,p))}}class Nu{static parseFrom(e,t){const i=Su.parse(e);if(!i)return[];let{vertices:n,features:r}=i;const s=1/eu(t);r.sort((e,t)=>e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,i)=>t===i.findIndex(t=>t.id===e.id&&t.idx===e.idx));const o=new Array;let a=0;const l=n.length;for(const e of r){if(e.constantHeight){o.push(new Fu(e.id,e.bounds,e.constantHeight));continue}for(;a!==l&&n[a].id<e.id;)a++;if(a===l||n[a].id!==e.id)continue;const t=new Array,i=new Array,r=a;for(;a!==l&&n[a].id===e.id;){const e=n[a];if(t.push({position:e.position,height:e.height,extent:e.extent}),a!==r&&n[a-1].idx===e.idx-1){const e=a-r;i.push({a:e-1,b:e})}a++}o.push(new Fu(e.id,e.bounds,void 0,t,i,s))}return o}static getElevationFeature(e,t){if(!t)return;const i=+e.properties[yu];return Number.isNaN(i)?void 0:t.find(e=>e.id===i)}}class ku{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*Qn,this.yOffset=(e.y*this.zScale-t.y)*Qn)}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,i){const n=this.constantElevation(t,i);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),i))}computeBiasedHeight(e,t){return t<=0?e:e+t*Ue(0,t,e>=0?e:Math.abs(.5*e))}}function zu(e){if(0===e)return[0,0,0];const t=Is(e);return[t(),t(),t()]}lo(Fu,"ElevationFeature");class Uu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new el,this.indexArray=new wl,this.segments=new Ql,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new nl),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){const r=this.layers[0],s=[];let o=null;"circle"===r.type&&(o=r.layout.get("circle-sort-key"));for(const{feature:r,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=uu(r,e);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=o?o.evaluate(u,{},i):void 0,d={id:a,properties:r.properties,type:r.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:cu(r,i,n),patterns:{},sortKey:h};s.push(d)}o&&s.sort((e,t)=>e.sortKey-t.sortKey);let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new dl,a=n.projection);for(const n of s){const{geometry:r,index:s,sourceLayerIndex:o}=n,l=e[s].feature;this.addFeature(n,r,s,t.availableImages,i,a,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,r,s,o,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,t,i,n,r,s,o){this.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Kl.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Jl.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(e,t,i,n,r,s,o,a){let l;"none"!==this.elevationMode&&(l=Nu.getElevationFeature(e,a));for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=Qn||n<0||n>=Qn)continue;if(s){const e=s.projectTilePoint(i,n,r),t=s.upVector(r,i,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t)}const o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=o.vertexLength;if(this.addCircleVertex(i,n,-1,-1),this.addCircleVertex(i,n,1,-1),this.addCircleVertex(i,n,1,1),this.addCircleVertex(i,n,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Ae(i,n)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e)}this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),o.vertexLength+=4,o.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},n,r,o,void 0,this.worldview)}addCircleVertex(e,t,i,n){this.layoutVertexArray.emplaceBack(2*e+(i+1)/2,2*t+(n+1)/2)}addGlobeExtVertex(e,t){const i=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*i,t[1]*i,t[2]*i)}}function Vu(e,t){for(let i=0;i<e.length;i++)if(Ku(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Ku(e,t[i]))return!0;return!!Wu(e,t)}function ju(e,t,i){return!!Ku(e,t)||!!Zu(t,e,i)}function Gu(e,t){if(1===e.length)return Ju(t,e[0]);for(let i=0;i<t.length;i++){const n=t[i];for(let t=0;t<n.length;t++)if(Ku(e,n[t]))return!0}for(let i=0;i<e.length;i++)if(Ju(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Wu(e,t[i]))return!0;return!1}function Hu(e,t,i){if(e.length>1){if(Wu(e,t))return!0;for(let n=0;n<t.length;n++)if(Zu(t[n],e,i))return!0}for(let n=0;n<e.length;n++)if(Zu(e[n],t,i))return!0;return!1}function Wu(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)if(qu(n,r,t[e],t[e+1]))return!0}return!1}function qu(e,t,i,n){return et(e,i,n)!==et(t,i,n)&&et(e,t,i)!==et(e,t,n)}function Xu(e,t,i){return(e.x-i.x)*(t.y-i.y)-(e.y-i.y)*(t.x-i.x)}function $u(e,t,i,n){const r=Xu(e,t,n),s=Xu(e,t,i);if(Math.sign(r)===Math.sign(s))return;const o=Xu(i,n,e),a=o+s-r;return Math.sign(o)!==Math.sign(a)?[o/(o-a),s/(s-r)]:void 0}function Zu(e,t,i){const n=i*i;if(1===t.length)return e.distSqr(t[0])<n;for(let i=1;i<t.length;i++)if(Yu(e,t[i-1],t[i])<n)return!0;return!1}function Yu(e,t,i){const n=t.distSqr(i);if(0===n)return e.distSqr(t);const r=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;return e.distSqr(r<0?t:r>1?i:i.sub(t)._mult(r)._add(t))}function Ju(e,t){let i,n,r,s=!1;for(let o=0;o<e.length;o++){i=e[o];for(let e=0,o=i.length-1;e<i.length;o=e++)n=i[e],r=i[o],n.y>t.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(s=!s)}return s}function Ku(e,t){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){const s=e[n],o=e[r];s.y>t.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function Qu(e,t,i,n,r){for(const s of e)if(t<=s.x&&i<=s.y&&n>=s.x&&r>=s.y)return!0;const s=[new Ae(t,i),new Ae(t,r),new Ae(n,r),new Ae(n,i)];if(e.length>2)for(const t of s)if(Ku(e,t))return!0;for(let t=0;t<e.length-1;t++)if(eh(e[t],e[t+1],s))return!0;return!1}function eh(e,t,i){const n=i[0],r=i[2];if(e.x<n.x&&t.x<n.x||e.x>r.x&&t.x>r.x||e.y<n.y&&t.y<n.y||e.y>r.y&&t.y>r.y)return!1;const s=et(e,t,i[0]);return s!==et(e,t,i[1])||s!==et(e,t,i[2])||s!==et(e,t,i[3])}function th(e,t,i,n,r,s){let o=t.y-e.y,a=e.x-t.x;if(s=s||0){const e=o*o+a*a;if(0===e)return!0;const t=Math.sqrt(e);o/=t,a/=t}return!((i.x-e.x)*o+(i.y-e.y)*a-s<0||(n.x-e.x)*o+(n.y-e.y)*a-s<0||(r.x-e.x)*o+(r.y-e.y)*a-s<0)}function ih(e,t,i,n,r,s,o){return!(th(e,t,n,r,s,o)||th(t,i,n,r,s,o)||th(i,e,n,r,s,o)||th(n,r,e,t,i,o)||th(r,s,e,t,i,o)||th(s,n,e,t,i,o))}function nh(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function rh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function sh(e,t,i,n,r){if(!t[0]&&!t[1])return e;const s=Ae.convert(t)._mult(r);"viewport"===i&&s._rotate(-n);const o=[];for(let t=0;t<e.length;t++)o.push(e[t].sub(s));return o}function oh(e,t,i,n){const r=Ae.convert(e)._mult(n);return"viewport"===t&&r._rotate(-i),r}let ah,lh;lo(Uu,"CircleBucket",{omit:["layers"]});class ch{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=dh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return 0===e.z||e.z<this.z&&e.x===this.x>>t&&e.y===this.y>>t}url(e,t){const i=function(e,t,i){const n=2**i,r=2*Math.PI*6378137,s=r*(e/n-.5),o=r*(.5-(t+1)/n);return`${s},${o},${s+r/n},${o+r/n}`}(this.x,this.y,this.z),n=function(e,t,i){let n,r="";for(let s=e;s>0;s--)n=1<<s-1,r+=(t&n?1:0)+(i&n?2:0);return r}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",n).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class uh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=dh(e,t.z,t.z,t.x,t.y)}}class hh{constructor(e,t,i,n,r){this.overscaledZ=e,this.wrap=t,this.canonical=new ch(i,+n,+r),this.key=0===t&&e===i?this.canonical.key:dh(t,e,i,n,r)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new hh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new hh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return dh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return dh(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new hh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new hh(t,this.wrap,t,i,n),new hh(t,this.wrap,t,i+1,n),new hh(t,this.wrap,t,i,n+1),new hh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new hh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new hh(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new uh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function dh(e,t,i,n,r){const s=1<<Math.min(i,22);let o=s*(r%s)+n%s;return e&&i<22&&(o+=s*s*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*o+i)+(t-i)}const ph=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new hh(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new hh(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new hh(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new hh(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];lo(ch,"CanonicalTileID"),lo(hh,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const fh=Ka([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:mh}=fh,gh=Ka([{name:"a_pos_3",components:3,type:"Int16"}]);var _h=Ka([{name:"a_pos",type:"Int16",components:2}]);function yh(e){return e*Rc/zc}const vh=[new Du([Bc,Bc,Bc],[Fc,Fc,Fc]),new Du([Bc,Bc,Bc],[0,0,Fc]),new Du([0,Bc,Bc],[Fc,0,Fc]),new Du([Bc,0,Bc],[0,Fc,Fc]),new Du([0,0,Bc],[Fc,Fc,Fc])];function xh(e,t,i,n=!0){const r=D([],e._camera.position,e.worldSize),s=[t,i,1,1];te(s,s,e.pixelMatrixInverse),Q(s,s,1/s[3]);const o=U([],Z([],s,r)),a=e.globeMatrix,l=[a[12],a[13],a[14]],c=Z([],l,r),u=A(c),h=U([],c),d=e.worldSize/(2*Math.PI),p=V(h,o),f=Math.asin(d/u);if(f<Math.acos(p)){if(!n)return null;const e=[],t=[];D(e,o,u/p),U(t,Z(t,e,c)),U(o,C(o,c,D(o,t,Math.tan(f)*u)))}const m=[];new Au(r,o).closestPointOnSphere(l,d,m);const g=U([],at(a,0)),_=U([],at(a,1)),y=U([],at(a,2)),v=V(g,m),x=V(_,m),b=V(y,m),w=De(Math.asin(-x/d));let T=De(Math.atan2(v,b));T=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,T);const S=Hc(T),E=ze(Wc(w),0,1);return new tu(S,E)}class bh{constructor(e,t,i){this.a=Z([],e,i),this.b=Z([],t,i),this.center=i;const n=U([],this.a),r=U([],this.b);this.angle=Math.acos(V(n,r))}}function wh(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,n){const r=Math.sin(i);return e*(Math.sin((1-n)*i)/r)+t*(Math.sin(n*i)/r)}(e.a[t],e.b[t],e.angle,ze(i,0,1))+e.center[t]}function Th(e){if(e.z<=1)return vh[e.z+2*e.y+e.x];const t=Ch(Ih(e));return Du.fromPoints(t)}function Sh(e,t,i){return D(e,e,1-i),B(e,e,t,i)}function Eh(e,t){const i=kh(t.zoom);if(0===i)return Th(e);const n=Ih(e),r=Ch(n),s=Hc(n.getWest())*t.worldSize,o=Hc(n.getEast())*t.worldSize,a=Wc(n.getNorth())*t.worldSize,l=Wc(n.getSouth())*t.worldSize,c=[s,a,0],u=[o,a,0],d=[s,l,0],p=[o,l,0],f=h([],t.globeMatrix);return H(c,c,f),H(u,u,f),H(d,d,f),H(p,p,f),r[0]=Sh(r[0],d,i),r[1]=Sh(r[1],p,i),r[2]=Sh(r[2],u,i),r[3]=Sh(r[3],c,i),Du.fromPoints(r)}function Ah(e,t,i){for(const n of e)H(n,n,t),D(n,n,i)}function Mh(e,t,i,n){const r=t/e.worldSize,s=e.globeMatrix;if(i.z<=1){const e=Th(i).getCorners();return Ah(e,s,r),Du.fromPoints(e)}const o=Ih(i,n),a=Ch(o,Rc+yh(e._tileCoverLift));Ah(a,s,r);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(o.contains(e.center)){for(const e of a)R(u,u,e),O(c,c,e);c[2]=0;const t=e.point,i=[t.x*r,t.y*r,0];return R(u,u,i),O(c,c,i),new Du(u,c)}if(e._tileCoverLift>0){for(const e of a)R(u,u,e),O(c,c,e);return new Du(u,c)}const h=[s[12]*r,s[13]*r,s[14]*r],d=o.getCenter(),p=ze(e.center.lat,-85.051129,Yc),f=ze(d.lat,-85.051129,Yc),m=Hc(e.center.lng),g=Wc(p);let _=m-Hc(d.lng);const y=g-Wc(f);_>.5?_-=1:_<-.5&&(_+=1);let v=0;Math.abs(_)>Math.abs(y)?v=_>=0?1:3:(v=y>=0?0:2,B(h,h,[s[4]*r,s[5]*r,s[6]*r],-Math.sin(Oe(y>=0?o.getSouth():o.getNorth()))*Rc));const x=a[v],b=a[(v+1)%4],w=new bh(x,b,h),T=[wh(w,0)||x[0],wh(w,1)||x[1],wh(w,2)||x[2]],S=kh(e.zoom);if(S>0){const n=function({x:e,y:t,z:i},n,r,s,o){const a=1/(1<<i);let l=e*a,c=l+a,u=t*a,h=u+a,d=0;const p=(l+c)/2-s;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*n-(s*=n))*r+s,c=((c+d)*n-s)*r+s,u=(u*n-(o*=n))*r+o,h=(h*n-o)*r+o,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(i,t,e._pixelsPerMercatorPixel,m,g);for(let e=0;e<a.length;e++)Sh(a[e],n[e],S);const r=C([],n[v],n[(v+1)%4]);D(r,r,.5),Sh(T,r,S)}for(const e of a)R(u,u,e),O(c,c,e);return u[2]=Math.min(x[2],b[2]),R(u,u,T),O(c,c,T),new Du(u,c)}function Ih({x:e,y:t,z:i},n=!1){const r=1/(1<<i),s=new Vc(Xc(e*r),t===(1<<i)-1&&n?-90:$c((t+1)*r)),o=new Vc(Xc((e+1)*r),0===t&&n?90:$c(t*r));return new jc(s,o)}function Ch(e,t=Rc){const i=Oe(e.getNorth()),n=Oe(e.getSouth()),r=Math.cos(i),s=Math.cos(n),o=Math.sin(i),a=Math.sin(n),l=e.getWest(),c=e.getEast();return[Nc(s,a,l,t),Nc(s,a,c,t),Nc(r,o,c,t),Nc(r,o,l,t)]}function Ph(e,t,i,n){const r=1<<i.z,s=(e/Qn+i.x)/r;return kc($c((t/Qn+i.y)/r),Xc(s),n)}function Lh({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const Rh=new Float64Array(16);function Oh(e){const t=Lh(e),i=v(Rh,[t,t,t]);return p(i,i,z([],e.min))}function Dh(e){const t=1/Lh(e);return y(Rh,e.min),f(Rh,Rh,[t,t,t])}function Bh(e){const t=Qn/(2*Math.PI);return e/(2*Math.PI)/t}function Fh(e,t){return Qn/(512*Math.pow(2,e))*Lh(Th(t))}function Nh(e,t,i,n,r){const s=Bh(i),o=[e,t,-i/(2*Math.PI)],a=u(new Float64Array(16));return p(a,a,o),f(a,a,[s,s,s]),m(a,a,Oe(-r)),g(a,a,Oe(-n)),a}function kh(e){return Ue(5,6,e)}function zh(e,t){const i=kc(t.lat,t.lng),n=function(e){const t=kc(e._center.lat,e._center.lng);let i=j([],M(0,1,0),t);const n=x([],-e.angle,t);i=H(i,i,n),x(n,-e._pitch,i);const r=U([],t);return D(r,r,yh(e.cameraToCenterDistance/e.pixelsPerMeter)),H(r,r,n),C([],t,r)}(e);return o=(r=P([],n,i))[0],a=r[1],l=r[2],c=(s=i)[0],u=s[1],h=s[2],p=(d=Math.sqrt((o*o+a*a+l*l)*(c*c+u*u+h*h)))&&V(r,s)/d,Math.acos(Math.min(Math.max(p,-1),1));var r,s,o,a,l,c,u,h,d,p}function Uh(e,t){return zh(e,t)>Math.PI/2*1.01}const Vh=Oe(85),jh=Math.cos(Vh),Gh=Math.sin(Vh),Hh=l(),Wh=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function qh(e,t,i,n,r,s,o,a,l){if(s&&e.queryGeometry.isAboveHorizon)return!1;s&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,p=i.projection.projectTilePoint(h.x,h.y,c);if(d>0){const e=i.projection.upVector(c,h.x,h.y);p.x+=e[0]*u*d,p.y+=e[1]*u*d,p.z+=e[2]*u*d}const f=s?h:Xh(p.x,p.y,p.z,n),m=s?e.tilespaceRays.map(e=>Yh(e,d)):e.queryGeometry.screenGeometry,g=te([],[p.x,p.y,p.z,1],n);if(!o&&s?l*=g[3]/i.cameraToCenterDistance:o&&!s&&(l*=i.cameraToCenterDistance/g[3]),s){const e=$c((t.y/Qn+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/qc(1,e)}if(ju(m,f,l))return!0}return!1}function Xh(e,t,i,n){const r=te([],[e,t,i,1],n);return new Ae(r[0]/r[3],r[1]/r[3])}const $h=M(0,0,0),Zh=M(0,0,1);function Yh(e,t){const i=S();return $h[2]=t,e.intersectsPlane($h,Zh,i),new Ae(i[0],i[1])}class Jh extends Uu{}let Kh,Qh,ed,td;function id(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function nd(e,t,i){const{width:n,height:r}=t;n===e.width&&r===e.height||(rd(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,r)},i,null),e.width=n,e.height=r,e.data=t.data)}function rd(e,t,i,n,r,s,o,a){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,c=t.data,u=4===s&&a;for(let a=0;a<r.height;a++){const h=((i.y+a)*e.width+i.x)*s,d=((n.y+a)*t.width+n.x)*s;if(u)for(let e=0;e<r.width;e++){const t=h+e*s+3,i=d+e*s;c[i+0]=255,c[i+1]=255,c[i+2]=255,c[i+3]=l[t]}else if(o)for(let e=0;e<r.width;e++){const t=h+e*s,i=d+e*s,n=new bi(l[t+0]/255,l[t+1]/255,l[t+2]/255,l[t+3]).toNonPremultipliedRenderColor(o).toArray();c[i+0]=n[0],c[i+1]=n[1],c[i+2]=n[2],c[i+3]=n[3]}else for(let e=0;e<r.width*s;e++)c[d+e]=l[h+e]}return t}lo(Jh,"HeatmapBucket",{omit:["layers"]});class sd{constructor(e,t){id(this,e,1,t)}resize(e){nd(this,new sd(e),1)}clone(){return new sd({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r){rd(e,t,i,n,r,1,null)}}class od{constructor(e,t){id(this,e,4,t)}resize(e){nd(this,new od(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new od({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r,s,o){rd(e,t,i,n,r,4,s,o)}}class ad{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t}}function ld(e){const t={},i=e.resolution||256,n=e.clips?e.clips.length:1,r=e.image||new od({width:i,height:n}),s=(i,n,s)=>{t[e.evaluationKey]=s;const o=e.expression.evaluate(t),a=o?o.toNonPremultipliedRenderColor(null):null;a&&(r.data[i+n+0]=Math.floor(255*a.r),r.data[i+n+1]=Math.floor(255*a.g),r.data[i+n+2]=Math.floor(255*a.b),r.data[i+n+3]=Math.floor(255*a.a))};if(e.clips)for(let t=0,r=0;t<n;++t,r+=4*i)for(let n=0,o=0;n<i;n++,o+=4){const a=n/(i-1),{start:l,end:c}=e.clips[t];s(r,o,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)s(0,t,e/(i-1));return r}lo(sd,"AlphaImage"),lo(od,"RGBAImage");const cd=Ka([{name:"a_pos",components:2,type:"Int16"}],4),ud=Ka([{name:"a_road_z_offset",components:1,type:"Float32"}],4),hd=Ka([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),dd=Ka([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function pd(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let s=fd(e,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(n&&(s=function(e,t,i,n){const r=[];for(let i=0,s=t.length;i<s;i++){const o=fd(e,t[i]*n,i<s-1?t[i+1]*n:e.length,n,!1);o===o.next&&(o.steiner=!0),r.push(Ed(o))}r.sort(bd);for(let e=0;e<r.length;e++)i=wd(r[e],i);return i}(e,t,s,i)),e.length>80*i){a=e[0],l=e[1];let t=a,n=l;for(let s=i;s<r;s+=i){const i=e[s],r=e[s+1];i<a&&(a=i),r<l&&(l=r),i>t&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return gd(s,o,i,a,l,c,0),o}function fd(e,t,i,n,r){let s;if(r===function(e,t,i,n){let r=0;for(let s=t,o=i-n;s<i;s+=n)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}(e,t,i,n)>0)for(let r=t;r<i;r+=n)s=Fd(r/n|0,e[r],e[r+1],s);else for(let r=i-n;r>=t;r-=n)s=Fd(r/n|0,e[r],e[r+1],s);return s&&Pd(s,s.next)&&(Nd(s),s=s.next),s}function md(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Pd(n,n.next)&&0!==Cd(n.prev,n,n.next))n=n.next;else{if(Nd(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function gd(e,t,i,n,r,s,o){if(!e)return;!o&&s&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Sd(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let e=0;e<i&&(a++,o=o.nextZ,o);e++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;r=o}s.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,s);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(s?yd(e,n,r,s):_d(e))t.push(l.i,e.i,c.i),Nd(e),e=c.next,a=c.next;else if((e=c)===a){o?1===o?gd(e=vd(md(e),t),t,i,n,r,s,2):2===o&&xd(e,t,i,n,r,s):gd(md(e),t,i,n,r,s,1);break}}}function _d(e){const t=e.prev,i=e,n=e.next;if(Cd(t,i,n)>=0)return!1;const r=t.x,s=i.x,o=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,s,o),h=Math.min(a,l,c),d=Math.max(r,s,o),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Md(r,a,s,l,o,c,f.x,f.y)&&Cd(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function yd(e,t,i,n){const r=e.prev,s=e,o=e.next;if(Cd(r,s,o)>=0)return!1;const a=r.x,l=s.x,c=o.x,u=r.y,h=s.y,d=o.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Sd(p,f,t,i,n),y=Sd(m,g,t,i,n);let v=e.prevZ,x=e.nextZ;for(;v&&v.z>=_&&x&&x.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==o&&Md(a,u,l,h,c,d,v.x,v.y)&&Cd(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&Md(a,u,l,h,c,d,x.x,x.y)&&Cd(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==o&&Md(a,u,l,h,c,d,v.x,v.y)&&Cd(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&Md(a,u,l,h,c,d,x.x,x.y)&&Cd(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function vd(e,t){let i=e;do{const n=i.prev,r=i.next.next;!Pd(n,r)&&Ld(n,i,i.next,r)&&Dd(n,r)&&Dd(r,n)&&(t.push(n.i,i.i,r.i),Nd(i),Nd(i.next),i=e=r),i=i.next}while(i!==e);return md(i)}function xd(e,t,i,n,r,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Id(o,e)){let a=Bd(o,e);return o=md(o,o.next),a=md(a,a.next),gd(o,t,i,n,r,s,0),void gd(a,t,i,n,r,s,0)}e=e.next}o=o.next}while(o!==e)}function bd(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function wd(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let s,o=-1/0;if(Pd(e,i))return i;do{if(Pd(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>o&&(o=e,s=i.x<i.next.x?i:i.next,e===n))return s}i=i.next}while(i!==t);if(!s)return null;const a=s,l=s.x,c=s.y;let u=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&Ad(r<c?n:o,r,l,c,r<c?o:n,r,i.x,i.y)){const t=Math.abs(r-i.y)/(n-i.x);Dd(i,e)&&(t<u||t===u&&(i.x>s.x||i.x===s.x&&Td(s,i)))&&(s=i,u=t)}i=i.next}while(i!==a);return s}(e,t);if(!i)return t;const n=Bd(i,e);return md(n,n.next),md(i,i.next)}function Td(e,t){return Cd(e.prev,e,t.prev)<0&&Cd(t.next,e,e.next)<0}function Sd(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ed(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Ad(e,t,i,n,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(n-a)>=(i-o)*(t-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function Md(e,t,i,n,r,s,o,a){return!(e===o&&t===a)&&Ad(e,t,i,n,r,s,o,a)}function Id(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Ld(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Dd(e,t)&&Dd(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Cd(e.prev,e,t.prev)||Cd(e,t.prev,t))||Pd(e,t)&&Cd(e.prev,e,e.next)>0&&Cd(t.prev,t,t.next)>0)}function Cd(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Pd(e,t){return e.x===t.x&&e.y===t.y}function Ld(e,t,i,n){const r=Od(Cd(e,t,i)),s=Od(Cd(e,t,n)),o=Od(Cd(i,n,e)),a=Od(Cd(i,n,t));return r!==s&&o!==a||!(0!==r||!Rd(e,i,t))||!(0!==s||!Rd(e,n,t))||!(0!==o||!Rd(i,e,n))||!(0!==a||!Rd(i,t,n))}function Rd(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Od(e){return e>0?1:e<0?-1:0}function Dd(e,t){return Cd(e.prev,e,e.next)<0?Cd(e,t,e.next)>=0&&Cd(e,e.prev,t)>=0:Cd(e,t,e.prev)<0||Cd(e,e.next,t)<0}function Bd(e,t){const i=kd(e.i,e.x,e.y),n=kd(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Fd(e,t,i,n){const r=kd(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Nd(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function kd(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function zd(e,t){const i=e.length;if(i<=1)return[e];const n=[];let r,s;for(let t=0;t<i;t++){const i=tt(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===s&&(s=i<0),s===i<0?(r&&n.push(r),r=[e[t]]):r.push(e[t]))}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(xn(n[e],t,1,n[e].length-1,Ud),n[e]=n[e].slice(0,t));return n}function Ud(e,t){return t.area-e.area}function Vd(e,t,i=1){if(!e)return null;const n="string"==typeof e?Yi.from(e).getPrimary():e.getPrimary(),r="string"==typeof e?null:e.getSecondary();for(const e of[n,r]){if(!e)continue;const n=e.id.toString();t.has(n)||t.set(n,[]),e.scaleSelf(i),t.get(n).push(e)}return{primary:n.toString(),secondary:r?r.toString():null}}function jd(e,t,i,n){const r=n.patternDependencies;let s=!1;for(const n of t){const t=n.paint.get(`${e}-pattern`);t.isConstant()||(s=!0),Vd(t.constantOr(null),r,i)&&(s=!0)}return s}function Gd(e,t,i,n,r,s){const o=s.patternDependencies;for(const a of t){const t=a.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){const e=Vd(t.evaluate({zoom:n},i,{},void 0,s.availableImages),o,r);if(!e)continue;const{primary:l,secondary:c}=e;l&&(i.patterns[a.id]=[l,c].filter(Boolean))}}return i}class Hd{constructor(){this.portals=[]}static isOnBorder(e,t){return e<=0&&t<=0||e>=Qn&&t>=Qn}static evaluate(e){if(0===e.length)return new Hd;let t=[];for(const i of e)t.push(...i.portals);if(0===t.length)return new Hd;for(const e of t){const t=e.va,i=e.vb;(Hd.isOnBorder(t.x,i.x)||Hd.isOnBorder(t.y,i.y))&&(e.type="border")}const i=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new Hd;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hash<t.hash?1:-1),t=i.concat(n);let r=i.length,s=r,o=r;do{if(s++,s===t.length||t[r].hash!==t[s].hash){if(s-r===2){o<r&&(t[o]=t[r],t[r]=null);const e=t[o],i=t[s-1];e.type=e.isTunnel!==i.isTunnel?"tunnel":"polygon",e.connection={a:e.connection.a,b:i.connection.a},o++}r=s}}while(r!==t.length);return t.splice(o),t.sort((e,t)=>e.hash<t.hash?1:-1),{portals:t}}}lo(Hd,"ElevationPortalGraph");class Wd{constructor(e,t,i){this.outPositions=e,this.outNormals=t,this.outIndices=i,this.vertexLookup=new Map}addVertex(e,t,i){let n=e[2];null!=i&&(n*=i);const r=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,s=this.vertexLookup.get(r);if(null!=s)return s;const o=this.outPositions.length;this.vertexLookup.set(r,o);const a=Math.trunc(16384*t[0]),l=Math.trunc(16384*t[1]),c=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],n),this.outNormals.emplaceBack(a,l,c),o}addTriangle(e,t,i){this.outIndices.emplaceBack(e,t,i)}addTriangles(e,t,i){if(0===e.length)return;const n=1===i.length,r=S(),s=S();for(let o=0;o<e.length;o+=3){const a=t[e[o+0]],l=t[e[o+1]],c=t[e[o+2]],u=n?i[0]:i[e[o+1]],h=n?i[0]:i[e[o+2]];I(r,a.x,a.y,n?i[0]:i[e[o+0]]);const d=this.addVertex(r,s);I(r,l.x,l.y,u);const p=this.addVertex(r,s);I(r,c.x,c.y,h);const f=this.addVertex(r,s);this.outIndices.emplaceBack(d,p,f)}}addQuad(e,t,i,n,r,s){const o=this.addVertex(e,r,s),a=this.addVertex(t,r,s),l=this.addVertex(i,r,s),c=this.addVertex(n,r,s);this.addTriangle(o,a,l),this.addTriangle(l,c,o)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class qd{constructor(e,t,i,n){this.unevaluatedPortals=new Hd,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new rl,this.vertexNormals=new sl,this.indexArray=new wl,this.tileToMeters=eu(e),this.bridgeProgramConfigurations=new Ac(t,{zoom:i,lut:n},e=>"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new Ac(t,{zoom:i,lut:n},e=>"fill-bridge-guard-rail-color"!==e)}addVertices(e,t){const i=this.unevalVertices.length;for(let i=0;i<e.length;i++)this.unevalVertices.push(e[i]),this.unevalHeights.push(t[i]);return i}addTriangles(e,t,i){const n=i?this.unevalTunnelTriangles:this.unevalTriangles;for(const i of e)n.push(i+t)}addRenderableRing(e,t,i,n,r,s){const o=[new Ae(r.min.x,r.min.y),new Ae(r.max.x,r.min.y),new Ae(r.max.x,r.max.y),new Ae(r.min.x,r.max.y)];for(let a=0;a<i-1;a++){const i=t+a,l=i+1,c=this.unevalVertices[i],u=this.unevalVertices[l];if(!(c.x>=r.min.x&&c.x<=r.max.x&&c.y>=r.min.y&&c.y<=r.max.y||u.x>=r.min.x&&u.x<=r.max.x&&u.y>=r.min.y&&u.y<=r.max.y||eh(c,u,o)))continue;if(this.isOnBorder(c.x,u.x)||this.isOnBorder(c.y,u.y))continue;const h=qd.computeEdgeHash(this.unevalVertices[i],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(qd.computePosHash(c));null!=p?d=p.next:(p=this.vertexHashLookup.get(qd.computePosHash(u)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:i,b:l,hash:h,portalHash:d,isTunnel:n,type:"unevaluated",featureInfo:s})}}addPortalCandidates(e,t,i,n,r){if(0!==t.length){this.vertexHashLookup.clear();for(const r of t){if(0===r.length)continue;const t=r[0];let s=qd.computeEdgeHash(t[t.length-2],t.at(-1));for(let r=0;r<t.length-1;r++){const o=t[r+0],a=t[r+1],l=de(a.x-o.x,a.y-o.y),c=_e(l);if(0===c)continue;let u="unevaluated";const h=n.pointElevation(o),d=n.pointElevation(a);Math.abs(h)<.01&&Math.abs(d)<.01?u="entrance":(this.isOnBorder(o.x,a.x)||this.isOnBorder(o.y,a.y))&&(u="border");const p=qd.computeEdgeHash(o,a);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:o,vb:a,vab:l,length:c,hash:p,isTunnel:i,type:u});const f=qd.computePosHash(o);this.vertexHashLookup.set(f,{prev:s,next:p}),s=p}}}}construct(e){if(0===this.unevalVertices.length)return;const t=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),i=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset},n=new Wd(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const r=t(),s=t(),o=t(),a=(e,t)=>{e.sort((e,i)=>e.type===t&&i.type!==t?-1:e.type!==t&&i.type===t?1:0);const i=e.findIndex(e=>e.type!==t);return i>=0?i:e.length};let l=0;this.unevalEdges.length>0&&(l=a(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),i(o);const c=t(),u=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=a(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t})}i(c),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),i(u),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),i(s),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),i(r),this.maskSegments=Ql.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.depthSegments=Ql.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableBridgeSegments=Ql.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableTunnelSegments=Ql.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.shadowCasterSegments=Ql.simpleSegment(0,r.primitiveOffset,0,r.primitiveLength)}update(e,t,i,n,r,s,o,a){this.bridgeProgramConfigurations.updatePaintArrays(e,t,r,i,n,s,o,a),this.tunnelProgramConfigurations.updatePaintArrays(e,t,r,i,n,s,o,a)}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,hd.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,dd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(e,t,i,n,r){const s=(s,o)=>{for(let a=0;a<o.length-1;a++){const l=o[a].featureIndex,c=o[a+1].vertexStart,u=e.feature(l);s.populatePaintArrays(c,u,l,{},i,t,n,void 0,r)}};s(this.bridgeProgramConfigurations,this.bridgeFeatureSections),s(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,t,i,n,r){const s=new Map;for(let o=n;o<r;o++){const n=i[o],r=n.a,a=n.b,l=qd.computePosHash(e[r]),c=qd.computePosHash(e[a]);let u=s.get(l);u||(u={},s.set(l,u));let h=s.get(c);h||(h={},s.set(c,h)),t[r]<=0&&t[a]<=0||(u.to=a,h.from=r)}return s}isTerminalVertex(e,t){const i=qd.computePosHash(this.unevalVertices[e]),n=t.get(i);return!n||!n.from||!n.to}constructBridgeStructures(e,t,i,n,r,s){e.clearVertexLookup();const o=this.computeVertexConnections(t,i,n,r.min,r.max),a=1/s,l=.5*a,c=(e,n)=>I(e,t[n].x,t[n].y,i[n]*a),u=S(),h=S(),d=S(),p=S(),f=S(),m=(e,i)=>{const n=o.get(qd.computePosHash(t[i])),r=n.from,s=n.to;if(!r||!s)return;c(u,r),c(h,i),c(d,s),X(p),$(u,h)||(Z(f,h,u),U(p,f)),$(d,h)||(Z(f,d,h),C(p,p,U(f,f)));const a=J(p);return a>0?D(e,p,1/a):void 0};let g=Number.POSITIVE_INFINITY;this.sortSubarray(n,r.min,r.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const _=S(),y=S(),v=S(),x=S(),b=S(),w=S(),T=S(),E=S(),A=S(),M=[S(),S(),S(),S()],P=[S(),S(),S(),S()],L=[{coord:new Ae(0,0),height:0},{coord:new Ae(0,0),height:0}],R=(e,t)=>e>t;for(let c=r.min;c<r.max;c++){const r=n[c];if(!r.featureInfo.guardRailEnabled)continue;if(!this.prepareEdgePoints(L,t,i,r,R))continue;const[u,h]=L;if(I(_,u.coord.x,u.coord.y,a*u.height),I(y,h.coord.x,h.coord.y,a*h.height),$(_,y))continue;Z(v,y,_),U(v,v);const d=m(E,r.a)||v,p=m(A,r.b)||v;I(x,d[1],-d[0],0),U(x,x),I(b,p[1],-p[0],0),U(b,b),j(E,x,d),U(w,E),j(E,b,p),U(T,E),C(M[0],_,D(E,Z(E,x,w),l)),C(M[1],_,D(E,C(E,x,w),l)),C(M[2],_,D(E,w,l)),M[3]=_,C(P[0],y,D(E,Z(E,b,T),l)),C(P[1],y,D(E,C(E,b,T),l)),C(P[2],y,D(E,T,l)),P[3]=y,g=this.addFeatureSection(r.featureInfo.featureIndex,g,this.bridgeFeatureSections,e);const f=e.addVertex(M[0],x,s),S=e.addVertex(M[1],x,s),O=e.addVertex(P[0],b,s),B=e.addVertex(P[1],b,s);e.addTriangle(f,S,O),e.addTriangle(S,B,O);const F=e.addVertex(M[1],w,s),N=e.addVertex(M[2],w,s),k=e.addVertex(P[1],T,s),V=e.addVertex(P[2],T,s);e.addTriangle(F,N,k),e.addTriangle(N,V,k),z(x,x),z(b,b);const G=e.addVertex(M[2],x,s),H=e.addVertex(M[3],x,s),W=e.addVertex(P[2],b,s),q=e.addVertex(P[3],b,s);e.addTriangle(G,H,W),e.addTriangle(H,q,W);const X=this.isTerminalVertex(r.a,o),Y=this.isTerminalVertex(r.b,o);u.height<.01&&X&&e.addQuad(M[3],M[2],M[1],M[0],z(d,d),s),h.height<.01&&Y&&e.addQuad(P[0],P[1],P[2],P[3],p,s)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,t,i,n,r,s){e.clearVertexLookup();let o=Number.POSITIVE_INFINITY;const a=(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,r.min,r.max,a),this.sortSubarray(n,s.min,s.max,a);const l=e=>U(e,e),c=[{coord:new Ae(0,0),height:0},{coord:new Ae(0,0),height:0}],u=(e,t)=>e<t,h=S(),d=S(),p=S(),f=S(),m=S();for(let s=r.min;s<r.max;s++){if(!this.prepareEdgePoints(c,t,i,n[s],u))continue;const[r,a]=c,g=l(I(m,-(a.coord.y-r.coord.y),a.coord.x-r.coord.x,0));o=this.addFeatureSection(n[s].featureInfo.featureIndex,o,this.tunnelFeatureSections,e),e.addQuad(I(h,r.coord.x,r.coord.y,r.height),I(d,a.coord.x,a.coord.y,a.height),I(p,a.coord.x,a.coord.y,n[s].isTunnel?-.1:0),I(f,r.coord.x,r.coord.y,n[s].isTunnel?-.1:0),g)}for(let r=s.min;r<s.max;r++){const s=n[r];s.isTunnel&&([s.a,s.b]=[s.b,s.a]);const a=t[s.a],c=t[s.b],u=l(I(m,-(c.y-a.y),c.x-a.x,0));o=this.addFeatureSection(s.featureInfo.featureIndex,o,this.tunnelFeatureSections,e),e.addQuad(I(h,c.x,c.y,0),I(d,a.x,a.y,0),I(p,a.x,a.y,i[s.a]+4),I(f,c.x,c.y,i[s.b]+4),u),e.addQuad(I(h,a.x,a.y,0),I(d,c.x,c.y,0),I(p,c.x,c.y,i[s.b]+4),I(f,a.x,a.y,i[s.a]+4),u)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,t,i,n){e.coord.x=t,e.coord.y=i,e.height=n}prepareEdgePoints(e,t,i,n,r){let s=t[n.a].x,o=t[n.a].y,a=t[n.b].x,l=t[n.b].y,c=i[n.a],u=i[n.b];const h=r(c,0),d=r(u,0);if(h&&d)return this.setElevatedPoint(e[0],s,o,c),this.setElevatedPoint(e[1],a,l,u),!0;if(!h&&!d)return!1;if(h){if(!d){const e=u/(u-c);a=xi(a,s,e),l=xi(l,o,e),u=xi(u,c,e)}}else{const e=c/(c-u);s=xi(s,a,e),o=xi(o,l,e),c=xi(c,u,e)}return this.setElevatedPoint(e[0],s,o,c),this.setElevatedPoint(e[1],a,l,u),!0}prepareEdges(e,t){if(0===t.length)return;t.sort((e,t)=>e.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let i=0,n=0,r=0,s=t[i].polygonIdx;do{n++,(n===t.length||t[i].hash!==t[n].hash)&&((1===n-i||t[n-1].polygonIdx!==s)&&(r<i&&(t[r]=t[i],t[i]=null),t[r].type="none",r++),i=n,i!==t.length&&(s=t[i].polygonIdx))}while(i!==t.length);if(t.splice(r),0!==t.length&&0!==e.length){t.sort((e,t)=>e.portalHash<t.portalHash?1:-1);let i=0,n=0;for(;i!==t.length&&n!==e.length;){const r=t[i],s=e[n];r.portalHash>s.hash?i++:s.hash>r.portalHash?n++:(r.type=s.type,i++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Qn&&t>=Qn}addFeatureSection(e,t,i,n){return e!==t&&(t=e,i.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,i,n){const r=e.slice(t,i);r.sort(n),e.splice(t,r.length,...r)}static computeEdgeHash(e,t){return(e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(qd.computePosHash(e))<<32n|BigInt(qd.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}function Xd(e,t){return e>t?1:e<t?-1:0}class $d{constructor(e=Xd,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t)}}splay(e){for(var t,i,n,r,s;e.parent;)(i=(t=e.parent).parent)&&i.parent?((n=i.parent).left===i?n.left=e:n.right=e,e.parent=n):(e.parent=null,this._root=e),r=e.left,s=e.right,e===t.left?(i&&(i.left===t?(t.right?(i.left=t.right,i.left.parent=i):i.left=null,t.right=i,i.parent=t):(r?(i.right=r,r.parent=i):i.right=null,e.left=i,i.parent=e)),s?(t.left=s,s.parent=t):t.left=null,e.right=t,t.parent=e):(i&&(i.right===t?(t.left?(i.right=t.left,i.right.parent=i):i.right=null,t.left=i,i.parent=t):(s?(i.left=s,s.parent=i):i.left=null,e.right=i,i.parent=e)),r?(t.right=r,r.parent=t):t.right=null,e.left=t,t.parent=e)}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,t){var i=this._root,n=null,r=this._compare;if(this._noDuplicates)for(;i;){if(n=i,0===r(i.key,e))return;i=r(i.key,e)<0?i.right:i.left}else for(;i;)n=i,i=r(i.key,e)<0?i.right:i.left;return i={key:e,data:t,left:null,right:null,parent:n},n?r(n.key,i.key)<0?n.right=i:n.left=i:this._root=i,this.splay(i),this._size++,i}find(e){for(var t=this._root,i=this._compare;t;){var n=i(t.key,e);if(n<0)t=t.right;else{if(!(n>0))return t;t=t.left}}return null}contains(e){for(var t=this._root,i=this._compare;t;){var n=i(e,t.key);if(0===n)return!0;t=n<0?t.left:t.right}return!1}remove(e){var t=this.find(e);if(!t)return!1;if(this.splay(t),t.left)if(t.right){var i=this.minNode(t.right);i.parent!==t&&(this.replace(i,i.right),i.right=t.right,i.right.parent=i),this.replace(t,i),i.left=t.left,i.left.parent=i}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var i=t.left,n=t.right,r=null;i&&(i.parent=null,r=this.maxNode(i),this.splay(r),this._root=r),n&&(i?r.right=n:this._root=n,n.parent=r),this._size--}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key)}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,i=[],n=!1,r=0;!n;)t?(i.push(t),t=t.left):i.length>0?(e(t=i.pop(),r++),t=t.right):n=!0;return this}range(e,t,i,n){const r=[],s=this._compare;let o,a=this._root;for(;0!==r.length||a;)if(a)r.push(a),a=a.left;else{if(a=r.pop(),o=s(a.key,t),o>0)break;if(s(a.key,e)>=0&&i.call(n,a))return this;a=a.right}return this}keys(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.key),e=e.right):n=!0;return i}values(){for(var e=this._root,t=[],i=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.data),e=e.right):n=!0;return i}at(e){for(var t=this._root,i=[],n=!1,r=0;!n;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),r===e)return t;r++,t=t.right}else n=!0;return null}load(e=[],t=[],i=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return i&&Yd(e,t,0,n-1,this._compare),this._root=Zd(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,i,n,r){return new $d(i,r).load(e,t,n)}}function Zd(e,t,i,n,r){const s=r-n;if(s>0){const o=n+Math.floor(s/2),a={key:t[o],data:i[o],parent:e};return a.left=Zd(a,t,i,n,o),a.right=Zd(a,t,i,o+1,r),a}return null}function Yd(e,t,i,n,r){if(i>=n)return;const s=e[i+n>>1];let o=i-1,a=n+1;for(;;){do{o++}while(r(e[o],s)<0);do{a--}while(r(e[a],s)>0);if(o>=a)break;let i=e[o];e[o]=e[a],e[a]=i,i=t[o],t[o]=t[a],t[a]=i}Yd(e,t,i,a,r),Yd(e,t,a+1,n,r)}const Jd=11102230246251565e-32,Kd=134217729,Qd=(3+8*Jd)*Jd;function ep(e,t,i,n,r){let s,o,a,l,c=t[0],u=n[0],h=0,d=0;u>c==u>-c?(s=c,c=t[++h]):(s=u,u=n[++d]);let p=0;if(h<e&&d<i)for(u>c==u>-c?(o=c+s,a=s-(o-c),c=t[++h]):(o=u+s,a=s-(o-u),u=n[++d]),s=o,0!==a&&(r[p++]=a);h<e&&d<i;)u>c==u>-c?(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=t[++h]):(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=n[++d]),s=o,0!==a&&(r[p++]=a);for(;h<e;)o=s+c,l=o-s,a=s-(o-l)+(c-l),c=t[++h],s=o,0!==a&&(r[p++]=a);for(;d<i;)o=s+u,l=o-s,a=s-(o-l)+(u-l),u=n[++d],s=o,0!==a&&(r[p++]=a);return 0===s&&0!==p||(r[p++]=s),p}function tp(e){return new Float64Array(e)}const ip=tp(4),np=tp(8),rp=tp(12),sp=tp(16),op=tp(4);function ap(e,t,i){null===t?(e.inOut=!1,e.otherInOut=!0):(e.isSubject===t.isSubject?(e.inOut=!t.inOut,e.otherInOut=t.otherInOut):(e.inOut=!t.otherInOut,e.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(e.prevInResult=!lp(t,i)||t.isVertical()?t.prevInResult:t)),e.resultTransition=lp(e,i)?function(e,t){let i,n=!e.inOut,r=!e.otherInOut;switch(t){case 0:i=n&&r;break;case 1:i=n||r;break;case 3:i=n!==r;break;case 2:i=e.isSubject?n&&!r:r&&!n}return i?1:-1}(e,i):0}function lp(e,t){switch(e.type){case 0:switch(t){case 0:return!e.otherInOut;case 1:return e.otherInOut;case 2:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case 3:return!0}break;case 2:return 0===t||1===t;case 3:return 2===t;case 1:return!1}return!1}class cp{constructor(e,t,i,n,r){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=n??!1,this.type=r||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){const t=this.point,i=this.otherEvent.point;return this.left?(t[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(t[1]-e[1])>0:(i[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(i[1]-e[1])>0}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new cp(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function up(e,t){return e[0]===t[0]&&e[1]===t[1]}function hp(e,t,i){const n=function(e,t,i,n,r,s){const o=(t-s)*(i-r),a=(e-r)*(n-s),l=o-a;if(0===o||0===a||o>0!=a>0)return l;const c=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,i,n,r,s,o){let a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S;const E=e-r,A=i-r,M=t-s,I=n-s;x=E*I,d=Kd*E,p=d-(d-E),f=E-p,d=Kd*I,m=d-(d-I),g=I-m,b=f*g-(x-p*m-f*m-p*g),w=M*A,d=Kd*M,p=d-(d-M),f=M-p,d=Kd*A,m=d-(d-A),g=A-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,ip[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,ip[1]=v-(_+h)+(h-w),S=y+_,h=S-y,ip[2]=y-(S-h)+(_-h),ip[3]=S;let C=function(e,t){let i=t[0];for(let e=1;e<4;e++)i+=t[e];return i}(0,ip),P=22204460492503146e-32*o;if(C>=P||-C>=P)return C;if(h=e-E,a=e-(E+h)+(h-r),h=i-A,c=i-(A+h)+(h-r),h=t-M,l=t-(M+h)+(h-s),h=n-I,u=n-(I+h)+(h-s),0===a&&0===l&&0===c&&0===u)return C;if(P=11093356479670487e-47*o+Qd*Math.abs(C),C+=E*u+I*a-(M*c+A*l),C>=P||-C>=P)return C;x=a*I,d=Kd*a,p=d-(d-a),f=a-p,d=Kd*I,m=d-(d-I),g=I-m,b=f*g-(x-p*m-f*m-p*g),w=l*A,d=Kd*l,p=d-(d-l),f=l-p,d=Kd*A,m=d-(d-A),g=A-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,op[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,op[1]=v-(_+h)+(h-w),S=y+_,h=S-y,op[2]=y-(S-h)+(_-h),op[3]=S;const L=ep(4,ip,4,op,np);x=E*u,d=Kd*E,p=d-(d-E),f=E-p,d=Kd*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=M*c,d=Kd*M,p=d-(d-M),f=M-p,d=Kd*c,m=d-(d-c),g=c-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,op[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,op[1]=v-(_+h)+(h-w),S=y+_,h=S-y,op[2]=y-(S-h)+(_-h),op[3]=S;const R=ep(L,np,4,op,rp);x=a*u,d=Kd*a,p=d-(d-a),f=a-p,d=Kd*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=l*c,d=Kd*l,p=d-(d-l),f=l-p,d=Kd*c,m=d-(d-c),g=c-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,op[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,op[1]=v-(_+h)+(h-w),S=y+_,h=S-y,op[2]=y-(S-h)+(_-h),op[3]=S;const O=ep(R,rp,4,op,sp);return sp[O-1]}(e,t,i,n,r,s,c)}(e[0],e[1],t[0],t[1],i[0],i[1]);return n>0?-1:n<0?1:0}function dp(e,t){const i=e.point,n=t.point;return i[0]>n[0]?1:i[0]<n[0]?-1:i[1]!==n[1]?i[1]>n[1]?1:-1:function(e,t,i){return e.left!==t.left?e.left?1:-1:0!==hp(i,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function pp(e,t,i){const n=new cp(t,!1,e,e.isSubject),r=new cp(t,!0,e.otherEvent,e.isSubject);return up(e.point,e.otherEvent.point),n.contourId=r.contourId=e.contourId,dp(r,e.otherEvent)>0&&(e.otherEvent.left=!0,r.left=!1),e.otherEvent.otherEvent=r,e.otherEvent=n,i.push(r),i.push(n),i}function fp(e,t){return e[0]*t[1]-e[1]*t[0]}function mp(e,t){return e[0]*t[0]+e[1]*t[1]}function gp(e,t,i){const n=function(e,t,i,n){const r=[t[0]-e[0],t[1]-e[1]],s=[n[0]-i[0],n[1]-i[1]];function o(e,t,i){return[e[0]+t*i[0],e[1]+t*i[1]]}const a=[i[0]-e[0],i[1]-e[1]];let l=fp(r,s),c=l*l;const u=mp(r,r);if(c>0){const t=fp(a,s)/l;if(t<0||t>1)return null;const n=fp(a,r)/l;return n<0||n>1?null:0===t||1===t?[o(e,t,r)]:0===n||1===n?[o(i,n,s)]:[o(e,t,r)]}if(l=fp(a,r),c=l*l,c>0)return null;const h=mp(r,a)/u,d=h+mp(r,s)/u,p=Math.min(h,d),f=Math.max(h,d);return p<=1&&f>=0?1===p?[o(e,p>0?p:0,r)]:0===f?[o(e,f<1?f:1,r)]:[o(e,p>0?p:0,r),o(e,f<1?f:1,r)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),r=n?n.length:0;if(0===r||1===r&&(up(e.point,t.point)||up(e.otherEvent.point,t.otherEvent.point))||2===r&&e.isSubject===t.isSubject)return 0;if(1===r)return!up(e.point,n[0])&&!up(e.otherEvent.point,n[0])&&pp(e,n[0],i),!up(t.point,n[0])&&!up(t.otherEvent.point,n[0])&&pp(t,n[0],i),1;const s=[];let o=!1,a=!1;return up(e.point,t.point)?o=!0:1===dp(e,t)?s.push(t,e):s.push(e,t),up(e.otherEvent.point,t.otherEvent.point)?a=!0:1===dp(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),o&&a||o?(t.type=1,e.type=t.inOut===e.inOut?2:3,o&&!a&&pp(s[1].otherEvent,s[0].point,i),2):a?(pp(s[0],s[1].point,i),3):s[0]!==s[3].otherEvent?(pp(s[0],s[1].point,i),pp(s[1],s[2].point,i),3):(pp(s[0],s[1].point,i),pp(s[3].otherEvent,s[2].point,i),3)}function _p(e,t){if(e===t)return 0;if(0!==hp(e.point,e.otherEvent.point,t.point)||0!==hp(e.point,e.otherEvent.point,t.otherEvent.point))return up(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]<t.point[1]?-1:1:1===dp(e,t)?t.isAbove(e.point)?-1:1:e.isBelow(t.point)?-1:1;if(e.isSubject!==t.isSubject)return e.isSubject?-1:1;{let i=e.point,n=t.point;if(i[0]===n[0]&&i[1]===n[1])return i=e.otherEvent.point,n=t.otherEvent.point,i[0]===n[0]&&i[1]===n[1]?0:(e.contourId??0)>(t.contourId??0)?1:-1}return 1===dp(e,t)?1:-1}class yp{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return null==this.holeOf}}function vp(e,t,i,n){let r,s=e+1,o=t[e].point;const a=t.length;for(s<a&&(r=t[s].point);s<a&&r[0]===o[0]&&r[1]===o[1];){if(!i[s])return s;s++,s<a&&(r=t[s].point)}for(s=e-1;i[s]&&s>n;)s--;return s}function xp(e,t,i){const n=new yp;if(null!=e.prevInResult){const r=e.prevInResult,s=r.outputContourId;if(r.resultTransition>0){const e=t[s];if(null!=e.holeOf){const r=e.holeOf;t[r].holeIds.push(i),n.holeOf=r,n.depth=t[s].depth}else t[s].holeIds.push(i),n.holeOf=s,n.depth=t[s].depth+1}else n.holeOf=null,n.depth=t[s].depth}else n.holeOf=null,n.depth=0;return n}const bp=Math.max,wp=Math.min;let Tp=0;function Sp(e,t,i,n,r,s){let o,a,l,c,u,h;for(o=0,a=e.length-1;o<a;o++){if(l=e[o],c=e[o+1],u=new cp(l,!1,void 0,t),h=new cp(c,!1,u,t),u.otherEvent=h,l[0]===c[0]&&l[1]===c[1])continue;u.contourId=h.contourId=i,s||(u.isExteriorRing=!1,h.isExteriorRing=!1),dp(u,h)>0?h.left=!0:u.left=!0;const a=l[0],d=l[1];r[0]=wp(r[0],a),r[1]=wp(r[1],d),r[2]=bp(r[2],a),r[3]=bp(r[3],d),n.push(u),n.push(h)}}const Ep=[];function Ap(e,t,i){let n=e,r=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(r=[t]);let s=function(e,t,i){let n=null;return e.length*t.length===0&&(0===i?n=Ep:2===i?n=e:(1===i||3===i)&&(n=0===e.length?t:e)),n}(n,r,i);if(s)return s===Ep?null:s;const o=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],l=function(e,t,i,n,r){const s=new Kn(void 0,dp);let o,a,l,c,u,h;for(l=0,c=e.length;l<c;l++)for(o=e[l],u=0,h=o.length;u<h;u++)a=0===u,a&&Tp++,Sp(o[u],!0,Tp,s,i,a);for(l=0,c=t.length;l<c;l++)for(o=t[l],u=0,h=o.length;u<h;u++)a=0===u,2===r&&(a=!1),a&&Tp++,Sp(o[u],!1,Tp,s,n,a);return s}(n,r,o,a,i);if(s=function(e,t,i,n,r){let s=null;return(i[0]>n[2]||n[0]>i[2]||i[1]>n[3]||n[1]>i[3])&&(0===r?s=Ep:2===r?s=e:(1===r||3===r)&&(s=e.concat(t))),s}(n,r,o,a,i),s)return s===Ep?null:s;const c=function(e,t,i,n,r,s){const o=new $d(_p),a=[],l=Math.min(n[2],r[2]);let c,u,h;for(;0!==e.length;){let t=e.pop();if(a.push(t),0===s&&t.point[0]>l||2===s&&t.point[0]>n[2])break;if(t.left){u=c=o.insert(t),h=o.minNode(),c=c!==h?o.prev(c):null,u=o.next(u);const i=c?c.key:null;let n;if(ap(t,i,s),u&&2===gp(t,u.key,e)&&(ap(t,i,s),ap(u.key,t,s)),c&&2===gp(c.key,t,e)){let e=c;e=e!==h?o.prev(e):null,n=e?e.key:null,ap(i,n,s),ap(t,i,s)}}else t=t.otherEvent,u=c=o.find(t),c&&u&&(c=c!==h?o.prev(c):null,u=o.next(u),o.remove(t),u&&c&&gp(c.key,u.key,e))}return a}(l,0,0,o,a,i),u=function(e){let t,i;const n=function(e){let t,i,n,r,s;const o=[];for(i=0,n=e.length;i<n;i++)t=e[i],(t.left&&t.inResult||!t.left&&t.otherEvent.inResult)&&o.push(t);let a=!1;for(;!a;)for(a=!0,i=0,n=o.length;i<n;i++)i+1<n&&1===dp(o[i],o[i+1])&&(r=o[i],o[i]=o[i+1],o[i+1]=r,a=!1);for(i=0,n=o.length;i<n;i++)t=o[i],t.otherPos=i;for(i=0,n=o.length;i<n;i++)t=o[i],t.left||(s=t.otherPos,t.otherPos=t.otherEvent.otherPos,t.otherEvent.otherPos=s);return o}(e),r={},s=[];for(t=0,i=n.length;t<i;t++){if(r[t])continue;const e=s.length,i=xp(n[t],s,e),o=t=>{r[t]=!0,t<n.length&&n[t]&&(n[t].outputContourId=e)};let a=t,l=t;for(i.points.push(n[t].point);o(a),a=n[a].otherPos,o(a),i.points.push(n[a].point),a=vp(a,n,r,l),!(a==l||a>=n.length)&&n[a];);s.push(i)}return s}(c),h=[];for(let e=0;e<u.length;e++){let t=u[e];if(t.isExterior()){let e=[t.points];for(let i=0;i<t.holeIds.length;i++)e.push(u[t.holeIds[i]].points);h.push(e)}}return h}function Mp(e,t,i,n){const r=[],s=0===n?(e,t,i,n,r,s)=>{e.push(new Ae(s,i+(s-t)/(n-t)*(r-i)))}:(e,t,i,n,r,s)=>{e.push(new Ae(t+(s-i)/(r-i)*(n-t),s))};for(const o of e){const e=[];for(const r of o){if(r.length<=2)continue;const o=[];for(let e=0;e<r.length-1;e++){const a=r[e].x,l=r[e].y,c=r[e+1].x,u=r[e+1].y,h=0===n?a:l,d=0===n?c:u;h<t?d>t&&s(o,a,l,c,u,t):h>i?d<i&&s(o,a,l,c,u,i):o.push(r[e]),d<t&&h>=t&&s(o,a,l,c,u,t),d>i&&h<=i&&s(o,a,l,c,u,i)}let a=r.at(-1);const l=0===n?a.x:a.y;l>=t&&l<=i&&o.push(a),o.length&&(a=o.at(-1),o[0].x===a.x&&o[0].y===a.y||o.push(o[0]),e.push(o))}e.length&&r.push(e)}return r}function Ip(e,t){const i=Ap(Pp(e),Pp([t]),0);return null==i?[]:Lp(i)}function Cp(e,t,i=0){const n=65536;let r=Pp(e,n);const s=[];for(;t.valid();t.next()){const[e,r]=t.get();let o=e.x*n,a=e.y*n,l=r.x*n,c=r.y*n;const u=l-o,h=c-a,d=Math.hypot(u,h);if(0===d)continue;o-=u*i,a-=h*i,l+=u*i,c+=h*i;const p=Math.trunc(h/d*3),f=-Math.trunc(u/d*3);s.push([[[o,a],[l,c],[l+p,c+f],[o+p,a+f],[o,a]]])}return s.length>0&&(r=Ap(r,s,2)),Lp(r,1/n,128)}function Pp(e,t=1){return[e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Lp(e,t=1,i){return e.map(e=>e.map((e,n)=>{const r=e.map(e=>{let n=e[0],r=e[1];return i&&(n=Math.round(n/i)*i,r=Math.round(r/i)*i),new Ae(n*t,r*t)._round()});return n>0&&r.reverse(),r}))}class Rp{constructor(e,t){this.layoutVertexArray=new el,this.indexArray=new wl,this.lineIndexArray=new _l,this.triangleSegments=new Ql,this.lineSegments=new Ql,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new nl)}update(e,t,i,n,r,s,o,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,ud.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,i,n,r,s,o){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,n,r,s,void 0,o)}}class Op{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Rp(e,!1),this.elevationBufferData=new Rp(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.hasPattern=jd("fill",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=uu(o,e);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:cu(o,i,n),patterns:{},sortKey:h};s.push(d)}r&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const n of s){const{geometry:r,index:s,sourceLayerIndex:o}=n;if(this.hasPattern){const e=Gd("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,s,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[s].feature,r,s,o,this.index)}}update(e,t,i,n,r,s,o){this.bufferData.update(e,t,i,n,r,s,o,this.worldview),this.elevationBufferData.update(e,t,i,n,r,s,o,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,n,r,s,o,this.worldview)}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e))}addFeatures(e,t,i,n,r,s){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,s,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,i,n,r,s=[],o,a){const l=zd(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,r,s,n,o,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,r,s,n,o,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,i,n,r){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,n,r,this.worldview))}addElevatedRoadFeature(e,t,i,n,r){const s=new Array,o=Nu.getElevationFeature(e,r);if(!o)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&s.push({polygons:e,elevationFeature:o,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:n};for(const t of s)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new qd(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let n=0;Object.hasOwn(e.properties,vu)&&(n=+e.properties[vu]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,i,t.elevationFeature,n)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const r=new ku(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,r,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a)}}addElevatedGeometry(e,t,i,n,r,s){const o={elevation:i,elevationSampler:t,bias:n,index:r,featureInfo:s},[a,l]=this.addGeometry(e,this.elevationBufferData,o);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=null;i&&(s=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=s&&(n=s,r=s));const o=(e,o,a)=>{if(null!=i)if(o.push(e),null!=s)t.elevatedLayoutVertexArray.emplaceBack(s),a.push(s);else{const s=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(s),a.push(s),n=Math.min(n,s),r=Math.max(r,s)}};for(const n of e){let e=0;for(const t of n)e+=t.length;const r=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),s=r.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(a.length/2);const r=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),s=r.vertexLength;i&&h.push(t.layoutVertexArray.length-d),o(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(s+e.length-1,s),a.push(e[0].x),a.push(e[0].y);for(let i=1;i<e.length;i++)o(e[i],c,u),t.layoutVertexArray.emplaceBack(e[i].x,e[i].y),t.lineIndexArray.emplaceBack(s+i-1,s+i),a.push(e[i].x),a.push(e[i].y);r.vertexLength+=e.length,r.primitiveLength+=e.length}const p=pd(a,l);for(let e=0;e<p.length;e+=3)t.indexArray.emplaceBack(s+p[e],s+p[e+1],s+p[e+2]);if(p.length>0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,n=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,n,e);const r=h.length;if(r>0){for(let s=0;s<r-1;s++)this.elevatedStructures.addRenderableRing(i.index,h[s]+n,h[s+1]-h[s],e,t,i.featureInfo);this.elevatedStructures.addRenderableRing(i.index,h[r-1]+n,c.length-h[r-1],e,t,i.featureInfo)}}r.vertexLength+=e,r.primitiveLength+=p.length/3}return[n,r]}prepareElevatedPolygons(e,t,i){const n=1/eu(i),r=[];for(const i of e){const e=Cp(i,new Bu(t,n),.1);r.push(...e)}return r}clipPolygonsToTile(e,t){const i=-t,n=-t,r=Qn+t,s=Qn+t;let o=0;const a=[],l=[];for(;o<e.length;o++){const t=e[o],c=Ln(t);(c.min.x>=i&&c.max.x<=r&&c.min.y>=n&&c.max.y<=s?a:l).push(t)}if(a.length===e.length)return e;const c=[new Ae(i,n),new Ae(r,n),new Ae(r,s),new Ae(i,s),new Ae(i,n)],u=a;for(const e of l)u.push(...Ip(e,c));return u}}let Dp,Bp,Fp,Np;lo(Op,"FillBucket",{omit:["layers","patternFeatures"]}),lo(Rp,"FillBufferData"),lo(qd,"ElevatedStructures");class kp{constructor(e,t,i,n){if(this.triangleCount=t.length/3,this.min=new Ae(0,0),this.max=new Ae(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[r,s]=[e[0].clone(),e[0].clone()];for(let t=1;t<e.length;++t){const i=e[t];r.x=Math.min(r.x,i.x),r.y=Math.min(r.y,i.y),s.x=Math.max(s.x,i.x),s.y=Math.max(s.y,i.y)}if(n){const e=Math.ceil(Math.max(s.x-r.x,s.y-r.y)/n);i=Math.max(i,e)}if(0===i)return;this.min=r,this.max=s;const o=this.max.sub(this.min);o.x=Math.max(o.x,1),o.y=Math.max(o.y,1);const a=Math.max(o.x,o.y)/i;this.cellsX=Math.max(1,Math.ceil(o.x/a)),this.cellsY=Math.max(1,Math.ceil(o.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let i=0;i<this.triangleCount;i++){const n=e[t[3*i+0]].sub(this.min),r=e[t[3*i+1]].sub(this.min),s=e[t[3*i+2]].sub(this.min),o=zp(Math.floor(Math.min(n.x,r.x,s.x)),this.xScale,this.cellsX),c=zp(Math.floor(Math.max(n.x,r.x,s.x)),this.xScale,this.cellsX),u=zp(Math.floor(Math.min(n.y,r.y,s.y)),this.yScale,this.cellsY),h=zp(Math.floor(Math.max(n.y,r.y,s.y)),this.yScale,this.cellsY),d=new Ae(0,0),p=new Ae(0,0),f=new Ae(0,0),m=new Ae(0,0);for(let e=u;e<=h;++e){d.y=p.y=e*a,f.y=m.y=(e+1)*a;for(let t=o;t<=c;++t)d.x=f.x=t*a,p.x=m.x=(t+1)*a,(ih(n,r,s,d,p,m)||ih(n,r,s,d,m,f))&&l.push({cellIdx:e*this.cellsX+t,triIdx:i})}}if(0===l.length)return;l.sort((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let c=0;for(;c<l.length;){const e=l[c].cellIdx,t={start:this.payload.length,len:0};for(;c<l.length&&l[c].cellIdx===e;)++t.len,this.payload.push(l[c++].triIdx);this.cells[e]=t}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,t){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=zp(e.x-this.min.x,this.xScale,this.cellsX),n=zp(e.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let e=0;e<r.len;e++){const i=this.payload[r.start+e],n=Math.floor(i/8),s=1<<i%8;if(!(this.lookup[n]&s)&&(this.lookup[n]|=s,t.push(i),t.length===this.triangleCount))return}}}query(e,t,i){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=zp(e.x-this.min.x,this.xScale,this.cellsX),r=zp(t.x-this.min.x,this.xScale,this.cellsX),s=zp(e.y-this.min.y,this.yScale,this.cellsY),o=zp(t.y-this.min.y,this.yScale,this.cellsY);for(let e=s;e<=o;e++)for(let t=n;t<=r;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;e<n.len;e++){const t=this.payload[n.start+e],r=Math.floor(t/8),s=1<<t%8;if(!(this.lookup[r]&s)&&(this.lookup[r]|=s,i.push(t),i.length===this.triangleCount))return}}}}function zp(e,t,i){return Math.max(0,Math.min(i-1,Math.floor(e*t)))}lo(kp,"TriangleGridIndex");class Up{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){const r=[];for(const{feature:s,id:o,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=uu(s,e);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:o,properties:s.properties,type:s.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:cu(s,i,n),patterns:{}};r.push(u)}for(const n of r){const{geometry:r,index:s,sourceLayerIndex:o}=n;this.addFeature(n,r,s,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[s].feature,r,s,o,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,n,r,s,o){}destroy(){}addFeature(e,t,i,n,r,s=[],o){for(const e of zd(t,2)){const t=[],i=[],n=[],r=new Ae(1/0,1/0),s=new Ae(-1/0,-1/0);for(const o of e)if(0!==o.length){o!==e[0]&&n.push(i.length/2);for(let e=0;e<o.length;e++)i.push(o[e].x),i.push(o[e].y),t.push(o[e]),r.x=Math.min(r.x,o[e].x),r.y=Math.min(r.y,o[e].y),s.x=Math.max(s.x,o[e].x),s.y=Math.max(s.y,o[e].y)}const o=pd(i,n),a=new kp(t,o,8,256);this.footprints.push({vertices:t,indices:o,grid:a,min:r,max:s})}}}lo(Up,"ClipBucket",{omit:["layers"]});const Vp=Ka([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),jp=Ka([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Gp=Ka([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),Hp=Ka([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Wp=Ka([{name:"a_join_normal_inside",components:3,type:"Int16"}]),qp=Ka([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Xp=Ka([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:$p}=Vp,Zp=Number.MAX_SAFE_INTEGER,Yp=Zp-1;function Jp(e,t,i,n){return e.order<t||e.order===Zp||!(e.clipMask&i)||function(e,t){if(0===t.length)return!1;let i=e;for(;""!==i;){if(t.includes(i))return!1;i=za(i)}return!0}(n,e.clipScope)}function Kp(e,t){return e.x-t.x||e.y-t.y}function Qp(e,t){return 0===Kp(e.min,t.min)&&0===Kp(e.max,t.max)}function ef(e,t){return!(e.min.x>t.max.x||e.max.x<t.min.x||e.min.y>t.max.y||e.max.y<t.min.y)}function tf(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i].sourceId!==t[i].sourceId||!Qp(e[i],t[i])||e[i].order!==t[i].order||e[i].clipMask!==t[i].clipMask||!Me(e[i].clipScope,t[i].clipScope))return!1;return!0}function nf(e,t,i){const n=1/Qn,r=1/(1<<i.canonical.z),s=(t.x*n+i.canonical.x)*r+i.wrap,o=(t.y*n+i.canonical.y)*r;return{min:new Ae((e.x*n+i.canonical.x)*r+i.wrap,(e.y*n+i.canonical.y)*r),max:new Ae(s,o)}}function rf(e,t,i){const n=1<<i.canonical.z,r=((t.x-i.wrap)*n-i.canonical.x)*Qn,s=(t.y*n-i.canonical.y)*Qn;return{min:new Ae(((e.x-i.wrap)*n-i.canonical.x)*Qn,(e.y*n-i.canonical.y)*Qn),max:new Ae(r,s)}}function sf(e,t,i,n,r,s,o){const a=e.indices,l=e.vertices,c=[];for(let u=n;u<n+r;u+=3){const n=t[i[u+0]+s],r=t[i[u+1]+s],h=t[i[u+2]+s],d=Math.min(n.x,r.x,h.x),p=Math.max(n.x,r.x,h.x),f=Math.min(n.y,r.y,h.y),m=Math.max(n.y,r.y,h.y);c.length=0,e.grid.query(new Ae(d,f),new Ae(p,m),c);for(let e=0;e<c.length;e++){const t=c[e];if(ih(l[a[3*t+0]],l[a[3*t+1]],l[a[3*t+2]],n,r,h,o))return!0}}return!1}function of(e,t,i,n){if(!e||!i)return!1;let r=e.vertices;if(!t.canonical.equals(n.canonical)||t.wrap!==n.wrap){if(i.vertices.length<e.vertices.length)return of(i,n,e,t);const s=t.canonical,o=n.canonical,a=Math.pow(2,o.z-s.z);r=e.vertices.map(e=>new Ae((e.x+s.x*Qn)*a-o.x*Qn,(e.y+s.y*Qn)*a-o.y*Qn))}return sf(i,r,e.indices,0,e.indices.length,0,0)}function af(e,t,i,n){const r=Math.pow(2,n.z-i.z);return new Ae((e+i.x*Qn)*r-n.x*Qn,(t+i.y*Qn)*r-n.y*Qn)}function lf(e,t){const i=[];t.grid.queryPoint(e,i);const n=t.indices,r=t.vertices;for(let t=0;t<i.length;t++){const s=i[t];if(Ku([r[n[3*s+0]],r[n[3*s+1]],r[n[3*s+2]]],e))return!0}return!1}const cf={None:0,Model:1,Symbol:2,FillExtrusion:4},uf=[new Ae(0,0),new Ae(Qn,0),new Ae(Qn,Qn),new Ae(0,Qn)];function hf(e,t){const i=[];let n=[];if(!t||e.length<2)return[e];if(2===e.length)return eh(e[0],e[1],uf)?[e]:[];for(let t=0;t<e.length+2;t++){const r=0===t?e.at(-1):e[(t-1)%e.length],s=e[t%e.length],o=e[(t+1)%e.length],a=eh(r,s,uf),l=eh(s,o,uf),c=a||l;c&&n.push(s),c&&l||n.length>0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const df=hu.types,pf=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],ff=["fill-extrusion-flood-light-ground-radius"],mf=Math.pow(2,13),gf=Math.pow(2,15)-1,_f=new Ae(0,1),yf=2147483648,vf=1073741824;function xf(e,t,i,n,r,s,o,a){e.emplaceBack((t<<1)+o,(i<<1)+s,(Math.floor(n*mf)<<1)+r,Math.round(a))}function bf(e,t,i){e.emplaceBack(t.x*Qn,t.y*Qn,i?1:0)}function wf(e,t,i,n,r,s){e.emplaceBack(t.x,t.y,(i.x<<1)+n,(i.y<<1)+r,s)}function Tf(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class Sf{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Ef{constructor(){this.data=[]}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}static serialize(e,t){const i=e.data.length,n=new Uint32Array(4*i),r=[];r.length=i;for(let t=0;t<i;t++){const i=e.data[t],s=4*t;n[s]=i.vertexOffset,n[s+1]=i.vertexCount,n[s+2]=i.indexOffset,n[s+3]=i.indexCount,r[t]=i.ringIndices}return t&&t.add(n.buffer),{scalars:n,rings:r}}static deserialize(e){const{scalars:t,rings:i}=e,n=t.length/4,r=new Ef,s=[];s.length=n,r.data=s;for(let e=0;e<n;e++){const n=4*e,s=new Sf;s.vertexOffset=t[n],s.vertexCount=t[n+1],s.indexOffset=t[n+2],s.indexCount=t[n+3],s.ringIndices=i[e],r.data[e]=s}return r}}class Af{constructor(){this.centroidXY=new Ae(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Ae(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Ae(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Ae(0,0)}span(){return new Ae(this.max.x-this.min.x,this.max.y-this.min.y)}}class Mf{constructor(){this.data=[],this.buffer=null}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}find(e){return this.data.find(e)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(e,t){const i=e.data.length,n=new Float64Array(15*i);for(let t=0;t<i;t++){const i=e.data[t],r=15*t;n[r]=i.centroidXY.x,n[r+1]=i.centroidXY.y,n[r+2]=i.min.x,n[r+3]=i.min.y,n[r+4]=i.max.x,n[r+5]=i.max.y,n[r+6]=i.groupCentroidPos.x,n[r+7]=i.groupCentroidPos.y,n[r+8]=i.vertexArrayOffset,n[r+9]=i.vertexCount,n[r+10]=i.groundVertexArrayOffset,n[r+11]=i.groundVertexCount,n[r+12]=i.footprintSegLen,n[r+13]=i.height,n[r+14]=i.buildingId}return t&&t.add(n.buffer),{buffer:n}}static deserialize(e){const t=e.buffer,i=t.length/15,n=new Mf;n.buffer=t;const r=[];r.length=i,n.data=r;let s=0;for(let e=0;e<i;e++){const i=15*e,r=new Af;r.centroidXY=new Ae(t[i],t[i+1]),r.min=new Ae(t[i+2],t[i+3]),r.max=new Ae(t[i+4],t[i+5]),r.groupCentroidPos=new Ae(t[i+6],t[i+7]),r.vertexArrayOffset=t[i+8],r.vertexCount=t[i+9],r.groundVertexArrayOffset=t[i+10],r.groundVertexCount=t[i+11],r.footprintSegLen=t[i+12],r.height=t[i+13],r.buildingId=t[i+14],r.footprintSegIdx=s,s+=r.footprintSegLen,n.data[e]=r}return n}}class If{constructor(){this.acc=new Ae(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,i){this.accCount++,this.acc._add(t);let n=!!this.borders;t.x<e.min.x?(e.min.x=t.x,n=!0):t.x>e.max.x&&(e.max.x=t.x,n=!0),t.y<e.min.y?(e.min.y=t.y,n=!0):t.y>e.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Qn)&&t.x===i.x)!=((0===t.y||t.y===Qn)&&t.y===i.y)&&this.processBorderOverlap(t,i),n&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,xi(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Qn!=e.x>Qn&&this.addBorderIntersection(1,xi(t.y,e.y,(Qn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,xi(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Qn!=e.y>Qn&&this.addBorderIntersection(3,xi(t.x,e.x,(Qn-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){return 0===this.accCount?new Ae(0,0):new Ae(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function Cf(e,t){const i=e.add(t)._unit(),n=ze(e.x*i.x+e.y*i.y,-1,1);var r,s,o;return o=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(o)))/4*gf*((r=e).x*(s=t).y-r.y*s.x<0?-1:1)}const Pf=[e=>e.x<0,e=>e.x>Qn,e=>e.y<0,e=>e.y>Qn];function Lf(e,t,i,n){const r=[4];if(0===n)return r;i._mult(n);const s=e.sub(i),o=t.sub(i),a=[e,t,s,o];for(let e=0;e<4;e++)for(const t of a)if(Pf[e](t)){r.push(e);break}return r}class Rf{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new al,this.indexArray=new wl,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut},e=>ff.includes(e)),this._segments=new Ql,this.hiddenByLandmarkVertexArray=new Fl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Ql}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,n=!1){const r=e.length;if(r>2){let s=Math.max(0,this._segments.get().length-1);const o=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let a;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=Cf(t.sub(e[r-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;l<r;l++){const c=l===r-1?0:l+1,u=e[l],h=e[c],d=e[c===r-1?0:c+1],p=h.sub(u)._perp()._unit(),f=Cf(p,d.sub(h)._perp()._unit()),m=a,g=f;if(Nf(u,h,t)||n&&kf(u,t)&&kf(h,t)){a=f;continue}const _=o.vertexLength;wf(this.vertexArray,u,h,1,1,m),wf(this.vertexArray,u,h,1,0,m),wf(this.vertexArray,u,h,0,1,g),wf(this.vertexArray,u,h,0,0,g),o.vertexLength+=4;const y=Lf(u,h,p,i);for(const e of y)this._segmentToGroundQuads[s].push({id:_,region:e}),this._segmentToRegionTriCounts[s][e]+=2,o.primitiveLength+=2;a=f}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let e=0;e<t;e++)this._segmentToGroundQuads[e].sort((e,t)=>e.region-t.region);for(let i=0;i<t;i++){const t=this._segmentToGroundQuads[i],n=e[i],r=this._segmentToRegionTriCounts[i];r.reduce((e,t)=>e+t,0);let s=0;for(let e=0;e<=4;e++){const t=r[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new Ql);const r={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:t};i.get().push(r)}s+=t}for(let e=0;e<t.length;e++){const i=t[e].id;this.indexArray.emplaceBack(i,i+1,i+3),this.indexArray.emplaceBack(i,i+3,i+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,t,i,n,r,s,o){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,i,n,r,s,void 0,o)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,jp.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,Gp.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,t,i,n,r,s,o,a){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,i,n,r,s,o,a)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&yf||e.flags&vf))}updateHiddenByLandmarkRange(e,t,i){if(!this.hasData())return;const n=t+e;if(0!==t){for(let t=e;t<n;++t)this.hiddenByLandmarkVertexArray.emplace(t,i?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,qp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Of{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new Mf,this.footprintIndices=new wl,this.footprintVertices=new el,this.footprintSegments=new Ef,this.layoutVertexArray=new ol,this.centroidVertexArray=new Xl,this.wallVertexArray=new Zl,this.indexArray=new wl,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut},e=>pf.includes(e)),this.segments=new Ql,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new Rf(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.features=[],this.hasPattern=jd("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=eu(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:s,index:o,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=uu(r,e);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:s,sourceLayerIndex:a,index:o,geometry:e?l.geometry:cu(r,i,n),properties:r.properties,type:r.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===df[c.type];if(this.hasPattern)this.features.push({featureId:r.id,feature:Gd("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const s of hf(e,h))this.addFeature(r.id,c,[s],o,i,{},t.availableImages,n,t.brightness);else this.addFeature(r.id,c,c.geometry,o,i,{},t.availableImages,n,t.brightness);t.featureIndex.insert(r,c.geometry,o,a,this.index,u)}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,n,r,s){for(const{featureId:e,feature:o}of this.features){const a="Polygon"===df[o.type],{geometry:l}=o;if(this.wallMode)for(const c of l)for(const l of hf(c,a))this.addFeature(e,o,[l],o.index,t,i,n,r,s);else this.addFeature(e,o,l,o.index,t,i,n,r,s)}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,n,r,s,o){this.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,this.worldview),this.groundEffect.update(e,t,r,i,n,s,o,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$p),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Wp.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Xp.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Hp.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,n,r,s,o,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Ae(0,0),new Ae(Qn,Qn)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===df[t.type],f=new If;f.centroidDataIndex=this.centroidData.length;const m=new Af;m.buildingId=e,t.properties&&Object.hasOwn(t.properties,"building_id")&&(m.buildingId=Number(t.properties.building_id)),f.buildingId=m.buildingId;const g=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},r);let y;if(m.height=_,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new dl),this.wallMode){if(d)return void Qe("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;y=function(e){const t=e[0].x===e.at(-1).x&&e[0].y===e.at(-1).y,i=function(e){let t=0;const i=e.length;for(let n=0;n<i;n++)t+=(e[(n+1)%i].x-e[n].x)*(e[(n+1)%i].y+e[n].y);return t>=0}(e);i||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],s=[],o=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return n;let l,c,u,h,d,p=0;for(;p<a-1&&e[p].equals(e[p+1]);)p++;t&&(l=e[a-2],d=e[p].sub(l)._unit()._perp());for(let i=p;i<a;i++){if(u=i===a-1?t?e[p+1]:void 0:e[i+1],u&&e[i].equals(u))continue;d&&(h=d),l&&(c=l),l=e[i],d=u?u.sub(l)._unit()._perp():h,h=h||d;let n=h.add(d);0===n.x&&0===n.y||n._unit();const f=n.x*d.x+n.y*d.y,m=0!==f?1/f:1/0,g=h.x*d.y-h.y*d.x>0;let _="miter";const y=2;"miter"===_&&m>y&&(_="bevel"),"bevel"===_&&(m>100&&(_="flipbevel"),m<y&&(_="miter"));const v=(e,t,i,n)=>{const a=new Ae(e.x,e.y),l=new Ae(e.x,e.y);a.x+=t.x*n,a.y+=t.y*n,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),o.push(t),r.push(a),s.push(l)};if("miter"===_)n._mult(m),v(l,n,0,0);else if("flipbevel"===_)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=g?e:0,i=g?0:e;c&&v(l,h,t,i),u&&v(l,d,t,i)}}n.geometry=[...r,...s.reverse(),r[0]],n.joinNormals=[...o,...o.reverse(),o.at(-1)];const f=n.geometry.length-1;for(let e=0;e<f/2;e++)if(e+1<f/2){let t=e,i=e+1,r=f-1-e,s=f-2-e;t=0===t?f-1:t-1,i=0===i?f-1:i-1,r=0===r?f-1:r-1,s=0===s?f-1:s-1,n.indices.push(r),n.indices.push(i),n.indices.push(t),n.indices.push(r),n.indices.push(s),n.indices.push(i)}return n}(i[0]),i=[y.geometry]}const v=(e,t)=>e<(t.length-1)/2||e===t.length-1,x=this.wallMode?[i]:zd(i,500);for(let e=x.length-1;e>=0;e--){const t=x[e];(0===t.length||zf(t[0]))&&x.splice(e,1)}let b;if(d)b=Gf(x,u,r);else{b=[];for(const e of x)b.push({polygon:e,bounds:u})}const w=p?this.edgeRadius:0,T=w>0&&this.zoom<17,S=(e,t)=>{if(0===e.length)return!1;const i=e.at(-1);return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of b){let i=0,n=0;for(const t of e)p&&!t[0].equals(t.at(-1))&&t.push(t[0]),n+=p?t.length-1:t.length;const s=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const o={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new Sf;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const n=[],o=[];i=s.vertexLength;for(let i=0;i<e.length;i++){const l=e[i];l.length&&0!==i&&o.push(n.length/2);const u=[];let p,f;p=l[1].sub(l[0])._perp()._unit(),a.ringIndices.push(l.length-1);for(let e=1;e<l.length;e++){const t=l[e],i=l[e===l.length-1?1:e+1],o=t.clone();if(w){f=i.sub(t)._perp()._unit();const e=p.add(f)._unit(),n=w*Math.min(4,1/(p.x*e.x+p.y*e.y));o.x+=n*e.x,o.y+=n*e.y,o.x=Math.round(o.x),o.y=Math.round(o.y),p=f}if(!g||0!==w&&!T||S(u,o)||u.push(o),xf(this.layoutVertexArray,o.x,o.y,0,0,1,1,0),this.wallMode){const t=v(e,l);bf(this.wallVertexArray,y.joinNormals[e],!t)}s.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),n.push(t.x,t.y),d&&Tf(this.layoutVertexExtArray,h.projectTilePoint(o.x,o.y,r),h.upVector(r,o.x,o.y))}g&&(0===w||T)&&(0!==u.length&&S(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c))}const l=this.wallMode?y.indices:pd(n,o);for(let e=0;e<l.length;e+=3)this.footprintIndices.emplaceBack(a.vertexOffset+l[e+0],a.vertexOffset+l[e+1],a.vertexOffset+l[e+2]),this.indexArray.emplaceBack(i+l[e],i+l[e+2],i+l[e+1]),s.primitiveLength++;a.indexCount+=l.length,a.vertexCount+=this.footprintVertices.length-a.vertexOffset}for(let n=0;n<e.length;n++){const o=e[n];f.startRing(m,o[0]);let a=o.length>4&&Uf(o[o.length-2],o[0],o[1]),l=w?Bf(o[o.length-2],o[0],o[1],w):0;const u=[];let _,x,b;x=o[1].sub(o[0])._perp()._unit();let T=!0;for(let e=1,n=0;e<o.length;e++){let c=o[e-1],p=o[e];const E=o[e===o.length-1?1:e+1];if(f.appendEdge(m,p,c),Nf(p,c,t)){w&&(x=E.sub(p)._perp()._unit(),T=!T);continue}const A=p.sub(c)._perp(),M=A.x/(Math.abs(A.x)+Math.abs(A.y)),I=A.y>0?1:0,C=c.dist(p);if(n+C>32768&&(n=0),w){b=E.sub(p)._perp()._unit();let e=Ff(c,p,E,Df(x,b),w);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,x=b,g&&this.zoom>=17&&(S(u,c)||u.push(c),S(u,p)||u.push(p))}const P=s.vertexLength,L=o.length>4&&Uf(c,p,E);let R=Vf(n,a,T);if(xf(this.layoutVertexArray,c.x,c.y,M,I,0,0,R),xf(this.layoutVertexArray,c.x,c.y,M,I,0,1,R),this.wallMode){const t=v(e-1,o),i=y.joinNormals[e-1];bf(this.wallVertexArray,i,t),bf(this.wallVertexArray,i,t)}if(n+=C,R=Vf(n,L,!T),a=L,xf(this.layoutVertexArray,p.x,p.y,M,I,0,0,R),xf(this.layoutVertexArray,p.x,p.y,M,I,0,1,R),this.wallMode){const t=v(e,o),i=y.joinNormals[e];bf(this.wallVertexArray,i,t),bf(this.wallVertexArray,i,t)}if(s.vertexLength+=4,this.indexArray.emplaceBack(P+0,P+1,P+2),this.indexArray.emplaceBack(P+1,P+3,P+2),s.primitiveLength+=2,w){const n=i+(1===e?o.length-2:e-2),r=1===e?i:n+1;if(this.indexArray.emplaceBack(P+1,n,P+3),this.indexArray.emplaceBack(n,r,P+3),s.primitiveLength+=2,void 0===_&&(_=P),!Nf(E,o[e],t)){const t=e===o.length-1?_:s.vertexLength;this.indexArray.emplaceBack(P+2,P+3,t),this.indexArray.emplaceBack(P+3,t+1,t),this.indexArray.emplaceBack(P+3,r,t+1),s.primitiveLength+=3}T=!T}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,r),i=h.projectTilePoint(p.x,p.y,r),n=h.upVector(r,c.x,c.y),s=h.upVector(r,p.x,p.y);Tf(e,t,n),Tf(e,t,n),Tf(e,i,s),Tf(e,i,s)}}p&&(i+=o.length-1),g&&w&&this.zoom>=17&&(0!==u.length&&S(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,w>0))}this.footprintSegments.push(a),o.triangleCount=this.indexArray.length-o.triangleArrayOffset,this.polygonSegments.push(o),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?_f:this.encodeCentroid(f,m),t.properties&&Object.hasOwn(t.properties,"building_id")){const e=m.buildingId;let t=this.buildingGroups.get(e);t||(t={accX:0,accY:0,accCount:0,mergedMin:new Ae(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Ae(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(e,t)),t.accX+=f.acc.x,t.accY+=f.acc.y,t.accCount+=f.accCount,t.mergedMin.x=Math.min(t.mergedMin.x,m.min.x),t.mergedMin.y=Math.min(t.mergedMin.y,m.min.y),t.mergedMax.x=Math.max(t.mergedMax.x,m.max.x),t.mergedMax.y=Math.max(t.mergedMax.y,m.max.y),t.partIndices.push(this.centroidData.length)}if(this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;t<f.borders.length;t++)f.borders[t][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[t].push(e)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,s,o,r,l,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,n,s,o,r,l,this.worldview),this.maxHeight=Math.max(this.maxHeight,_)}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(0===e.partIndices.length)continue;const t=new If;t.acc=new Ae(e.accX,e.accY),t.accCount=e.accCount;const i=new Af;i.min=e.mergedMin,i.max=e.mergedMax;const n=this.encodeCentroid(t,i),r=t.centroid();for(const t of e.partIndices){const i=this.centroidData.get(t);i.centroidXY.x===_f.x&&i.centroidXY.y===_f.y||(i.centroidXY=n),i.min=e.mergedMin,i.max=e.mergedMax,i.groupCentroidPos=r}}this.buildingGroups.clear()}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const i=this.centroidData.get(t),n=+(i.min.y+i.max.y>Qn),r=2*n+(+(i.min.x+i.max.x>Qn)^n);for(let n=0;n<i.polygonSegLen;n++){const s=i.polygonSegIdx+n;e.push({centroidIdx:t,subtile:r,polygonSegmentIdx:s,triangleSegmentIdx:this.polygonSegments[s].triangleSegIdx})}}const t=new wl;e.sort((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let i=0,n=0,r=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;r++}const s=e.length;for(;n!==e.length;){i=e[n].triangleSegmentIdx;let o=0,a=n,l=n;for(let t=a;t<r&&e[t].subtile===o;t++)l++;for(;a!==r;){const n=e[a];o=n.subtile;const s=this.centroidData.get(n.centroidIdx).min.clone(),c=this.centroidData.get(n.centroidIdx).max.clone(),u={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let i=a;i<l;i++){const n=e[i],r=this.polygonSegments[n.polygonSegmentIdx],o=this.centroidData.get(n.centroidIdx).min,a=this.centroidData.get(n.centroidIdx).max,l=this.indexArray.uint16;for(let e=r.triangleArrayOffset;e<r.triangleArrayOffset+r.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);u.primitiveLength+=r.triangleCount,s.x=Math.min(s.x,o.x),s.y=Math.min(s.y,o.y),c.x=Math.max(c.x,a.x),c.y=Math.max(c.y,a.y)}u.primitiveLength>0&&this.triangleSubSegments.push({segment:u,min:s,max:c}),a=l;for(let t=a;t<r&&e[t].subtile===e[a].subtile;t++)l++}n=r;for(let t=n;t<s&&e[t].triangleSegmentIdx===e[n].triangleSegmentIdx;t++)r++}t._trim(),this.indexArray=t}getVisibleSegments(e,t,i){const n=new Ql;if(this.wallMode){for(const e of this.triangleSubSegments)n.segments.push(e.segment);return n}let r=0,s=0;const o=1<<e.canonical.z;if(t){const i=t.getMinMaxForTile(e);i&&(r=i.min,s=i.max)}s+=this.maxHeight;const a=e.toUnwrapped();let l;const c=[a.canonical.x/o+a.wrap,a.canonical.y/o],u=[(a.canonical.x+1)/o+a.wrap,(a.canonical.y+1)/o],h=(e,t,i)=>[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Qn,d[1]=e.min.y/Qn,p[0]=e.max.x/Qn,p[1]=e.max.y/Qn;const t=h(c,u,d),o=h(c,u,p);if(0===new Du([t[0],t[1],r],[o[0],o[1],s]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(e,t){const i=e.centroid(),n=t.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(6,Math.round(n.y*this.tileToMeter/10));return new Ae(ze(i.x,1,8191)<<3|r,ze(i.y,1,8191)<<3|s)}encodeBorderCentroid(e){if(!e.borders)return new Ae(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Ae(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Ae((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData.get(e.centroidDataIndex);if(t.flags&=yf,0!==t.groupCentroidPos.x||0!==t.groupCentroidPos.y){const e=t.span(),i=Math.min(7,Math.round(e.x*this.tileToMeter/10)),n=Math.min(6,Math.round(e.y*this.tileToMeter/10));t.centroidXY=new Ae(ze(t.groupCentroidPos.x,1,8191)<<3|i,ze(t.groupCentroidPos.y,1,8191)<<3|n)}else t.centroidXY=new Ae(0,0);this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,n=-1073741824&e.flags?_f:e.centroidXY,r=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||r!==n.x){for(let e=t;e<i;++e)this.centroidVertexArray.emplace(e,n.x,n.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(tf(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=1073741823;const r=[];for(const t of this.activeReplacements){if(t.order<i)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));if(t.footprint.buildingIds)for(const e of this.centroidData)e.flags&yf||e.flags&vf||t.min.x>e.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=t.clipMask!==cf.None?-1073741824:yf);else for(const i of this.centroidData)if(!(i.flags&yf||i.flags&vf||t.min.x>i.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let s=0;s<i.footprintSegLen;s++){const o=this.footprintSegments.get(i.footprintSegIdx+s);if(r.length=0,Hf(this.footprintVertices,o.vertexOffset,o.vertexCount,t.footprintTileId.canonical,e.canonical,r),sf(t.footprint,r,this.footprintIndices.uint16,o.indexOffset,o.indexCount,-o.vertexOffset,-n)){i.flags|=t.clipMask!==cf.None?-1073741824:yf;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,t,i){let n=!1;for(let r=0;r<i.footprintSegLen;r++){const s=this.footprintSegments.get(i.footprintSegIdx+r);let o=0;for(const i of s.ringIndices){for(let r=o,a=i+o-1;r<i+o;a=r++){const i=this.footprintVertices.int16[2*(r+s.vertexOffset)+0],o=this.footprintVertices.int16[2*(r+s.vertexOffset)+1],l=this.footprintVertices.int16[2*(a+s.vertexOffset)+1];o>t!=l>t&&e<(this.footprintVertices.int16[2*(a+s.vertexOffset)+0]-i)*(t-o)/(l-o)+i&&(n=!n)}o=i}}return n}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Qn)*Qn+(t+Qn);if(Object.hasOwn(this.partLookup,r)){const e=this.partLookup[r];return e?{height:e.height,hidden:!!(e.flags&yf)}:void 0}const s=this.centroidData.buffer,o=this.centroidData.length;for(let a=0;a<o;a++){const o=15*a;if(e>s[o+4]||s[o+2]>e||t>s[o+5]||s[o+3]>t)continue;const l=s[o+13];if(l<=i)continue;const c=this.centroidData.get(a);this.footprintContainsPoint(e,t,c)&&(i=l,this.partLookup[r]=c,n=!!(c.flags&yf))}if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function Df(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function Bf(e,t,i,n){const r=t.sub(e)._perp()._unit(),s=i.sub(t)._perp()._unit();return Ff(e,t,i,Df(r,s),n)}function Ff(e,t,i,n,r){const s=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(i)/3,r*s/n)}function Nf(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function kf(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function zf(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=Qn)||e.every(e=>e.y<=0)||e.every(e=>e.y>=Qn)}function Uf(e,t,i){if(e.x<0||e.x>=Qn||t.x<0||t.x>=Qn||i.x<0||i.x>=Qn)return!1;const n=i.sub(t),r=n.perp(),s=e.sub(t);return(n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&r.x*s.x+r.y*s.y<0}function Vf(e,t,i){const n=t?2|e:-3&e;return i?1|n:-2&n}function jf(){const e=Math.PI/32,t=Math.tan(e),i=zc;return i*Math.sqrt(1+2*t*t)-i}function Gf(e,t,i){const n=1<<i.z,r=Xc(i.x/n),s=Xc((i.x+1)/n),o=$c(i.y/n),a=$c((i.y+1)/n);return function(e,t,i,n,r=0,s){const o=[];if(!e.length||!i||!n)return o;const a=(e,t)=>{for(const i of e)o.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),u=l-c,h=[];for(let e=0;e<Math.abs(u);e++)h.push(u>0?0:1);for(let e=0;e<Math.min(l,c);e++)h.push(0),h.push(1);let d=e;if(d=Mp(d,t[0].y-r,t[1].y+r,1),d=Mp(d,t[0].x-r,t[1].x+r,0),!d.length)return o;const p=[];for(h.length?p.push({polygons:d,bounds:t,depth:0}):a(d,t);p.length;){const e=p.pop(),t=e.depth,i=h[t],n=e.bounds[0],o=e.bounds[1],l=0===i?n.x:n.y,c=0===i?o.x:o.y,u=s?s(i,l,c):.5*(l+c),d=Mp(e.polygons,l-r,u+r,i),f=Mp(e.polygons,u-r,c+r,i);if(d.length){const e=[n,new Ae(0===i?u:o.x,1===i?u:o.y)];h.length>t+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Ae(0===i?u:n.x,1===i?u:n.y),o];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return o}(e,t,Math.ceil((s-r)/11.25),Math.ceil((o-a)/11.25),1,(e,t,r)=>{if(0===e)return.5*(t+r);{const e=$c((i.y+t/Qn)/n);return(Wc(.5*($c((i.y+r/Qn)/n)+e))*n-i.y)*Qn}})}function Hf(e,t,i,n,r,s){const o=Math.pow(2,n.z-r.z);for(let a=0;a<i;a++){let i=e.int16[2*(a+t)+0],l=e.int16[2*(a+t)+1];i=(i+r.x*Qn)*o-n.x*Qn,l=(l+r.y*Qn)*o-n.y*Qn,s.push(new Ae(i,l))}}let Wf,qf,Xf,$f;lo(Of,"FillExtrusionBucket",{omit:["layers","features"]}),lo(Af,"PartData"),lo(Mf,"PartDataArray"),lo(Ef,"FootprintSegmentArray"),lo(If,"BorderCentroidData"),lo(Rf,"GroundEffect");class Zf extends Ae{constructor(e,t,i){super(e,t),this.z=i}}class Yf extends Zf{constructor(e,t,i,n){super(e,t,i),this.w=n}}function Jf(e,t,i,n){const r="x"===i?"y":"x",s=(n-e[i])/(t[i]-e[i]);e[r]=Math.round(e[r]+(t[r]-e[r])*s),e[i]=n,Object.hasOwn(e,"z")&&(e.z=xi(e.z,t.z,s)),Object.hasOwn(e,"w")&&(e.w=xi(e.w,t.w,s))}function Kf(e,t,i,n){const r=i,s=n;for(const i of["x","y"]){let n=e,o=t;n[i]>=o[i]&&(n=t,o=e),n[i]<r&&o[i]>r&&Jf(n,o,i,r),n[i]<s&&o[i]>s&&Jf(o,n,i,s)}}function Qf(e,t,i,n,r,s){const o=[];for(let a=0;a<e.length;a++){const l=e[a];let c;const u=o.length;let h=0;for(let e=0;e<l.length-1;e++){let u=l[e],d=l[e+1],p=0;const f=h;let m,g;s&&(p=Math.hypot(d.x-u.x,d.y-u.y),h+=p,m=u,g=d),u.x<t&&d.x<t||(u.x<t?u=new Ae(t,u.y+(t-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x<t&&(d=new Ae(t,u.y+(t-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y<i&&d.y<i||(u.y<i?u=new Ae(u.x+(i-u.y)/(d.y-u.y)*(d.x-u.x),i)._round():d.y<i&&(d=new Ae(u.x+(i-u.y)/(d.y-u.y)*(d.x-u.x),i)._round()),u.x>=n&&d.x>=n||(u.x>=n?u=new Ae(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=n&&(d=new Ae(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=r&&d.y>=r||(u.y>=r?u=new Ae(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round():d.y>=r&&(d=new Ae(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round()),c&&u.equals(c.at(-1))||(c=[u],o.push(c),s&&s.push({progress:{min:f+tm(m,g,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:g})),c.push(d),s&&(s.at(-1).progress.max=f+tm(m,g,d)*p,s.at(-1).nextPoint=g)))))}if(s&&h>0)for(let e=u;e<o.length;e++)s[e].progress.min/=h,s[e].progress.max/=h}return o}function em(e,t,i,n,r){if(e.length<2)return void n.push(e);const s=[];for(;t.valid();){const[i,n]=t.get();for(let t=0;t<e.length-1;t++){const r=e[t],o=e[t+1],a=$u(r,o,i,n);if(a){const[e]=a,i=new Ae(xi(r.x,o.x,e),xi(r.y,o.y,e));s.push({t:t+e,distance:0,point:i})}}t.next()}if(0===s.length)return void n.push(e);s.sort((e,t)=>e.t-t.t);let o=0,a=0,l=[];for(n.push(l);o!==e.length;){if(a===s.length){for(;o!==e.length;)0!==l.length&&l.at(-1).equals(e[o])||l.push(e[o]),o++;break}s[a].t<=o?(0!==l.length&&l.at(-1).equals(s[a].point)||l.push(s[a].point),Math.trunc(s[a].t),a++):(0!==l.length&&l.at(-1).equals(e[o])||l.push(e[o]),o++)}}function tm(e,t,i){return e.x!==t.x?(i.x-e.x)/(t.x-e.x):e.y!==t.y?(i.y-e.y)/(t.y-e.y):0}function im(e,t){return e.x*t.x+e.y*t.y}function nm(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i<t.length;i++){const s=t[i],o=e[0],a=r.sub(n),l=s.sub(n),c=o.sub(n),u=im(a,a),h=im(a,l),d=im(l,l),p=im(c,a),f=im(c,l),m=u*d-h*h,g=(d*p-h*f)/m,_=(u*f-h*p)/m,y=n.z*(1-g-_)+r.z*g+s.z*_;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function rm(e,t,i){let n=1/0;Gu(i,t)&&(n=nm(i,t[0]));for(let r=0;r<t.length;r++){const s=t[r],o=e[r];for(let e=0;e<s.length-1;e++){const t=s[e],r=[t,s[e+1],o[e+1],o[e],t];Vu(i,r)&&(n=Math.min(n,nm(i,r)))}}return n!==1/0&&n}function sm(e,t,i,n,r,s,o,a,l,c,u){return"globe"===e.projection.name?function(e,t,i,n,r,s,o,a,l,c,u){const h=[],d=[],p=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],g=(e,t,i,n)=>{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=jf();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],y=[];for(const h of _){const d=h.x+r.x,_=h.y+r.y,v=e.projection.projectTilePoint(d,_,u),x=e.projection.upVector(u,h.x,h.y);let b=i,w=n;if(o){const e=om(d,_,i,n,o,a,l,c);b+=e.base,w+=e.top}0!==i?g(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):g(f,v.x,v.y,v.z),g(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),H(f,f,s),H(m,m,s),t.push(new Zf(f[0],f[1],f[2])),y.push(new Zf(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,i,n,r,s,o,a,l,c,u):o?function(e,t,i,n,r,s,o,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+n.x,d=c.y+n.y,f=om(u,d,t,i,s,o,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,te(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new Zf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,te(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new Zf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(g)}c.push(e),u.push(p)}return[c,u]}(t,i,n,r,s,o,a,l,c):function(e,t,i,n,r){const s=[],o=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const t of e){const e=[],i=[];for(const s of t){const t=s.x+n.x,o=s.y+n.y,m=r[0]*t+r[4]*o+r[12],g=r[1]*t+r[5]*o+r[13],_=r[2]*t+r[6]*o+r[14],y=r[3]*t+r[7]*o+r[15],v=m+a,x=g+l,b=_+c,w=Math.max(y+u,1e-5),T=m+h,S=g+d,E=_+p,A=Math.max(y+f,1e-5);e.push(new Zf(v/w,x/w,b/w)),i.push(new Zf(T/A,S/A,E/A))}s.push(e),o.push(i)}return[s,o]}(t,i,n,r,s)}function om(e,t,i,n,r,s,o,a){const l=o*r.getElevationAt(e,t,!0,!0),c=0!==s[0],u=c?0===s[1]?o*(s[0]/7-450):o*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),s=10*(t[0]-8*n),o=10*(t[1]-8*r),a=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(s*l-1)),u=Math.floor(.5*(o*l-1)),h=e.tileCoordToPixel(n,r),d=2*c+1,p=2*u+1,f=function(e,t,i,n,r){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+r,i,!0),e.getElevationAtPixel(t,i+r,!0),e.getElevationAtPixel(t+n,i+r,!0)]}(e,h.x-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+g)/d),v=Math.min(.25,.5*l*_/p);return a+Math.max(y*s,v*o)}(r,s,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+n,l+i+2):l+n}}let am=null,lm=null,cm=null,um=null;const hm=5120,dm=5121,pm=5122,fm=5123,mm=5125,gm=5126,_m={[hm]:Int8Array,[dm]:Uint8Array,[pm]:Int16Array,[fm]:Uint16Array,[mm]:Uint32Array,[gm]:Float32Array},ym={[hm]:"DT_INT8",[dm]:"DT_UINT8",[pm]:"DT_INT16",[fm]:"DT_UINT16",[mm]:"DT_UINT32",[gm]:"DT_FLOAT32"},vm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xm(e,t,i){const n=i.json.bufferViews.length,r=i.buffers.length;t.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:e.byteLength},i.buffers[r]=e}const bm="KHR_draco_mesh_compression";function wm(e,t){const i=e.extensions&&e.extensions[bm];if(!i)return;const n=new am.Decoder,r=Cm(t,i.bufferView),s=new am.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,s))throw new Error("Failed to decode Draco mesh");const o=t.json.accessors[e.indices],a=_m[o.componentType],l=o.count*a.BYTES_PER_ELEMENT,c=am._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(s,l,c):n.GetTrianglesUInt32Array(s,l,c),xm(am.memory.buffer.slice(c,c+l),o,t),am._free(c);for(const r of Object.keys(i.attributes)){const o=n.GetAttributeByUniqueId(s,i.attributes[r]),a=t.json.accessors[e.attributes[r]],l=ym[a.componentType],c=a.count*vm[a.type]*_m[a.componentType].BYTES_PER_ELEMENT,u=am._malloc(c);n.GetAttributeDataArrayForAllPoints(s,o,am[l],c,u),xm(am.memory.buffer.slice(u,u+c),a,t),am._free(u)}n.destroy(),s.destroy(),delete e.extensions[bm]}const Tm="EXT_meshopt_compression";function Sm(e,t){if(!e.extensions||!e.extensions[Tm])return;const i=e.extensions[Tm],n=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);cm.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=r.buffer,delete e.extensions[Tm]}const Em=1179937895,Am=new TextDecoder("utf8");function Mm(e,t){return new URL(e,t).href}async function Im(e,t,i,n,r){const s=await fetch(Mm(e.uri,n),{signal:r}),o=await s.arrayBuffer();t.buffers[i]=o}function Cm(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}async function Pm(e,t,i,n,r){if(e.uri){const s=Mm(e.uri,n),o=await fetch(s,{signal:r}),a=await o.blob(),l=await createImageBitmap(a);t.images[i]=l}else if(void 0!==e.bufferView){const n=Cm(t,e.bufferView),r=new Blob([n],{type:e.mimeType}),s=await createImageBitmap(r);t.images[i]=s}}async function Lm(e,t=0,i,n){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Em){const i=new Uint32Array(e,t);let n=2;const s=(i[n++]>>2)-3,o=i[n++]>>2;if(n++,r.json=JSON.parse(Am.decode(i.subarray(n,n+o))),n+=o,n<s){const s=i[n++];n++;const o=t+(n<<2);r.buffers[0]=e.slice(o,o+s)}}else r.json=JSON.parse(Am.decode(new Uint8Array(e,t)));const{buffers:s,images:o,meshes:a,extensionsUsed:l,bufferViews:c}=r.json;if(s){const e=[];for(let t=0;t<s.length;t++){const o=s[t];o.uri?e.push(Im(o,r,t,i,n)):r.buffers[t]||(r.buffers[t]=null)}await Promise.all(e)}if(n&&n.aborted)throw new DOMException("Aborted","AbortError");const u=[],h=l&&l.includes(bm),d=l&&l.includes(Tm);if(h&&u.push(function(){if(!am)return null!=lm||(lm=function(e){let t,i=null;function n(){t=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(e,{a:{a:r,d:function(e,i,n){return t.copyWithin(e,i,i+n)},c:function(e){const r=t.length,s=Math.max(e>>>0,Math.ceil(1.2*r)),o=Math.ceil((s-r)/65536);try{return i.grow(o),n(),!0}catch(e){return!1}},b:r}}).then(e=>{const{Rb:r,Qb:s,P:o,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:g,e:_,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=e.instance.exports;i=_;const S=(()=>{let e=0,i=0,n=0,o=0;return a=>{n&&(r(o),r(e),i+=n,n=e=0),e||(i+=128,e=s(i));const l=a.length+7&-8;let c=e;l>=i&&(n=l,c=o=s(l));for(let e=0;e<a.length;e++)t[c+e]=a[e];return c}})();return n(),g(),{memory:_,_free:r,_malloc:s,Mesh:class{constructor(){this.ptr=o()}destroy(){a(this.ptr)}},Decoder:class{constructor(){this.ptr=c()}destroy(){m(this.ptr)}DecodeArrayToMesh(e,t,i){const n=S(e),r=u(this.ptr,n,t,i.ptr);return!!l(r)}GetAttributeByUniqueId(e,t){return{ptr:h(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,i){d(this.ptr,e.ptr,t,i)}GetTrianglesUInt32Array(e,t,i){p(this.ptr,e.ptr,t,i)}GetAttributeDataArrayForAllPoints(e,t,i,n,r){f(this.ptr,e.ptr,t.ptr,i,n,r)}},DT_INT8:y(),DT_UINT8:v(),DT_INT16:x(),DT_UINT16:b(),DT_UINT32:w(),DT_FLOAT32:T()}})}(fetch(ft())).then(e=>{am=e,lm=null})),lm}()),d&&u.push(function(){var e;if(!cm)return null!=um||(um=(e=fetch(mt()),WebAssembly.instantiateStreaming(e,{}).then(e=>{const{sbrk:t,memory:i,meshopt_decodeVertexBuffer:n,meshopt_decodeIndexBuffer:r,meshopt_decodeIndexSequence:s,meshopt_decodeFilterOct:o,meshopt_decodeFilterQuat:a,meshopt_decodeFilterExp:l}=e.instance.exports,c={ATTRIBUTES:n,TRIANGLES:r,INDICES:s},u={OCTAHEDRAL:o,QUATERNION:a,EXPONENTIAL:l};return e.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(e,n,r,s,o,a){const l=n+3&-4,h=t(l*r),d=t(s.length),p=new Uint8Array(i.buffer);p.set(s,d);const f=c[o](h,n,r,d,s.length);if(0===f&&u[a]&&u[a](h,l,r),e.set(p.subarray(h,h+n*r)),t(h-t(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}}})).then(e=>{cm=e,um=null})),um}()),o)for(let e=0;e<o.length;e++)u.push(Pm(o[e],r,e,i,n));if(u.length&&await Promise.all(u),n&&n.aborted)throw new DOMException("Aborted","AbortError");if(h&&a)for(const{primitives:e}of a)for(const t of e)wm(t,r);if(d&&a&&c)for(const e of c)Sm(e,r);return r}async function Rm(e,t){const i=await async function(e,t){if(t&&t.aborted)throw new DOMException("Aborted","AbortError");return new Promise((i,n)=>{const r=Yt(e,(e,t)=>{e?n(e):i(t)});t&&t.addEventListener("abort",()=>{r.cancel(),n(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:e,type:"arrayBuffer"},t);return Lm(i,0,e,t)}function Om(e){switch(e){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Dm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Bm{constructor(e,t,i,n){this.context=e,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:r}=this,{gl:s}=r,{x:o,y:a}=t&&t.position?t.position:{x:0,y:0},l=o+i,c=a+n;this.size&&(this.size[0]!==l||this.size[1]!==c)&&(!t||void 0===t.recreateWhenResize||t.recreateWhenResize)&&(s.bindTexture(s.TEXTURE_2D,null),s.deleteTexture(this.texture),this.texture=s.createTexture(),this.size=null),s.bindTexture(s.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA8&&(!t||!1!==t.premultiply));const u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;s.texStorage2D(s.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?s.texSubImage2D(s.TEXTURE_2D,0,o,a,Om(this.format),Dm(this.format),e):"data"in e&&e.data&&s.texSubImage2D(s.TEXTURE_2D,0,o,a,i,n,Om(this.format),Dm(this.format),e.data)),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,i,n,r){const{context:s}=this,{gl:o}=s;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n),r!==this.compareMode&&(r?(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_FUNC,r)):o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_MODE,o.NONE),this.compareMode=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Fm{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Nm=Ka([{name:"a_pos_3f",components:3,type:"Float32"}]),km=Ka([{name:"a_color_3f",components:3,type:"Float32"}]),zm=Ka([{name:"a_color_4f",components:4,type:"Float32"}]),Um=Ka([{name:"a_uv_2f",components:2,type:"Float32"}]),Vm=Ka([{name:"a_normal_3f",components:3,type:"Float32"}]),jm=Ka([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Gm=Ka([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Hm(e,t){const i=qm(e.projection,e.zoom,e.width,e.height),n=function(e,t,i,n,r){const s=new Vc(i.lng-180*Xm,i.lat),o=new Vc(i.lng+180*Xm,i.lat),a=e.project(s.lng,s.lat),l=e.project(o.lng,o.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=tu.fromLngLat(i);h.y=ze(h.y,-1+Xm,1-Xm);const p=h.toLngLat(),m=e.project(p.lng,p.lat),g=tu.fromLngLat(p);g.x+=Xm;const y=g.toLngLat(),v=e.project(y.lng,y.lat),x=Zm(v.x-m.x,v.y-m.y,c),b=tu.fromLngLat(p);b.y+=Xm;const w=b.toLngLat(),T=e.project(w.lng,w.lat),S=Zm(T.x-m.x,T.y-m.y,c),E=Math.abs(x.x)/Math.abs(S.y),A=u([]);_(A,A,-c*(1-(r?0:n)));const M=u([]);return f(M,M,[1,1-(1-E)*n,1]),M[4]=-S.x/S.y*n,_(M,M,c),d(M,A,M),M}(e.projection,0,e.center,i,t),r=Wm(e);return f(n,n,[r,r,1]),n}function Wm(e){const t=e.projection,i=qm(e.projection,e.zoom,e.width,e.height),n=$m(t,e.center),r=$m(t,Vc.convert(t.center));return Math.pow(2,n*i+(1-i)*r)}function qm(e,t,i,n,r=1/0){const s=e.range;if(!s)return 0;const o=Math.min(r,Math.max(i,n)),a=Math.log2(o/1024);return Ue(s[0]+a,s[1]+a,t)}const Xm=1/4e4;function $m(e,t){const i=ze(t.lat,-85.051129,Yc),n=new Vc(t.lng-180*Xm,i),r=new Vc(t.lng+180*Xm,i),s=e.project(n.lng,i),o=e.project(r.lng,i),a=tu.fromLngLat(n),l=tu.fromLngLat(r),c=o.x-s.x,u=o.y-s.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Zm(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}const Ym=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function Jm(e,t,i){u(e),_(e,e,Oe(t[2])),m(e,e,Oe(t[0])),g(e,e,Oe(t[1])),f(e,e,i),d(e,e,Ym)}function Km(e,t,i,n,r,s,o,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[n[0]-t[0],n[1]-t[1],0];if(A(l)<1e-12||A(c)<1e-12)return ne(e);const u=j([],l,c);U(u,u),P(c,n,t),l[2]=(s-r)*a,c[2]=(o-r)*a;const h=l;return j(h,l,c),U(h,h),ue(e,u,h)}function Qm(e,t,i=!1){const n=kh(t.zoom),r=function(e,t,i){const n=t.worldSize,r=[e[12],e[13],e[14]],s=$c(r[1]/n),o=Xc(r[0]/n),a=u([]),l=qc(1,s)*n,c=qc(1,0)*n*Kc(s,t.zoom),h=1/Bh(n);let m=c*h;if(i){const e=qm(t.projection,t.zoom,t.width,t.height,1024);m=h*t.projection.pixelSpaceConversion(t.center.lat,n,e)}const g=kc(s,o);C(g,g,D([],U([],g),l*m*r[2]));const _=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const n=j([],i,t);return j(i,t,n),0===k(i)&&(i=[0,1,0],j(n,t,i)),U(n,n),U(i,i),U(t,t),[n[0],n[1],n[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(g);f(a,a,[m,m,m*l]),p(a,a,[-r[0],-r[1],-r[2]]);const y=d([],t.globeMatrix,_);return d(y,y,a),d(y,y,e),y}(e,t,i);if(n>0){const i=function(e,t){const i=t.worldSize,n=qc(1,0)*i*Kc(t.center.lat,t.zoom)/Bh(i),r=qc(1,t.center.lat)*i,s=u([]);g(s,s,Oe(t.center.lng)),m(s,s,Oe(t.center.lat)),p(s,s,[0,0,Rc]),f(s,s,[n,n,n*r]);const o=t.point;return p(s,s,[-o.x,-o.y,0]),d(s,s,e),d(s,t.globeMatrix,s)}(e,t);return function(e,t,i){const n=(e,t,i)=>{const n=A(e),r=A(t),s=Sh(e,t,i);return D(s,s,1/A(s)*xi(n,r,i))},r=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),s=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),o=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=Sh([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[r[0],r[1],r[2],0,s[0],s[1],s[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function eg(e,t,i,n){const r=Du.projectAabbCorners(n,i);let s=Number.MAX_VALUE;for(let e=0;e<r.length;++e){const i=r[e];i[0]=(.5*i[0]+.5)*t.width,i[1]=(.5-.5*i[1])*t.height,i[2]<s&&(s=i[2])}const o=function(e){const t=[];let i=0;for(let t=1;t<e.length;t++)(e[t][0]<e[i][0]||e[t][0]===e[i][0]&&e[t][1]<e[i][1])&&(i=t);let n,r=i;const s=new Uint8Array(e.length);do{if(s[r])break;t.push(new Ae(e[r][0],e[r][1])),s[r]=1,n=(r+1)%e.length;for(let t=0;t<e.length;t++){if(e[t][0]===e[n][0]&&e[t][1]===e[n][1]||e[t][0]===e[r][0]&&e[t][1]===e[r][1])continue;const i=[e[t][0]-e[r][0],e[t][1]-e[r][1]],s=[e[n][0]-e[r][0],e[n][1]-e[r][1]],o=i[0]*s[1]-i[1]*s[0];(o>0||0===o&&i[0]*s[0]+i[1]*s[1]>=0&&i[0]*i[0]+i[1]*i[1]>s[0]*s[0]+s[1]*s[1])&&(n=t)}r=n}while(r!==i);return t.length>0&&t.push(t[0]),t}(r);if(Vu(e,o))return s}const tg=64,ig={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function ng(e,t,i,n,r,s,o,a,l,c=!1){const h=i.zoom,m=i.project(n),g=Kc(n.lat,h),_=1/g;u(e),p(e,e,[m.x+o[0]*_,m.y+o[1]*_,o[2]]);let y=1,v=1;const x=i.worldSize;if(c){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new tu(m.x/x,m.y/x),0));const t=te([],[m.x,m.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;y=t,v=t*Kc(i.center.lat,h)}else if("globe"===i.projection.name){const t=Qm(e,i),r=[0,0,0,1];te(r,r,d([],i.projMatrix,t));const s=r[3]/i.cameraToCenterDistance,o=kh(h),a=i.projection.pixelsPerMeter(n.lat,x)*Kc(n.lat,h),l=i.projection.pixelsPerMeter(i.center.lat,x)*Kc(i.center.lat,h);y=s/xi(a,Jc(i.center.lat),o),v=s*g/a,y*=l,v*=l}}else y=_;f(e,e,[y,y,v]);const b=[...e],T=t.orientation,S=[];if(Jm(S,[T[0]+(r?r[0]:0),T[1]+(r?r[1]:0),T[2]+(r?r[2]:0)],s),d(e,b,S),a&&i.elevation){let r=0;const s=[];if(l&&i.elevation){r=function(e,t,i,n,r){const s=t.elevation;if(!s)return 0;const o=Du.projectAabbCorners(i,n),a=qc(1,r.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const r of n){const n=e[r.corners[0]],s=e[r.corners[1]],o=e[r.corners[2]],a=[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])],l=j(a,a,[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])]);U(l,l),r.dotProductWithUp=V(l,i)}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(o,a),c=o[l[0]],u=o[l[1]],h=o[l[2]],d=o[l[3]],p=s.getAtPointOrZero(new tu(c[0]/t.worldSize,c[1]/t.worldSize),0),f=s.getAtPointOrZero(new tu(u[0]/t.worldSize,u[1]/t.worldSize),0),m=s.getAtPointOrZero(new tu(h[0]/t.worldSize,h[1]/t.worldSize),0),g=s.getAtPointOrZero(new tu(d[0]/t.worldSize,d[1]/t.worldSize),0),_=(p+g)/2,y=(f+m)/2;return _>y?f<m?Km(e,u,d,c,f,g,p,a):Km(e,h,c,d,m,p,g,a):p<g?Km(e,c,u,h,p,f,m,a):Km(e,d,h,u,g,m,f,a),Math.max(_,y)}(s,i,t.aabb,e,n);const o=d([],w([],s),S);d(e,b,o)}else r=i.elevation.getAtPointOrZero(new tu(m.x/x,m.y/x),0);0!==r&&(e[14]+=r)}}class rg{constructor(e,t,i,n,r){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=null!=i?new Vc(i[0],i[1]):new Vc(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new Du([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){d(e.globalMatrix,t,e.localMatrix);const i=this.nodeOverrides.get(e.name);if(void 0!==i){const t=[];r=i.orientation,u(n=t),g(n,n,Oe(r[1])),_(n,n,Oe(r[2])),m(n,n,Oe(r[0])),d(e.globalMatrix,e.globalMatrix,t)}var n,r;if(e.meshes)for(const t of e.meshes){const i=Du.applyTransformFast(t.aabb,e.globalMatrix);this.aabb.encapsulate(i)}if(e.children)for(const t of e.children)this._applyTransformations(t,e.globalMatrix)}computeBoundsAndApplyParent(){const e=u([]);this.aabb=new Du([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const t of this.nodes)this._applyTransformations(t,e)}computeModelMatrix(e,t,i,n,r,s,o=!1){ng(this.matrix,this,e.transform,this.position,t,i,n,r,s,o)}upload(e){if(!this.uploaded){for(const t of this.nodes)ag(t,e);for(const e of this.nodes)cg(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)hg(e)}}function sg(e,t,i=!1){e.uploaded||(e.gfxTexture=new Bm(t,e.image,i?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function og(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Nm.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Vm.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Um.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?km:zm).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Gm.members,!0)),e.segments=Ql.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&sg(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&sg(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&sg(n.normalTexture,t),n.occlusionTexture&&sg(n.occlusionTexture,t,i),n.emissionTexture&&sg(n.emissionTexture,t)}function ag(e,t,i){if(e.meshes)for(const n of e.meshes)og(n,t,i);if(e.lodMeshes)for(const n of e.lodMeshes)og(n,t,i);if(e.children)for(const n of e.children)ag(n,t,i)}function lg(e){e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy()}function cg(e){if(e.meshes)for(const t of e.meshes)lg(t);if(e.lodMeshes)for(const t of e.lodMeshes)lg(t);if(e.children)for(const t of e.children)cg(t)}function ug(e){var t;e.vertexBuffer&&(e.vertexBuffer.destroy(),e.indexBuffer.destroy(),e.normalBuffer&&e.normalBuffer.destroy(),e.texcoordBuffer&&e.texcoordBuffer.destroy(),e.colorBuffer&&e.colorBuffer.destroy(),e.pbrBuffer&&e.pbrBuffer.destroy(),e.segments.destroy(),e.material&&((t=e.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()))}function hg(e){if(e.meshes)for(const t of e.meshes)ug(t);if(e.lodMeshes)for(const t of e.lodMeshes)ug(t);if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)hg(t)}function dg(e,t,i,n){return e[0]<=n[0]&&t[0]>=i[0]&&e[1]<=n[1]&&t[1]>=i[1]&&e[2]<=n[2]&&t[2]>=i[2]}function pg(e,t,i,n,r,s,o,a,l,c,u){const h=.5*(c[0]+u[0]),d=.5*(c[1]+u[1]),p=.5*(c[2]+u[2]),f=.5*(u[0]-c[0]),m=.5*(u[1]-c[1]),g=.5*(u[2]-c[2]),_=e-h,y=t-d,v=i-p,x=n-h,b=r-d,w=s-p,T=o-h,S=a-d,E=l-p,A=x-_,M=b-y,I=w-v,C=T-x,P=S-b,L=E-w,R=_-T,O=y-S,D=v-E;let B,F,N,k,z,U;if(B=v*M-y*I,F=w*M-b*I,N=E*M-S*I,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(I)*m+Math.abs(M)*g,k>U||z<-U)return!1;if(B=v*P-y*L,F=w*P-b*L,N=E*P-S*L,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(L)*m+Math.abs(P)*g,k>U||z<-U)return!1;if(B=v*O-y*D,F=w*O-b*D,N=E*O-S*D,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(D)*m+Math.abs(O)*g,k>U||z<-U)return!1;if(B=_*I-v*A,F=x*I-w*A,N=T*I-E*A,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(I)*f+Math.abs(A)*g,k>U||z<-U)return!1;if(B=_*L-v*C,F=x*L-w*C,N=T*L-E*C,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(L)*f+Math.abs(C)*g,k>U||z<-U)return!1;if(B=_*D-v*R,F=x*D-w*R,N=T*D-E*R,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(D)*f+Math.abs(R)*g,k>U||z<-U)return!1;if(B=y*A-_*M,F=b*A-x*M,N=S*A-T*M,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(M)*f+Math.abs(A)*m,k>U||z<-U)return!1;if(B=y*C-_*P,F=b*C-x*P,N=S*C-T*P,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(P)*f+Math.abs(C)*m,k>U||z<-U)return!1;if(B=y*R-_*O,F=b*R-x*O,N=S*R-T*O,k=Math.min(B,F,N),z=Math.max(B,F,N),U=Math.abs(O)*f+Math.abs(R)*m,k>U||z<-U)return!1;if(k=Math.min(_,x,T),z=Math.max(_,x,T),k>f||z<-f)return!1;if(k=Math.min(y,b,S),z=Math.max(y,b,S),k>m||z<-m)return!1;if(k=Math.min(v,w,E),z=Math.max(v,w,E),k>g||z<-g)return!1;const V=M*L-I*P,j=I*C-A*L,G=A*P-M*C,H=-(V*_+j*y+G*v);return U=f*Math.abs(V)+m*Math.abs(j)+g*Math.abs(G),!(Math.abs(H)>U)}const fg=[];class mg{serializeFromGltf(e,t,i,n){if(e.length<7)return;let r=0;if(109!==e[r++]||98!==e[r++]||120!==e[r++]||98!==e[r++]||118!==e[r++]||104!==e[r++])return;if(43!==e[r++])return;const s=new DataView(e.buffer,e.byteOffset),o=s.getUint16(r,!0);if(r+=2,0===o)return;this._nodes=[];let a=0;for(let e=0;e<o;e++){const e=[t[3*a],t[3*a+1],t[3*a+2]],n=[i[3*a],i[3*a+1],i[3*a+2]];a++;const o=s.getUint16(r,!0);r+=2;let l=0,c=0;65535===o&&(l=s.getUint16(r,!0),r+=2,c=s.getUint32(r,!0),r+=4),this._nodes.push({aabbMin:e,aabbMax:n,backChild:o,indexCount:l,indexOffset:c})}const l=s.getUint32(r,!0);this._indices=n.slice(0,l)}setVertices(e){this._vertices=e}findHighestPoint(e,t){if(!this._nodes||0===this._nodes.length)return null;if(!dg(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,t))return null;const i=fg;i.length=0,i.push(0);let n=-1/0;for(;i.length>0;){const r=i.pop(),s=this._nodes[r];if(s.aabbMax[2]<=n)continue;if(65535===s.backChild){for(let i=0;i<s.indexCount;i+=3){const r=3*this._indices[s.indexOffset+i],o=3*this._indices[s.indexOffset+i+1],a=3*this._indices[s.indexOffset+i+2];pg(this._vertices[r],this._vertices[r+1],this._vertices[r+2],this._vertices[o],this._vertices[o+1],this._vertices[o+2],this._vertices[a],this._vertices[a+1],this._vertices[a+2],e,t)&&(n=Math.max(n,this._vertices[r+2],this._vertices[o+2],this._vertices[a+2]))}continue}const o=r+1,a=s.backChild,l=this._nodes[o],c=this._nodes[a],u=dg(l.aabbMin,l.aabbMax,e,t),h=dg(c.aabbMin,c.aabbMax,e,t);u&&h?l.aabbMax[2]<c.aabbMax[2]?(i.push(o),i.push(a)):(i.push(a),i.push(o)):u?i.push(o):h&&i.push(a)}return n>=0?n:null}}function gg(e,t){const i=e.json.bufferViews[t.bufferView],n=_m[t.componentType];return new n(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==vm[t.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vm[t.type]))}function _g(e,t,i,n){const r=_m[t.componentType],s=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),o=e.json.bufferViews[t.bufferView],a=o.byteStride?o.byteStride/r.BYTES_PER_ELEMENT:vm[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e<t.count*a;e+=a,i+=c)for(let t=0;t<c;t++)l[i+t]=n[e+t]*s;i._trim()}function yg(e,t,i){const n=e.indices,r=e.attributes,s={};s.indexArray=new wl;const o=t.json.accessors[n],a=o.count/3;s.indexArray.reserve(a);const l=gg(t,o);for(let e=0;e<a;e++)s.indexArray.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);s.indexArray._trim(),s.vertexArray=new cl;const c=t.json.accessors[r.POSITION];s.vertexArray.reserve(c.count);const u=gg(t,c);for(let e=0;e<c.count;e++)s.vertexArray.emplaceBack(u[3*e],u[3*e+1],u[3*e+2]);if(s.vertexArray._trim(),s.aabb=new Du(c.min,c.max),s.centroid=function(e,t){const i=[0,0,0],n=e.length;if(n>0){for(let r=0;r<n;r++){const n=3*e[r];i[0]+=t[n],i[1]+=t[n+1],i[2]+=t[n+2]}i[0]/=n,i[1]/=n,i[2]/=n}return i}(l,u),void 0!==r.COLOR_0){const e=t.json.accessors[r.COLOR_0],i=vm[e.type],n=gg(t,e);s.colorArray=3===i?new cl:new ml,s.colorArray.resize(e.count),_g(t,e,s.colorArray,n)}if(void 0!==r.NORMAL){s.normalArray=new cl;const e=t.json.accessors[r.NORMAL];s.normalArray.resize(e.count);const i=gg(t,e);_g(t,e,s.normalArray,i)}if(void 0!==r.TEXCOORD_0&&i.length>0){s.texcoordArray=new Pl;const e=t.json.accessors[r.TEXCOORD_0];s.texcoordArray.resize(e.count);const i=gg(t,e);_g(t,e,s.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const e=t.json.accessors[r._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=gg(t,e))}void 0!==r._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(gg(t,t.json.accessors[r._FEATURE_RGBA4444]).buffer));const h=e.material;return s.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:s,occlusionTexture:o,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=o?t[o.index]:void 0;if(o&&o.extensions&&o.extensions.KHR_texture_transform&&m){const e=o.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new bi(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new bi(...i),alphaMode:n,alphaCutoff:r,normalTexture:s?t[s.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),s}function vg(e,t,i){const{matrix:n,rotation:r,translation:s,scale:o,mesh:a,extras:l,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,i,n){var r=t[0],s=t[1],o=t[2],a=t[3],l=r+r,c=s+s,u=o+o,h=r*l,d=r*c,p=r*u,f=s*c,m=s*u,g=o*u,_=a*l,y=a*c,v=a*u,x=n[0],b=n[1],w=n[2];return e[0]=(1-(f+g))*x,e[1]=(d+v)*x,e[2]=(p-y)*x,e[3]=0,e[4]=(d-v)*b,e[5]=(1-(h+g))*b,e[6]=(m+_)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-_)*w,e[10]=(1-(h+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],r||[0,0,0,1],s||[0,0,0],o||[1,1,1]),d.globalMatrix=c(d.localMatrix),void 0!==a){d.meshes=i[a];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:n}=t.aabb;e[0]+=i[0]+n[0],e[1]+=i[1]+n[1]}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2)}if(l&&(l.id&&(d.id=l.id),l.lights&&(d.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.codePointAt(e);return i}(e),i=[],n=t.length/24,r=new Uint16Array(t.buffer),s=new Float32Array(t.buffer);for(let e=0;e<n;e++){const t=r[2*e*6]/30,n=r[2*e*6+1]/30,o=r[2*e*6+10]/100,a=s[6*e+1],l=s[6*e+2],c=s[6*e+3],u=s[6*e+4],h=c-a,d=u-l,p=Math.hypot(h,d);i.push({pos:[a+.5*h,l+.5*d,n],normal:[d/p,-h/p,0],width:p,height:t,depth:o,points:[a,l,c,u]})}return i}(l.lights)),l.MAPBOX_geometry_bloom&&(d.isGeometryBloom=l.MAPBOX_geometry_bloom)),u){const e=[];for(const n of u)e.push(vg(t.json.nodes[n],t,i));d.children=e}if(e.extensions&&e.extensions.mbx_bvh&&(d.meshBVH=function(e,t,i){const n=t.binaryAccessor,r=t.positionMinAccessor,s=t.positionMaxAccessor,o=t.indexAccessor;if(!(Number.isInteger(n)&&Number.isInteger(r)&&Number.isInteger(s)&&Number.isInteger(o)))return null;const a=e.json.accessors;if(n>=a.length||r>=a.length||s>=a.length||o>=a.length)return null;const l=a[n],c=a[r],u=a[s],h=a[o];if(void 0===l.bufferView||void 0===c.bufferView||void 0===u.bufferView||void 0===h.bufferView)return null;const d=e.json.bufferViews;if(l.bufferView>=d.length||c.bufferView>=d.length||u.bufferView>=d.length||h.bufferView>=d.length)return null;const p=d[l.bufferView],f=d[c.bufferView],m=d[u.bufferView],g=d[h.bufferView];if(p.buffer>=e.buffers.length||f.buffer>=e.buffers.length||m.buffer>=e.buffers.length||g.buffer>=e.buffers.length)return null;const _=(e,t,i)=>e>=0&&e<=i&&t<=i-e,y=l.byteOffset||0,v=c.byteOffset||0,x=u.byteOffset||0,b=h.byteOffset||0;if(!(_(y,0,p.byteLength)&&_(v,3*c.count*4,f.byteLength)&&_(x,3*u.count*4,m.byteLength)&&_(b,4*h.count,g.byteLength)))return null;const w=new Uint8Array(e.buffers[p.buffer],(p.byteOffset||0)+y,p.byteLength-y),T=new Float32Array(e.buffers[f.buffer],(f.byteOffset||0)+v,3*c.count),S=new Float32Array(e.buffers[m.buffer],(m.byteOffset||0)+x,3*u.count),E=new Uint32Array(e.buffers[g.buffer],(g.byteOffset||0)+b,h.count),A=new mg;if(A.serializeFromGltf(w,T,S,E),void 0!==i&&e.json.meshes&&e.json.meshes[i]){const t=e.json.meshes[i].primitives[0];if(t&&void 0!==t.attributes.POSITION&&t.attributes.POSITION<a.length){const i=a[t.attributes.POSITION];if(void 0!==i.bufferView&&i.bufferView<d.length){const t=d[i.bufferView];if(t.buffer<e.buffers.length){const n=i.byteOffset||0,r=t.byteStride?t.byteStride/4:3;if(_(n,i.count*r*4,t.byteLength)){const s=(t.byteOffset||0)+n;if(3===r)A.setVertices(new Float32Array(e.buffers[t.buffer],s,3*i.count));else{const n=new Float32Array(e.buffers[t.buffer],s,i.count*r),o=new Float32Array(3*i.count);for(let e=0;e<i.count;e++)o[3*e]=n[e*r],o[3*e+1]=n[e*r+1],o[3*e+2]=n[e*r+2];A.setVertices(o)}}}}}}return A}(t,e.extensions.mbx_bvh,a)),!d.meshBVH&&d.children)for(const e of d.children)if(e.meshBVH){d.meshBVH=e.meshBVH;break}return d}function xg(e){if(0===e.vertices.length||0===e.indices.length)return null;const t=new kp(e.vertices,e.indices,8,256),[i,n]=[t.min.clone(),t.max.clone()];return{vertices:e.vertices,indices:e.indices,grid:t,min:i,max:n}}function bg(e){if(!e.extras||!e.extras.ground)return null;const t=e.extras.ground;if(!t||!Array.isArray(t)||0===t.length)return null;const i=t[0];if(!i||!Array.isArray(i)||0===i.length)return null;const n=[];for(const e of i){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],i=e[1];"number"==typeof t&&"number"==typeof i&&n.push(new Ae(t,i))}if(n.length<3)return null;n.length>1&&n.at(-1).equals(n[0])&&n.pop();let r=0;for(let e=0;e<n.length;e++){const t=n[e],i=n[(e+1)%n.length],s=n[(e+2)%n.length];r+=(t.x-i.x)*(s.y-i.y)-(s.x-i.x)*(t.y-i.y)}r>0&&n.reverse();const s=pd(n.flatMap(e=>[e.x,e.y]),[]);return 0===s.length?null:{vertices:n,indices:s}}function wg(e,t){const i=[],n=[];let r=0;const s=[];for(const o of e){r=i.length;const e=o.vertexArray.float32,a=o.indexArray.uint16;for(let n=0;n<o.vertexArray.length;n++)s[0]=e[3*n+0],s[1]=e[3*n+1],s[2]=e[3*n+2],H(s,s,t),i.push(new Ae(s[0],s[1]));for(let e=0;e<3*o.indexArray.length;e++)n.push(a[e]+r)}if(n.length%3!=0)return null;for(let e=0;e<n.length;e+=3){const t=i[n[e+0]],r=i[n[e+1]],s=i[n[e+2]];(t.x-r.x)*(s.y-r.y)-(s.x-r.x)*(t.y-r.y)>0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:i,indices:n}}function Tg(e,t){for(let i=0;i<e.length;i++)if(e[i].name===t)return i;return-1}function Sg(e){const t=function(e,t){const i=[],n=WebGL2RenderingContext;if(e.json.textures)for(const r of e.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(s,e.json.samplers[r.sampler]),i.push({image:t[r.source],sampler:s,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const n of e.json.meshes){const r=[];for(const i of n.primitives)r.push(yg(i,e,t));i.push(r)}return i}(e,t),{scenes:n,scene:r,nodes:s}=e.json;let o=n?Tg(n,"Default Scene"):-1;o<0&&(o=r||0);const a=n?n[o].nodes:[...s.keys()],l=[];for(const t of a)l.push(vg(s[t],e,i));!function(e,t,i){const n={},r=new Set;for(let s=0;s<e.length;s++){const e=i[t[s]];if(!e.extras)continue;const o=e.extras["mapbox:footprint:version"],a=e.extras["mapbox:footprint:id"];(o||a)&&r.add(s),"1.0.0"===o&&a&&(n[a]=s)}for(let s=0;s<e.length;s++){if(r.has(s))continue;const o=e[s],a=i[t[s]];if(!a.extras)continue;let l=null;o.id in n&&(l=wg(e[n[o.id]].meshes,o.localMatrix)),l||(l=bg(a)),l&&(o.footprint=xg(l))}if(r.size>0){const t=Array.from(r.values()).sort((e,t)=>e-t);for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(l,a,e.json.nodes);const c=n?Tg(n,"LOD"):-1;if(c>=0){const t=n[c].nodes,r=new Map;for(const n of t){const t=vg(s[n],e,i);t.id&&r.set(t.id,t)}for(const e of l)if(e.id){const t=r.get(e.id);t&&t.meshes&&(e.lodMeshes=t.meshes,t.meshBVH&&(e.meshBVH=t.meshBVH))}}return l}function Eg(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,n=e.aabb.min[1]-1,r=tg/(e.aabb.max[0]-i+2),s=tg/(e.aabb.max[1]-n+2);for(let o=0;o<t.length;o+=3){const a=t[o+2],l=(t[o+0]-i)*r|0,c=(t[o+1]-n)*s|0;a>e.heightmap[c*tg+l]&&(e.heightmap[c*tg+l]=a)}}function Ag(e,t,i,n,r){i.reserve(i.length+4*e.length),n.reserve(n.length+10*e.length),r.reserve(r.length+10*e.length);let s=n.length;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*t,a=[-o.normal[1],o.normal[0],0],l=Math.min(.29,.1*o.width/o.depth),c=o.width-2*o.depth*t*(l+.01),u=B([],o.pos,a,c/2),h=B([],o.pos,a,-c/2),d=[u[0],u[1],u[2]+o.height],p=[h[0],h[1],h[2]+o.height],f=B([],o.normal,a,l);D(f,f,e);const m=B([],o.normal,a,-l);D(m,m,e),C(f,u,f),C(m,h,m),u[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const g=c/e/2;r.emplaceBack(-g-l,-1,g,.8),r.emplaceBack(g+l,-1,g,.8),r.emplaceBack(-g,0,g,1.3),r.emplaceBack(g,0,g,1.3),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(0,0,g,1.3),r.emplaceBack(0,0,g,1.3),r.emplaceBack(g+l,-1.2,g,.8),r.emplaceBack(g+l,-1.2,g,.8),i.emplaceBack(6+s,4+s,8+s),i.emplaceBack(7+s,9+s,5+s),i.emplaceBack(0+s,1+s,2+s),i.emplaceBack(1+s,3+s,2+s),s+=10}}function Mg(e,t){const i={};i.indexArray=new wl,i.vertexArray=new cl,i.colorArray=new ml,Ag(e,t,i.indexArray,i.vertexArray,i.colorArray);const n={defined:!0};n.emissiveFactor=bi.black;const r={};return r.baseColorFactor=bi.white,n.pbrMetallicRoughness=r,i.material=n,i.aabb=new Du([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}lo(mg,"ModelBVH");const Ig=Ka([{name:"a_pos_3f",components:3,type:"Float32"}]),Cg=Ka([{name:"a_normal_3",components:3,type:"Int16"}]),Pg=Ka([{name:"a_centroid_3",components:3,type:"Int16"}]),Lg=Ka([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Rg=Ka([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Og=Ka([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Dg=Ka([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Bg=Ka([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Fg=Ka([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Ng=4096;class kg{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Ng),this.memoryStackNextFree=this.memoryStack}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Ng?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Ng?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters)}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t)}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0)}setFauxFacadeOptions(e,t,i){this.module.setFauxFacadeOptions(e?1:0,t?1:0,i)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),i=this.createFloatArray(t.coordinates);if(-1===e||-1===i)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,i,e,t.ringIndices.length-1)}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const i=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===i||-1===n)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,i,t.length,n,e.coordinates.length)}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const i=this.module.getMeshCount(),n=new Array(i);for(let e=0;e<i;e++){const t=this.module.getPositionsPtr(e),i=this.module.getPositionsLength(e),r=new Float32Array(this.module.heapF32.buffer,t,i),s=this.module.getNormalsPtr(e),o=this.module.getNormalsLength(e),a=new Float32Array(this.module.heapF32.buffer,s,o),l=this.module.getAOPtr(e),c=this.module.getAOLength(e),u=new Float32Array(this.module.heapF32.buffer,l,c),h=this.module.getUVPtr(e),d=this.module.getUVLength(e),p=new Float32Array(this.module.heapF32.buffer,h,d),f=this.module.getFauxFacadePtr(e),m=this.module.getFauxFacadeLength(e),g=new Uint8Array(this.module.heapU8.buffer,f,m),_=this.module.getIndicesPtr(e),y=this.module.getIndicesLength(e),v=new Int16Array(this.module.heap16.buffer,_,y),x=this.module.getBuildingPart(e);n[e]={positions:r,normals:a,ao:u,uv:p,isFauxFacade:g,indices:v,buildingPart:x}}const r=this.module.getRingCount(),s=[];for(let e=0;e<r;e++){const t=this.module.getRingPtr(e),i=this.module.getRingLength(e),n=new Float32Array(this.module.heapF32.buffer,t,i);s.push(n)}return{meshes:n,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:s}}}const zg=hu.types,Ug=32767;function Vg(e,t){const i=Qn+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return!1;return!0}function jg(e){switch(e){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}let Gg=null,Hg=null,Wg=null;class qg{constructor(){this.layoutVertexArray=new cl,this.layoutAttenuationArray=new ml,this.layoutColorArray=new _l,this.indexArray=new wl,this.indexArrayForConflation=new wl,this.segmentsBucket=new Ql}}class Xg{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Ql,this.entranceBloom=new qg;const t=66560;this.layoutVertexArray=new cl,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new tl,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new tl,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new _l,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new Bl,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new Fl,this.layoutAOArray.reserve(t),this.indexArray=new wl,this.indexArray.reserve(66560),this.indexArrayForConflation=new wl,this.segmentsBucket=new Ql,this.entranceBloom=new qg,e&&(this.layoutFacadePaintArray=new _l,this.layoutFacadeDataArray=new hl,this.layoutFacadeVerticalRangeArray=new _l)}reserve(e,t,i){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),i&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class $g{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Pl,this.footprintsIndices=new Rl,this.footprintsMin=new Ae(1/0,1/0),this.footprintsMax=new Ae(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Xg(!1),this.buildingWithFacade=new Xg(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new Rf(e),this.groundEffect.groundRadiusArray=new nl,this.hasAppearances=null}updateFootprints(e,t){const i=new kp([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:i,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e})}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){if(!Wg)return;const r=eu(i);this.tileToMeter=r,this.brightness=t.brightness,Wg.setStyle({normalScale:[1,-1,r],tileToMeters:r}),Wg.setAOOptions(!1,.3),Wg.setMetricOptions(!1,16),Wg.setStructuralOptions(!0),Wg.setFacadeClassifierOptions(3);const s=new Map,o=new Map;let a=0;for(const{feature:t}of e){if("LineString"!==zg[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new la(this.zoom),t,i))continue;const r=uu(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new la(this.zoom),r,i))continue;const l=e?r.geometry:cu(t,i,n),c=[];for(const e of l)for(const t of e)c.push(t.x),c.push(t.y);const u={coordinates:c,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=o.get(h);d||(d=[],o.set(h,d)),d.push(u),++a}this.maxHeight=0;const l=new Array,c=new Set,u=e=>{null!=e&&c.add(e)},h=(e,t)=>{null!=e&&l.push({buildingId:e,footprintIndex:t})},d=64*(e.length-a),p=d/2;this.buildingWithFacade.reserve(d,p,!0),this.buildingWithoutFacade.reserve(2*d,2*p,!1),this.footprintsIndices.reserve(16*(e.length-a)),this.footprintsVertices.reserve(8*(e.length-a));for(const{feature:a,id:l,index:d,sourceLayerIndex:p}of e){if("LineString"===zg[a.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new la(this.zoom),a,i))continue;let f=null;if(a.properties&&Object.hasOwn(a.properties,"building_id")&&(f=Number(a.properties.building_id),c.has(f)))continue;const m=uu(a,e);if(!e&&!this.layers[0]._featureFilter.filter(new la(this.zoom),m,i))continue;const g=e?m.geometry:cu(a,i,n),_=zd(g,500);let y=!1;for(const e of _)if(1!==e.length){y=!0;break}if(y){u(f);continue}if(!Vg(g,163)){u(f);continue}const v=this.layers[0],x=jg(v.layout.get("building-roof-shape").evaluate(a,{},i)),b=v.layout.get("building-base").evaluate(a,{},i),w=v.layout.get("building-height").evaluate(a,{},i),T=v.layout.get("building-flood-light-ground-radius").evaluate(a,{},i),S=v.paint.get("building-ambient-occlusion-intensity"),E=T/this.tileToMeter;a.properties["building-part"]="roof";const A=v.paint.get("building-color").evaluate(a,{},this.canonical).toPremultipliedRenderColor(this.lut),M=v.paint.get("building-emissive-strength").evaluate(a,{},this.canonical);a.properties["building-part"]="wall";const I=v.paint.get("building-color").evaluate(a,{},this.canonical).toPremultipliedRenderColor(this.lut),C=v.paint.get("building-emissive-strength").evaluate(a,{},this.canonical);a.properties["building-part"]="window";const P=v.paint.get("building-color").evaluate(a,{},this.canonical).toPremultipliedRenderColor(this.lut),L=v.paint.get("building-emissive-strength").evaluate(a,{},this.canonical);a.properties["building-part"]="door";const R=v.paint.get("building-color").evaluate(a,{},this.canonical).toPremultipliedRenderColor(this.lut),O=v.paint.get("building-emissive-strength").evaluate(a,{},this.canonical);let D=v.layout.get("building-flood-light-wall-radius").evaluate(a,{},i);D=ze(D,0,2048);const B=D/2048*Ug,F=s.get(l),N=o.get(F)||[],k=0!==N.length&&v.layout.get("building-facade").evaluate(a,{},i);Wg.setFacadeOptions(4,!0),Wg.setFauxFacadeOptions(k,!1,1);let z=0,U=0,V=0,j=0,G=0,H=0,W=0,q=0,X=0,$=0,Z=0;if(k){let e=Math.round(v.layout.get("building-facade-floors").evaluate(a,{},i));if(0===b){e=Math.max(1,e-(N.length>0?1:0));let t=4;if(w>100){const e=[10,13,15];t=e[a.id?a.id%e.length:0]}else w<=10&&(t=3);Wg.setFacadeOptions(t,!0),G=(w<15?1.3:1.61803)*t/r}else G=b/r;H=w/r,G=Math.min(G,H),V=v.layout.get("building-facade-unit-width").evaluate(a,{},i)/r,j=(H-G)/e,Wg.setFauxFacadeOptions(!0,!0,V);const t=v.layout.get("building-facade-window").evaluate(a,{},i);z=t[0],U=t[1],W=Math.floor(65535*Math.min(1,G/Qn)),q=Math.floor(65535*Math.min(1,H/Qn)),X=Math.floor(255*z)<<8|Math.floor(255*U),$=Math.floor(65535*Math.min(1,V/Qn)),Z=Math.floor(65535*Math.min(1,j/Qn))}const Y=Array(_.length),J={x:1/0,y:1/0},K={x:-1/0,y:-1/0},Q={x:0,y:0};let ee=0;for(let e=0;e<_.length;e++){const t=_[e];if(t.length>0){const i=[],n=Array(t.length+1);n[0]=0;for(let e=0;e<t.length;e++){const r=t[e];for(let e=0;e<r.length;e++){const t=r[r.length-e-1];J.x=Math.min(J.x,t.x),J.y=Math.min(J.y,t.y),K.x=Math.max(K.x,t.x),K.y=Math.max(K.y,t.y),Q.x+=t.x,Q.y+=t.y,ee++,i.push(t.x),i.push(t.y)}n[e+1]=i.length}Y[e]={id:a.id?a.id:0,height:w,minHeight:b,sourceId:0,roofType:x,coordinates:i,ringIndices:n}}}Q.x/=ee||1,Q.y/=ee||1;const te=Wg.generateMesh(Y,N);if("string"==typeof te){Qe(`Unable to generate building ${a.id}: ${te}`),u(f);continue}if(0===te.meshes.length||0===te.modifiedPolygonRings.length){u(f);continue}const ie=k?this.buildingWithFacade:this.buildingWithoutFacade;let ne=0;for(const e of te.meshes)ne+=e.positions.length/3;const re=ie.segmentsBucket.prepareSegment(ne,ie.layoutVertexArray,ie.indexArray),se=[];let oe=null,ae=0,le=-1;const ce=ie.layoutVertexArray.length,ue=ce+ne;ie.layoutVertexArray.resize(ue),ie.layoutCentroidArray.resize(ue),ie.layoutNormalArray.resize(ue),ie.layoutAOArray.resize(ue),ie.layoutColorArray.resize(ue),ie.layoutFloodLightDataArray.resize(ue),k&&(ie.layoutFacadePaintArray.resize(ue),ie.layoutFacadeDataArray.resize(ue),ie.layoutFacadeVerticalRangeArray.resize(ue));const he=ie.indexArray.length;let de=0,pe=ce;for(const e of te.meshes){let t,i;if(1===e.buildingPart)t=A,i=M;else if(0===e.buildingPart)t=I,i=C;else if(2===e.buildingPart)t=P,i=L;else{if(3!==e.buildingPart)continue;t=R,i=O}if(i=ze(i,0,1),3===e.buildingPart){const t=new Array;for(let i=0;i<e.positions.length;i+=12){const n=e.positions[i+0],r=e.positions[i+1],s=e.positions[i+3],o=e.positions[i+4],a=e.positions[i+2],l=e.positions[i+8]-a,c=1,u=s-n,h=o-r,d=Math.hypot(u,h);t.push({pos:[n+.5*u,r+.5*h,a],normal:[h/d,-u/d,0],width:d,height:l,depth:c,points:[n,r,s,o]})}const i=ie.entranceBloom.segmentsBucket.prepareSegment(10*t.length,ie.entranceBloom.layoutVertexArray,ie.entranceBloom.indexArray),n=ie.entranceBloom.layoutVertexArray.length;ae=ie.entranceBloom.indexArray.length,Ag(t,.5/this.tileToMeter,ie.entranceBloom.indexArray,ie.entranceBloom.layoutVertexArray,ie.entranceBloom.layoutAttenuationArray);const r=ie.entranceBloom.layoutVertexArray.length-n;le=ie.entranceBloom.indexArray.length-ae;for(let e=0;e<r;e++)ie.entranceBloom.layoutColorArray.emplaceBack(255*R.r<<8|255*R.g,255*R.b<<8|51*O);i.vertexLength+=r,i.primitiveLength+=le,oe={part:e.buildingPart,vertexOffset:n,vertexLength:r}}ie.layoutVertexArray.float32.set(e.positions,3*pe);const n=e.positions.length/3;for(let r=0;r<n;++r){const n=3*r;de=Math.max(de,e.positions[n+2]);const s=e.normals[n+1]*Ug,o=e.normals[n+2]*Ug,a=3*(pe+r);ie.layoutNormalArray.int16[a]=e.normals[n]*Ug,ie.layoutNormalArray.int16[a+1]=s,ie.layoutNormalArray.int16[a+2]=o;const l=e.ao[r];ie.layoutAOArray.uint8[pe+r]=255*l;const c=1+(l-1)*S,u=255*t.b*c<<8|255*i;ie.layoutColorArray.uint16[2*(pe+r)]=255*t.r*c<<8|255*t.g*c,ie.layoutColorArray.uint16[2*(pe+r)+1]=u}const r=Math.min(8191,Math.max(0,Math.floor(Q.x))),s=Math.min(8191,Math.max(0,Math.floor(Q.y))),o=Math.floor(w),a=20,l=4*r+Math.min(3,Math.round((K.x-J.x)*this.tileToMeter/a)),c=4*s+Math.min(3,Math.round((K.y-J.y)*this.tileToMeter/a));for(let e=0;e<n;++e){const t=3*(pe+e);ie.layoutCentroidArray.int16[t]=l,ie.layoutCentroidArray.int16[t+1]=c,ie.layoutCentroidArray.int16[t+2]=o}if(ie.layoutFloodLightDataArray.int16.fill(0===e.buildingPart?B:0,pe,pe+n),k){const t=255*P.r<<8|255*P.g,i=255*P.b<<8|255*L;for(let e=0;e<n;++e){const n=2*(pe+e);ie.layoutFacadePaintArray.uint16[n]=t,ie.layoutFacadePaintArray.uint16[n+1]=i}for(let t=0;t<n;++t)if(e.isFauxFacade[t]){const i=Math.min(65535,Math.floor(e.uv[2*t]*te.outerRingLength));ie.layoutFacadeDataArray.emplace(pe+t,1|i,X,$,Z),ie.layoutFacadeVerticalRangeArray.emplace(pe+t,W,q)}else ie.layoutFacadeDataArray.emplace(pe+t,0,0,0,0),ie.layoutFacadeVerticalRangeArray.emplace(pe+t,0,0)}const u=re.vertexLength,h=e.indices.length/3,d=ie.indexArray.length;ie.indexArray.resize(d+h);for(let t=0;t<h;++t){const i=3*t,n=3*d+i;ie.indexArray.uint16[n]=u+e.indices[i],ie.indexArray.uint16[n+1]=u+e.indices[i+1],ie.indexArray.uint16[n+2]=u+e.indices[i+2]}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||se.push({part:e.buildingPart,vertexOffset:pe,vertexLength:e.positions.length/3}),pe+=n,re.vertexLength+=n,re.primitiveLength+=e.indices.length/3}this.maxHeight=Math.max(this.maxHeight,de);const fe=ie.indexArray.length-he,me=this.footprintsIndices.length,ge=this.footprintsVertices.length,_e=[],ye=new Ae(1/0,1/0),ve=new Ae(-1/0,-1/0),xe=this.groundEffect.vertexArray.length;for(const e of te.modifiedPolygonRings){const t=[],i=new Ae(1/0,1/0),n=new Ae(-1/0,-1/0);for(let r=0;r<e.length;r+=2){const s=e.length-r-2;i.x=Math.min(i.x,e[s]),i.y=Math.min(i.y,e[s+1]),n.x=Math.max(n.x,e[s]),n.y=Math.max(n.y,e[s+1]);const o=new Ae(e[s],e[s+1]);t.push(o),_e.push(o.x,o.y),this.footprintsVertices.emplaceBack(o.x,o.y)}ye.x=Math.min(ye.x,i.x),ye.y=Math.min(ye.y,i.y),ve.x=Math.max(ve.x,n.x),ve.y=Math.max(ve.y,n.y),this.groundEffect.addData(t,[i,n],E)}const be=this.groundEffect.vertexArray.length-xe;this.groundEffect.groundRadiusArray.reserveForAdditional(be);for(let e=0;e<be;e++)this.groundEffect.groundRadiusArray.emplaceBack(T);(J.x<0||K.x>Qn||J.y<0||K.y>Qn)&&this.featuresOnBorder.push({featureId:a.id,footprintIndex:this.footprints.length});{const e=pd(_e,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,me),this.buildingIds.add(null!=f?f:a.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,ye.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,ye.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,ve.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,ve.y);const t={footprintVertexOffset:ge,footprintVertexLength:this.footprintsVertices.length-ge,footprintIndexOffset:me,footprintIndexLength:this.footprintsIndices.length-me,min:ye,max:ve,hiddenFlags:0,indicesOffset:he,indicesLength:fe,bloomIndicesOffset:ae,bloomIndicesLength:le,groundEffectVertexOffset:xe,groundEffectVertexLength:be,hasFauxFacade:k,height:de,promoteId:l,feature:m,parts:se,buildingBloom:oe},i=this.footprints.length;void 0!==a.id&&this.featureFootprintLookup.set(a.id,i),h(f,i),this.footprints.push(t)}this.programConfigurations.populatePaintArrays(ie.layoutVertexArray.length,a,d,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(a,d,{},t.availableImages,i,t.brightness),t.featureIndex.insert(a,g,d,p,this.index,ce)}l.forEach(({buildingId:e,footprintIndex:t})=>{c.has(e)&&(this.footprints[t].hiddenFlags|=4)});const f=new Set;this.buildingIds.forEach((e,t,i)=>{c.has(e)||f.add(e)}),this.buildingIds=f,this.groundEffect.prepareBorderSegments()}update(e,t,i,n,r,s,o){this.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o),this.groundEffect.update(e,t,r,i,n,s,o),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,Ig.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,Cg.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,Pg.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,Fg.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,Og.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Dg.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,Ig.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,Bg.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,t,i=!0){let n=!1;const r=i?t:0,s=0|(i?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],i=e.hiddenFlags&s|r;e.hiddenFlags!==i&&(e.hiddenFlags=i,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16))};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,i=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n<i;n++)t.indexArrayForConflation.uint16[3*n+0]=0,t.indexArrayForConflation.uint16[3*n+1]=0,t.indexArrayForConflation.uint16[3*n+2]=0;const n=e.bloomIndicesOffset+e.bloomIndicesLength;for(let i=e.bloomIndicesOffset;i<n;i++)t.entranceBloom.indexArrayForConflation.uint16[3*i+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+2]=0}}const i=t=>{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0))};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,Lg.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,Rg.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Lg.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const i=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const r=t[n.promoteId],s=n.feature;s.properties["building-part"]="roof";const o=e.paint.get("building-color").evaluate(s,r,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(s,r,this.canonical);s.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(s,r,this.canonical).toPremultipliedRenderColor(this.lut),c=e.paint.get("building-emissive-strength").evaluate(s,r,this.canonical);s.properties["building-part"]="window";const u=e.paint.get("building-color").evaluate(s,r,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(s,r,this.canonical);s.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(s,r,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(s,r,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,r=o;1===e.part?(r=o,t=a):0===e.part?(r=l,t=c):2===e.part?(r=u,t=h):3===e.part&&(r=d,t=p),t=ze(t,0,1);for(let s=0;s<e.vertexLength;s++){const o=e.vertexOffset+s,a=1+(f.layoutAOArray.uint8[o]/255-1)*i;f.layoutColorArray.emplace(o,r.r*a*255<<8|r.g*a*255,r.b*a*255<<8|255*t),n.hasFauxFacade&&f.layoutFacadePaintArray.emplace(o,255*u.r<<8|255*u.g,255*u.b<<8|255*h)}}const m=n.buildingBloom;if(m)for(let e=0;e<m.vertexLength;e++)f.entranceBloom.layoutColorArray.emplace(m.vertexOffset+e,255*d.r<<8|255*d.g,255*d.b<<8|51*p)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(tf(this.activeReplacements,n))return;this.activeReplacements=n;for(const e of this.footprints)e.hiddenFlags&=-2;const r=[];for(const t of this.activeReplacements){if(t.order<i)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));for(const i of this.footprints)i.min.x>t.max.x||i.max.x<t.min.x||i.min.y>t.max.y||i.max.y<t.min.y||(r.length=0,Yg(this.footprintsVertices,i.footprintVertexOffset,i.footprintVertexLength,t.footprintTileId.canonical,e.canonical,r),sf(t.footprint,r,this.footprintsIndices.uint16,i.footprintIndexOffset,i.footprintIndexLength,0,-n)&&(i.hiddenFlags|=1))}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(void 0!==e.id){const t=this.featureFootprintLookup.get(e.id);return this.footprints[t]}return null}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Qn)*Qn+(t+Qn);if(Object.hasOwn(this.footprintLookup,r)){const e=this.footprintLookup[r];return e?{height:e.height,hidden:0!==e.hiddenFlags}:void 0}const s=new Ae(e,t);for(const o of this.footprints)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||Zg(s,this.footprintsVertices.float32.subarray(2*o.footprintVertexOffset,2*(o.footprintVertexOffset+o.footprintVertexLength)),this.footprintsIndices.uint16.subarray(o.footprintIndexOffset,o.footprintIndexOffset+o.footprintIndexLength))&&(i=o.height,this.footprintLookup[r]=o,n=0!==o.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.footprintLookup[r]=void 0}}function Zg(e,t,i){for(let n=0;n<i.length;n+=3){const r=i[n],s=i[n+1],o=i[n+2],a=t[2*r+0],l=t[2*r+1],c=t[2*s+0],u=t[2*s+1],h=t[2*o+0],d=t[2*o+1],p=(a-h)*(e.y-d)-(l-d)*(e.x-h),f=(c-a)*(e.y-l)-(u-l)*(e.x-a);if(p<0!=f<0&&0!==p&&0!==f)continue;const m=(h-c)*(e.y-u)-(d-u)*(e.x-c);if(0===m||m<0==p+f<=0)return!0}return!1}function Yg(e,t,i,n,r,s){const o=Math.pow(2,n.z-r.z);for(let a=0;a<i;a++){let i=e.float32[2*(a+t)+0],l=e.float32[2*(a+t)+1];i=(i+r.x*Qn)*o-n.x*Qn,l=(l+r.y*Qn)*o-n.y*Qn,s.push(new Ae(i,l))}}async function Jg(){return function(){if(!nt(self))return null;if(null!=Wg||null!=Hg)return null;if(null!=Gg)return Gg;const e=fetch(gt());return Gg=function(e){let t,i,n,r,s;function o(){t=new Uint8Array(s.buffer),i=new Int16Array(s.buffer),n=new Int32Array(s.buffer),r=new Float32Array(s.buffer)}function a(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},c={a:{a:a,f:function(e){const i=t.length,n=Math.max(e>>>0,Math.ceil(1.2*i)),r=Math.ceil((n-i)/65536);try{return s.grow(r),o(),!0}catch(e){return!1}},g:a,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,c):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,c))).then(e=>{const a=e.instance.exports;return(0,a.g)(),s=a.f,o(),new kg({setStyle:a.h,setAOOptions:a.i,setMetricOptions:a.j,setStructuralOptions:a.k,setFacadeOptions:a.l,setFauxFacadeOptions:a.m,setFacadeClassifierOptions:a.n,addFeature:a.o,addFacade:a.p,generateMesh:a.q,getLastError:a.r,getOuterRingLength:a.s,getMeshCount:a.t,getPositionsPtr:a.u,getPositionsLength:a.v,getNormalsPtr:a.w,getNormalsLength:a.x,getAOPtr:a.y,getAOLength:a.z,getUVPtr:a.A,getUVLength:a.B,getFauxFacadePtr:a.C,getFauxFacadeLength:a.D,getIndicesPtr:a.E,getIndicesLength:a.F,getBuildingPart:a.G,getRingCount:a.H,getRingPtr:a.I,getRingLength:a.J,malloc:a.K,free:a.L,heapU8:t,heap16:i,heap32:n,heapF32:r})})}(e).then(e=>{Gg=null,Wg=e}).catch(e=>{Qe("Could not load building-gen"),Gg=null,Hg=e}),Gg}()}lo($g,"BuildingBucket",{omit:["layers"]}),lo(Xg,"BuildingGeometry"),lo(qg,"BuildingBloomGeometry");const Kg=Ka([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Qg=Ka([{name:"a_z_offset_width",components:3,type:"Float32"}],4),e_=Ka([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),t_=Ka([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:i_}=Kg,n_=Ka([{name:"a_packed",components:3,type:"Float32"}]),{members:r_}=n_,s_=Ka([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:o_}=s_;class a_{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new sd({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=qe(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const n=[];let r=e.length%2==1?-e.at(-1)*i:0,s=e[0]*i,o=!0;n.push({left:r,right:s,isDash:o,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){o=!o;const l=e[t];r=a*i,a+=l,s=a*i,n.push({left:r,right:s,isDash:o,zeroLength:0===l})}return n}addRoundDash(e,t,i){const n=t/2;for(let t=-i;t<=i;t++){const r=this.width*(this.nextRow+i+t);let s=0,o=e[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=e[++s]);const l=Math.abs(a-o.left),c=Math.abs(a-o.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(o.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const i=e[0],n=e.at(-1);i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let s=0,o=e[s];for(let i=0;i<this.width;i++){i/o.right>1&&(o=e[++s]);const n=Math.abs(i-o.left),a=Math.abs(i-o.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(o.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const n="round"===t,r=n?7:0,s=2*r+1;if(this.nextRow+s>this.height)return Qe("LineAtlas out of space"),null;0===e.length&&e.push(1);let o=0;for(let t=0;t<e.length;t++)e[t]<0&&(Qe("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),o+=e[t];if(0!==o){const i=this.width/o,s=this.getDashRanges(e,this.width,i);n?this.addRoundDash(s,i,r):this.addRegularDash(s,"square"===t?.5*i:0)}const a=this.nextRow+r;this.nextRow+=s;const l=Math.floor(o),c={tl:[a,r],br:[l,Math.round(65535*(o-l))]};return this.positions[i]=c,c}}lo(a_,"LineAtlas");const l_=hu.types,c_=Math.cos(Math.PI/180*37.5),u_=Math.cos(Math.PI/180*5);class h_{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ll,this.layoutVertexArray2=new cl,this.patternVertexArray=new cl,this.indexArray=new wl,this.programConfigurations=new Ac(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Ql,this.maxLineLength=0,this.zOffsetVertexArray=new cl,this.elevationIdColVertexArray=new cl,this.elevationGroundScaleVertexArray=new nl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.showElevationIdDebug=t.showElevationIdDebug,this.hasPattern=jd("line",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("line-sort-key");this.tileToMeter=eu(i);const s=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===s)this.elevationType="road";else{const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==s&&"ground"!==s&&t?"none":"offset","offset"===this.elevationType&&"none"===s&&Qe(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===s}const o=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==o;const a=[];for(const{feature:s,id:o,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=uu(s,e);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i):void 0,d={id:o,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:cu(s,i,n),patterns:{},sortKey:h};a.push(d)}r&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const n of a){const{geometry:r,index:s,sourceLayerIndex:o}=n;if(u&&this.addFeatureDashes(n,l),this.hasPattern){const e=Gd("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,s,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures);c.insert(e[s].feature,r,s,o,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else{const t=r.value,i=n.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===s.kind)continue;let o,a;if("constant"===r.kind){if(o=r.value,!o)continue}else o=r.evaluate({zoom:i},e);a="constant"===s.kind?s.value:s.evaluate({zoom:i},e),t.addDash(o,a),e.patterns[n.id]=[t.getKey(o,a)]}}update(e,t,i,n,r,s,o,a,l){this.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,l)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}addFeatures(e,t,i,n,r,s){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,s,e.elevationFeatures)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,r_)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,o_)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Qg.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,e_.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,t_.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,i_),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let i,n;if(t&&t>0?(i=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,i)&&Object.hasOwn(e.properties,n))return{start:+e.properties[i],end:+e.properties[n]}}addFeature(e,t,i,n,r,s,o,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),this.isSeaLevelReference){const e=l.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e)}if("road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,a,c,u,h,d)){const[r,s]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t<r.length;t++){const i=r[t],o=s[t],a={progress:{min:o.progress.min,max:o.progress.max},nextDir:this.computeSegNextDir(o,i),prevDir:this.computeSegPrevDir(o,i)};this.addLine(i,e,n,c,u,h,d,a,p&&o.parentIndex>0?o.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i<t.length;i++)this.addLine(t[i],e,n,c,u,h,d,void 0,p&&i>0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,s,n,o,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Qf(e,-t,-t,Qn+t,Qn+t)}clipRuntimeLinesToTile(e,t){const i=[];return[Qf(e,-t,-t,Qn+t,Qn+t,i),i]}addElevatedRoadFeature(e,t,i,n,r,s,o,a){const l=[],c=Nu.getElevationFeature(e,n);if(c){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,c,i);for(const e of n)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,r,s,o,a);const l=new ku(i,t.elevationTileID);if(t.elevation){const e=this.showElevationIdDebug?zu(t.elevation.id):null;for(let i=n;i<this.layoutVertexArray.length;i++){const n=new Ae(this.layoutVertexArray.int16[6*i]>>1,this.layoutVertexArray.int16[6*i+1]>>1),r=l.pointElevation(n,t.elevation,.05);this.updateHeightRange(r),this.zOffsetVertexArray.emplaceBack(r,0,0),e?this.elevationIdColVertexArray.emplaceBack(e[0],e[1],e[2]):this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}}else this.fillNonElevatedRoadSegment(n)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const n=[],r=1/eu(i);for(const i of e)em(i,new Bu(t,r),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t<this.layoutVertexArray.length;t++)this.zOffsetVertexArray.emplaceBack(0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e}}addLine(e,t,i,n,r,s,o,a,l){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=l?this.lineFeatureClips(t,l):this.lineClips;const c="none"===n;this.patternJoinNone=this.hasPattern&&c,this.currentLineJoinType=n,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const u=a&&a.progress.min>0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:dt(e.min,t,i),max:dt(e.max,t,i)}}(a.progress,{min:0,max:1},i),e>0&&(n=(i.max-i.min)/e)}const r=+t.properties.mapbox_clip_feature_len,s=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(r)||Number.isNaN(s)){for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);const t=this.totalDistance/(i.max-i.min);this.totalFeatureLength=Number.isFinite(t)?t:0,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=r,this.distance=s*n,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const d="Polygon"===l_[t.type];let p=e.length;for(;p>=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f<p-1&&e[f].equals(e[f+1]);)f++;if(p<(d?3:2))return;"bevel"===n&&(s=1.05);const m=this.segments.prepareSegment(10*p,this.layoutVertexArray,this.indexArray);let g,_,y,v,x,b,w,T;a&&a.prevDir&&(b=a.prevDir.perp()),a&&a.nextDir&&(w=a.nextDir.perp()),this.e1=this.e2=-1,d&&(g=e[p-2],x=e[f].sub(g)._unit()._perp());for(let t=f;t<p;t++){if(y=t===p-1?d?e[f+1]:void 0:e[t+1],y&&e[t].equals(y))continue;x&&(v=x),g&&(_=g),g=e[t],T=this.evaluateLineProgressFeatures(_?_.dist(g):0),x=y?y.sub(g)._unit()._perp():v,v=v||x;const i=_&&y;let a=i?n:d||c?"butt":r;const l=v.x*x.x+v.y*x.y;if(c){const e=function(e){if(e.patternJoinNone){const t=e.segmentPoints.length/2,i=e.lineSoFar-e.segmentStart;for(let n=0;n<t;++n){const t=e.segmentPoints[2*n+1],r=Math.round(e.segmentPoints[2*n])+.5+.25*t;e.patternVertexArray.emplaceBack(r,i,e.segmentStart),e.patternVertexArray.emplaceBack(r,i,e.segmentStart)}e.segmentPoints.length=0}e.e1=e.e2=-1};if(i&&l<u_){this.updateDistance(_,g),this.addCurrentVertex(g,v,1,1,m,T),e(this),this.addCurrentVertex(g,x,-1,-1,m,T);continue}if(_){if(!y){this.updateDistance(_,g),this.addCurrentVertex(g,v,1,1,m,T),e(this);continue}a="miter"}}let S=v.add(x);0===S.x&&0===S.y||S._unit();const E=S.x*x.x+S.y*x.y,A=0!==E?1/E:1/0,M=2*Math.sqrt(2-2*E),I=E<c_&&_&&y,C=v.x*x.y-v.y*x.x>0,P=this.overscaling<=16?122880/(512*this.overscaling):0;if(i&&"round"===a)if(A<o)a="miter";else if(A<=2){const e=d_(g,-10,8202);a="offset"===this.elevationType&&(e||this.hasCrossSlope)?"miter":"fakeround"}if("miter"===a&&A>s&&(a="bevel"),"bevel"===a&&(A>2&&(a="flipbevel"),A<s&&(a="miter")),_&&!("miter"===a&&I)&&this.updateDistance(_,g),"miter"===a)if(I){const e=g.dist(_);if(e>2*P){const t=g.sub(g.sub(_)._mult(P/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,v,0,0,m,T),_=t}this.updateDistance(_,g),S._mult(A),this.addCurrentVertex(g,S,0,0,m,T);const t=g.dist(y);if(t>2*P){const e=g.add(y.sub(g)._mult(P/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,x,0,0,m,T),g=e}}else S._mult(A),this.addCurrentVertex(g,S,0,0,m,T);else if("flipbevel"===a){if(A>100)S=x.mult(-1);else{const e=A*v.add(x).mag()/v.sub(x).mag();S._perp()._mult(e*(C?-1:1))}this.addCurrentVertex(g,S,0,0,m,T),this.addCurrentVertex(g,S.mult(-1),0,0,m,T)}else if("bevel"===a||"fakeround"===a){const e=g.dist(_);let t=1;if("offset"===this.elevationType&&"bevel"===a&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=T&&_&&y){const i=4*P;e<i&&(t=Math.max(0,e/i))}null!=T&&_&&this.addCurrentVertex(g,w||v,-t,-t,m,T);const i=e<=2*P&&"bevel"!==a,n=S.mult(C?1:-1);n._mult(A);const r=x.mult(C?-1:1),s=v.mult(C?-1:1),o=this.evaluateLineProgressFeatures(this.distance);if(null==T&&(this.addHalfVertex(g,n.x,n.y,!1,!C,0,m,o),i||this.addHalfVertex(g,n.x+2*s.x,n.y+2*s.y,!1,C,0,m,o)),"fakeround"===a){const e=Math.round(180*M/Math.PI/20);this.addHalfVertex(g,s.x,s.y,!1,C,0,m,o);for(let t=0;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+l*(l*(3.55645-1.43519*l)-3.2452))*e*e+(.848013+l*(.215638*l-1.06021)))}const n=r.sub(s)._mult(i)._add(s)._unit();this.addHalfVertex(g,n.x,n.y,!1,C,0,m,o)}this.addHalfVertex(g,r.x,r.y,!1,C,0,m,o)}i||null!=T||this.addHalfVertex(g,n.x+2*r.x,n.y+2*r.y,!1,C,0,m,o),null!=T&&y&&this.addCurrentVertex(g,b||x,t,t,m,T)}else if("butt"===a)this.addCurrentVertex(g,S,0,0,m,T);else if("square"===a){if(!_){const e=u?0:-1;this.addCurrentVertex(g,S,e,e,m,T)}if(this.addCurrentVertex(g,S,0,0,m,T),_){const e=h?0:1;this.addCurrentVertex(g,S,e,e,m,T)}}else if("round"===a){if(_){const e=!i&&w?w:v;this.addCurrentVertex(g,e,0,0,m,T),!i&&h||this.addCurrentVertex(g,e,1,1,m,T,!0)}if(y){const e=!i&&b?b:x;!i&&u||this.addCurrentVertex(g,e,-1,-1,m,T,!0),this.addCurrentVertex(g,e,0,0,m,T)}}}}addVerticesTo(e,t,i,n,r,s,o,a,l,c){const u=(t.w-e.w)/this.tessellationStep|0;let h=0;const d=this.scaledDistance;if(u>1){this.lineSoFar=e.w;const i=(t.x-e.x)/u,n=(t.y-e.y)/u,r=(t.z-e.z)/u,s=(t.w-e.w)/u,o=t.x-e.x,a=t.y-e.y,d=Math.sqrt(o*o+a*a);if(0===d)return;const p=-a/d,f=o/d,m=p,g=f,_=-p,y=-f;for(let t=1;t<u;++t){e.x+=i,e.y+=n,e.z+=r,this.lineSoFar+=s,h+=s;const t=this.evaluateLineProgressFeatures(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(e,m,g,c,!1,0,l,t),this.addHalfVertex(e,_,y,c,!0,0,l,t)}}this.lineSoFar=t.w,this.scaledDistance=d;const p=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,i,n,c,!1,o,l,p),this.addHalfVertex(t,r,s,c,!0,-a,l,p)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&"offset"!==this.elevationType)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):Qe(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const i=this.evaluateElevationGroundScale();return"offset"!==this.elevationType?{zOffset:0,variableWidth:t,elevationGroundScale:i}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:t,elevationGroundScale:i}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t,elevationGroundScale:i}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?"constant"===this.elevationGroundScaleValue.kind?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,t,i,n,r,s,o=!1){const a=t.x+t.y*i,l=t.y-t.x*i,c=t.y*n-t.x,u=-t.y-t.x*n;if(null!=s){const t="offset"===this.elevationType,h="offset"===this.elevationType?2:10,d=-h,p=Qn+h,f=s.zOffset,m=new Yf(e.x,e.y,f,this.lineSoFar),g=!!t&&d_(e,d,p),_=this.lineSoFar,y=this.distance;if(this.currentVertex)if(g){const t=this.currentVertexIsOutside,s=this.currentVertex,h=new Yf(e.x,e.y,f,this.lineSoFar);if(Kf(s,h,d,p),!d_(h,d,p)){if(t){this.e1=this.e2=-1,this.distance-=s.dist(m),this.lineSoFar=s.w;const e=this.evaluateLineProgressFeatures(s.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(s,a,l,o,!1,i,r,e),this.addHalfVertex(s,c,u,o,!0,-n,r,e),this.prevDistance=this.distance}this.distance=this.prevDistance+s.dist(h),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(s,h,a,l,c,u,i,n,r,o),this.distance=y,this.scaledDistance=this.distance/this.totalDistance}}else{const e=this.currentVertex;if(this.currentVertexIsOutside){Kf(e,m,d,p),this.e1=this.e2=-1,this.distance-=e.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e.w;const t=this.evaluateLineProgressFeatures(e.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(e,a,l,o,!1,i,r,t),this.addHalfVertex(e,c,u,o,!0,-n,r,t),this.prevDistance=this.distance,this.distance=y,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(e,m,a,l,c,u,i,n,r,o)}else g||(this.addHalfVertex(e,a,l,o,!1,i,r,s),this.addHalfVertex(e,c,u,o,!0,-n,r,s));this.currentVertex=m,this.currentVertexIsOutside=g,this.lineSoFar=_}else this.addHalfVertex(e,a,l,o,!1,i,r,s),this.addHalfVertex(e,c,u,o,!0,-n,r,s)}addHalfVertex({x:e,y:t},i,n,r,s,o,a,l){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),s||this.segmentPoints.push(this.lineSoFar-this.segmentStart,o)),this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(s?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const e=xi(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,e)}const c=a.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),s?this.e2=c:this.e1=c,null!=l&&(this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function d_(e,t,i){return e.x<t||e.x>i||e.y<t||e.y>i}let p_,f_;function m_(e,t,i){return t*(Qn/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}lo(h_,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const g_=(e,t,i)=>(1-i)*e+i*t;function __(e,t){return 1/m_(e,1,t.tileZoom)}function y_(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const v_=e=>{const t=[];x_(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT"),"multiply"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_MULTIPLY"),"additive"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_ADDITIVE");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),r=!!e.paint.get("line-pattern").constantOr(1);return n&&r&&t.push("LINE_JOIN_NONE"),t};function x_(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let b_;const w_=()=>b_||(b_={layout:p_||(p_=new xa({"line-cap":new ya(ba.layout_line["line-cap"]),"line-join":new ya(ba.layout_line["line-join"]),"line-miter-limit":new _a(ba.layout_line["line-miter-limit"]),"line-round-limit":new _a(ba.layout_line["line-round-limit"]),"line-sort-key":new ya(ba.layout_line["line-sort-key"]),"line-z-offset":new ya(ba.layout_line["line-z-offset"]),"line-elevation-reference":new _a(ba.layout_line["line-elevation-reference"]),"line-cross-slope":new _a(ba.layout_line["line-cross-slope"]),visibility:new _a(ba.layout_line.visibility),"line-width-unit":new _a(ba.layout_line["line-width-unit"]),"line-elevation-ground-scale":new ya(ba.layout_line["line-elevation-ground-scale"])})),paint:f_||(f_=new xa({"line-opacity":new ya(ba.paint_line["line-opacity"]),"line-color":new ya(ba.paint_line["line-color"]),"line-translate":new _a(ba.paint_line["line-translate"]),"line-translate-anchor":new _a(ba.paint_line["line-translate-anchor"]),"line-width":new ya(ba.paint_line["line-width"]),"line-gap-width":new ya(ba.paint_line["line-gap-width"]),"line-offset":new ya(ba.paint_line["line-offset"]),"line-blur":new ya(ba.paint_line["line-blur"]),"line-dasharray":new ya(ba.paint_line["line-dasharray"]),"line-pattern":new ya(ba.paint_line["line-pattern"]),"line-pattern-cross-fade":new _a(ba.paint_line["line-pattern-cross-fade"]),"line-gradient":new va(ba.paint_line["line-gradient"]),"line-trim-offset":new _a(ba.paint_line["line-trim-offset"]),"line-trim-fade-range":new _a(ba.paint_line["line-trim-fade-range"]),"line-trim-color":new _a(ba.paint_line["line-trim-color"]),"line-emissive-strength":new ya(ba.paint_line["line-emissive-strength"]),"line-border-width":new ya(ba.paint_line["line-border-width"]),"line-border-color":new ya(ba.paint_line["line-border-color"]),"line-occlusion-opacity":new _a(ba.paint_line["line-occlusion-opacity"]),"line-blend-mode":new _a(ba.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new _a(ba.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},b_);class T_ extends ya{possiblyEvaluate(e,t){return t=new la(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let S_;function E_(e,t){return t>0?t+2*e:e}const A_=Ka([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),M_=Ka([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),I_=Ka([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ka([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const C_=Ka([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),P_=Ka([{name:"a_feature_index",components:1,type:"Float32"}],4),L_=Ka([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),R_=Ka([{name:"a_texb",components:2,type:"Uint16"}]),O_=Ka([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),D_=Ka([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Ka([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const B_=Ka([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),F_=Ka([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ka([{name:"triangle",components:3,type:"Uint16"}]),Ka([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Ka([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Ka([{type:"Float32",name:"offsetX"}]),Ka([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const N_=class e{constructor(t=null,i=0,n=4096){if(this.batchIndex=i,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=t||null,this.propsDwords=n,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(e.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),!e._blockIndicesTemplate){e._blockIndicesTemplate=new Uint32Array(this.propsDwords);for(let t=0;t<this.propsDwords;t++)e._blockIndicesTemplate[t]=t}this.blockIndicesData=new Uint32Array(e._blockIndicesTemplate),t&&this._initBuffers(t)}_initBuffers(t){const i=t.gl;if(this.totalBytes>t.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${t.maxUniformBlockSize}`);if(this.headerBuffer=i.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferData(i.UNIFORM_BUFFER,e.HEADER_BYTES,i.DYNAMIC_DRAW),this.propertiesBuffer=i.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),this.blockIndicesBuffer=i.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),i.bindBuffer(i.UNIFORM_BUFFER,null)}writeHeader(e){const t=this.headerData;t[0]=e.dataDrivenMask,t[1]=e.zoomDependentMask,t[2]=e.dataDrivenBlockSizeVec4,t[3]=e.offsets[0],t[4]=e.offsets[1],t[5]=e.offsets[2],t[6]=e.offsets[3],t[7]=e.offsets[4],t[8]=e.offsets[5],t[9]=e.offsets[6],t[10]=e.offsets[7],t[11]=e.offsets[8]}writeDataDrivenBlock(t,i,n){const r=4*n.dataDrivenBlockSizeVec4;if(0===r)return;const s=i*r;if(s+r>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${i} exceeds propertiesData capacity`);for(let i=0;i<9;i++)n.dataDrivenMask&1<<i&&this._copyFromFlat(s+n.offsets[i],i,t,e.EVAL_FLAT_OFFSETS[i],n.zoomDependentMask)}static getMaxFeatureCount(e,t=4096){const i=4*e.dataDrivenBlockSizeVec4;return 0===i?1/0:Math.floor(t/i)}_copyFromFlat(e,t,i,n,r){const s=this.propertiesData,o=8===t,a=!!(r&1<<t);t<2||o&&a?(s[e]=i[n],s[e+1]=i[n+1],s[e+2]=i[n+2],s[e+3]=i[n+3]):o||a?(s[e]=i[n],s[e+1]=i[n+1]):s[e]=i[n]}upload(e){this.context||(this.context=e);const t=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e),t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.headerData),t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.propertiesData),t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.blockIndicesData),t.bindBuffer(t.UNIFORM_BUFFER,null)}bind(e,t){const i=e.gl,n=(e,n,r)=>{if(!n)return;const s=i.getUniformBlockIndex(t,e);s!==i.INVALID_INDEX&&(i.uniformBlockBinding(t,s,r),i.bindBufferBase(i.UNIFORM_BUFFER,r,n))},r=3*this.batchIndex;n("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,r),n("SymbolPaintPropertiesUniform",this.propertiesBuffer,r+1),n("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,r+2)}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};N_.HEADER_DWORDS=12,N_.HEADER_BYTES=48,N_.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],N_.EVAL_FLAT_SIZES=[4,4,2,2,2,2,2,2,4],N_.EVAL_FLAT_TOTAL=24,N_._blockIndicesTemplate=null;let k_=N_;function z_(e,t,i,n,r,s,o,a){return!!e&&("constant"===e.kind?"none"===e.value:"composite"===e.kind||"source"===e.kind?"none"===e.evaluate({zoom:0,brightness:s,worldview:a},t,i,r,n,o):"string"==typeof e&&"none"===e)}lo(k_,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class U_{constructor(e,t,i,n,r="",s,o){this.layer=e,this.zoom=t,this.lut=i,this.isText=n,this.propDefs=this._getPropDefs(),this.worldview=r,this.maxUniformBufferBindings=s||24,this.uboSizeDwords=o||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(e,n),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map,this.isLightConstant=!0,this._evalFlat=new Float32Array(k_.EVAL_FLAT_TOTAL)}_getPropDefs(){const e=this.isText?"text":"icon";return[{name:`${e}-color`,useThemeName:`${e}-color-use-theme`,isColor:!0},{name:`${e}-halo-color`,useThemeName:`${e}-halo-color-use-theme`,isColor:!0},{name:`${e}-opacity`,useThemeName:null,isColor:!1},{name:`${e}-halo-width`,useThemeName:null,isColor:!1},{name:`${e}-halo-blur`,useThemeName:null,isColor:!1},{name:`${e}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${e}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${e}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const e=this.layer.paint,t=this.propDefs;let i=0,n=0,r=0,s=0,o=!0;const a=[0,0,0,0,0,0,0,0,0];for(let l=0;l<9;l++){const{name:c,isColor:u,isVec2:h}=t[l],d=e.get(c),p=!(!d||"function"!=typeof d.isConstant||d.isConstant()),f=this._appearancesHavePaintProperties(c),m=p||f,g=!(!d||!d.value||"composite"!==d.value.kind),_=this.layer._transitionablePaint._values[c],y=!m&&"camera"===(_&&_.value&&_.value.expression&&_.value.expression.kind);if(m){i|=1<<l,g&&(n|=1<<l);const e=d&&d.value;e&&!1===e.isLightConstant&&(o=!1),u?(s%4!=0&&(s=s+3&-4),a[l]=s,s+=4):h?g?(s%4!=0&&(s=s+3&-4),a[l]=s,s+=4):(s%4==3&&s++,a[l]=s,s+=2):(a[l]=s,s+=g?2:1)}else y&&(r|=1<<l)}const l=(0===s?0:s+3&-4)/4;return this.isLightConstant=o,{dataDrivenMask:i,zoomDependentMask:n,cameraMask:r,dataDrivenBlockSizeVec4:l,offsets:a}}get hasCameraExpression(){return!(!this.cachedHeader||!this.cachedHeader.cameraMask)}evaluateAllProperties(e,t,i,n,r,s,o){const{params:a,paramsNext:l}=this._getCachedParams(r),c={feature:e,featureState:t,canonical:i,availableImages:n,params:a,paramsNext:l,formattedSection:s},u=this.cachedHeader,h=this.propDefs;this._evalFlat||(this._evalFlat=new Float32Array(k_.EVAL_FLAT_TOTAL));const d=this._evalFlat;for(let e=0;e<9;e++){const{name:t,useThemeName:i,isColor:n,isVec2:s}=h[e],a=!!(u&&u.zoomDependentMask&1<<e),l=k_.EVAL_FLAT_OFFSETS[e];n?this._evaluateColorValue(t,i,c,r,a,o,d,l):s?this._evaluateTranslateValue(t,a,c,o,d,l):this._evaluateFloatValue(t,a,c,o,d,l)}return d}_evaluateColorValue(e,t,i,n,r,s,o,a){const l=this.layer.paint,c=e,u=s&&s.hasPaintProperty(c)?s.paintProperties.get(c):l.get(e),h=t,d=t&&s&&s.hasPaintProperty(h)?s.paintProperties.get(h):t?l.get(t):void 0;if(!u)return o[a]=0,o[a+1]=0,o[a+2]=0,void(o[a+3]=1);const p=z_(d&&"string"!=typeof d?d.value:void 0,i.feature,i.featureState,i.availableImages,i.canonical,n,i.formattedSection,this.worldview)?null:this.lut;let f,m;u.isConstant()?f=m=u.constantOr(bi.transparent):(f=u.property.evaluate(u.value,i.params,i.feature,i.featureState,i.canonical,i.availableImages,u.iconImageUseTheme,i.formattedSection),m=r?u.property.evaluate(u.value,i.paramsNext,i.feature,i.featureState,i.canonical,i.availableImages,u.iconImageUseTheme,i.formattedSection):f);const g=(f||bi.transparent).toNonPremultipliedRenderColor(p);if(o[a]=ec(255*g.r,255*g.g),o[a+1]=ec(255*g.b,255*g.a),r){const e=(m||bi.transparent).toNonPremultipliedRenderColor(p);o[a+2]=ec(255*e.r,255*e.g),o[a+3]=ec(255*e.b,255*e.a)}else o[a+2]=0,o[a+3]=0}_evaluateFloatValue(e,t,i,n,r,s){const o=this.layer.paint,a=e.endsWith("opacity")?1:0,l=e,c=n&&n.hasPaintProperty(l)?n.paintProperties.get(l):o.get(e);if(!c)return r[s]=a,void(r[s+1]=0);if(c.isConstant())return r[s]=c.constantOr(a),void(r[s+1]=0);const u=c.property.evaluate(c.value,i.params,i.feature,i.featureState,i.canonical,i.availableImages,c.iconImageUseTheme,i.formattedSection);if(r[s]=null!=u?u:a,t){const e=c.property.evaluate(c.value,i.paramsNext,i.feature,i.featureState,i.canonical,i.availableImages,c.iconImageUseTheme,i.formattedSection);r[s+1]=null!=e?e:a}else r[s+1]=0}_evaluateTranslateValue(e,t,i,n,r,s){const o=this.layer.paint,a=e,l=n&&n.hasPaintProperty(a)?n.paintProperties.get(a):o.get(e);if(!l)return r[s]=0,r[s+1]=0,r[s+2]=0,void(r[s+3]=0);if("function"!=typeof l.isConstant){const e=l||[0,0];return r[s]=e[0],r[s+1]=e[1],r[s+2]=0,void(r[s+3]=0)}if(l.isConstant()){const e=l.constantOr([0,0]);return r[s]=e[0],r[s+1]=e[1],r[s+2]=0,void(r[s+3]=0)}const c=l.property.evaluate(l.value,i.params,i.feature,i.featureState,i.canonical,i.availableImages,l.iconImageUseTheme,i.formattedSection)||[0,0];if(r[s]=c[0],r[s+1]=c[1],t){const e=l.property.evaluate(l.value,i.paramsNext,i.feature,i.featureState,i.canonical,i.availableImages,l.iconImageUseTheme,i.formattedSection)||[0,0];r[s+2]=e[0],r[s+3]=e[1]}else r[s+2]=0,r[s+3]=0}_getCachedParams(e){return this.cachedParams&&this.cachedParamsNext&&this.cachedBrightness===e||(this.cachedParams=new la(this.zoom,{brightness:e,worldview:this.worldview}),this.cachedParamsNext=new la(this.zoom+1,{brightness:e,worldview:this.worldview}),this.cachedBrightness=e),{params:this.cachedParams,paramsNext:this.cachedParamsNext}}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(void 0!==e?t=>t.hasPaintProperty(e):this.isText?e=>e.hasTextPaintProperties():e=>e.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(e,t){const i=e.paint,n=t?"text":"icon",r=[`${n}-color`,`${n}-halo-color`,`${n}-opacity`,`${n}-halo-width`,`${n}-halo-blur`,`${n}-emissive-strength`,`${n}-occlusion-opacity`,"symbol-z-offset",`${n}-translate`];for(const e of r){const t=i.get(e);if(t&&"object"==typeof t&&"isConstant"in t&&!t.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(e,t){if(0===t.dataDrivenMask)return"";const i=[];for(let n=0;n<this.propDefs.length;n++){if(!(t.dataDrivenMask&1<<n))continue;const r=k_.EVAL_FLAT_OFFSETS[n],s=k_.EVAL_FLAT_SIZES[n];let o=String(e[r]);for(let t=1;t<s;t++)o+=`,${String(e[r+t])}`;i.push(o)}return i.join("|")}getCurrentBatchIndex(){return this.cachedHeader&&0!==this.maxFeaturesPerBatch?Math.floor(this.featureCount/this.maxFeaturesPerBatch):0}populateUBO(e,t,i,n,r,s,o){const a=e.id;if(!this.cachedHeader){this.cachedHeader=this.buildHeader();const e=k_.getMaxFeatureCount(this.cachedHeader,this.uboSizeDwords);this.maxFeaturesPerBatch=isFinite(e)?e:Number.MAX_SAFE_INTEGER}const l=this.cachedHeader,c=this.evaluateAllProperties(e,{},i,n,r,s);if(this.canDeduplicate){const e=this._hashDataDrivenValues(c,l),i=this.propertyHashToUBOIndex.get(e);if(void 0!==i){const e=isFinite(this.maxFeaturesPerBatch)?Math.floor(i/this.maxFeaturesPerBatch):0,n=isFinite(this.maxFeaturesPerBatch)?i%this.maxFeaturesPerBatch:i,r={batchIndex:e,localFeatureIndex:n,vtFeatureIndex:t,featureId:a};return this.allFeatures.push(r),null!=a&&(this.featureVertexRangesFromId.has(a)||this.featureVertexRangesFromId.set(a,[]),this.featureVertexRangesFromId.get(a).push(r)),n}this.propertyHashToUBOIndex.set(e,this.featureCount)}const u=this.featureCount++,h=isFinite(this.maxFeaturesPerBatch)?Math.floor(u/this.maxFeaturesPerBatch):0,d=isFinite(this.maxFeaturesPerBatch)?u%this.maxFeaturesPerBatch:u,p=o?o.maxUniformBufferBindings:this.maxUniformBufferBindings;if(3*h+2>=p){Qe(`Too many symbol features: batch ${h} requires binding points up to ${3*h+2}, device limit ${p}. Some features will render incorrectly.`);const e={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:t,featureId:a};return this.allFeatures.push(e),null!=a&&(this.featureVertexRangesFromId.has(a)||this.featureVertexRangesFromId.set(a,[]),this.featureVertexRangesFromId.get(a).push(e)),0}this.ubos[h]||(this.ubos[h]=new k_(o,h,this.uboSizeDwords),this.ubos[h].writeHeader(l)),this.ubos[h].writeDataDrivenBlock(c,d,l);const f={batchIndex:h,localFeatureIndex:d,vtFeatureIndex:t,featureId:a};return this.allFeatures.push(f),null!=a&&(this.featureVertexRangesFromId.has(a)||this.featureVertexRangesFromId.set(a,[]),this.featureVertexRangesFromId.get(a).push(f)),d}updateFeatures(e,t,i,n,r,s,o){if(this.layer=t,this.cachedConstantUniforms=null,!this.cachedHeader)return;const a=this.cachedHeader;for(const t of e){const e=this.featureVertexRangesFromId.get(t);if(!e)continue;const l=s[t]||{};for(const s of e){if(!i)continue;const e=i.feature(s.vtFeatureIndex);if(!e)continue;const c={type:e.type,id:t,properties:e.properties||{},geometry:[]},u=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(s.vtFeatureIndex):void 0,h=this.evaluateAllProperties(c,l,n,r,o,void 0,u);this.ubos[s.batchIndex]&&this.ubos[s.batchIndex].writeDataDrivenBlock(h,s.localFeatureIndex,a)}}}updateDynamicExpressions(e,t,i,n,r,s){if(this.layer=e,this.cachedConstantUniforms=null,!this.cachedHeader)return;if(0===this.cachedHeader.dataDrivenMask)return;const o=this.cachedHeader;for(const e of this.allFeatures){if(!t)continue;const a=t.feature(e.vtFeatureIndex);if(!a)continue;const l=null!=e.featureId&&r[e.featureId]||{},c={type:a.type,id:e.featureId,properties:a.properties||{},geometry:[]},u=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(e.vtFeatureIndex):void 0,h=this.evaluateAllProperties(c,l,i,n,s,void 0,u);this.ubos[e.batchIndex]&&this.ubos[e.batchIndex].writeDataDrivenBlock(h,e.localFeatureIndex,o)}}updateFeaturePaintForAppearance(e,t,i,n,r,s,o){if(!this.layer)return!1;if(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,o||null),!this.cachedHeader)return!1;const a=this.cachedHeader;if(0===a.dataDrivenMask)return!1;let l=!1;for(const c of this.allFeatures){if(c.vtFeatureIndex!==e)continue;const u=this.evaluateAllProperties(t,i,n,r,s,void 0,o);this.ubos[c.batchIndex]&&(this.ubos[c.batchIndex].writeDataDrivenBlock(u,c.localFeatureIndex,a),l=!0)}return l}getConstantUniformValues(e,t){const i=this.cachedHeader,n=!(!i||!i.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===t&&(!n||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const r=this.layer.paint,s=this.propDefs,o=n?new la(e,{brightness:t,worldview:this.worldview}):null,a={type:1,id:void 0,properties:{},geometry:[]},l=e=>{const n=s[e],l=r.get(n.name);if(!l)return[0,0,0,1];const c=n.useThemeName?r.get(n.useThemeName):void 0,u=z_(c&&"string"!=typeof c?c.value:void 0,a,{},[],void 0,t,void 0,this.worldview)?null:this.lut;let h;h=i&&i.cameraMask&1<<e&&o?l.property.evaluate(l.value,o,a,{},void 0,[]):l.constantOr(bi.transparent);const d=(h||bi.transparent).toNonPremultipliedRenderColor(u);return[d.r,d.g,d.b,d.a]},c=(e,t)=>{const n=r.get(s[e].name);if(!n)return t;if(i&&i.cameraMask&1<<e&&o){const e=n.property.evaluate(n.value,o,a,{},void 0,[]);return null!=e?e:t}return n.constantOr(t)},u={fill_np_color:l(0),halo_np_color:l(1),opacity:c(2,1),halo_width:c(3,0),halo_blur:c(4,0),emissive_strength:c(5,0),occlusion_opacity:c(6,1),z_offset:c(7,0)};return this.cachedConstantUniforms=u,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,u}upload(e){for(const t of this.ubos)t.upload(e)}bind(e,t,i=0){this.ubos[i]&&this.ubos[i].bind(e,t)}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId.clear(),this.allFeatures=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex&&this.propertyHashToUBOIndex.clear()}}lo(U_,"SymbolPropertyBinderUBO",{omit:["layer","cachedParams","cachedParamsNext","cachedBrightness","propertyHashToUBOIndex","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex","_evalFlat"]});var V_=24;function j_(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),oa.applyArabicShaping&&(e=oa.applyArabicShaping(e)),e}(e.text,t,i)}),e}const G_={"!":"︕","#":"＃",$:"＄","%":"％","&":"＆","(":"︵",")":"︶","*":"＊","+":"＋",",":"︐","-":"︲",".":"・","/":"／",":":"︓",";":"︔","<":"︿","=":"＝",">":"﹀","?":"︖","@":"＠","[":"﹇","\\":"＼","]":"﹈","^":"＾",_:"︳","`":"｀","{":"︷","|":"―","}":"︸","~":"～","¢":"￠","£":"￡","¥":"￥","¦":"￤","¬":"￢","¯":"￣","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"￦","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","！":"︕","（":"︵","）":"︶","，":"︐","－":"︲","．":"・","：":"︓","；":"︔","＜":"︿","＞":"﹀","？":"︖","［":"﹇","］":"﹈","＿":"︳","｛":"︷","｜":"―","｝":"︸","｟":"︵","｠":"︶","｡":"︒","｢":"﹁","｣":"﹂","←":"↑","→":"↓"};function H_(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"｀"===e||"￣"===e||"︑"===e||"︒"===e}function W_(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const q_=4294967296,X_=1/q_,$_="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let Z_=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){const i=this.readVarint(),n=i>>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*q_;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*q_;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,s;if(s=n[i.pos++],r=(112&s)>>4,s<128)return Y_(e,r,t);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return Y_(e,r,t);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return Y_(e,r,t);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return Y_(e,r,t);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return Y_(e,r,t);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return Y_(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&$_?$_.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r<i;){const t=e[r];let s,o,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(s=e[r+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===c?(s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*X_),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*X_),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(n,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,s=0;s<t.length;s++){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!r){n>56319||s+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&J_(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const n=this.pos-i;n>=128&&J_(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,K_,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Q_,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,iy,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,ey,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,ty,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,ny,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,ry,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,sy,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,oy,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Y_(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function J_(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function K_(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function Q_(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function ey(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function ty(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function iy(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function ny(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function ry(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function sy(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i])}function oy(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}function ay(e,t,i){t.glyphs=[],1===e&&i.readMessage(ly,t)}function ly(e,t,i){if(3===e){const{id:e,bitmap:n,width:r,height:s,left:o,top:a,advance:l}=i.readMessage(cy,{});t.glyphs.push({id:e,bitmap:new sd({width:r+6,height:s+6},n),metrics:{width:r,height:s,left:o,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function cy(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const uy={horizontal:1,vertical:2,horizontalOnly:3};class hy{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,t){const i=new hy;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new hy;return t.image=e,t}}class dy{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t,i,n=1){const r=new dy;for(let s=0;s<e.sections.length;s++){const o=e.sections[s];o.image?r.addImageSection(o,i,n):r.addTextSection(o,t)}return r}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(e,t){let i="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n+1)||null,s=e.charCodeAt(n-1)||null;i+=!t&&(r&&qo(r)&&!G_[e[n+1]]||s&&qo(s)&&!G_[e[n-1]])||!G_[e[n]]?e[n]:G_[e[n]]}return i}(this.text,e)}trim(){let e=0;for(let t=0;t<this.text.length&&fy[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&fy[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new dy;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(hy.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(i)}addImageSection(e,t,i=1){const n=e.image?e.image.getPrimary():null;if(!n)return void Qe("Can't add FormattedSection with an empty image.");n.scaleSelf(t*i);const r=this.getNextImageSectionCharCode();r?(this.text+=String.fromCodePoint(r),this.sections.push(hy.forImage(n)),this.sectionIndex.push(this.sections.length-1)):Qe("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function py(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m=1,g=1){const _=dy.fromFeature(e,r,m,g);h===uy.vertical&&_.verticalizePunctuation(d);let y=[];const v=function(e,t,i,n,r,s,o=1){if(!e)return[];const a=[],l=function(e,t,i,n,r,s,o=1){let a=0;for(let i=0;i<e.length();i++){const l=e.getSection(i);a+=gy(e.getCodePoint(i),l,n,r,t,s,o)}return a/Math.max(1,Math.ceil(a/i))}(e,t,i,n,r,s,o),c=e.text.includes("​");let u=0;for(let i=0;i<e.length();i++){const h=e.getSection(i),d=e.getCodePoint(i);if(fy[d]||(u+=gy(d,h,n,r,t,s,o)),i<e.length()-1){const t=Go(d);(my[d]||t||h.image)&&a.push(vy(i+1,u,l,a,yy(d,e.getCodePoint(i+1),t&&c),!1))}}return xy(vy(e.length(),u,l,a,0,!0))}(_,c,s,t,n,p,g),{processBidirectionalText:x,processStyledBidirectionalText:b}=oa;if(x&&1===_.sections.length){const e=x(_.toString(),v);for(const t of e){const e=new dy;e.text=t,e.sections=_.sections;for(let i=0;i<t.length;i++)e.sectionIndex.push(0);y.push(e)}}else if(b){const e=b(_.text,_.sectionIndex,v);for(const t of e){const e=new dy;e.text=t[0],e.sectionIndex=t[1],e.sections=_.sections,y.push(e)}}else y=function(e,t){const i=[],n=e.text;let r=0;for(const n of t)i.push(e.substring(r,n)),r=n;return r<n.length&&i.push(e.substring(r,n.length)),i}(_,v);const w=[],T={positionedLines:w,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(e,t,i,n,r,s,o,a,l,c,u,h,d=1){let p=0,f=0,m=0;const g="right"===a?1:"left"===a?0:.5;let _=!1;for(const e of r){const i=e.getSections();for(const e of i){if(e.image)continue;const i=t[e.fontStack];if(i&&(_=void 0!==i.ascender&&void 0!==i.descender,!_))break}if(!_)break}let y=0;for(const o of r){o.trim();const r=o.getMaxScale(),a=(r-1)*V_,v={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=v;const x=v.positionedGlyphs;let b=0;if(!o.length()){f+=s,++y;continue}let w=0,T=0;for(let s=0;s<o.length();s++){const a=o.getSection(s),m=o.getSectionIndex(s),g=o.getCodePoint(s);let y=a.scale,v=null,S=null,E=null,A=V_,M=0,I=l;I===uy.vertical&&Wo(g)&&(I=uy.horizontal);const C=!(I===uy.horizontal||!u&&!Ho(g)||u&&(fy[g]||Xo(g)));if(a.image){const t=n.get(a.image.toString());if(!t)continue;E=a.image,e.iconsInText=e.iconsInText||!0,S=t.paddedRect;const i=t.displaySize,s=i[0]*d,o=i[1]*d;y=y*V_/h,v={width:s,height:o,left:0,top:-3,advance:C?o:s,localGlyph:!1},M=_?-v.height*y:r*V_-17-o*y,A=v.advance;const l=(C?s:o)*y-V_*r;l>0&&l>b&&(b=l)}else{const e=i[a.fontStack];if(!e)continue;e[g]&&(S=e[g]);const n=t[a.fontStack];if(!n)continue;const s=n.glyphs[g];if(!s)continue;if(v=s.metrics,A=8203!==g?V_:0,_){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*y;w<i&&(w=i,T=(e-t)/2*y),M=-e*y}else M=(r-y)*V_-17}C?(e.verticalizable=!0,x.push({glyph:g,image:E,x:p,y:f+M,vertical:C,scale:y,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:m,metrics:v,rect:S}),p+=A*y+c):(x.push({glyph:g,image:E,x:p,y:f+M,vertical:C,scale:y,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:m,metrics:v,rect:S}),p+=v.advance*y+c)}0!==x.length&&(m=Math.max(p-c,m),_?wy(x,g,b,T,s*r/2):wy(x,g,b,0,s/2)),p=0;const S=s*r+b;v.lineOffset=Math.max(b,a),f+=S,++y}const v=f,{horizontalAlign:x,verticalAlign:b}=by(o);(function(e,t,i,n,r,s){const o=(t-i)*r,a=-s*n;for(const t of e)for(const e of t.positionedGlyphs)e.x+=o,e.y+=a})(e.positionedLines,g,x,b,m,v),e.top+=-b*v,e.bottom=e.top+v,e.left+=-x*m,e.right=e.left+m,e.hasBaseline=_}(T,t,i,n,y,o,a,l,h,c,d,f,g),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(w))return T}const fy={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},my={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function gy(e,t,i,n,r,s,o=1){if(t.image){const e=n.get(t.image.toString());return e?e.displaySize[0]*o*t.scale*V_/s+r:0}{const n=i[t.fontStack],s=n&&n.glyphs[e];return s?s.metrics.advance*t.scale+r:0}}function _y(e,t,i,n){const r=Math.pow(e-t,2);return n?e<t?r/2:2*r:r+Math.abs(i)*i}function yy(e,t,i){let n=0;return 10===e&&(n-=1e4),i&&(n+=150),40!==e&&65288!==e||(n+=50),41!==t&&65289!==t||(n+=50),n}function vy(e,t,i,n,r,s){let o=null,a=_y(t,i,r,s);for(const e of n){const n=_y(t-e.x,i,r,s)+e.badness;n<=a&&(o=e,a=n)}return{index:e,x:t,priorBreak:o,badness:a}}function xy(e){return e?xy(e.priorBreak).concat(e.index):[]}function by(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function wy(e,t,i,n,r){if(!(t||i||n||r))return;const s=e.length-1,o=e[s],a=(o.x+o.metrics.advance*o.scale)*t;for(let t=0;t<=s;t++)e[t].x-=a,e[t].y+=i+n+r}function Ty(e){return void 0!==e.imagePrimary&&void 0!==e.top&&void 0!==e.bottom&&void 0!==e.left&&void 0!==e.right}function Sy(e,t,i,n){const{horizontalAlign:r,verticalAlign:s}=by(n),o=i[0]-e.displaySize[0]*r,a=i[1]-e.displaySize[1]*s;return{imagePrimary:e,imageSecondary:t,top:a,bottom:a+e.displaySize[1],left:o,right:o+e.displaySize[0]}}function Ey(e,t,i,n,r,s){const o=e.imagePrimary;let a;if(o.content){const e=o.content,t=o.pixelRatio||1;a=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}const l=t.left*s,c=t.right*s;let u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-o.displaySize[0])/2,h=p+o.displaySize[0]);const f=t.top*s,m=t.bottom*s;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-o.displaySize[1])/2,d=u+o.displaySize[1]),{imagePrimary:o,imageSecondary:void 0,top:u,right:h,bottom:d,left:p,collisionPadding:a}}function Ay(e){return!e.imagePrimary.stretchX}function My(e){return!e.imagePrimary.stretchY}function Iy(e){return{width:e.right-e.left,height:e.bottom-e.top}}const Cy=128;function Py(e,t,i,n){const{expression:r}=t;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new la(e+1,{worldview:i}),void 0,void 0,void 0,n)};if("source"===r.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:s}=r;let o=0;for(;o<t.length&&t[o]<=e;)o++;o=Math.max(0,o-1);let a=o;for(;a<t.length&&t[a]<e+1;)a++;a=Math.min(t.length-1,a);const l=t[o],c=t[a];return"composite"===r.kind?{kind:"composite",minZoom:l,maxZoom:c,interpolationType:s}:{kind:"camera",minZoom:l,maxZoom:c,minSize:r.evaluate(new la(l,{worldview:i}),void 0,void 0,void 0,n),maxSize:r.evaluate(new la(c,{worldview:i}),void 0,void 0,void 0,n),interpolationType:s}}}function Ly(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/Cy:"composite"===e.kind?xi(n/Cy,r/Cy,i):t}function Ry(e,t,i=1){let n=0,r=0;if("constant"===e.kind)r=e.layoutSize*i;else if("source"!==e.kind){const{interpolationType:s,minZoom:o,maxZoom:a}=e,l=s?ze(rs.interpolationFactor(s,t,o,a),0,1):0;"camera"===e.kind?r=xi(e.minSize,e.maxSize,l)*i:n=l*i}return{uSizeT:n,uSize:r}}class Oy extends Ae{constructor(e,t,i,n,r){super(e,t),this.angle=n,this.z=i,void 0!==r&&(this.segment=r)}clone(){return new Oy(this.x,this.y,this.z,this.angle,this.segment)}}function Dy(e,t,i,n,r){if(void 0===t.segment)return!0;let s=t,o=t.segment+1,a=0;for(;a>-i/2;){if(o--,o<0)return!1;a-=e[o].dist(s),s=e[o]}a+=e[o].dist(e[o+1]),o++;const l=[];let c=0;for(;a<i/2;){const t=e[o],i=e[o+1];if(!i)return!1;let s=e[o-1].angleTo(t)-t.angleTo(i);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),c+=s;a-l[0].distance>n;)c-=l.shift().angleDelta;if(c>r)return!1;o++,a+=t.dist(i)}return!0}function By(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function Fy(e,t,i){return e?.6*t*i:0}function Ny(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function ky(e,t,i,n,r,s){const o=Fy(i,r,s),a=Ny(i,n)*s;let l=0;const c=By(e)/2;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1],s=n.dist(r);if(l+s>c){const u=(c-l)/s,h=xi(n.x,r.x,u),d=xi(n.y,r.y,u),p=new Oy(h,d,0,r.angleTo(n),i);return!o||Dy(e,p,a,o,t)?p:void 0}l+=s}}function zy(e,t,i,n,r,s,o,a,l){const c=Fy(n,s,o),u=Ny(n,r),h=u*o,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),Uy(e,d?t/2*a%t:(u/2+2*s)*o*a%t,t,c,i,h,d,!1,l)}function Uy(e,t,i,n,r,s,o,a,l){const c=s/2,u=By(e);let h=0,d=t-i,p=[];for(let t=0;t<e.length-1;t++){const o=e[t],a=e[t+1],f=o.dist(a),m=a.angleTo(o);for(;d+i<h+f;){d+=i;const g=(d-h)/f,_=xi(o.x,a.x,g),y=xi(o.y,a.y,g);if(_>=0&&_<l&&y>=0&&y<l&&d-c>=0&&d+c<=u){const i=new Oy(_,y,0,m,t);n&&!Dy(e,i,s,n,r)||p.push(i)}}h+=f}return a||p.length||o||(p=Uy(e,h/2,i,n,r,s,o,!0,l)),p}function Vy(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,s=Math.max(s,t.y+t.h),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e<n.length&&(n[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(n.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:r,h:s,fill:t/(r*s)||0}}function jy(e,t){return e.id<t.id?-1:e.id>t.id?1:e.version<t.version?-1:e.version>t.version?1:e.sx<t.sx?-1:e.sx>t.sx?1:e.sy<t.sy?-1:e.sy>t.sy?1:0}function Gy(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return t}function Hy(e,t){return(e<<5)-e+t}function Wy(e,t,i,n){for(const[r]of e.entries()){const e=n&&n.get(r)||Zi.parse(r),s=e.id.toString(),o=t.get(s)||0;i.push({id:r,version:o,sx:e.sx,sy:e.sy})}}lo(Oy,"Anchor");class qy{constructor(e,t,i,n,r){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=t.size>0,Wy(e,i,this.iconDescriptors,r),Wy(t,i,this.patternDescriptors,r),this.iconDescriptors.sort(jy),this.patternDescriptors.sort(jy);let s=0;const o=n?n.data:"";o&&(s=Hy(s,Gy(o))),s=Hy(s,1);for(const e of this.iconDescriptors)s=Hy(s,Gy(e.id)),s=Hy(s,e.version),s=Hy(s,e.sx),s=Hy(s,e.sy);s=Hy(s,1);for(const e of this.patternDescriptors)s=Hy(s,Gy(e.id)),s=Hy(s,e.version),s=Hy(s,e.sx),s=Hy(s,e.sy);this.hash=s}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,jy)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,jy)}isSubsetArray(e,t,i){let n=0,r=0;if(e.length>t.length)return!1;for(;n<e.length&&r<t.length;){const s=i(e[n],t[r]);if(0===s)n++,r++;else{if(s<0)return!1;r++}}return n===e.length}}lo(qy,"AtlasContentDescriptor");class Xy{static getImagePositionScale(e,t,i){if(t&&e){const{sx:t,sy:i}=e;return{x:t,y:i}}return{x:i,y:i}}constructor(e,t,i,n){this.paddedRect=e;const{pixelRatio:r,version:s,stretchX:o,stretchY:a,content:l,sdf:c,usvg:u}=t;this.pixelRatio=r,this.stretchX=o,this.stretchY=a,this.content=l,this.version=s,this.padding=i,this.sdf=c,this.usvg=u,this.scale=Xy.getImagePositionScale(n,u,r)}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function $y(e,t,i){const n=Zi.parse(e),r=function(e,t,i=[1,1]){return{x:0,y:0,w:(e.data?e.data.width:e.width*i[0])+2*t,h:(e.data?e.data.height:e.height*i[1])+2*t}}(t,i,[n.sx,n.sy]);return{bin:r,imagePosition:new Xy(r,t,i,n),imageVariant:n}}function Zy(e,t){const i=[];for(const[n,r]of e.entries()){const e=Zi.parse(n);e&&(i.push({key:n,value:r,variant:e}),t&&t.set(n,e))}i.sort((e,t)=>{const i=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==i?i:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:0});const n=new Map;for(const e of i)n.set(e.key,e.value);return n}class Yy{constructor(e){this.sourceAtlasHash=e}}class Jy{constructor(e,t,i,n){const r=new Map,s=new Map;this.haveRenderCallbacks=[];const o=[],a=void 0!==n,l=a?new Map:void 0,c=a?Zy(e,l):e,u=a?Zy(t,l):t;this.addImages(c,r,1,o),this.addImages(u,s,2,o);const{w:h,h:d}=Vy(o),p=new od({width:h||1,height:d||1});for(const[e,t]of c.entries()){const i=r.get(e).paddedRect;od.copy(t.data,p,{x:0,y:0},{x:i.x+1,y:i.y+1},t.data,null,t.sdf)}for(const[e,t]of u.entries()){const n=s.get(e),r=n.paddedRect;let o=n.padding;const a=r.x+o,l=r.y+o,c=t.data.width,u=t.data.height;o=o>1?o-1:o,od.copy(t.data,p,{x:0,y:0},{x:a,y:l},t.data,i),od.copy(t.data,p,{x:0,y:u-o},{x:a,y:l-o},{width:c,height:o},i),od.copy(t.data,p,{x:0,y:0},{x:a,y:l+u},{width:c,height:o},i),od.copy(t.data,p,{x:c-o,y:0},{x:a-o,y:l},{width:o,height:u},i),od.copy(t.data,p,{x:0,y:0},{x:a+c,y:l},{width:o,height:u},i),od.copy(t.data,p,{x:c-o,y:u-o},{x:a-o,y:l-o},{width:o,height:o},i),od.copy(t.data,p,{x:0,y:u-o},{x:a+c,y:l-o},{width:o,height:o},i),od.copy(t.data,p,{x:0,y:0},{x:a+c,y:l+u},{width:o,height:o},i),od.copy(t.data,p,{x:c-o,y:0},{x:a-o,y:l+u},{width:o,height:o},i)}this.lut=i,this.image=p,this.iconPositions=r,this.patternPositions=s,a&&(this.contentDescriptor=new qy(c,u,n,i,l))}addImages(e,t,i,n){for(const[r,s]of e.entries()){const{bin:e,imagePosition:o,imageVariant:a}=$y(r,s,i);t.set(r,o),n.push(e),s.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r of e.getUpdatedImages(i)){for(const n of this.iconPositions.keys()){const s=Zi.parse(n);if(gi.isEqual(s.id,r)){const s=e.getImage(r,i);this.patchUpdatedImage(this.iconPositions.get(n),s,t,null)}}for(const s of this.patternPositions.keys()){const o=Zi.parse(s);if(gi.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.patternPositions.get(s),o,t,n||this.lut)}}}}patchUpdatedImage(e,t,i,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,s]=e.tl,o=e.sdf;if(this.lut||o){const e={width:t.data.width,height:t.data.height},a=new od(e);od.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,n,o),i.update(a,{position:{x:r,y:s},recreateWhenResize:!1})}else i.update(t.data,{position:{x:r,y:s},recreateWhenResize:!1})}}lo(Xy,"ImagePosition"),lo(Jy,"ImageAtlas",{omit:["lut"]}),lo(Yy,"ImageAtlasReference");class Ky{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client"}loadGlyphRange(e,t,i,n,r){if("server"===this.fontstackCompositing)return void Ky.loadGlyphRange(e,t,i,n,r);const s=e.split(",").map(e=>e.trim()).filter(e=>e.length>0);0!==s.length?1!==s.length?this._loadMultipleFonts(s,t,i,n,r):this._loadFont(s[0],t,i,n,r):r(new Error("Empty fontstack"))}_loadMultipleFonts(e,t,i,n,r){const s=e.map(()=>null),o={completed:0,firstError:null,callbackCalled:!1},a=(t,i,n)=>{if(!o.callbackCalled&&(i&&!o.firstError&&(o.firstError=i),n&&(s[t]=n),o.completed++,o.completed===e.length)){o.callbackCalled=!0;const e=s.filter(e=>null!==e);if(0===e.length)return void r(o.firstError||new Error("All fonts failed to load"));const t=this._composeGlyphs(e);r(null,t)}};for(let r=0;r<e.length;r++)this._loadFont(e[r],t,i,n,(e,t)=>{a(r,e,t)})}_loadFont(e,t,i,n,r){const s=`${e}:${t}`;if(this.cachedRanges.has(s)){const e=this.cachedRanges.get(s);return void At.frame(()=>r(null,e))}const o=this.pendingRequests.get(s);o?o.push(r):(this.pendingRequests.set(s,[r]),Ky.loadGlyphRange(e,t,i,n,(e,t)=>{e||this.cachedRanges.set(s,t||null);const i=this.pendingRequests.get(s);if(this.pendingRequests.delete(s),i)for(const n of i)n(e,t)}))}_composeGlyphs(e){const t={};let i,n;for(const r of e)if(void 0===i&&void 0!==r.ascender&&(i=r.ascender),void 0===n&&void 0!==r.descender&&(n=r.descender),r.glyphs)for(const e in r.glyphs)void 0===t[e]&&(t[e]=r.glyphs[e]);return{glyphs:t,ascender:i,descender:n}}}Ky.loadGlyphRange=function(e,t,i,n,r){const s=256*t,o=s+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${s}-${o}`),Ht.Glyphs);Kt(a,(e,t)=>{if(e)r(e);else if(t){const e={},i=function(e){return new Z_(e).readFields(ay,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})};const Qy=1e20,ev=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);ev[e]=t*Math.abs(t)}function tv(e,t,i,n,r,s,o,a,l){for(let c=t;c<t+n;c++)iv(e,i*s+c,s,r,o,a,l);for(let c=i;c<i+r;c++)iv(e,c*s+t,1,n,o,a,l)}function iv(e,t,i,n,r,s,o){s[0]=0,o[0]=-Qy,o[1]=Qy,r[0]=e[t];for(let a=1,l=0,c=0;a<n;a++){r[a]=e[t+a*i];const n=a*a;do{const e=s[l];c=(r[a]-r[e]+n-e*e)/(a-e)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=Qy}for(let a=0,l=0;a<n;a++){for(;o[l+1]<a;)l++;const n=s[l],c=a-n;e[t+a*i]=r[n]+c*c}}ev[255]=-Qy;const nv=/bold/i,rv=/medium/i,sv=/light/i,ov={none:0,ideographs:1,all:2};class av{constructor(e,t,i,n){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new Ky({fontstackCompositing:n})}setURL(e){this.url=e}prefetchRange(e,t){const i=this.url||pt.GLYPHS_URL;if(!i)return;let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{}}),n.ranges[t]||n.requests[t]||(n.requests[t]=[],this.glyphLoader.loadGlyphRange(e,t,i,this.requestManager,(e,i)=>{if(i){n.ascender=i.ascender,n.descender=i.descender;for(const e in i.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=i.glyphs[+e]);n.ranges[t]=!0}for(const r of n.requests[t]||[])r(e,i);delete n.requests[t]}))}getGlyphs(e,t){const i=[],n=this.url||pt.GLYPHS_URL;for(const t in e)for(const n of e[t])i.push({stack:t,id:n});je(i,({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=r.glyphs[t];if(void 0!==s)return void i(null,{stack:e,id:t,glyph:s});if(s=this._tinySDF(r,e,t),s)return r.glyphs[t]=s,void i(null,{stack:e,id:t,glyph:s});const o=Math.floor(t/256);if(256*o>65535)return Qe("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:s});if(r.ranges[o])return void i(null,{stack:e,id:t,glyph:s});let a=r.requests[o];a||(a=r.requests[o]=[],this.glyphLoader.loadGlyphRange(e,o,n,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const i of a)i(e,t);delete r.requests[o]})),a.push((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null})})},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==ov.none&&(this.localGlyphMode===ov.all?!!this.localFontFamily:!!this.localFontFamily&&(Co(e)||Ro(e)||xo(e)||bo(e)||vo(e)||Io(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";nv.test(t)?i="900":rv.test(t)?i="500":sv.test(t)&&(i="200"),r=e.tinySDF=new av.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}const s=r.fontWeight;if(this.localGlyphs[s][i])return this.localGlyphs[s][i];const o=String.fromCodePoint(i),{data:a,width:l,height:c,glyphWidth:u,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=r.draw(o);return this.localGlyphs[s][i]={id:i,bitmap:new sd({width:l,height:c},a),metrics:{width:u/2,height:h/2,left:d/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function lv(e,t){return e+t[1]-t[0]}function cv(e,t,i,n,r=1){const s=[],o=e.imagePrimary,a=o.pixelRatio,l=o.paddedRect.w-2,c=o.paddedRect.h-2,u=(e.right-e.left)*r,h=(e.bottom-e.top)*r,d=o.stretchX||[[0,l]],p=o.stretchY||[[0,c]],f=d.reduce(lv,0),m=p.reduce(lv,0),g=l-f,_=c-m;let y=0,v=f,x=0,b=m,w=0,T=g,S=0,E=_;if(o.content&&n){const e=o.content;y=hv(d,0,e[0]),x=hv(p,0,e[1]),v=hv(d,e[0],e[2]),b=hv(p,e[1],e[3]),w=e[0]-y,S=e[1]-x,T=e[2]-e[0]-v,E=e[3]-e[1]-b}const A=(n,s,l,c)=>{const d=fv(n.stretch-y,v,u,e.left*r),p=mv(n.fixed-w,T,n.stretch,f),g=fv(s.stretch-x,b,h,e.top*r),_=mv(s.fixed-S,E,s.stretch,m),A=fv(l.stretch-y,v,u,e.left*r),M=mv(l.fixed-w,T,l.stretch,f),I=fv(c.stretch-x,b,h,e.top*r),C=mv(c.fixed-S,E,c.stretch,m),P=new Ae(d,g),L=new Ae(A,g),R=new Ae(A,I),O=new Ae(d,I),D=new Ae(p/a,_/a),B=new Ae(M/a,C/a),F=t*Math.PI/180;if(F){const e=Math.sin(F),t=Math.cos(F),i=[t,-e,e,t];P._matMult(i),L._matMult(i),O._matMult(i),R._matMult(i)}const N=n.stretch+n.fixed,k=l.stretch+l.fixed,z=s.stretch+s.fixed,U=c.stretch+c.fixed,V=e.imageSecondary;return{tl:P,tr:L,bl:O,br:R,texPrimary:{x:o.paddedRect.x+1+N,y:o.paddedRect.y+1+z,w:k-N,h:U-z},texSecondary:V?{x:V.paddedRect.x+1+N,y:V.paddedRect.y+1+z,w:k-N,h:U-z}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:B,minFontScaleX:T/a/u,minFontScaleY:E/a/h,isSDF:i}};if(o.stretchX||o.stretchY){const e=dv(d,g,f),t=dv(p,_,m);for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)s.push(A(n,t[e],r,t[e+1]))}}else s.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return s}function uv(e,t){const i=e.stretchY||[[0,e.paddedRect.h-2]];return e.stretchX||e.stretchY?pv(e.stretchX||[[0,e.paddedRect.w-2]])*pv(i):1}function hv(e,t,i){let n=0;for(const r of e)n+=Math.max(t,Math.min(i,r[1]))-Math.max(t,Math.min(i,r[0]));return n}function dv(e,t,i){const n=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=n.at(-1);n.push({fixed:t-e.stretch,stretch:e.stretch}),n.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return n.push({fixed:t+1,stretch:i}),n}function pv(e){return 2*e.length+1}function fv(e,t,i,n){return e/t*i+n}function mv(e,t,i,n){return e-t*i/n}function gv(e,t,i,n){const r=t+e.positionedLines[n].lineOffset;return 0===n?i+r/2:i+(r+(t+e.positionedLines[n-1].lineOffset))/2}function _v(e,t,i,n,r,s,o,a,l,c=1){const u=[];if(0===t.positionedLines.length)return u;const h=(void 0!==l?l:n.layout.get("text-rotate").evaluate(s,{}))*Math.PI/180,d=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const f=t.positionedLines.length,m=p/f;let g=t.top-i[1];for(let e=0;e<f;++e){const n=t.positionedLines[e];g=gv(t,m,g,e);for(const e of n.positionedGlyphs){if(!e.rect)continue;const n=e.rect||{};let s=4,l=!0,p=1,f=0;if(e.image){const t=o.get(e.image.toString());if(!t)continue;if(t.sdf){Qe("SDF images are not supported in formatted text and will be ignored.");continue}l=!1,p=t.pixelRatio,s=1/p,t.usvg||(p/=c)}const m=(r||a)&&e.vertical,_=e.metrics.advance*e.scale/2,y=e.metrics,v=e.rect;if(null===v)continue;a&&t.verticalizable&&(f=e.image?_-e.metrics.width*e.scale/2:0);const x=r?[e.x+_,e.y]:[0,0];let b=[0,0],w=[0,0],T=!1;r||(m?(w=[e.x+_+d[0],e.y+d[1]-f],T=!0):b=[e.x+_+i[0],e.y+i[1]-f]);const S=v.w*e.scale/(p*(e.localGlyph?2:1)),E=v.h*e.scale/(p*(e.localGlyph?2:1));let A,M,I,C;if(m){const t=e.y-g,i=new Ae(-_,_-t),n=-Math.PI/2,r=new Ae(...w);A=new Ae(-_+b[0],b[1]),A._rotateAround(n,i)._add(r),A.x+=-t+_,A.y-=(y.left-s)*e.scale;const o=e.image?y.advance*e.scale:V_*e.scale,a=String.fromCodePoint(e.glyph);H_(a)?A.x+=(1-s)*e.scale:W_(a)?A.x+=o-y.height*e.scale+(-s-1)*e.scale:A.x+=e.image||y.width+2*s===v.w&&y.height+2*s===v.h?(o-E)/2:(o-(y.height+2*s)*e.scale)/2,M=new Ae(A.x,A.y-S),I=new Ae(A.x+E,A.y),C=new Ae(A.x+E,A.y-S)}else{const t=(y.left-s)*e.scale-_+b[0],i=(-y.top-s)*e.scale+b[1],n=t+S,r=i+E;A=new Ae(t,i),M=new Ae(n,i),I=new Ae(t,r),C=new Ae(n,r)}if(h){let e;e=r?new Ae(0,0):T?new Ae(d[0],d[1]):new Ae(i[0],i[1]),A._rotateAround(h,e),M._rotateAround(h,e),I._rotateAround(h,e),C._rotateAround(h,e)}const P=new Ae(0,0),L=new Ae(0,0);u.push({tl:A,tr:M,bl:I,br:C,texPrimary:n,texSecondary:void 0,writingMode:t.writingMode,glyphOffset:x,sectionIndex:e.sectionIndex,isSDF:l,pixelOffsetTL:P,pixelOffsetBR:L,minFontScaleX:0,minFontScaleY:0})}}return u}function yv(e,t=1,i=!1){let n=1/0,r=1/0,s=-1/0,o=-1/0;const a=e[0];for(let e=0;e<a.length;e++){const t=a[e];(!e||t.x<n)&&(n=t.x),(!e||t.y<r)&&(r=t.y),(!e||t.x>s)&&(s=t.x),(!e||t.y>o)&&(o=t.y)}const l=Math.min(s-n,o-r);let c=l/2;const u=new Kn([],vv);if(0===l)return new Ae(n,r);for(let t=n;t<s;t+=l)for(let i=r;i<o;i+=l)u.push(new xv(t+c,i+c,c,e));let h=function(e){let t=0,i=0,n=0;const r=e[0];for(let e=0,s=r.length,o=s-1;e<s;o=e++){const s=r[e],a=r[o],l=s.x*a.y-a.x*s.y;i+=(s.x+a.x)*l,n+=(s.y+a.y)*l,t+=3*l}return new xv(i/t,n/t,0,e)}(e),d=u.length;for(;u.length;){const i=u.pop();(i.d>h.d||!h.d)&&(h=i),i.max-h.d<=t||(c=i.h/2,u.push(new xv(i.p.x-c,i.p.y-c,c,e)),u.push(new xv(i.p.x+c,i.p.y-c,c,e)),u.push(new xv(i.p.x-c,i.p.y+c,c,e)),u.push(new xv(i.p.x+c,i.p.y+c,c,e)),d+=4)}return h.p}function vv(e,t){return t.max-e.max}av.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=t,this.radius=i,this.cutoff=n,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${o} ${s} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:s}=this.ctx.measureText(e),o=Math.ceil(i),a=Math.floor(r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-a)),c=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(n))),u=l+2*this.buffer,h=c+2*this.buffer,d=Math.max(u*h,0),p=new Uint8ClampedArray(d),f={data:p,width:u,height:h,glyphWidth:l,glyphHeight:c,glyphTop:o,glyphLeft:a,glyphAdvance:t};if(0===l||0===c)return f;const{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,c),m.fillText(e,g-a,g+o);const v=m.getImageData(g,g,l,c);y.fill(Qy,0,d),_.fill(0,0,d);let x=3;for(let e=0;e<c;e++){let t=(e+g)*u+g;for(let e=0;e<l;e++,x+=4,t++){const e=v.data[x];if(0===e)continue;const i=ev[e];y[t]=Math.max(0,i),_[t]=Math.max(0,-i)}}tv(y,0,0,u,h,u,this.f,this.v,this.z),tv(_,g,g,l,c,u,this.f,this.v,this.z);const b=255/this.radius,w=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(y[e])-Math.sqrt(_[e]);p[e]=Math.round(w-b*t)}return f}};class xv{constructor(e,t,i,n){this.p=new Ae(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;r<t.length;r++){const s=t[r];for(let t=0,r=s.length,o=r-1;t<r;o=t++){const r=s[t],a=s[o];r.y>e.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Yu(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const bv=Object.keys,wv=Number.POSITIVE_INFINITY,Tv=Math.sqrt(2);function Sv(e,t,i,n,r,s){const o=Ty(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],a={top:e.top-o[1],bottom:e.bottom+o[3],left:e.left-o[0],right:e.right+o[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0}(a,n),s&&(a.left+=s[0],a.right+=s[0],a.top+=s[1],a.bottom+=s[1]),i&&function(e,t,i){if(!t)return;const n=Oe(t),r=new Ae(i?i[0]:0,i?i[1]:0),s=new Ae(e.left,e.top),o=new Ae(e.right,e.top),a=new Ae(e.left,e.bottom),l=new Ae(e.right,e.bottom);s._rotateAround(n,r),o._rotateAround(n,r),a._rotateAround(n,r),l._rotateAround(n,r),e.left=Math.min(s.x,o.x,a.x,l.x),e.right=Math.max(s.x,o.x,a.x,l.x),e.top=Math.min(s.y,o.y,a.y,l.y),e.bottom=Math.max(s.y,o.y,a.y,l.y)}(a,i,r),t?{top:Math.min(t.top,a.top),bottom:Math.max(t.bottom,a.bottom),left:Math.min(t.left,a.left),right:Math.max(t.right,a.right),scaled:t.scaled||a.scaled}:a}function Ev(e,[t,i]){let n=0,r=0;if(i===wv){t<0&&(t=0);const i=t/Tv;switch(e){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=t;break;case"right":n=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}}return[n,r]}function Av(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f){const m=e.layers[0],g=m.appearances;if(0===g.length)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const _={iconBBox:null,iconVerticalBBox:null},y={textBBox:null,textVerticalBBox:null},{baseIconRotate:v,baseTextRotate:x,iconScaleFactor:b}=function(e,t,i){const n=e.get("icon-rotate").evaluate(t,{},i),r=e.get("text-rotate").evaluate(t,{},i),[s,o]=e.get("icon-size-scale-range");return{baseIconRotate:n,baseTextRotate:r,iconScaleFactor:ze(1,s,o)}}(n,r,s);t&&(_.iconBBox=Sv(t,_.iconBBox,v),i)&&(_.iconVerticalBBox=Sv(i,_.iconVerticalBBox,v+90));const w=qv(h.horizontal);w&&(y.textBBox=Sv(w,y.textBBox,x,1,p)),h.vertical&&(y.textVerticalBBox=Sv(h.vertical,y.textVerticalBBox,x+90,1,p));for(const i of g)i.hasIconLayoutProperties()&&Mv(_,e,m,i,r,s,a,v,o,l,t,c,b,u,f),i.hasTextLayoutProperties()&&Cv(y,m,i,r,s,p,x,d,w,h.vertical);return{iconBBox:_.iconBBox,iconVerticalBBox:_.iconVerticalBBox,textBBox:y.textBBox,textVerticalBBox:y.textVerticalBBox}}function Mv(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f){const{appearanceIconOffset:m,appearanceIconRotate:g,appearanceIconSize:_}=Iv(n,i,r,s,o,a,l,c.iconScaleFactor);let y=null,v=null,x=null;n.hasLayoutProperty("icon-image")?x=function(e,t,i,n,r,s,o,a){let l=null;const c=t.getAppearanceValueAndResolveTokens(i,"icon-image",n,r,a);if(c){const u=e.getResolvedImageFromTokens(c),h=i.hasLayoutProperty("icon-size")?i.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],d=Ov(u,Py(e.zoom,h,e.worldview,a),h,r,e.zoom,n,e.pixelRatio,o,e.worldview,a);l=s.get(d.iconPrimary.toString())}return l}(t,i,n,r,s,h,d,f):u&&(x=u.imagePrimary),x&&(y=Sy(x,null,m,p),t.allowVerticalPlacement&&(v=Sy(x,null,m,p)));const b=l>0?_/l:1;y&&(e.iconBBox=Sv(y,e.iconBBox,g,1!==b?b:void 0)),v&&(e.iconVerticalBBox=Sv(v,e.iconVerticalBBox,g+90,1!==b?b:void 0))}function Iv(e,t,i,n,r,s,o,a){const l=e.hasLayoutProperty("icon-offset")?t.getAppearanceValueAndResolveTokens(e,"icon-offset",i,n,[]):null,c=l&&Array.isArray(l)?l:r,u=e.hasLayoutProperty("icon-rotate")?t.getAppearanceValueAndResolveTokens(e,"icon-rotate",i,n,[]):null,h="number"==typeof u?u:s,d=e.hasLayoutProperty("icon-size")?t.getAppearanceValueAndResolveTokens(e,"icon-size",i,n,[]):null;return{appearanceIconOffset:c,appearanceIconRotate:h,appearanceIconSize:"number"==typeof d?d*a:o}}function Cv(e,t,i,n,r,s,o,a,l,c){const{appearanceTextOffset:u,appearanceTextRotate:h,appearanceTextSize:d}=Pv(i,t,n,r,s,o,a),p=d/a,f=[(u[0]-s[0])*p,(u[1]-s[1])*p],m=0!==f[0]||0!==f[1];l&&(e.textBBox=Sv(l,e.textBBox,h,p,u,m?f:void 0)),c&&(e.textVerticalBBox=Sv(c,e.textVerticalBBox,h+90,p,u,m?f:void 0))}function Pv(e,t,i,n,r,s,o){const a=e.hasLayoutProperty("text-offset")?t.getAppearanceValueAndResolveTokens(e,"text-offset",i,n,[]):null,l=a&&Array.isArray(a)?[a[0]*V_,a[1]*V_]:r,c=e.hasLayoutProperty("text-rotate")?t.getAppearanceValueAndResolveTokens(e,"text-rotate",i,n,[]):null,u="number"==typeof c?c:s,h=e.hasLayoutProperty("text-size")?t.getAppearanceValueAndResolveTokens(e,"text-size",i,n,[]):null;return{appearanceTextOffset:l,appearanceTextRotate:u,appearanceTextSize:"number"==typeof h?h:o}}function Lv(e,t,i,n,r,s,o,a,l){if(!t||!t.usvg)return;const c=Iy(n),u=Iy(r),h="both"!==s&&"width"!==s||!Ay(n)?1:u.width/c.width,d="both"!==s&&"height"!==s||!My(n)?1:u.height/c.height;i.scaleSelf(h,d);const p=i.toString();o.set(p,i),a.set(p,t);const{imagePosition:f}=$y(p,t,1);l.set(p,f)}function Rv(e,t,i,n,r,s,o,a,l,c){if(!e)return;const u=function(e,t,i,n,r,s,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new la(e.maxZoom,{worldview:s}),i,o).evaluate(r,{},i,o),a=t.possiblyEvaluate(new la(e.minZoom,{worldview:s}),i,o).evaluate(r,{},i,o);return Math.max(n,a)}return t.possiblyEvaluate(new la(n,{worldview:s}),i,o).evaluate(r,{},i,o)}(t,i,n,r,s,l,c);return e.scaleSelf(u*a*o)}function Ov(e,t,i,n,r,s,o,a,l,c){return{iconPrimary:Rv(e.getPrimary(),t,i,n,r,s,o,a,l,c),iconSecondary:Rv(e.getSecondary(),t,i,n,r,s,o,a,l,c)}}function Dv(e,t,i){if(!t)return;const n=i.get(e.toString()),r=i.get(t.toString());n&&r&&(n.paddedRect.w===r.paddedRect.w&&n.paddedRect.h===r.paddedRect.h||Qe(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==r.usvg&&Qe(`Mismatch in icon variant image types: ${e.id} and ${t.id}`))}function Bv(e,t,i,n){if(!e)return;const r=t.get(i.toString());if(r&&(e.imagePrimary=r),n){const i=t.get(n.toString());e.imageSecondary=i}}function Fv(e,t){for(const i in e.horizontal)Nv(e.horizontal[i],t);Nv(e.vertical,t)}function Nv(e,t){if(e)for(const i of e.positionedLines)for(const e of i.positionedGlyphs)if(null!==e.image){const i=e.image.toString();e.rect=t.get(i).paddedRect}}function kv(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function zv(e,t,i,n,r,s,o,a,l){const c=qv(s.horizontal)||s.vertical,u=i.get("icon-text-fit-padding").evaluate(n,{},r);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&s.vertical&&(h=Ey(t,s.vertical,l,u,a,o)),c&&(d=Ey(t,c,l,u,a,o))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function Uv(e,t){return e*t/24}function Vv(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T){let S=o.textMaxSize.evaluate(t,{},d);void 0===S?S=a*o.textScaleFactor:S*=o.textScaleFactor;const E=e.layers[0].layout,A=Uv(a,o.textScaleFactor),M=qv(i.horizontal)||i.vertical,I=e.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),C=e.getAppearanceFeatureData(t.index);("none"!==g||I)&&C&&(C.textShaping=M,C.iconTextFitPadding=E.get("icon-text-fit-padding").evaluate(t,{},d),C.fontScale=A,C.textScaleFactor=o.textScaleFactor);const P="globe"===p.name,L=e.tilePixelRatio*S/24,R=(k=e.overscaling,e.zoom>18&&k>2&&(k>>=1),Math.max(Qn/(512*k),1)*E.get("symbol-spacing")),O=E.get("text-padding")*e.tilePixelRatio,D=E.get("icon-padding")*e.tilePixelRatio,B=Oe(E.get("text-max-angle")),F="map"===E.get("icon-rotation-alignment")&&"point"!==v,N=R/2;var k;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);const z=t.properties?+t.properties[yu]:null,U=z&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(z):65535,V=(a,l,v)=>{if(l.x<0||l.x>=Qn||l.y<0||l.y>=Qn)return;let T=null;if(P){const{x:e,y:t,z:i}=p.projectTilePoint(l.x,l.y,v);T={anchor:new Oy(e,t,i,0,void 0),up:p.upVector(v,l.x,l.y)}}!function(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E,A,M,I,C,P,L){const R=e.addToLineVertexArray(t,n);let O,D,B,F,N,k,z,U=0,V=0,j=0,G=0,H=-1,W=-1;const q={};let X=ui("");const $=i?i.anchor:t,Z="none"!==M;let Y=0,J=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(x,{},S);Y=e[0]*V_,J=e[1]*V_}else Y=l.layout.get("text-radial-offset").evaluate(x,{},S)*V_,J=wv;if(e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)k=$v(e),a&&(z=$v(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;B=Xv(c,$,t,u,h,d,e,p,i,m,L),a&&(F=Xv(c,$,t,u,h,d,a,_,i,null,P))}}if(s){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=cv(s,n,w,Z,b.iconScaleFactor),o=a?cv(a,n,w,Z,b.iconScaleFactor):void 0;D=Xv(c,$,t,u,h,d,s,_,n,null,C);const p=function(e,t,i,n,r,s,o,a,l,c){const u=e.layers[0],h=u.appearances;let d=t.length;if(i&&(d=Math.max(d,i.length)),0===h.length)return d;const[p,f]=n.get("icon-size-scale-range"),m=ze(1,p,f);for(const t of h)if(t.hasLayoutProperty("icon-image")){const i=u.getAppearanceValueAndResolveTokens(t,"icon-image",s,o,c);if(i){const n=e.getResolvedImageFromTokens(i);if(n){const i=t.hasLayoutProperty("icon-size")?t.getUnevaluatedLayoutProperty("icon-size"):r._values["icon-size"],l=Ov(n,Py(e.zoom,i,e.worldview,c),i,o,e.zoom,s,e.pixelRatio,m,e.worldview,c),u=a.get(l.iconPrimary.toString());u&&(d=Math.max(d,uv(u)))}}}return d}(e,r,o,l.layout,l._unevaluatedLayout,x,S,e.iconAtlasPositions,0,T);U=4*p;const f=l.layout.get("icon-size").evaluate(x,{},S,T),m=b.compositeIconSizes?b.compositeIconSizes[0].evaluate(x,{},S,T):0,g=b.compositeIconSizes?b.compositeIconSizes[1].evaluate(x,{},S,T):0,M=Wv(e.layerIds[0],e.iconSizeData,f,s.imagePrimary.usvg?1:b.iconScaleFactor,m,g);e.addSymbols(e.icon,r,M,v,y,x,void 0,i,t,R.lineStartIndex,R.lineLength,-1,T,S,E,A,e.symbolInstances.length,p),H=e.icon.placedSymbolArray.length-1,o&&(V=4*p,e.addSymbols(e.icon,o,M,v,y,x,uy.vertical,i,t,R.lineStartIndex,R.lineLength,-1,T,S,E,A,e.symbolInstances.length,p),W=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const s=n,a=r.horizontal[s];O||(X=ui(a.text),f?N=$v(a):O=Xv(c,$,t,u,h,d,a,p,l.layout.get("text-rotate").evaluate(x,{},S),m,L));const g=1===a.positionedLines.length;if(j+=Hv(e,i,t,a,o,l,f,x,m,R,r.vertical?uy.horizontal:uy.horizontalOnly,g?bv(r.horizontal):[s],q,H,b,T,S,e.symbolInstances.length,E),g)break}r.vertical&&(G+=Hv(e,i,t,r.vertical,o,l,f,x,m,R,uy.vertical,["vertical"],q,W,b,T,S,e.symbolInstances.length,E));let K=-1;const Q=(e,t)=>e?Math.max(e,t):t;K=Q(N,K),K=Q(k,K),K=Q(z,K);const ee=K>-1?1:0;e.glyphOffsetArray.length>=65535&&Qe("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,$.x,$.y,$.z,q.right>=0?q.right:-1,q.center>=0?q.center:-1,q.left>=0?q.left:-1,q.vertical>=0?q.vertical:-1,H,W,X,void 0!==O?O:e.collisionBoxArray.length,void 0!==O?O+1:e.collisionBoxArray.length,void 0!==B?B:e.collisionBoxArray.length,void 0!==B?B+1:e.collisionBoxArray.length,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,F||e.collisionBoxArray.length,F?F+1:e.collisionBoxArray.length,u,j,G,U,V,ee,0,Y,J,K,0,Z?1:0,I)}(e,l,T,a,i,n,s,r,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,O,y,c,0,D,F,_,t,o,u,h,d,f,m,g,U,x,b,w)};if("line"===v)for(const r of Qf(t.geometry,0,0,Qn,Qn)){const t=zy(r,R,B,i.vertical||M,n,24,L,e.overscaling,Qn);for(const i of t)M&&Zv(e,M.text,N,i)||V(r,i,d)}else if("line-center"===v){for(const e of t.geometry)if(e.length>1){const t=ky(e,B,i.vertical||M,n,24,L);t&&V(e,t,d)}}else if("Polygon"===t.type)for(const e of zd(t.geometry,0)){const t=yv(e,16);V(e[0],new Oy(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)V(e,new Oy(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)V([t],new Oy(t.x,t.y,0,0,void 0),d)}const jv=255,Gv=jv*Cy;function Hv(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y){const v=_v(0,n,l,s,o,a,r,e.allowVerticalPlacement,void 0,f.textScaleFactor),x=s.layout.get("text-size").evaluate(a,{},g),b=f.compositeTextSizes?f.compositeTextSizes[0].evaluate(a,{},g):0,w=f.compositeTextSizes?f.compositeTextSizes[1].evaluate(a,{},g):0,T=Wv(e.layerIds[0],e.textSizeData,x,f.textScaleFactor,b,w);e.addSymbols(e.text,v,T,l,o,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,g,y,!1,_,v.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*v.length}function Wv(e,t,i,n,r,s){const o=t;let a=null;return"source"===o.kind?(a=[Cy*i*n],a[0]>Gv&&Qe(`${e}: Value for "text-size" or "icon-size" is >= ${jv}. Reduce your "text-size" or "icon-size".`)):"composite"===o.kind&&(a=[Cy*r*n,Cy*s*n],(a[0]>Gv||a[1]>Gv)&&Qe(`${e}: Value for "text-size" or "icon-size" is >= ${jv}. Reduce your "text-size" or "icon-size".`)),a}function qv(e){for(const t in e)return e[t];return null}function Xv(e,t,i,n,r,s,o,a,l,c,u){let h,d,p,f;if(h=u?u.top:o.top,d=u?u.bottom:o.bottom,p=u?u.left:o.left,f=u?u.right:o.right,Ty(o)&&o.collisionPadding){const e=o.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3]}if(l){const e=new Ae(p,h),t=new Ae(f,h),i=new Ae(p,d),n=new Ae(f,d),r=Oe(l);let s=new Ae(0,0);c&&(s=new Ae(c[0],c[1])),e._rotateAround(r,s),t._rotateAround(r,s),i._rotateAround(r,s),n._rotateAround(r,s),p=Math.min(e.x,t.x,i.x,n.x),f=Math.max(e.x,t.x,i.x,n.x),h=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,h,f,d,a,n,r,s),e.length-1}function $v(e){Ty(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Zv(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])<i)return!0}else r[t]=[];return r[t].push(n),!1}function Yv(e,t){const i=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,r=Math.min(n,e.isOrthographic?-10*t:0),s=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch);Math.sin(i),Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),Math.sin(e._pitch);const o=s*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10)}return Math.max(o,(e._camera.position[2]*e.worldSize+1e3*e.pixelsPerMeter)/Math.cos(e._pitch))}function Jv(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),n=e.x*i,r=(e.x+1)*i,s=e.y*i,o=(e.y+1)*i,a=Xc(n),l=Xc(r),c=$c(s),u=$c(o),h=t.project(a,c),d=t.project(l,c),p=t.project(l,u),f=t.project(a,u);let m=Math.min(h.x,d.x,p.x,f.x),g=Math.min(h.y,d.y,p.y,f.y),_=Math.max(h.x,d.x,p.x,f.x),y=Math.max(h.y,d.y,p.y,f.y);const v=i/16;function x(e,i,n,r,s,o){const a=(n+s)/2,l=(r+o)/2,c=t.project(Xc(a),$c(l)),u=Math.max(0,m-c.x,g-c.y,c.x-_,c.y-y);m=Math.min(m,c.x),_=Math.max(_,c.x),g=Math.min(g,c.y),y=Math.max(y,c.y),u>v&&(x(e,c,n,r,a,l),x(c,i,a,l,s,o))}x(h,d,n,s,r,s),x(d,p,r,s,r,o),x(p,f,r,o,n,o),x(f,h,n,o,n,s),m-=v,g-=v,_+=v,y+=v;const b=1/Math.max(_-m,y-g);return{scale:b,x:m*b,y:g*b,x2:_*b,y2:y*b,projection:t}}function Kv(e,{x:t,y:i},n=0){return new Ae(((t-n)*e.scale-e.x)*Qn,(i*e.scale-e.y)*Qn)}const Qv=u(new Float32Array(16));class ex{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new Vc(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i,n=!0){return e._coordinatePoint(e.locationCoordinate(t,i),n)}pixelsPerMeter(e,t){return qc(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return Yv(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const r=e.horizonLineFromTop(!1),s=new Ae(t,Math.max(r,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,i){const n=new Ae(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return Qv}createTileMatrix(e,t,i){let n,r,s;const o=i.canonical,a=u(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Jv(o,this);n=1,r=l.x+i.wrap*l.scale,s=l.y,f(a,a,[n/l.scale,n/l.scale,e.pixelsPerMeter/t])}else n=t/e.zoomScale(o.z),r=(o.x+Math.pow(2,o.z)*i.wrap)*n,s=o.y*n;return p(a,a,[r,s,0]),f(a,a,[n/Qn,n/Qn,1]),a}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class tx extends ex{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],n=Math.sin(Oe(t));this.n=(n+Math.sin(Oe(i)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:n,r0:r}=this,s=Oe(e-this.center[0]),o=Oe(t),a=Math.sqrt(n-2*i*Math.sin(o))/i;return{x:a*Math.sin(s*i),y:a*Math.cos(s*i)-r,z:0}}unproject(e,t){const{n:i,c:n,r0:r}=this,s=r+t;let o=Math.atan2(e,Math.abs(s))*Math.sign(s);s*i<0&&(o-=Math.PI*Math.sign(e)*Math.sign(s));const a=Oe(this.center[0])*i;o=Ve(o,-Math.PI-a,Math.PI-a);const l=ze(De(o/i)+this.center[0],-180,180),c=Math.asin(ze((n-(e*e+s*s)*i*i)/(2*i),-1,1)),u=ze(De(c),-85.051129,Yc);return new Vc(l,u)}}const ix=1.340264,nx=-.081106,rx=893e-6,sx=.003796,ox=Math.sqrt(3)/2;class ax extends ex{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(ox*Math.sin(t)),n=i*i,r=n*n*n;return{x:.5*(e*Math.cos(i)/(ox*(ix+3*nx*n+r*(7*rx+9*sx*n)))/Math.PI+.5),y:1-.5*(i*(ix+nx*n+r*(rx+sx*n))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=i*i,r=n*n*n;for(let e,s,o,a=0;a<12&&(s=i*(ix+nx*n+r*(rx+sx*n))-t,o=ix+3*nx*n+r*(7*rx+9*sx*n),e=s/o,i=ze(i-e,-Math.PI/3,Math.PI/3),n=i*i,r=n*n*n,!(Math.abs(e)<1e-12));++a);const s=ox*e*(ix+3*nx*n+r*(7*rx+9*sx*n))/Math.cos(i),o=Math.asin(Math.sin(i)/ox),a=ze(180*s/Math.PI,-180,180),l=ze(180*o/Math.PI,-85.051129,Yc);return new Vc(a,l)}}class lx extends ex{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),n=ze(360*(.5-t),-85.051129,Yc);return new Vc(i,n)}}const cx=Math.PI/2;function ux(e){return Math.tan((cx+e)/2)}class hx extends ex{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30];let n=Oe(t),r=Oe(i);this.southernCenter=n+r<0,this.southernCenter&&(n=-n,r=-r);const s=Math.cos(n),o=ux(n);this.n=n===r?Math.sin(n):Math.log(s/Math.cos(r))/Math.log(ux(r)/o),this.f=s*Math.pow(ux(n),this.n)/this.n}project(e,t){t=Oe(t),this.southernCenter&&(t=-t),e=Oe(e-this.center[0]);const i=1e-6,{n:n,f:r}=this;r>0?t<-cx+i&&(t=-cx+i):t>cx-i&&(t=cx-i);const s=r/Math.pow(ux(t),n);let o=s*Math.sin(n*e),a=r-s*Math.cos(n*e);return o=.5*(o/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:o,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:n}=this,r=n-t,s=Math.sign(r),o=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*s;r*i<0&&(a-=Math.PI*Math.sign(e)*s);const l=ze(De(a/i)+this.center[0],-180,180),c=ze(De(2*Math.atan(Math.pow(n/o,1/i))-cx),-85.051129,Yc);return new Vc(l,this.southernCenter?-c:c)}}class dx extends ex{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Hc(e),y:Wc(t),z:0}}unproject(e,t){const i=Xc(e),n=$c(t);return new Vc(i,n)}}const px=Oe(Yc);class fx extends ex{project(e,t){const i=(t=Oe(t))*t,n=i*i;return{x:.5*((e=Oe(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,s=i*i;do{s=i*i;const e=s*s;r=(i*(1.007226+s*(.015085+e*(.028874*s-.044475-.005916*e)))-t)/(1.007226+s*(.045255+e*(.259866*s-.311325-.005916*11*e))),i=ze(i-r,-px,px)}while(Math.abs(r)>1e-6&&--n>0);s=i*i;const o=ze(De(e/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),a=De(i);return new Vc(o,a)}}const mx=Oe(Yc);class gx extends ex{project(e,t){t=Oe(t),e=Oe(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),s=Math.sin(r)/r,o=.5*(e*n+2*i*Math.sin(e/2)/s)||0,a=.5*(t+Math.sin(t)/s)||0;return{x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,r=25;const s=1e-6;let o=0,a=0;do{const r=Math.cos(n),s=Math.sin(n),l=2*s*r,c=s*s,u=r*r,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(r*h)*Math.sqrt(1/m):0,y=.5*(2*_*r*d+2*i/Math.PI)-e,v=.5*(_*s+n)-t,x=.5*g*(u*f+_*r*h*c)+1/Math.PI,b=g*(p*l/4-_*s*d),w=.125*g*(l*d-_*s*u*p),T=.5*g*(c*h+_*f*r)+.5,S=b*w-T*x;o=(v*b-y*T)/S,a=(y*w-v*x)/S,i=ze(i-o,-Math.PI,Math.PI),n=ze(n-a,-mx,mx)}while((Math.abs(o)>s||Math.abs(a)>s)&&--r>0);return new Vc(De(i),De(n))}}class _x extends ex{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Oe(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:n}=this;return{x:Oe(e)*n*i+.5,y:-Math.sin(Oe(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,s=ze(De((e-.5)/i)/n,-180,180),o=Math.asin(ze(r*n,-1,1)),a=ze(De(o),-85.051129,Yc);return new Vc(s,a)}}class yx extends dx{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,i){const n=Ph(e,t,i);return H(n,n,Oh(Th(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,i){const n=kc(t.lat,t.lng),r=U([],n),s=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;B(n,n,r,qc(1,0)*Qn*s);const o=u(new Float64Array(16));return d(o,e.pixelMatrix,e.globeMatrix),H(n,n,o),new Ae(n[0],n[1])}pixelsPerMeter(e,t){return qc(1,0)*t}pixelSpaceConversion(e,t,i){const n=qc(1,e)*t,r=xi(qc(1,45)*t,n,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const n=Dh(Th(i.canonical));return d(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=Oh(Th(t));return g(n,n,Oe(i.lng)),m(n,n,Oe(i.lat)),f(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return xh(e,t,i,!0)||new tu(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(e,t){return!xh(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,s=e._camera.forward(),o=C([],D([],s,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=D([],r.up(),u),d=D([],r.right(),u*c),p=U([],C([],C([],s,h),d)),f=[];let m;if(new Au(o,p).closestPointOnSphere(l,a,f)){const t=C([],f,l),i=Z([],t,o);m=Math.cos(e.fovAboveCenter)*A(i)}else{const e=Z([],o,l),t=Z([],l,o);U(t,t);const i=A(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(V(s,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=kh(e.zoom);if(i>0){const n=Yv(e,qc(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return xi(t,n+r*(1-Math.cos(s)),Math.pow(i,10))}return t}upVector(e,t,i){return Ph(t,i,e,1)}upVectorScale(e){return{metersToTile:yh(Lh(Th(e)))}}}function vx(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new dx(e);case"equirectangular":return new lx(e);case"naturalEarth":return new fx(e);case"equalEarth":return new ax(e);case"winkelTripel":return new gx(e);case"albers":return i?new _x(e):new tx(e);case"lambertConformalConic":return i?new _x(e):new hx(e);case"globe":return new yx(e)}throw new Error(`Invalid projection name: ${e.name}`)}class xx{constructor(e,t){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=t,this.appearances=e;const i=e.map(e=>function(e){if(!e.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const t=e.condition.expression;return{featureDependent:!Ir(t),stateDependent:!Cr(t),zoomDependent:!Pr(t,["zoom"]),pitchDependent:!Pr(t,["pitch"]),brightnessDependent:!Pr(t,["brightness","measure-light"]),worldviewDependent:!Pr(t,["worldview"])}}(e));this.anyFeatureDependent=i.some(e=>e.featureDependent),this.anyStateDependent=i.some(e=>e.stateDependent)}update(e,t){const i=this.lastParams,n=!i||i.zoom!==e.zoom||i.pitch!==(e.pitch||0)||i.brightness!==(e.brightness||0)||i.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const r=t&&this.anyStateDependent;if(!n&&!r&&-2!==this.lastAllFeaturesIndex)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!r){const t=this.evaluateAllFeatures(e);return t===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=t,{kind:"all-features",appearanceIndex:t})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;t<this.appearances.length;t++){const i=this.appearances[t];if(i.condition&&i.condition.evaluate(e,void 0,void 0,void 0))return t}return-1}}const bx=hu.types,wx=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Tx(e,t,i,n,r,s,o,a,l,c,u,h,d){const p=a?Math.min(Gv,Math.round(a[0])):0,f=a?Math.min(Gv,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),s,o,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function Sx(e,t,i){e.emplaceBack(t,i)}function Ex(e,t,i,n,r,s,o){e.emplaceBack(t,i,n,r,s,o)}const Ax=(e,t,i,n)=>{for(let r=0;r<t;r++)e.emplaceBack(i[0],i[1],i[2],n[0],n[1],n[2])};function Mx(e,t,i,n,r){e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r)}function Ix(e){for(const t of e.sections)if(Yo(t.text))return!0;return!1}const Cx=12;class Px{constructor(e){this.layoutVertexArray=new pl,this.indexArray=new wl,this.programConfigurations=e,this.segments=new Ql,this.dynamicLayoutVertexArray=new ml,this.opacityVertexArray=new gl,this.placedSymbolArray=new Ul,this.iconTransitioningVertexArray=new _l,this.globeExtVertexArray=new fl,this.zOffsetVertexArray=new nl,this.orientationVertexArray=new El,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new nl,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getBatchGrouping(e){const t=e.get().length===this.segments.get().length;if(t&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const i=new Map;for(const t of e.get()){const e=void 0!==t.batchIndex?t.batchIndex:0;i.has(e)||i.set(e,[]),i.get(e).push(t)}const n=Array.from(i.keys()).sort((e,t)=>e-t),r=new Map;for(const e of n){const t=i.get(e);r.set(e,new Ql(t))}return t&&(this.cachedBatchIndices=n,this.cachedBatchSegments=r),{batchIndices:n,batchSegments:r}}snapshotSymbolVertexData(e,t){const i=e*Cx;return this.layoutVertexArray.uint16.slice(i,i+t*Cx)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*Cx)}updateSymbolVertexData(e,t,i,n,r,s,o,a,l,c,u,h,d){const p=this.layoutVertexArray.uint16,f=e*Cx;p[f]=t,p[f+1]=i,p[f+2]=n,p[f+3]=r,p[f+4]=s,p[f+5]=o,p[f+6]=a,p[f+7]=l,p[f+8]=c,p[f+9]=u,p[f+10]=h,p[f+11]=d}upload(e,t,i,n,r,s){this.isEmpty()||(i&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,A_.members,!!s),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,I_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,wx,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,R_.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,M_.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,C_.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,L_.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,P_.members,!1))),(i||n)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}lo(Px,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Lx{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Ql,this.collisionVertexArray=new bl,this.collisionVertexArrayExt=new ml}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,O_.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,D_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}lo(Lx,"CollisionBuffers");class Rx{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=u([]),this.placementViewportMatrix=u([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=Py(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=Py(this.zoom,t["icon-size"],this.worldview,e.availableImages);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.lut=e.lut,this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>uy[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return!1;const i=Array.isArray(e)?e:[e];return t.some(e=>i.some(t=>e.hasLayoutProperty(t)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new Px(new Ac(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Px(new Ac(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new U_(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new U_(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new Gl,this.lineVertexArray=new Hl,this.symbolInstances=new jl}calculateGlyphDependencies(e,t,i,n,r){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&r&&e<=65535){const e=G_[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,n,r,s,o){if(!e.hasLayoutProperty("icon-size"))return o*s;let a=1;const l=e.getUnevaluatedLayoutProperty("icon-size"),c=Py(this.zoom,l,this.worldview,r),u=Ry(c,t);if("constant"!==c.kind&&"camera"!==c.kind||(a=u.uSize),"composite"===c.kind){const{minZoom:e,maxZoom:t}=c,s=l.possiblyEvaluate(new la(e,{worldview:this.worldview}),n),o=l.possiblyEvaluate(new la(t,{worldview:this.worldview}),n),h=s.evaluate(i,{},n,r);a=h+(o.evaluate(i,{},n,r)-h)*u.uSizeT}return"source"===c.kind&&(a=l.possiblyEvaluate(new la(this.zoom,{worldview:this.worldview}),n).evaluate(i,{},n,r)),a*s}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!tf(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?Yi.build(e):e}populate(e,t,i,n){const r=this.layers[0],s=r.layout,o="globe"===this.projection.name,a=s.get("text-font"),l=s.get("text-field"),c=s.get("icon-image"),[u,h]=s.get("icon-size-scale-range"),d=ze(t.scaleFactor||1,u,h),[p,f]=s.get("text-size-scale-range"),m=ze(t.scaleFactor||1,p,f),g=("constant"!==l.value.kind||l.value.value instanceof $i&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),_="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,y=this.hasAnyAppearanceLayoutProperty("icon-image"),v=s.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!g&&!_&&!y)return;const x=t.iconDependencies,b=t.glyphDependencies,w=t.availableImages,T=new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),S=e=>{const t=e.id.toString();x.has(t)?x.get(t).push(e):x.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=r._featureFilter.needGeometry,p=uu(e,h);if(!r._featureFilter.filter(T,p,i))continue;if(h||(p.geometry=cu(e,i,n)),o&&1!==e.type&&i.z<=5){const e=p.geometry,t=.98078528056,n=(e,n)=>V(Ph(e.x,e.y,i,1),Ph(n.x,n.y,i,1))<t;for(let t=0;t<e.length;t++)e[t]=su(e[t],n)}let f,E;if(g){const e=r.getValueAndResolveTokens("text-field",p,i,w),t=$i.factory(e);Ix(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ra()||this.hasRTLText&&oa.isParsed())&&(f=j_(t,r,p))}if(_){const e=r.getValueAndResolveTokens("icon-image",p,i,w);E=this.getResolvedImageFromTokens(e)}const A=this.layers[0];let M=!1;if(!E&&y){const e=A.getAppearances();for(const t of e)if(t.getLayoutProperty("icon-image")){const e=A.getAppearanceValueAndResolveTokens(t,"icon-image",p,i,w);if(e){E=this.getResolvedImageFromTokens(e),M=!0;break}}}if(!f&&!E)continue;const I=this.sortFeaturesByKey?v.evaluate(p,{},i):void 0,C={id:l,text:f,icon:E,index:c,sourceLayerIndex:u,geometry:p.geometry,properties:e.properties,type:bx[e.type],sortKey:I};if(this.features.push(C),this.featureAppearanceData.set(c,{id:l,properties:e.properties,usesAppearanceIconAsPlaceholder:M}),E){const e=A._unevaluatedLayout._values,{iconPrimary:t,iconSecondary:n}=Ov(E,this.iconSizeData,e["icon-size"],i,this.zoom,C,this.pixelRatio,d,this.worldview,w);S(t),n&&(this.hasAnySecondaryIcon=!0,S(n))}const P=A.getAppearances();if(0!==P.length&&P.forEach(e=>{if(!e.getLayoutProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,A,p,i,w,C,d);t&&S(t)}),f){const e=a.evaluate(p,{},i).join(","),t="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(uy.vertical);for(const i of f.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio*m),t=e.id.toString(),n=x.get(t)||[];n.push(e),x.set(t,n)}else{const n=Uo(f.toString()),r=i.fontStack||e,s=b[r]=b[r]||{};this.calculateGlyphDependencies(i.text,s,t,this.allowVerticalPlacement,n)}}}if("line"===s.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function s(t){n.push(e[t]),r++}function o(e,t,r){const s=i[e];return delete i[e],i[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(r[0]),s}function a(e,i,r){const s=t[i];return delete t[i],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=r[0].concat(n[s].geometry[0]),s}function l(e,t,i){const n=i?t[0].at(-1):t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,d=u.text?u.text.toString():null;if(!d){s(c);continue}const p=l(d,h),f=l(d,h,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,h),r=o(p,f,n[e].geometry);delete t[p],delete i[f],i[l(d,n[r].geometry,!0)]=r,n[e].geometry=null}else p in i?o(p,f,h):f in t?a(p,f,h):(s(c),t[p]=r-1,i[f]=r-1)}return n.filter(e=>e.geometry)}(this.features)),"hd-road-markup"===s.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e)}}else s.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}getCombinedIconPrimary(e,t,i,n,r,s,o){let a,l;if(e.hasLayoutProperty("icon-image")){const s=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,n,r);a=this.getResolvedImageFromTokens(s)}else{const e=t.getValueAndResolveTokens("icon-image",i,n,r);a=this.getResolvedImageFromTokens(e)}if(a){const i=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"];l=Ov(a,Py(this.zoom,i,this.worldview,r),i,n,this.zoom,s,this.pixelRatio,o,this.worldview,r).iconPrimary}return l}updateSymbolInstanceIconVertices(e,t,i,n,r,s){const{canonical:o,availableImages:a,globalProperties:l,layer:c,iconScaleFactor:u,featureState:h,layoutIconOffset:d,layoutIconSize:p,layoutIconRotate:f}=s;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===i)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const m=i>=0?c.appearances[i]:null;if(m){const i=this.getCombinedIconPrimary(m,c,n,o,a,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},u);if(!i)return{vertexOffsetDelta:0,hasChanges:!1};const s=i.toString(),g=this.iconAtlasPositions&&this.iconAtlasPositions.get(s);if(g){const{appearanceIconOffset:i,appearanceIconRotate:s}=Iv(m,c,n,o,d,f,p,u);let _=Sy(g,void 0,i,c.layout.get("icon-anchor").evaluate(n,h,o));const y=g.sdf,v=c.layout.get("icon-text-fit").constantOr("none");"none"!==v&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(_=Ey(_,t.textShaping,v,t.iconTextFitPadding,i,t.fontScale));const x=this.calculateEffectiveAppearanceIconSize(m,l.zoom,n,o,a,u,p),b=0,w=1+(Math.min(Gv,Math.round(x*Cy))<<1),T=cv(_,s,y,"none"!==v,u);t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(r,e.numIconVertices));const S=Math.floor(e.numIconVertices/4),E=Math.min(T.length,S);let A=r;for(let i=0;i<E;++i){const n=T[i],r=t.layoutBasedIconVertexData[0]||e.tileAnchorX,s=t.layoutBasedIconVertexData[1]||e.tileAnchorY,o=16*n.pixelOffsetTL.x,a=16*n.pixelOffsetTL.y,l=16*n.pixelOffsetBR.x,c=16*n.pixelOffsetBR.y,u=16*n.minFontScaleX,h=16*n.minFontScaleY;this.icon.updateSymbolVertexData(A,r,s,Math.round(32*n.tl.x),Math.round(32*n.tl.y),n.texPrimary.x,n.texPrimary.y,b,w,o,a,u,h),this.icon.updateSymbolVertexData(A+1,r,s,Math.round(32*n.tr.x),Math.round(32*n.tr.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y,b,w,l,a,u,h),this.icon.updateSymbolVertexData(A+2,r,s,Math.round(32*n.bl.x),Math.round(32*n.bl.y),n.texPrimary.x,n.texPrimary.y+n.texPrimary.h,b,w,o,c,u,h),this.icon.updateSymbolVertexData(A+3,r,s,Math.round(32*n.br.x),Math.round(32*n.br.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y+n.texPrimary.h,b,w,l,c,u,h),A+=4}const M=e.numIconVertices-4*E;for(let e=0;e<M;++e)this.icon.updateSymbolVertexData(A+e,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(t.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(r,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(r+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(t.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(r,t.layoutBasedIconVertexData),t.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:t.layoutBasedIconVertexData.length/Cx,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,t,i,n,r,s){const{canonical:o,layer:a,textScaleFactor:l,imageMap:c,featureState:u,layoutTextOffset:h,layoutTextSize:d,layoutTextRotate:p,layoutMinZoomSize:f,layoutMaxZoomSize:m,layoutTextSizeMinZoom:g,layoutTextSizeMaxZoom:_,availableImages:y}=s,v=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!v)return{vertexOffsetDelta:v?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===i)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const x=i>=0?a.appearances[i]:null;if(x&&t.textShaping){const{appearanceTextOffset:i,appearanceTextRotate:s,appearanceTextSize:v}=Pv(x,a,n,o,h,p,d);t.fontScale=Uv(v,t.textScaleFactor);const b=x.getUnevaluatedLayoutProperty("text-size");let w=this.textSizeData,T=g,S=_;x.hasLayoutProperty("text-size")&&(w=Py(this.zoom,b,this.worldview,y),T="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,S="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const E=t.textShaping.bottom-h[1],A=t.textShaping.left-h[0],M=t.textShaping.right-h[0];t.textShaping.top=i[1]+(t.textShaping.top-h[1]),t.textShaping.bottom=i[1]+E,t.textShaping.left=i[0]+A,t.textShaping.right=i[0]+M;const I=_v(0,t.textShaping,i,a,!1,n,c,this.allowVerticalPlacement,s),C=v&&"composite"===w.kind?b.possiblyEvaluate(new la(T,{}),o).evaluate(n,u,o):f,P=v&&"composite"===w.kind?b.possiblyEvaluate(new la(S,{}),o).evaluate(n,u,o):m,L=Wv(x.name,w,v,l,C,P),R=Array.isArray(L)?L[1]:v,O=0,D=1+(Math.min(Gv,Math.round(R*Cy))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(r,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t<I.length&&t<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++t){const i=I[t],n=i.glyphOffset[1],s=e.tileAnchorX,o=e.tileAnchorY,a=r+4*t;this.text.updateSymbolVertexData(a,s,o,Math.round(32*i.tl.x),Math.round(32*(n+i.tl.y)),i.texPrimary.x,i.texPrimary.y,O,D,i.pixelOffsetTL.x,i.pixelOffsetTL.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(a+1,s,o,Math.round(32*i.tr.x),Math.round(32*(n+i.tr.y)),i.texPrimary.x+i.texPrimary.w,i.texPrimary.y,O,D,i.pixelOffsetBR.x,i.pixelOffsetTL.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(a+2,s,o,Math.round(32*i.bl.x),Math.round(32*(n+i.bl.y)),i.texPrimary.x,i.texPrimary.y+i.texPrimary.h,O,D,i.pixelOffsetTL.x,i.pixelOffsetBR.y,i.minFontScaleX,i.minFontScaleY),this.text.updateSymbolVertexData(a+3,s,o,Math.round(32*i.br.x),Math.round(32*(n+i.br.y)),i.texPrimary.x+i.texPrimary.w,i.texPrimary.y+i.texPrimary.h,O,D,i.pixelOffsetBR.x,i.pixelOffsetBR.y,i.minFontScaleX,i.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return t.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(r,t.layoutBasedTextVertexData),t.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:t.layoutBasedTextVertexData.length/Cx,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(e){this.text&&this.text.programConfigurations.updateExpressions(e),this.icon&&this.icon.programConfigurations.updateExpressions(e)}update(e,t,i,n,r,s,o,a){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,t,r,i,n,s,o,this.worldview),a)if(s)this.text.uboBinder&&!this.text.uboBinder.isLightConstant&&this.text.uboBinder.updateDynamicExpressions(r[0],t,a,i,e,o),this.icon.uboBinder&&!this.icon.uboBinder.isLightConstant&&this.icon.uboBinder.updateDynamicExpressions(r[0],t,a,i,e,o);else if(Object.keys(e).length>0){const n=new Set(Object.keys(e).map(e=>{const t=Number(e);return!isNaN(t)&&Number.isSafeInteger(t)&&String(t)===e?t:e}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(n,r[0],t,a,i,e,o),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(n,r[0],t,a,i,e,o)}}updateRoadElevation(e){if("road"!==this.elevationType||!this.elevationFeatures)return;if(this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let t=!1;const i=eu(e),n=1/i;let r=!1,s=!1;for(let e=0;e<this.symbolInstances.length;e++){const o=this.symbolInstances.get(e),a=M(1,0,0),l=M(0,1,0),{numHorizontalGlyphVertices:c,numVerticalGlyphVertices:u,numIconVertices:h,numVerticalIconVertices:d}=o,p=c>0||u>0,f=h>0,m=this.elevationFeatures[o.elevationFeatureIndex];if(m){const e=new Ae(o.tileAnchorX,o.tileAnchorY),c=.075+m.pointElevation(e);o.zOffset!==c&&(t=!0,o.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,n),h=ue(ie(),M(0,0,1),u);q(a,a,h),q(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(r=r||p,s=s||f)}if(p&&(Ax(this.text.orientationVertexArray,c,a,l),Ax(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=o;e>=0&&Ax(this.icon.orientationVertexArray,h,a,l),t>=0&&Ax(this.icon.orientationVertexArray,d,a,l)}}r||(this.text.orientationVertexArray=void 0),s||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(e,t,n)=>{i+=t,i>e.length&&e.resize(i);for(let r=-t;r<0;r++)e.emplace(r+i,n)},t=(e,t,i)=>{n+=t,n>e.length&&e.resize(n);for(let r=-t;r<0;r++)e.emplace(r+n,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,n=0;for(let i=0;i<this.symbolInstances.length;i++){const n=this.symbolInstances.get(i),{numHorizontalGlyphVertices:r,numVerticalGlyphVertices:s,numIconVertices:o}=n,a=n.zOffset,l=o>0;if((r>0||s>0)&&(e(this.text.zOffsetVertexArray,r,a),e(this.text.zOffsetVertexArray,s,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=n;e>=0&&t(this.icon.zOffsetVertexArray,o,a),i>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,i,n,r){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,t,i,n,r,s=!1){const o={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!i||!this.featureAppearanceData)return o;const a=t||{},l=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,c=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!l&&!c)return o;const u=this.layers[0],h=u.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===u.appearancesVersion||(this.featureAppearances=new xx(u.appearances,u.appearancesVersion));const d=this.featureAppearances.update(n,s);if("no-changes"===d.kind)return o;let p=1,f=0,m=!1,g=!1;if(l){const[e,t]=h.get("icon-size-scale-range");p=ze(1,e,t)}let _=1,y=0,v=!1;if(c){const[e,t]=h.get("text-size-scale-range");_=ze(1,e,t)}const x=new Map;if(r&&i)for(const e of i){const t=r.getImage(e,u.scope);if(t){const i=new Zi(e.toString());x.set(i.toString(),t)}}for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t),s=this.getAppearanceFeatureData(r.featureIndex);if(!s)continue;const o=s.id,b=void 0!==o?a[String(o)]:void 0,w={type:"Point",id:s.id,properties:s.properties,geometry:[]};let T;if("all-features"===d.kind)T=d.appearanceIndex;else{const t=u.appearances?u.appearances.findIndex(t=>t.isActive({globals:n,feature:w,canonical:e,featureState:b})):-1;T=t>=0?t:-1}const S=s.activeAppearanceIndex!==T;if(c){const t=h.get("text-size"),n="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,o="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,a={canonical:e,layer:u,featureState:b,availableImages:i,textScaleFactor:_,imageMap:x,layoutTextOffset:h.get("text-offset").evaluate(w,b,e).map(e=>e*V_),layoutTextSize:t.evaluate(w,b,e),layoutTextRotate:h.get("text-rotate").evaluate(w,b,e),layoutMinZoomSize:t.evaluate(w,{zoom:n},e),layoutMaxZoomSize:t.evaluate(w,{zoom:o},e),layoutTextSizeMinZoom:n,layoutTextSizeMaxZoom:o},l=this.updateSymbolInstanceTextVertices(r,s,T,w,y,a);y+=l.vertexOffsetDelta,v=v||l.hasChanges}if(l){const t={canonical:e,layer:u,featureState:b,availableImages:i,globalProperties:n,iconScaleFactor:p,layoutIconOffset:h.get("icon-offset").evaluate(w,b,e),layoutIconSize:h.get("icon-size").evaluate(w,b,e,i),layoutIconRotate:h.get("icon-rotate").evaluate(w,b,e)},o=this.updateSymbolInstanceIconVertices(r,s,T,w,f,t);f+=o.vertexOffsetDelta,m=m||o.hasChanges}if(S){const t=r.featureIndex,s=n?n.brightness:null,o=b||{},a=T>=0?u.appearances[T]:null;this.text.uboBinder&&(this.text.uboBinder.layer=u,g=this.text.uboBinder.updateFeaturePaintForAppearance(t,w,o,e,i,s,a)||g),this.icon.uboBinder&&(this.icon.uboBinder.layer=u,g=this.icon.uboBinder.updateFeaturePaintForAppearance(t,w,o,e,i,s,a)||g)}s.activeAppearanceIndex=T}return m&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),v&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:m||v,hasUboChanges:g}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=vx(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_){const y=e.indexArray,v=e.layoutVertexArray,x=e.globeExtVertexArray,b=_,w=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,T=e.segments.prepareSegment(4*b,v,y,this.canOverlap?s.sortKey:void 0,w),S=this.glyphOffsetArray.length,E=T.vertexLength,A=this.allowVerticalPlacement&&o===uy.vertical?Math.PI/2:0,M=s.text&&s.text.sections;let I=v.length,C=-1;for(let n=0;n<t.length;n++){const{tl:r,tr:o,bl:c,br:u,texPrimary:h,texSecondary:g,pixelOffsetTL:_,pixelOffsetBR:b,minFontScaleX:w,minFontScaleY:S,glyphOffset:E,isSDF:P,sectionIndex:L}=t[n],R=T.vertexLength,O=E[1];if(Tx(v,l.x,l.y,r.x,O+r.y,h.x,h.y,i,P,_.x,_.y,w,S),Tx(v,l.x,l.y,o.x,O+o.y,h.x+h.w,h.y,i,P,b.x,_.y,w,S),Tx(v,l.x,l.y,c.x,O+c.y,h.x,h.y+h.h,i,P,_.x,b.y,w,S),Tx(v,l.x,l.y,u.x,O+u.y,h.x+h.w,h.y+h.h,i,P,b.x,b.y,w,S),a){const{x:t,y:i,z:n}=a.anchor,[r,s,o]=a.up;Ex(x,t,i,n,r,s,o),Ex(x,t,i,n,r,s,o),Ex(x,t,i,n,r,s,o),Ex(x,t,i,n,r,s,o),Mx(e.dynamicLayoutVertexArray,t,i,n,A)}else Mx(e.dynamicLayoutVertexArray,l.x,l.y,l.z,A);if(m){const t=g||h;Sx(e.iconTransitioningVertexArray,t.x,t.y),Sx(e.iconTransitioningVertexArray,t.x+t.w,t.y),Sx(e.iconTransitioningVertexArray,t.x,t.y+t.h),Sx(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h)}if(y.emplaceBack(R,R+1,R+2),y.emplaceBack(R+1,R+2,R+3),T.vertexLength+=4,T.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),(n===t.length-1||L!==t[n+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(v.length,s,s.index,{},d,p,f,M&&M[L],this.worldview),e.uboBinder&&e.featureIdArray)){const t=e.uboBinder.populateUBO(s,s.index,p,d,f,M&&M[L],void 0);C=t;const i=v.length-I;for(let n=0;n<i;n++)e.featureIdArray.emplaceBack(t);I=v.length}}const P=_-t.length;if(0!==P&&(this._addNullVertices(P,v,i,a,x,e,m,T,y),e.uboBinder&&e.featureIdArray&&C>=0)){const t=4*P;for(let i=0;i<t;i++)e.featureIdArray.emplaceBack(C)}const L=a?a.anchor:l;e.placedSymbolArray.emplaceBack(L.x,L.y,L.z,l.x,l.y,S,this.glyphOffsetArray.length-S,E,c,u,l.segment,i?i[0]:0,i?i[1]:0,n[0],n[1],o,0,0,0,h,0),e.symbolInstanceIndices.push(g)}_addNullVertices(e,t,i,n,r,s,o,a,l){for(let c=0;c<e;c++){for(let e=0;e<4;e++)Tx(t,0,0,0,0,0,0,i,!1,0,0,0,0),n?(Ex(r,0,0,0,0,0,0),Mx(s.dynamicLayoutVertexArray,0,0,0,0)):Mx(s.dynamicLayoutVertexArray,0,0,0,0),o&&Sx(s.iconTransitioningVertexArray,0,0);const e=a.vertexLength;l.emplaceBack(e,e+1,e+2),l.emplaceBack(e+1,e+2,e+3),a.vertexLength+=4,a.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,t,i,n,r,s,o){e.emplaceBack(t,i,n,r,s,Math.round(o.x),Math.round(o.y))}_addCollisionDebugVertices(e,t,i,n,r,s,o){const a=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=a.vertexLength,c=o.tileAnchorX,u=o.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,t,e.padding,o.zOffset),this._commitLayoutVertex(i.layoutVertexArray,n,r,s,c,u,new Ae(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,r,s,c,u,new Ae(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,r,s,c,u,new Ae(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,n,r,s,c,u,new Ae(e.x1,e.y2)),a.vertexLength+=4;const h=i.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),a.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,n,r,s){for(let o=n;o<r;o++){const n=i.get(o),r=this.getSymbolInstanceTextSize(e,s,t,o);this._addCollisionDebugVertices(n,r,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s)}}_addIconDebugCollisionBoxes(e,t,i,n,r,s){for(let o=n;o<r;o++){const n=i.get(o),r=this.getSymbolInstanceIconSize(e,t,s.placedIconSymbolIndex);this._addCollisionDebugVertices(n,r,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s)}}generateCollisionDebugBuffers(e,t,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Lx(vl,B_.members,_l),this.iconCollisionBox=new Lx(vl,B_.members,_l);const n=Ry(this.iconSizeData,e),r=Ry(this.textSizeData,e,i);for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);this._addTextDebugCollisionBoxes(r,e,t,s.textBoxStartIndex,s.textBoxEndIndex,s),this._addTextDebugCollisionBoxes(r,e,t,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._addIconDebugCollisionBoxes(n,e,t,s.iconBoxStartIndex,s.iconBoxEndIndex,s),this._addIconDebugCollisionBoxes(n,e,t,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s)}}getSymbolInstanceTextSize(e,t,i,n){const r=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),s=Ly(this.textSizeData,e,r)/V_;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=Ly(this.iconSizeData,e,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(e,t,i,n){e.emplaceBack(t,-i,-i,n),e.emplaceBack(t,i,-i,n),e.emplaceBack(t,i,i,n),e.emplaceBack(t,-i,i,n)}_updateTextDebugCollisionBoxes(e,t,i,n,r,s,o){for(let o=n;o<r;o++){const n=i.get(o),r=this.getSymbolInstanceTextSize(e,s,t,o);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,r,n.padding,s.zOffset)}}_updateIconDebugCollisionBoxes(e,t,i,n,r,s,o){for(let o=n;o<r;o++){const n=i.get(o),r=this.getSymbolInstanceIconSize(e,t,s.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,r,n.padding,s.zOffset)}}updateCollisionDebugBuffers(e,t,i,n){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const r=Ry(this.iconSizeData,e,n),s=Ry(this.textSizeData,e,i);for(let o=0;o<this.symbolInstances.length;o++){const a=this.symbolInstances.get(o);this._updateTextDebugCollisionBoxes(s,e,t,a.textBoxStartIndex,a.textBoxEndIndex,a,i),this._updateTextDebugCollisionBoxes(s,e,t,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a,i),this._updateIconDebugCollisionBoxes(r,e,t,a.iconBoxStartIndex,a.iconBoxEndIndex,a,n),this._updateIconDebugCollisionBoxes(r,e,t,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a,n)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,i,n,r,s,o,a,l){const c={};if(t<i){const{x1:i,y1:n,x2:r,y2:s,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(t);c.textBox={x1:i,y1:n,x2:r,y2:s,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.textFeatureIndex=p}if(n<r){const{x1:t,y1:i,x2:r,y2:s,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(n);c.verticalTextBox={x1:t,y1:i,x2:r,y2:s,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalTextFeatureIndex=p}if(s<o){const{x1:t,y1:i,x2:n,y2:r,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(s);c.iconBox={x1:t,y1:i,x2:n,y2:r,padding:o,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.iconFeatureIndex=p}if(a<l){const{x1:t,y1:i,x2:n,y2:r,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(a);c.verticalIconBox={x1:t,y1:i,x2:n,y2:r,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalIconFeatureIndex=p}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<n;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),n=[],r=[],s=[];for(let e=0;e<this.symbolInstances.length;++e){s.push(e);const o=this.symbolInstances.get(e);n.push(0|Math.round(t*o.tileAnchorX+i*o.tileAnchorY)),r.push(o.featureIndex)}return s.sort((e,t)=>n[e]-n[t]||r[t]-r[e]),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const i=this.sortKeyRanges.at(-1);i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:o,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(e,t){const i=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const i of this.symbolsByBatch.values())for(const n of i){const i=this.symbolInstances.get(n.index);n.rotatedY=0|Math.round(e*i.tileAnchorX+t*i.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let n=0;n<this.symbolInstances.length;n++){const r=this.symbolInstances.get(n),s=Math.floor(n/i),o=0|Math.round(e*r.tileAnchorX+t*r.tileAnchorY);this.symbolsByBatch.has(s)||this.symbolsByBatch.set(s,[]),this.symbolsByBatch.get(s).push({index:n,rotatedY:o,featureIndex:r.featureIndex})}}for(const e of this.symbolsByBatch.values())e.sort((e,t)=>e.rotatedY-t.rotatedY||t.featureIndex-e.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,t){for(const i of e){const e=i.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){i.primitiveOffset=this.text.indexArray.length,i.primitiveLength=0;continue}i.primitiveOffset=this.text.indexArray.length;const r=this.text.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:s}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),s>=0&&this.addIndicesForPlacedSymbol(this.text,s)}i.primitiveLength=this.text.indexArray.length-r}}rebuildIconSegmentIndices(e,t){for(const i of e){const e=i.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){i.primitiveOffset=this.icon.indexArray.length,i.primitiveLength=0;continue}i.primitiveOffset=this.icon.indexArray.length;const r=this.icon.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=t;i>=0&&this.addIndicesForPlacedSymbol(this.icon,i),n>=0&&this.addIndicesForPlacedSymbol(this.icon,n)}i.primitiveLength=this.icon.indexArray.length-r}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const e=Math.sin(this.sortedAngle),t=Math.cos(this.sortedAngle),i=this.getOrCreateSortedSymbolsByBatch(e,t),n=Array.from(i.keys()).sort((e,t)=>e-t);for(const e of n){const t=i.get(e);for(const{index:e}of t){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),i),this.rebuildIconSegmentIndices(this.icon.segments.get(),i),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let i;return this.elevationFeatures&&t<this.elevationFeatures.length&&(i=this.elevationFeatures[t]),i}}function Ox(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>i in e?String(e[i]):"")}let Dx,Bx,Fx;lo(Rx,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Rx.addDynamicAttributes=Mx;class Nx{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Ci,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}lo(Nx,"FormatSectionOverride",{omit:["defaultValue"]});const kx=()=>Fx||(Fx={layout:Dx||(Dx=new xa({"symbol-placement":new _a(ba.layout_symbol["symbol-placement"]),"symbol-spacing":new _a(ba.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _a(ba.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ya(ba.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _a(ba.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new _a(ba.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new _a(ba.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new _a(ba.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new _a(ba.layout_symbol["icon-ignore-placement"]),"icon-optional":new _a(ba.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _a(ba.layout_symbol["icon-rotation-alignment"]),"icon-size":new ya(ba.layout_symbol["icon-size"]),"icon-size-scale-range":new _a(ba.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ya(ba.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ya(ba.layout_symbol["icon-text-fit-padding"]),"icon-image":new ya(ba.layout_symbol["icon-image"]),"icon-image-use-theme":new _a({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ya(ba.layout_symbol["icon-rotate"]),"icon-padding":new _a(ba.layout_symbol["icon-padding"]),"icon-keep-upright":new _a(ba.layout_symbol["icon-keep-upright"]),"icon-offset":new ya(ba.layout_symbol["icon-offset"]),"icon-anchor":new ya(ba.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _a(ba.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _a(ba.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _a(ba.layout_symbol["text-rotation-alignment"]),"text-field":new ya(ba.layout_symbol["text-field"]),"text-font":new ya(ba.layout_symbol["text-font"]),"text-size":new ya(ba.layout_symbol["text-size"]),"text-size-scale-range":new _a(ba.layout_symbol["text-size-scale-range"]),"text-max-width":new ya(ba.layout_symbol["text-max-width"]),"text-line-height":new ya(ba.layout_symbol["text-line-height"]),"text-letter-spacing":new ya(ba.layout_symbol["text-letter-spacing"]),"text-justify":new ya(ba.layout_symbol["text-justify"]),"text-radial-offset":new ya(ba.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _a(ba.layout_symbol["text-variable-anchor"]),"text-anchor":new ya(ba.layout_symbol["text-anchor"]),"text-max-angle":new _a(ba.layout_symbol["text-max-angle"]),"text-writing-mode":new _a(ba.layout_symbol["text-writing-mode"]),"text-rotate":new ya(ba.layout_symbol["text-rotate"]),"text-padding":new _a(ba.layout_symbol["text-padding"]),"text-keep-upright":new _a(ba.layout_symbol["text-keep-upright"]),"text-transform":new ya(ba.layout_symbol["text-transform"]),"text-offset":new ya(ba.layout_symbol["text-offset"]),"text-allow-overlap":new _a(ba.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new _a(ba.layout_symbol["text-ignore-placement"]),"text-optional":new _a(ba.layout_symbol["text-optional"]),visibility:new _a(ba.layout_symbol.visibility)})),paint:Bx||(Bx=new xa({"icon-opacity":new ya(ba.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ya(ba.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ya(ba.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ya(ba.paint_symbol["text-emissive-strength"]),"icon-color":new ya(ba.paint_symbol["icon-color"]),"icon-halo-color":new ya(ba.paint_symbol["icon-halo-color"]),"icon-halo-width":new ya(ba.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ya(ba.paint_symbol["icon-halo-blur"]),"icon-translate":new _a(ba.paint_symbol["icon-translate"]),"icon-translate-anchor":new _a(ba.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new _a(ba.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ya(ba.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ya(ba.paint_symbol["text-occlusion-opacity"]),"text-color":new ya(ba.paint_symbol["text-color"],{runtimeType:Oi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ya(ba.paint_symbol["text-halo-color"]),"text-halo-width":new ya(ba.paint_symbol["text-halo-width"]),"text-halo-blur":new ya(ba.paint_symbol["text-halo-blur"]),"text-translate":new _a(ba.paint_symbol["text-translate"]),"text-translate-anchor":new _a(ba.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new _a(ba.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new _a(ba.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new _a(ba.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new _a(ba.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ya(ba.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},Fx);class zx extends Xa{constructor(e,t,i,n){super(e,kx(),t,i,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=u([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(i=>{i.recalculate(e,t,this.iconImageUseTheme)}),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.includes(t)||e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,t,i,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,i,n){e=ht(e),t=ut(t);const r=l(),s=e/3,o=1-2*s,a=[o,s,s,0,s,o,s,0,s,s,o,0,0,0,0,1],c=.5-.5*t,u=n-i;return d(r,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),d(r,r,a),r}(e,t,i,n),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||Qs(s.value)||!r?r:Ox(t.properties,r)}getAppearanceValueAndResolveTokens(e,t,i,n,r){const s=e.getLayoutProperty(t);if(!s)return;const o=s.evaluate(i,{},n,r),a=e.getUnevaluatedLayoutProperties()._values[t];return a.isDataDriven()||Qs(a.value)||!o||"string"!=typeof o?o:Ox(i.properties,o)}createBucket(e){return new Rx(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of kx().paint.overridableProperties){if(!zx.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Nx(t),n=new Ks(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new to("source",n):new io("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new ma(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&zx.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=kx().paint.properties[t];let r=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof $i)s(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof tn&&Qi(t.value)===Ni?s(t.value.sections):t instanceof on?s(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new Ec(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let Ux,Vx,jx,Gx;var Hx=Ka([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function Wx(e,t,i,n,r,s,l,c){const u=[e,t,1,i,n,1,r,s,1],h=[l,c,1],d=o([],u),[p,f,m]=W(h,h,d);return a(u,u,[p,0,0,0,f,0,0,0,m])}function qx(e,t,i,n,r,s,l,c){const u=function(e,t,i,n,r,s,l,c){const u=Wx(0,0,1,0,1,1,0,1),h=Wx(e,t,i,n,r,s,l,c);return a(h,h,o([],u))}(e,t,i,n,r,s,l,c);return[u[2]/u[8]/Qn,u[5]/u[8]/Qn]}function Xx(e){return[e[0],Math.min(Math.max(e[1],-85.051129),Yc)]}class $x extends mi{constructor(e,t,i,n){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new hi("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=ii(this.map._requestManager.transformRequest(this.url,Ht.Image),(t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new di(t)):i&&(this.image=i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Fm(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new hi("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Fm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const n of e)n[1]>i&&(i=n[1]),n[1]<t&&(t=n[1]);const n=(i+t)/2;if(n>Yc?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(tu.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const s of e)t=Math.min(t,s.x),i=Math.min(i,s.y),n=Math.max(n,s.x),r=Math.max(r,s.y);const s=Math.max(n-t,r-i),o=Math.max(0,Math.floor(-Math.log2(s))),a=Math.pow(2,o);let l=Math.floor((t+n)/2*a);return l>1&&(l-=1),new ch(o,l,Math.floor((i+r)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new hi("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Fm||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=Jv(new ch(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,n=e[2].x-e[1].x,r=e[2].y-e[1].y,s=e[3].x-e[2].x,o=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-n*i,u=n*o-s*r,h=s*l-a*o,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return void(this._unsupportedCoords=!0);const n=Jv(this.tileID,this.map.transform.projection),[r,s,l,c]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return Kv(n,t)._round()});this.perspectiveTransform=qx(r.x,r.y,s.x,s.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new il;u.emplaceBack(r.x,r.y,0,0),u.emplaceBack(s.x,s.y,Qn,0),u.emplaceBack(c.x,c.y,0,Qn),u.emplaceBack(l.x,l.y,Qn,Qn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,Hx.members),this.boundsSegments=Ql.simpleSegment(0,0,4,2);const h=[],d=function(e){return[Xx(e[0]),Xx(e[1]),Xx(e[2]),Xx(e[3])]}(this.coordinates),[p,f,m,g]=function(e){let t=e[0][0],i=t,n=e[0][1],r=n;for(let s=1;s<e.length;s++)e[s][0]<t?t=e[s][0]:e[s][0]>i&&(i=e[s][0]),e[s][1]<n?n=e[s][1]:e[s][1]>r&&(r=e[s][1]);return[t,n,i-t,r-n]}(d);{const n=new il,[r,s,l,c]=function(e){let t=e[0].x,i=t,n=e[0].y,r=n;for(let s=1;s<e.length;s++)e[s].x<t?t=e[s].x:e[s].x>i&&(i=e[s].x),e[s].y<n?n=e[s].y:e[s].y>r&&(r=e[s].y);return[t,n,i-t,r-n]}(i),u=e=>[(e.x-r)/l,(e.y-s)/c],[d,_,y,v]=i.map(u),x=function(e,t,i,n,r,s,l,c){const u=Wx(0,0,1,0,1,1,0,1);return a(u,u,o([],Wx(e,t,i,n,r,s,l,c)))}(d[0],d[1],_[0],_[1],y[0],y[1],v[0],v[1]);this.elevatedGlobePerspectiveTransform=qx(d[0],d[1],_[0],_[1],y[0],y[1],v[0],v[1]);const b=(e,t)=>{h.push(e.lng);const i=Math.round((e.lng-p)/m*Qn),r=Math.round((e.lat-f)/g*Qn),s=u(t),o=W([],[s[0],s[1],1],x),a=Math.round(o[0]/o[2]*Qn),l=Math.round(o[1]/o[2]*Qn);n.emplaceBack(i,r,a,l)},w=i[3].x-i[0].x,T=i[3].y-i[0].y,S=i[2].x-i[1].x,E=i[2].y-i[1].y;for(let e=0;e<65;e++){const n=e/64,r=[i[0].x+n*w,i[0].y+n*T],s=[i[1].x+n*S,i[1].y+n*E],o=s[0]-r[0],a=s[1]-r[1];for(let e=0;e<65;e++){const i=e/64,n={x:r[0]+o*i,y:r[1]+a*i};b(t.projection.unproject(n.x,n.y),n)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,Hx.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new wl;const n=(e,n,r)=>{i.emplaceBack(e,n,r);const s=h[e],o=h[n],a=h[r],l=Math.min(Math.min(s,o),a),c=Math.max(Math.max(s,o),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,r=i+1,s=i+65,o=s+1;n(i,s,r),n(r,s,o)}[t,i]=function(e,t){const i=Array.from({length:e.length},(e,t)=>t);i.sort((t,i)=>e[t]-e[i]);const n=[],r=new wl;for(let s=0;s<i.length;s++){const o=i[s];n.push(e[o]);const a=3*o,l=a+1;r.emplaceBack(t.uint16[a],t.uint16[l],t.uint16[l+1])}return[n,r]}(t,i),this.elevatedGlobeTrianglesCenterLongitudes=t,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(i)}this.elevatedGlobeSegments=Ql.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,m/Qn,0,g/Qn,0,0,f,p,0])}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,i=t.gl;!this._dirty||this.texture instanceof Fm||(this.texture?this.texture.update(this.image):(this.texture=new Bm(t,this.image,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){const t=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!t)return null;const i=this.elevatedGlobeTrianglesCenterLongitudes;let n=(r=e+180)+360*Math.round((i[0]-r)/360);var r;const s=new Ql,o=(e,i)=>{s.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)<=a){const e=ct(i,0,i.length,n+a);return e===i.length||o(e,lt(i,e+1,i.length,n+360-a)-e),s}n<i[0]&&(n+=360);const l=lt(i,0,i.length,n-a);if(l===i.length)return o(0,i.length),s;o(0,l-0);const c=ct(i,l+1,i.length,n+a);return c!==i.length&&o(c,i.length-c),s}}const Zx=1024,Yx=(Math.pow(Zx,2)-1)/268170240;class Jx extends Xa{constructor(e,t,i,n){super(e,{layout:jx||(jx=new xa({visibility:new _a(ba.layout_raster.visibility)})),paint:Gx||(Gx=new xa({"raster-opacity":new _a(ba.paint_raster["raster-opacity"]),"raster-color":new va(ba.paint_raster["raster-color"]),"raster-color-mix":new _a(ba.paint_raster["raster-color-mix"]),"raster-color-range":new _a(ba.paint_raster["raster-color-range"]),"raster-hue-rotate":new _a(ba.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _a(ba.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _a(ba.paint_raster["raster-brightness-max"]),"raster-saturation":new _a(ba.paint_raster["raster-saturation"]),"raster-contrast":new _a(ba.paint_raster["raster-contrast"]),"raster-resampling":new _a(ba.paint_raster["raster-resampling"]),"raster-fade-duration":new _a(ba.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new _a(ba.paint_raster["raster-emissive-strength"]),"raster-array-band":new _a(ba.paint_raster["raster-array-band"]),"raster-elevation":new _a(ba.paint_raster["raster-elevation"]),"raster-elevation-reference":new _a(ba.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){return!(e&&e._source instanceof $x&&(e._source.onNorthPole||e._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}updateColorRamp(e){if(!this.hasColorMap())return;if(!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[i,n]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(i)&&isNaN(n)||i===this._curRampRange[0]&&n===this._curRampRange[1]||(this.colorRamp=ld({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:i,end:n}],resolution:Zx}),this.colorRampTexture=null,this._curRampRange=[i,n])}is3D(e){return this.paint.get("raster-elevation")>0}}let Kx,Qx,eb,tb,ib,nb,rb;class sb extends Xa{constructor(e,t,i,n){super(e,{layout:Kx||(Kx=new xa({visibility:new _a(ba["layout_raster-particle"].visibility)})),paint:Qx||(Qx=new xa({"raster-particle-array-band":new _a(ba["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new _a(ba["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new va(ba["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new _a(ba["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new _a(ba["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new _a(ba["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new _a(ba["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new _a(ba["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp(),this.lastInvalidatedAt=At.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return"none"!==this.visibility}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=ld({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=At.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class ob extends Xa{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(e){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}function ab(e,t,i){const n=[0,0,1],r=ne([]);return se(r,r,i?-Oe(e)+Math.PI:Oe(e)),re(r,r,-Oe(t)),q(n,n,r),U(n,n)}class lb{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class cb{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Ol,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let n=Math.floor(i[t+2]);const r=1.05*(i[t+2]-n);return n/=100,[i[t]%1*1.05,i[t+1]%1*1.05,r,n]}tileCoordinatesForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let n=i[t+0];return n=n>Qn?n-Qn:n,new Ae(Math.trunc(n),Math.trunc(i[t+1]))}translationForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+4],i[t+5],i[t+6]]}rotationScaleForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+10],i[t+11],i[t+12],i[t+13],i[t+14],i[t+15]]}transformForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+4],i[t+10],i[t+11],i[t+12],i[t+5],i[t+13],i[t+14],i[t+15],i[t+6],0,0,0,1]}}class ub{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,i,n){this.tileToMeter=eu(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const s="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of e){const e=null!=a?a:o.properties&&Object.hasOwn(o.properties,"id")?o.properties.id:void 0,u=uu(o,r);if(!this.layers[0]._featureFilter.filter(new la(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h={id:e,sourceLayerIndex:c,index:l,geometry:r?u.geometry:cu(o,i,n),properties:o.properties,type:o.type,patterns:{}},d=this.addFeature(h,h.geometry,u,s,i);d&&t.featureIndex.insert(o,h.geometry,l,c,this.index,this.instancesPerModel[d].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const n of this.modelUris){const r=e.getModel(n,t);if(!r)continue;const s=this.instancesPerModel[n];if(s){const e=.5*F(r.aabb.max,r.aabb.min)*s.maxScale+s.maxXYTranslationDistance,t=Math.min(Qn,Math.max(e/this.tileToMeter,256));i=Math.max(t,i)}}return i}update(e,t,i,n){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)Object.hasOwn(i.idToFeaturesIndex,t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const n=this.layers[0],r=t.feature,s=this.canonical,o=n.paint.get("model-rotation").evaluate(r,{},s),a=n.paint.get("model-scale").evaluate(r,{},s),l=n.paint.get("model-translation").evaluate(r,{},s);$(t.rotation,o)&&$(t.scale,a)&&$(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,n){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(tf(this.activeReplacements,r))return!1;this.activeReplacements=r;let s=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],o=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;t<a;t++){const a=16*(t+r);let l=o.float32[a+0];const c=l>Qn;l=c?l-Qn:l;const u=Math.floor(l),h=Math.floor(o.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!Jp(t,i,cf.Model,n)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=lf(af(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;o.float32[a]=d?l+Qn:l,s=s||d!==c}}}return s}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,jm.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0)}addFeature(e,t,i,n,r){const s=this.layers[0],o=s.layout.get("model-id"),a=s.layout.get("model-allow-density-reduction"),l=o.evaluate(i,{},this.canonical);if(!l)return Qe(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;!l.includes("://")&&!this.styleDefinedModelURLs[l]||this.modelUris.includes(l)||this.modelUris.push(l),this.instancesPerModel[l]||(this.instancesPerModel[l]=new cb);const c=this.instancesPerModel[l],u=c.instancedDataArray,h=new lb(i,u.length);let d;n&&(d=Nu.getElevationFeature(e,n));for(const e of t)for(const t of e){if(t.x<0||t.x>=Qn||t.y<0||t.y>=Qn)continue;if(0!==this.lookupDim&&a){const e=(this.lookupDim-1)/Qn,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}}this.instanceCount++;const e=u.length;if(u.resize(e+1),n){c.instancesRoadElevation||(c.instancesRoadElevation=[]);const e=d?d.pointElevation(new Ae(t.x,t.y)):0;c.instancesRoadElevation.push(e)}c.instancesEvaluatedElevation.push(0),u.float32[16*e]=t.x,u.float32[16*e+1]=t.y}return h.instancedDataCount=c.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(c.idToFeaturesIndex[e.id]=c.features.length),c.features.push(h),this.evaluate(h,{},c,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,i,n){const r=this.layers[0],s=e.feature,o=this.canonical,a=e.rotation=r.paint.get("model-rotation").evaluate(s,t,o),l=e.scale=r.paint.get("model-scale").evaluate(s,t,o),c=e.translation=r.paint.get("model-translation").evaluate(s,t,o),u=Object.assign({},r.paint.get("model-color").evaluate(s,t,o));u.a=r.paint.get("model-color-mix-intensity").evaluate(s,t,o);const h=[];this.maxVerticalOffset<c[2]&&(this.maxVerticalOffset=c[2]);const d=c[0]*c[0]+c[1]*c[1],p=d>0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Jm(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t<e.instancedDataCount;++t){const r=e.instancedDataOffset+t,s=16*r,a=i.instancedDataArray.float32;let l=0;n&&(l=a[s+6]-i.instancesEvaluatedElevation[r]);const d=0|a[s+1];a[s]=(0|a[s])+u.r/1.05,a[s+1]=d+u.g/1.05,a[s+2]=f,a[s+3]=1/(o.z>10?this.tileToMeter:eu(o,d)),a[s+4]=c[0],a[s+5]=c[1],a[s+6]=c[2]+(i.instancesRoadElevation?i.instancesRoadElevation[r]:0)+l,a[s+7]=h[0],a[s+8]=h[1],a[s+9]=h[2],a[s+10]=h[4],a[s+11]=h[5],a[s+12]=h[6],a[s+13]=h[8],a[s+14]=h[9],a[s+15]=h[10],i.instancesEvaluatedElevation[r]=c[2]}}}lo(ub,"ModelBucket",{omit:["layers"]}),lo(cb,"PerModelAttributes"),lo(lb,"ModelFeature");class hb{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const n=i||e.findDEMTileFor(t);if(!n||!n.dem)return;const r=n.dem,s=n.tileID,o=1<<t.canonical.z-s.canonical.z;return new hb(n,r.dim/Qn/o,[(t.canonical.x/o-s.canonical.x)*r.dim,(t.canonical.y/o-s.canonical.y)*r.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1];return new Ae(Math.floor(e*this._scale+this._offset[0]),Math.floor(i))}getElevationAt(e,t,i,n){const r=e*this._scale+this._offset[0],s=t*this._scale+this._offset[1],o=Math.floor(r),a=Math.floor(s),l=this._dem;return n=!!n,i?xi(xi(l.get(o,a,n),l.get(o,a+1,n),s-a),xi(l.get(o+1,a,n),l.get(o+1,a+1,n),s-a),r-o):l.get(o,a,n)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*qc(1,e)*this._dem.stride}}const db=new Float32Array(262144),pb=new Uint8Array(262144),fb=[0,0,0],mb=[0,0,0];function gb(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,gb(i));return t}function _b(e,t,i){if(e.meshes)for(const n of e.meshes){if(n.aabb.min[0]===1/0)continue;const r=Du.applyTransform(n.aabb,e.globalMatrix);i.insert(t,r.min[0],r.min[1],r.max[0],r.max[1])}if(e.children)for(const n of e.children)_b(n,t,i)}const yb=["","wall","door","roof","window","lamp","logo"];class vb{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.targetLod=-1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:gb(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Du([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new Du([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&(i.transformedAabb=Du.applyTransformFast(i.aabb,this.node.globalMatrix),t.encapsulate(i.transformedAabb)),e++;this.aabb=t}return this.aabb}}class xb{constructor(e,t,i,n,r,s,o,a){this.id=i,this.layers=e,this.layerIds=this.layers.map(e=>e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=ig.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=ig.HasMapboxMeshFeatures),r&&(this.modelTraits|=ig.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=s,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new vb(e)),_b(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&t.push({footprint:n.footprint,id:e})}}updateAppearances(e,t,i,n){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Me(e,this.states))for(const t of i)this.evaluate(t,e);this.states=structuredClone(e)}populate(){}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):ag(t,e,!0)}for(const e of t)cg(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);if(e.lodMeshes)for(const i of e.lodMeshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const n=e.transform.projectionOptions,r=e.style.getBrightness(),s=this.brightness!==r;if(!this.uploaded||this.dirty||n.name!==this.projection.name||bb(i.paint.get("model-color").value,s)||bb(i.paint.get("model-color-mix-intensity").value,s)||bb(i.paint.get("model-roughness").value,s)||bb(i.paint.get("model-emissive-strength").value,s)||bb(i.paint.get("model-height-based-emissive-strength-multiplier").value,s)){this.projection=n,this.brightness=r;const e=this.getNodesInfo();for(const t of e)t.state=null;return!0}return!1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},n)}}evaluate(e,t){const i=this.getNodesInfo();for(const n of i){if(!n.node.meshes)continue;const i=n.feature,r=t&&t[i.id];if(Me(r,n.state))continue;n.state=structuredClone(r);const s=n.node.meshes&&n.node.meshes[0].featureData,o=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,s){for(let t=0;t<yb.length;t++){const s=yb[t];s.length&&(i.properties.part=s);const o=e.paint.get("model-color").evaluate(i,r,l).toPremultipliedRenderColor(null),a=e.paint.get("model-color-mix-intensity").evaluate(i,r,l);n.evaluatedColor[t]=[o.r,o.g,o.b,a],n.evaluatedRMEA[t][0]=e.paint.get("model-roughness").evaluate(i,r,l),n.evaluatedRMEA[t][2]=e.paint.get("model-emissive-strength").evaluate(i,r,l),n.evaluatedRMEA[t][3]=o.a,n.emissionHeightBasedParams[t]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(i,r,l),!n.hasTranslucentParts&&o.a<1&&(n.hasTranslucentParts=!0)}delete i.properties.part,Tb(n,o!==n.evaluatedColor[2]||a!==n.evaluatedRMEA[2],this.modelTraits)}else n.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(i,r,l);n.evaluatedTranslation=e.paint.get("model-translation").evaluate(i,r,l),n.evaluatedScale=e.paint.get("model-scale").evaluate(i,r,l),this.updatePbrBuffer(n.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,t,i,n){const r=e.findDEMTileFor(i);if(r&&(r.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(r.dem&&r.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=r.tileID.overscaledZ;const t=hb.create(e,i,r);if(!t)return;this.modelTraits&ig.HasMapboxMeshFeatures&&this.updateDEM(e,t,i,n);for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.vertices||!i.footprint.vertices.length)continue;const n=i.footprint.vertices;let r=t.getElevationAt(n[0].x,n[0].y,!0,!0);for(let e=1;e<n.length;e++)r=Math.min(r,t.getElevationAt(n[e].x,n[e].y,!0,!0));i.elevation=r}}this.terrainTile=r.tileID.canonical,this.terrainExaggeration=t}}updateDEM(e,t,i,n){let r=t._dem._modifiedForSources[n];if(void 0===r&&(t._dem._modifiedForSources[n]=[],r=t._dem._modifiedForSources[n]),r.includes(i.canonical))return;const s=t._dem.dim;r.push(i.canonical);let o=!1;for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.grid)continue;const n=i.footprint.grid,r=t.tileCoordToPixel(n.min.x,n.min.y),a=t.tileCoordToPixel(n.max.x,n.max.y),l=Math.min(Math.min(s-a.y,r.x),Math.min(r.y,s-a.x));if(l<0)continue;const c=ze(l,2,5);let u=Math.max(0,r.x-c),h=Math.max(0,r.y-c),d=Math.min(a.x+c,s-1),p=Math.min(a.y+c,s-1);for(let e=h;e<=p;++e)for(let t=u;t<=d;++t)pb[e*s+t]=255;let f=0,m=0;for(let e=0;e<n.cellsY;++e)for(let i=0;i<n.cellsX;++i){if(!n.cells[e*n.cellsX+i])continue;const r=t.tileCoordToPixel(n.min.x+i/n.xScale,n.min.y+e/n.yScale),o=t.tileCoordToPixel(n.min.x+(i+1)/n.xScale,n.min.y+(e+1)/n.yScale);for(let e=r.y;e<=Math.min(o.y+1,s-1);++e)for(let i=r.x;i<=Math.min(o.x+1,s-1);++i)255===pb[e*s+i]&&(pb[e*s+i]=0,f+=t.getElevationAtPixel(i,e),m++)}const g=f/m;u=Math.max(1,r.x-c),h=Math.max(1,r.y-c),d=Math.min(a.x+c,s-2),p=Math.min(a.y+c,s-2),o=!0;for(let e=h;e<=p;++e)for(let i=u;i<=d;++i)0===pb[e*s+i]&&(db[e*s+i]=t._dem.set(i,e,g));for(let e=1;e<c;++e){u=Math.max(1,r.x-e),h=Math.max(1,r.y-e),d=Math.min(a.x+e,s-2),p=Math.min(a.y+e,s-2);for(let i=h;i<=p;++i)for(let n=u;n<=d;++n){const r=i*s+n;if(255===pb[r]){let o=0,a=0,l=-1,u=-1;for(let t=-1;t<=1;++t)for(let r=-1;r<=1;++r){const c=(i+t)*s+n+r;if(pb[c]>=e)continue;const h=db[c],d=Math.abs(h);d>a&&(o=h,a=d,l=r,u=t)}if(a>.1){const s=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(n,i)+o*s;const h=t._dem.get(n+l,i+u),d=t._dem.get(n-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),db[r]=t._dem.set(n,i,a),pb[r]=e}}}}}o&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=At.now())}setFilter(e){this.filter=e?Ea(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new la(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)cg(t.node),hg(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!i.some(e=>e.footprint===t)}}getHeightAtTileCoord(e,t){const i=[0,0,0],n=u([]);for(const r of this.getNodesInfo()){const s=r.node.meshes[0],o=s.transformedAabb;if(e<o.min[0]||t<o.min[1]||e>o.max[0]||t>o.max[1])continue;if(!0===r.node.hidden)return{height:1/0,maxHeight:r.feature.properties.height,hidden:!1,verticalScale:r.evaluatedScale[2]};if(h(n,r.node.globalMatrix),i[0]=e,i[1]=t,i[2]=0,H(i,i,n),r.node.meshBVH){const e=i[0],t=i[1];fb[0]=e-1,fb[1]=t-1,fb[2]=-1e3,mb[0]=e+1,mb[1]=t+1,mb[2]=1e3;const n=r.node.meshBVH.findHighestPoint(fb,mb);if(null!==n)return{height:n,maxHeight:r.feature.properties.height,hidden:r.hiddenByReplacement,verticalScale:r.evaluatedScale[2]};continue}const a=(i[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*tg|0,l=Math.min(63,(i[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*tg|0)*tg+Math.min(63,a),c=s.heightmap[l];if(c<0&&r.node.footprint){const i=[];if(r.node.footprint.grid.query(new Ae(e,t),new Ae(e,t),i),i.length>0)return{height:void 0,maxHeight:r.feature.properties.height,hidden:r.hiddenByReplacement,verticalScale:r.evaluatedScale[2]};continue}if(r.hiddenByReplacement)return;return{height:c,maxHeight:r.feature.properties.height,hidden:!1,verticalScale:r.evaluatedScale[2]}}}}function bb(e,t){return e instanceof to&&!e.isLightConstant&&t}function wb(e,t,i,n,r,s,o,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;const h=15&t|(15&t)<<4;i[3]>0&&(l=xi(l,255*i[0],i[3]),c=xi(c,255*i[1],i[3]),u=xi(u,255*i[2],i[3]));const d=h/255;l*=d,c*=d,u*=d;const p=l<<8|c,f=u<<8|Math.floor(255*n[3]),m=function(e){const t=ze(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],g=ze(r[0],0,1),_=ze(r[1],0,1),y=ze(r[2],0,1),v=ze(r[3],0,1);let x,b,w,T;if(g!==_&&o!==s&&_!==g){const e=o-s;b=1/(e*(_-g)),w=-(s+e*g)/(e*(_-g));const t=ze(r[4],-1,1);T=Math.pow(10,t),x=255*y<<8|255*v}else x=65535,b=0,w=1,T=1;if(e.emplaceBack(p,f,m,x,b,w,T),a){const e=a.length;a.clear();for(let t=0;t<e;t++)a.emplaceBack(p,f,m,x,b,w,T)}}function Tb(e,t,i){const n=e.node;let r=0;const s=i&ig.HasMeshoptCompression;for(const i of n.meshes){if(n.lights&&n.lightMeshIndex===r)continue;if(!i.featureData)continue;i.featureArray=new Dl,i.featureArray.reserve(i.featureData.length);let o=t;for(const t of i.featureData){const r=s?65535&t:t>>16&65535,a=s?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(o&&2===l&&n.lights&&(d=new Dl,d.resize(10*n.lights.length)),wb(i.featureArray,r,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&o){o=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),r++}if(n.lodMeshes)for(const t of n.lodMeshes)if(t.featureData){t.featureArray=new Dl,t.featureArray.reserve(t.featureData.length);for(const i of t.featureData){const n=s?i>>16&65535:65535&i,r=(15&n)<8?15&n:0;wb(t.featureArray,s?65535&i:i>>16&65535,e.evaluatedColor[r],e.evaluatedRMEA[r],e.emissionHeightBasedParams[r],t.aabb.min[2],t.aabb.max[2],null)}t.featureArray._trim()}}lo(xb,"Tiled3dModelBucket",{omit:["layers"]}),lo(vb,"Tiled3dModelFeature");const Sb=["id","tile","layer","source","sourceLayer","state"];class Eb{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=n,this.properties=e?e.properties:{},this.id=r}clone(){const e=new Eb(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of Sb)void 0!==this[t]&&(e[t]=this[t]);return e}}class Ab extends mi{constructor(e,t,i,n){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(e,t){return Rm(this.map._requestManager.transformRequest(e,Ht.Model).url,t)}async loadModel(e,t,i){try{const n=await this.loadGLTFFromURI(t.uri,i);if(i.aborted)return;const r=this._modelsInfo.get(e);if(!r)return;const s=Sg(n),o=r.modelSpec,a=new rg(e,o.uri,o.position,o.orientation,s);Ab.applyModelSpecification(a,o),a.computeBoundsAndApplyParent(),this.models.push(a),r.model=a}catch(i){if(i instanceof Error&&"AbortError"===i.name)return;const n=i instanceof Error?i.message:"Unknown error";this.fire(new di(new Error(`Could not load model ${e} from ${t.uri}: ${n}`)))}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const i in this._options.models){const n=this._options.models[i],r=this._modelsInfo.get(i);if(r&&r.model){r.modelSpec=n;const e=r.model;e.position=null!=n.position?new Vc(n.position[0],n.position[1]):new Vc(0,0),e.orientation=null!=n.orientation?n.orientation:[0,0,0],Ab.applyModelSpecification(e,n),e.computeBoundsAndApplyParent(),this.models.push(e)}else r?r.modelSpec=n:(this._modelsInfo.set(i,{modelSpec:n,model:null}),t.push(this.loadModel(i,n,e)))}0!==t.length?(await Promise.allSettled(t),e.aborted||this.fire(new hi("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new hi("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(e,t){t.nodeOverrides&&Ab.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&Ab.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const i of t)e.nodeOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={orientation:[0,0,0]};if(Object.hasOwn(i,"orientation")){const e=i.orientation;e&&(n.orientation=e)}e.nodeOverrides.set(t,n)})}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const i of t)e.materialOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={color:new bi(1,1,1),colorMix:0,emissionStrength:0,opacity:1},r=i["model-color"];void 0!==r&&(n.color.r=r[0],n.color.g=r[1],n.color.b=r[2]);const s=i["model-color-mix-intensity"];void 0!==s&&(n.colorMix=s);const o=i["model-emissive-strength"];void 0!==o&&(n.emissionStrength=o);const a=i["model-opacity"];void 0!==a&&(n.opacity=a),e.materialOverrides.set(t,n)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(0===this._modelsInfo.size)return!0;for(const e of this._modelsInfo.values())if(null==e.model)return!1;return!0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){this.cancelModelRequests();const e=ka(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];const t=new Map;for(const i in e){const n=e[i],r=this._modelsInfo.get(i);r&&r.modelSpec.uri===n.uri&&t.set(i,r)}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,i]of t)i.model||t.delete(e)}this._modelsInfo=t,this._options.models=e,this.load()}}function Mb(e,t,i,n){const r=1<<e.z;t.lat=$c((n/Qn+e.y)/r),t.lng=Xc((i/Qn+e.x)/r)}function Ib(e,t,i,n){const r=e.getNodesInfo()[t];if(!r||r.hiddenByReplacement||!r.node.meshes)return;let s=Number.MAX_VALUE;const o=r.node,a=i.tile,l=n.calculatePosMatrix(a.tileID.toUnwrapped(),n.worldSize),c=r.evaluatedScale;let u=0;n.elevation&&o.elevation&&(u=o.elevation*n.elevation.exaggeration()),p(l,l,[(o.anchor?o.anchor[0]:0)*(c[0]-1),(o.anchor?o.anchor[1]:0)*(c[1]-1),u]),f(l,l,c);const h=i.queryGeometry,m=h.isPointQuery()?h.screenBounds:h.screenGeometry,g=function(e){const t=d([],l,e.globalMatrix);d(t,n.expandedFarZProjMatrix,t);for(let i=0;i<e.meshes.length;++i){const r=e.meshes[i];if(i===e.lightMeshIndex)continue;const o=eg(m,n,t,r.aabb);null!=o&&(s=Math.min(o,s))}if(e.children)for(const t of e.children)g(t)};if(g(o),s===Number.MAX_VALUE)return;const _=new Vc(0,0);return Mb(a.tileID.canonical,_,r.node.anchor[0],r.node.anchor[1]),{intersectionZ:s,position:_,feature:r.feature}}const Cb={circle:class extends Xa{constructor(e,t,i,n){super(e,{layout:ah||(ah=new xa({"circle-sort-key":new ya(ba.layout_circle["circle-sort-key"]),"circle-elevation-reference":new _a(ba.layout_circle["circle-elevation-reference"]),visibility:new _a(ba.layout_circle.visibility)})),paint:lh||(lh=new xa({"circle-radius":new ya(ba.paint_circle["circle-radius"]),"circle-color":new ya(ba.paint_circle["circle-color"]),"circle-blur":new ya(ba.paint_circle["circle-blur"]),"circle-opacity":new ya(ba.paint_circle["circle-opacity"]),"circle-translate":new _a(ba.paint_circle["circle-translate"]),"circle-translate-anchor":new _a(ba.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new _a(ba.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new _a(ba.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ya(ba.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ya(ba.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ya(ba.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new _a(ba.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n)}createBucket(e){return new Uu(e)}queryRadius(e){const t=e;return nh("circle-radius",this,t)+nh("circle-stroke-width",this,t)+rh(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,n,r,s,o,a){const l=oh(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return qh(e,n,s,o,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,t,i){const n=Wh(this);return{config:new Ec(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}is3D(e){return!e&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}},heatmap:class extends Xa{createBucket(e){return new Jh(e)}constructor(e,t,i,n){super(e,{layout:Kh||(Kh=new xa({visibility:new _a(ba.layout_heatmap.visibility)})),paint:Qh||(Qh=new xa({"heatmap-radius":new ya(ba.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ya(ba.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _a(ba.paint_heatmap["heatmap-intensity"]),"heatmap-color":new va(ba.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _a(ba.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ld({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}queryRadius(e){return nh("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,n,r,s,o,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return qh(e,n,s,o,a,!0,!0,new Ae(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,i){return"heatmap"===e?{config:new Ec(this,{zoom:t,lut:i}),overrideFog:!1}:{}}},hillshade:class extends Xa{constructor(e,t,i,n){super(e,{layout:ed||(ed=new xa({visibility:new _a(ba.layout_hillshade.visibility)})),paint:td||(td=new xa({"hillshade-illumination-direction":new _a(ba.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new _a(ba.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new _a(ba.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new _a(ba.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new _a(ba.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new _a(ba.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new _a(ba.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n)}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,i){return{overrideFog:!1}}},fill:class extends Xa{constructor(e,t,i,n){super(e,{layout:Dp||(Dp=new xa({"fill-sort-key":new ya(ba.layout_fill["fill-sort-key"]),visibility:new _a(ba.layout_fill.visibility),"fill-elevation-reference":new _a(ba.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new ya(ba.layout_fill["fill-construct-bridge-guard-rail"])})),paint:Bp||(Bp=new xa({"fill-antialias":new _a(ba.paint_fill["fill-antialias"]),"fill-opacity":new ya(ba.paint_fill["fill-opacity"]),"fill-color":new ya(ba.paint_fill["fill-color"]),"fill-outline-color":new ya(ba.paint_fill["fill-outline-color"]),"fill-translate":new _a(ba.paint_fill["fill-translate"]),"fill-translate-anchor":new _a(ba.paint_fill["fill-translate-anchor"]),"fill-pattern":new ya(ba.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new _a(ba.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new _a(ba.paint_fill["fill-emissive-strength"]),"fill-z-offset":new ya(ba.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new ya(ba.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new ya(ba.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t,i){return{config:new Ec(this,{zoom:t,lut:i}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Op(e)}queryRadius(){return rh(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,n,r,s){return!e.queryGeometry.isAboveHorizon&&Gu(sh(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(e){if(0!==this.paint.get("fill-z-offset").constantOr(1))return!0;const t=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?t&&!e:t}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends Xa{constructor(e,t,i,n){super(e,{layout:Wf||(Wf=new xa({visibility:new _a(ba["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new _a(ba["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new _a(ba["layout_fill-extrusion"]["source-max-zoom"])})),paint:qf||(qf=new xa({"fill-extrusion-opacity":new _a(ba["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ya(ba["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _a(ba["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _a(ba["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ya(ba["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new _a(ba["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new ya(ba["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ya(ba["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new _a(ba["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new _a(ba["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new _a(ba["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new _a(ba["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new _a(ba["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new _a(ba["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new _a(ba["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new _a(ba["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new _a(ba["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new _a(ba["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ya(ba["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ya(ba["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new _a(ba["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new _a(ba["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new _a(ba["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new _a(ba["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new _a(ba["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new ya(ba["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new ya(ba["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new _a(ba["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Of(e)}queryRadius(){return rh(this.paint.get("fill-extrusion-translate"))}is3D(e){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,i,n,r,s,o,a,l){const c=oh(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(t,i),h=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],p=a&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=e.tile.getBucket(this);if(m instanceof Of){const e=m.centroidData.find(e=>l>=e.vertexArrayOffset&&l<e.vertexArrayOffset+e.vertexCount);if(e&&e.flags&vf)return!1;if(p){const e=m.centroidVertexArray,t=l+1;t<e.length&&(d[0]=e.geta_centroid_pos0(t),d[1]=e.geta_centroid_pos1(t))}}if(0===d[0]&&1===d[1])return!1;"globe"===s.projection.name&&(n=Gf([n],[new Ae(0,0),new Ae(Qn,Qn)],e.tileID.canonical).map(e=>e.polygon).flat());const g=p?a:null,[_,y]=sm(s,n,h,u,c,o,g,d,f,s.center.lat,e.tileID.canonical),v=e.queryGeometry;return rm(_,y,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},building:class extends Xa{constructor(e,t,i,n){super(e,{layout:Xf||(Xf=new xa({visibility:new _a(ba.layout_building.visibility),"building-facade":new ya(ba.layout_building["building-facade"]),"building-facade-floors":new ya(ba.layout_building["building-facade-floors"]),"building-facade-unit-width":new ya(ba.layout_building["building-facade-unit-width"]),"building-facade-window":new ya(ba.layout_building["building-facade-window"]),"building-roof-shape":new ya(ba.layout_building["building-roof-shape"]),"building-height":new ya(ba.layout_building["building-height"]),"building-base":new ya(ba.layout_building["building-base"]),"building-flood-light-wall-radius":new ya(ba.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ya(ba.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ya(ba.layout_building["building-flip-roof-orientation"])})),paint:$f||($f=new xa({"building-opacity":new _a(ba.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new _a(ba.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new _a(ba.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new _a(ba.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new _a(ba.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new _a(ba.paint_building["building-vertical-scale"]),"building-cast-shadows":new _a(ba.paint_building["building-cast-shadows"]),"building-color":new ya(ba.paint_building["building-color"]),"building-emissive-strength":new ya(ba.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new _a(ba.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new _a(ba.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new _a(ba.paint_building["building-front-cutoff"]),"building-flood-light-color":new _a(ba.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new _a(ba.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new _a(ba.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}prepare(){return Jg()}createBucket(e){return new $g(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(e){return!0}queryRadius(e){return 0}queryIntersectsFeature(e,t,i,n,r,s,o,a,l,c){let u=this.layout.get("building-height").evaluate(t,i);const h=this.layout.get("building-base").evaluate(t,i),d=e.tile.getBucket(this).getFootprint(t);if(d){if(0!==d.hiddenFlags)return!1;u=d.height}const[p,f]=sm(s,n,h,u,new Ae(0,0),o,null,[0,0],1,s.center.lat,e.tileID.canonical),m=e.queryGeometry;return rm(p,f,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends Xa{constructor(e,t,i,n){const r=w_();super(e,r,t,i,n),r.layout&&(this.layout=new ga(r.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof zr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(S_)return S_;const e=w_();return S_=new T_(e.paint.properties["line-width"].specification),S_.useIntegerZoom=!0,S_})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new h_(e)}getProgramIds(){const e=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return"default"!==this.paint.get("line-blend-mode")&&e.push("lineBlendComposite"),e}getDefaultProgramParams(e,t,i){if("lineBlendComposite"===e)return{};const n=v_(this);return{config:new Ec(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,i=E_(nh("line-width",this,t),nh("line-gap-width",this,t)),n=nh("line-offset",this,t);return i/2+Math.abs(n)+rh(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,r,s){if(e.queryGeometry.isAboveHorizon)return!1;const o=sh(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*E_(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(n=function(e,t){const i=[],n=new Ae(0,0);for(let r=0;r<e.length;r++){const s=e[r],o=[];for(let e=0;e<s.length;e++){const i=s[e],r=s[e+1],a=0===e?n:i.sub(s[e-1])._unit()._perp(),l=e===s.length-1?n:r.sub(i)._unit()._perp(),c=a._add(l)._unit();c._mult(1/(c.x*l.x+c.y*l.y)),o.push(c._mult(t)._add(i))}i.push(o)}return i}(n,l*e.pixelToTileUnitsFactor)),function(e,t,i){for(let n=0;n<t.length;n++){const r=t[n];if(e.length>=3)for(let t=0;t<r.length;t++)if(Ku(e,r[t]))return!0;if(Hu(e,r,i))return!0}return!1}(o,n,a)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(e){return!this.hasElevatedBuckets||this.layout&&"hd-road-markup"===this.layout.get("line-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("line-elevation-reference")}hasOffscreenPass(){return"default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo()}onRemove(e){this._destroyLineBlendFbo(e.painter&&e.painter.context&&e.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(e){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),e&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(e),this.lineBlendDensityReadback=null}},symbol:zx,background:class extends Xa{constructor(e,t,i,n){super(e,{layout:Ux||(Ux=new xa({visibility:new _a(ba.layout_background.visibility)})),paint:Vx||(Vx=new xa({"background-pitch-alignment":new _a(ba.paint_background["background-pitch-alignment"]),"background-color":new _a(ba.paint_background["background-color"]),"background-pattern":new _a(ba.paint_background["background-pattern"]),"background-opacity":new _a(ba.paint_background["background-opacity"]),"background-emissive-strength":new _a(ba.paint_background["background-emissive-strength"]),"background-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,i){return{overrideFog:!1}}is3D(e){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:Jx,"raster-particle":sb,sky:class extends Xa{constructor(e,t,i,n){super(e,{layout:eb||(eb=new xa({visibility:new _a(ba.layout_sky.visibility)})),paint:tb||(tb=new xa({"sky-type":new _a(ba.paint_sky["sky-type"]),"sky-atmosphere-sun":new _a(ba.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new _a(ba.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new _a(ba.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new _a(ba.paint_sky["sky-gradient-radius"]),"sky-gradient":new va(ba.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new _a(ba.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new _a(ba.paint_sky["sky-atmosphere-color"]),"sky-opacity":new _a(ba.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=ld({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),n=!i,r=e.style.light,s=r.properties.get("position");return n&&"viewport"===r.properties.get("anchor")&&Qe("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?ab(s.azimuthal,90-s.polar,t):ab(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return ab(i[0],90-i[1],t)}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends Xa{constructor(e,t,i,n){super(e,{paint:ib||(ib=new xa({}))},t,null)}},model:class extends Xa{constructor(e,t,i,n){super(e,{layout:nb||(nb=new xa({visibility:new _a(ba.layout_model.visibility),"model-id":new ya(ba.layout_model["model-id"]),"model-allow-density-reduction":new _a(ba.layout_model["model-allow-density-reduction"])})),paint:rb||(rb=new xa({"model-opacity":new ya(ba.paint_model["model-opacity"]),"model-rotation":new ya(ba.paint_model["model-rotation"]),"model-scale":new ya(ba.paint_model["model-scale"]),"model-translation":new ya(ba.paint_model["model-translation"]),"model-color":new ya(ba.paint_model["model-color"]),"model-color-mix-intensity":new ya(ba.paint_model["model-color-mix-intensity"]),"model-type":new _a(ba.paint_model["model-type"]),"model-cast-shadows":new _a(ba.paint_model["model-cast-shadows"]),"model-receive-shadows":new _a(ba.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new _a(ba.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ya(ba.paint_model["model-emissive-strength"]),"model-roughness":new ya(ba.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ya(ba.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new _a(ba.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new _a(ba.paint_model["model-front-cutoff"]),"model-elevation-reference":new _a(ba.paint_model["model-elevation-reference"]),"model-ignore-line-cutout":new _a(ba.paint_model["model-ignore-line-cutout"]),"model-color-use-theme":new ya({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new ub(e)}getProgramIds(){return["model"]}is3D(e){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e instanceof xb?8191:0}queryRenderedFeatures(e,t,i){const n=t.getSource();if(!(n&&n instanceof Ab))return{};const r=n,s={};s[this.id]=[];const o=s[this.id];let a=0;for(const n of r.models){const r=t.getFeatureState(this.sourceLayer,n.id),s={type:"Unknown",id:n.id,properties:n.featureProperties},l=this.paint.get("model-rotation").evaluate(s,r),c=this.paint.get("model-scale").evaluate(s,r),u=this.paint.get("model-translation").evaluate(s,r),h=this.paint.get("model-elevation-reference");let p=[];ng(p,n,i,n.position,l,c,u,"ground"===h,"ground"===h,!1),"globe"===i.projection.name&&(p=Qm(p,i));const f=d([],i.projMatrix,p),m=eg(e.isPointQuery()?e.screenBounds:e.screenGeometry,i,f,n.aabb);if(null!=m){const e=new Eb(void 0,0,0,0,n.id);e.layer=this.layer,e.properties=structuredClone(n.featureProperties),e.properties.layer=this.id,e.properties.uri=n.uri,e.properties.orientation=n.orientation,e.sourceLayer=this.sourceLayer,e.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},e.state=r,e.source=this.source,o.push({featureIndex:a,feature:e,intersectionZ:m})}++a}return s}queryIntersectsFeature(e,t,i,n,r,s,o,a,l,c){if(!this.modelManager)return!1;const u=this.modelManager,h=e.tile.getBucket(this);if(!(h&&h instanceof ub))return!1;for(const i in h.instancesPerModel){const n=h.instancesPerModel[i],r=void 0!==t.id?t.id:t.properties&&Object.hasOwn(t.properties,"id")?t.properties.id:void 0;if(Object.hasOwn(n.idToFeaturesIndex,r)){const t=n.features[n.idToFeaturesIndex[r]],o=u.getModel(i,c||this.scope);if(!o)return!1;let a=[];const l=new Vc(0,0),p=h.canonical;let f=Number.MAX_VALUE;for(let i=0;i<t.instancedDataCount;++i){const r=16*(t.instancedDataOffset+i),c=n.instancedDataArray.float32,u=[c[r+4],c[r+5],c[r+6]];Mb(p,l,Math.floor(c[r]),Math.floor(c[r+1])),ng(a,o,s,l,t.rotation,t.scale,u,!1,!1,!1),"globe"===s.projection.name&&(a=Qm(a,s));const h=d([],s.projMatrix,a),m=e.queryGeometry,g=eg(m.isPointQuery()?m.screenBounds:m.screenGeometry,s,h,o.aabb);null!=g&&(f=Math.min(g,f))}return f!==Number.MAX_VALUE&&f}}return!1}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){const t=this._transitionablePaint._values[e];return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof io}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends Xa{constructor(e,t,i,n){super(e,{layout:Fp||(Fp=new xa({"clip-layer-types":new _a(ba.layout_clip["clip-layer-types"]),"clip-layer-scope":new _a(ba.layout_clip["clip-layer-scope"]),visibility:new _a(ba.layout_clip.visibility)})),paint:Np||(Np=new xa({}))},t,i,n)}recalculate(e,t){super.recalculate(e,t)}createBucket(e){return new Up(e)}is3D(e){return!0}}};class Pb{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,t)}delete(e){this.cache.delete(e)}}lo(Pb,"LRUCache");class Lb{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Rb{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class Ob{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new oo(Qn,Qn,512),this.featureIndexArray=new ql,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,t,i,n,r,s=0,o=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,s);const l=this.grid;for(let e=0;e<t.length;e++){const i=t[e],n=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];n[0]=Math.min(n[0],t.x),n[1]=Math.min(n[1],t.y),n[2]=Math.max(n[2],t.x),n[3]=Math.max(n[3],t.y)}0!==o&&(n[0]-=o,n[1]-=o,n[2]+=o,n[3]+=o),n[0]<Qn&&n[1]<Qn&&n[2]>=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new gu(new Z_(this.rawTileData)).layers,this.sourceLayerCoder=new Rb(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t){const{tilespaceGeometry:i,transform:n,tileTransform:r,pixelPosMatrix:s,availableImages:o,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.queryKeys(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,n,r)=>Qu(i.bufferedTilespaceGeometry,e-l,t-l,n+l,r+l));u.sort(Bb);let h=null;n.elevation&&u.length>0&&(h=hb.create(n.elevation,this.tileID));const d={};let p;for(let l=0;l<u.length;l++){const c=u[l];if(c===p)continue;p=c;const f=this.featureIndexArray.get(c);let m=null;this.is3DTile?this.loadMatchingModelFeature(d,f,e,i,n,a):this.loadMatchingFeature(d,f,e,o,a,(e,o,a,l=0)=>(m||(m=cu(e,this.tileID.canonical,r)),o.queryIntersectsFeature(i,e,a,m,this.z,n,s,h,l,t.scope)))}return d}loadMatchingFeature(e,t,i,n,r,s){const{featureIndex:o,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!Je(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(o),g=this.getId(m,f);for(let t=0;t<u.length;t++){const i=u[t];if(!h[i])continue;const{styleLayer:a,targets:l}=h[i];let d={};void 0!==g&&(d=p.getFeatureState(a.sourceLayer,g));const f=!s||s(m,a,d,c);if(!f)continue;const _=new Eb(m,this.z,this.x,this.y,g);_.tile=this.tileID.canonical,_.state=d;let y=this.serializedLayersCache.get(i);y||(y=a.serialize(),y.id=i,this.serializedLayersCache.set(i,y)),_.source=y.source,_.sourceLayer=y["source-layer"],_.layer=Object.assign({},y),_.layer.paint=Db(y.paint,a.paint,m,d,n),_.layer.layout=Db(y.layout,a.layout,m,d,n);let v=!1;for(const e of l){this.updateFeatureProperties(_,e);const{filter:t}=e;if(t)if(m.properties=_.properties,t.needGeometry){const e=uu(m,!0);if(!t.filter(new la(this.tileID.overscaledZ,{worldview:r}),e,this.tileID.canonical))continue}else if(!t.filter(new la(this.tileID.overscaledZ,{worldview:r}),m))continue;v=!0,e.targetId&&this.addFeatureVariant(_,e)}v&&this.appendToResult(e,i,o,_,f)}}loadMatchingModelFeature(e,t,i,n,r,s){const{featureIndex:o,bucketIndex:a}=t,l=this.bucketLayerIDs[a],c=i.layers,u=Object.keys(c);if(!u.length||Je(u,l))for(let t=0;t<l.length;t++){const a=l[t],{styleLayer:u,targets:h}=c[a];if("model"!==u.type)continue;const d=n.tile,p=d.getBucket(u);if(!(p&&p instanceof xb))continue;const f=Ib(p,o,n,r);if(!f)continue;const{z:m,x:g,y:_}=d.tileID.canonical,{feature:y,intersectionZ:v,position:x}=f;let b={};void 0!==y.id&&(b=i.sourceCache.getFeatureState(u.sourceLayer,y.id));const w=new Eb({},m,g,_,y.id);w.tile=this.tileID.canonical,w.state=b,w.properties=y.properties,w.geometry={type:"Point",coordinates:[x.lng,x.lat]};let T=this.serializedLayersCache.get(a);T||(T=u.serialize(),T.id=a,this.serializedLayersCache.set(a,T)),w.source=T.source,w.sourceLayer=T["source-layer"],w.layer=Object.assign({},T);let S=!1;for(const e of h){this.updateFeatureProperties(w,e);const{filter:t}=e;if(t)if(y.properties=w.properties,t.needGeometry){if(!t.filter(new la(this.tileID.overscaledZ,{worldview:s}),y,this.tileID.canonical))continue}else if(!t.filter(new la(this.tileID.overscaledZ,{worldview:s}),y))continue;S=!0,e.targetId&&this.addFeatureVariant(w,e)}S&&this.appendToResult(e,a,o,w,v)}}updateFeatureProperties(e,t,i){if(t.properties){const n={};for(const r in t.properties){const s=t.properties[r].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,i);null!=s&&(n[r]=s)}e.properties=n}}addFeatureVariant(e,t,i){const n={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(n.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(n)}appendToResult(e,t,i,n,r){let s=e[t];void 0===s&&(s=e[t]=[]),s.push({featureIndex:i,feature:n,intersectionZ:r})}lookupSymbolFeatures(e,t,i,n,r,s){const o={};this.loadVTLayers();for(const a of e)this.loadMatchingFeature(o,{bucketIndex:t,sourceLayerIndex:i,featureIndex:a,layoutVertexArrayOffset:0},n,r,s);return o}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const n=this.sourceLayerCoder.decode(i),r=this.vtFeatures[n];if(r[t])return r[t];const s=this.vtLayers[n].feature(t);return r[t]=s,s}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){const n=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[t];if(null!=n)if(Array.isArray(n)){if(!this.promoteIdExpression){const e=eo(n);if("success"!==e.result)return void Qe(`Failed to create expression for promoteId: ${e.value.map(e=>`${e.key}: ${e.message}`).join(", ")}`);this.promoteIdExpression=e.value}i=this.promoteIdExpression.evaluate({zoom:0},e)}else i=e.properties[n];"boolean"==typeof i&&(i=Number(i))}return i}}function Db(e,t,i,n,r){return $e(e,(e,s)=>{const o=t instanceof ga?t.get(s):null;return o&&o.evaluate?o.evaluate(i,n,void 0,r):o})}function Bb(e,t){return t-e}function Fb(e,t){const i={};if(!t)return i;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0])),n.updateExpressions&&n.updateExpressions(e);for(const t of e)i[t.fqid]=n}}return i}lo(Ob,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Nb=32,kb=33,zb=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,n=0,r=0,s=0,o=0,a=0;for(1&t?r=s=o=Nb:i=n=a=Nb;(t>>=1)>1;){const e=i+r>>1,l=n+s>>1;1&t?(r=i,s=n,i=o,n=a):(i=r,n=s,r=o,s=a),o=e,a=l}const l=4*e;zb[l+0]=i,zb[l+1]=n,zb[l+2]=r,zb[l+3]=s}const Ub=new Uint16Array(2178),Vb=new Uint8Array(1089),jb=new Uint16Array(1089);function Gb(e){return 0===e?-.03125:32===e?.03125:0}const Hb={Other:0,Symbol:1,FillExtrusion:2},Wb={type:2,extent:Qn,loadGeometry:()=>[[new Ae(0,0),new Ae(8193,0),new Ae(8193,8193),new Ae(0,8193),new Ae(0,0)]]};class qb{constructor(){this.tasks={},this.taskQueue=[],Xe(["process"],this),this.invoker=new Lb(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=function({type:e,renderSourceType:t,zoom:i}){i=i||0;const n=t===Hb.Symbol;return"message"===e?0:"maybePrepare"!==e||n?"parseTile"!==e||n?"parseTile"===e&&n?300-i:"maybePrepare"===e&&n?400-i:500:200-i:100-i}(t);if(0===n){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const n=this.tasks[this.taskQueue[i]];n.priority<t&&(t=n.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}function Xb(e,t,i){try{t=function(e){if(!e.variants)return e;if(!Array.isArray(e.variants))throw new Error("variants must be an array");for(const t of e.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(t.capabilities))throw new Error("capabilities must be an array");if(1===t.capabilities.length&&"meshopt"===t.capabilities[0])return Object.assign(e,t)}return e}(t)}catch(e){return new Error("Failed to process TileJSON variants",{cause:e})}const n=Ge(Object.assign({},t,e),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return e.url&&t.tiles&&e.tiles&&(n.tiles=t.tiles),n.tiles=i.canonicalizeTileset(n,e.url),n}const $b=new Map,Zb=new Map;class Yb{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Jb(e,t,i,n){let r=0,s=Number.MAX_VALUE;for(let o=0;o<3;o++)if(Math.abs(n[o])<1e-15){if(i[o]<e[o]||i[o]>t[o])return null}else{const a=1/n[o];let l=(e[o]-i[o])*a,c=(t[o]-i[o])*a;if(l>c){const e=l;l=c,c=e}if(l>r&&(r=l),c<s&&(s=c),r>s)return null}return r}function Kb(e,t,i,n,r,s,o,a,l,c,u){const h=n-e,d=r-t,p=s-i,f=o-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,y=u[2]*f-u[0]*g,v=u[0]*m-u[1]*f,x=h*_+d*y+p*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-e,T=c[1]-t,S=c[2]-i,E=(w*_+T*y+S*v)*b;if(E<0||E>1)return null;const A=T*p-S*d,M=S*h-w*p,I=w*d-T*h,C=(u[0]*A+u[1]*M+u[2]*I)*b;return C<0||E+C>1?null:(f*A+m*M+g*I)*b}function Qb(e,t,i){return(e-t)/(i-t)}function ew(e,t,i,n,r,s,o,a,l){const c=1<<i,u=s-n,h=o-r,d=(e+1)/c*u+n,p=(t+0)/c*h+r,f=(t+1)/c*h+r;a[0]=(e+0)/c*u+n,a[1]=p,l[0]=d,l[1]=f}class tw{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let n=Math.ceil(Math.pow(2,t));const r=1/n,s=(e,t,i,n,r)=>{const s=n?1:0,o=(e+1)*i-s,a=t*i,l=(t+1)*i-s;r[0]=e*i,r[1]=a,r[2]=o,r[3]=l};let o=new Yb(n);const a=[];for(let t=0;t<n*n;t++){s(t%n,Math.floor(t/n),r,!1,a);const i=nw(a[0],a[1],e),l=nw(a[2],a[1],e),c=nw(a[2],a[3],e),u=nw(a[0],a[3],e);o.minimums.push(Math.min(i,l,c,u)),o.maximums.push(Math.max(i,l,c,u)),o.leaves.push(1)}for(i.push(o),n/=2;n>=1;n/=2){const e=i.at(-1);o=new Yb(n);for(let t=0;t<n*n;t++){s(t%n,Math.floor(t/n),2,!0,a);const i=e.getElevation(a[0],a[1]),r=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),u=e.isLeaf(a[0],a[1]),h=e.isLeaf(a[2],a[1]),d=e.isLeaf(a[2],a[3]),p=e.isLeaf(a[0],a[3]),f=Math.min(i.min,r.min,l.min,c.min),m=Math.max(i.max,r.max,l.max,c.max),g=u&&h&&d&&p;o.maximums.push(m),o.minimums.push(f),o.leaves.push(m-f<=5&&g?1:0)}i.push(o)}return i}(this.dem),i=t.length-1,n=t[i];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,n,r,s,o=1){return Jb([e,t,-100],[i,n,this.maximums[0]*o],r,s)}raycast(e,t,i,n,r,s,o=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,n,r,s,o);if(null==a)return null;const l=[],c=[],u=[],h=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:g}=d.pop();if(this.leaves[a]){ew(f,m,g,e,t,i,n,u,h);const a=1<<g,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,_=(m+1)/a,y=nw(l,d,this.dem)*o,v=nw(c,d,this.dem)*o,x=nw(c,_,this.dem)*o,b=nw(l,_,this.dem)*o,w=Kb(u[0],u[1],y,h[0],u[1],v,h[0],h[1],x,r,s),T=Kb(h[0],h[1],x,u[0],h[1],b,u[0],u[1],y,r,s),S=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(S!==Number.MAX_VALUE)return S;{const e=B([],r,s,p);if(iw(y,v,b,x,Qb(e[0],u[0],h[0]),Qb(e[1],u[1],h[1]))>=e[2])return p}continue}let _=0;for(let d=0;d<this._siblingOffset.length;d++){ew((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],g+1,e,t,i,n,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+d]*o;const p=Jb(u,h,r,s);if(null!=p){const e=p;l[d]=e;let t=!1;for(let i=0;i<_&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[_]=d),_++}}for(let e=0;e<_;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:g+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const s=n-1,o=e[s];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const n=2*t+this._siblingOffset[e][0],r=2*i+this._siblingOffset[e][1],s=o.getElevation(n,r),c=o.isLeaf(n,r),u=this._addNode(s.min,s.max,c);c&&(a|=1<<e),l||(l=u)}for(let n=0;n<this._siblingOffset.length;n++)a&1<<n||this._construct(e,2*t+this._siblingOffset[n][0],2*i+this._siblingOffset[n][1],s,l+n)}}function iw(e,t,i,n,r,s){return xi(xi(e,i,s),xi(t,n,s),r)}function nw(e,t,i){const n=i.dim,r=ze(e*n-.5,0,n-1),s=ze(t*n-.5,0,n-1),o=Math.floor(r),a=Math.floor(s),l=Math.min(o+1,n-1),c=Math.min(a+1,n-1);return iw(i.get(o,a),i.get(l,a),i.get(o,c),i.get(l,c),r-o,s-a)}const rw={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function sw(e,t,i){return(256*e*256+256*t+i)/10-1e4}function ow(e,t,i){return 256*e+t+i/256-32768}class aw{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void Qe(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const r=this.dim=t.height-2,s=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(let e=0;e<r;e++)s[this._idx(-1,e)]=s[this._idx(0,e)],s[this._idx(r,e)]=s[this._idx(r-1,e)],s[this._idx(e,-1)]=s[this._idx(e,0)],s[this._idx(e,r)]=s[this._idx(e,r-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(r,-1)]=s[this._idx(r-1,0)],s[this._idx(-1,r)]=s[this._idx(0,r-1)],s[this._idx(r,r)]=s[this._idx(r-1,r-1)]}const o="terrarium"===i?ow:sw;for(let e=0;e<s.length;++e){const t=4*e;this.floatView[e]=o(this.pixels[t],this.pixels[t+1],this.pixels[t+2])}this._timestamp=At.now()}_buildQuadTree(){this._tree=new tw(this)}get(e,t,i=!1){i&&(e=ze(e,-1,this.dim),t=ze(t,-1,this.dim));const n=this._idx(e,t);return this.floatView[n]}set(e,t,i){const n=this._idx(e,t),r=this.floatView[n];return this.floatView[n]=i,i-r}static getUnpackVector(e){return rw[e]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],n=aw.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new ad({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:s=o-1;break;case 1:o=s+1}const a=-t*this.dim,l=-i*this.dim;for(let t=s;t<o;t++)for(let i=n;i<r;i++){const n=4*this._idx(i,t),r=4*this._idx(i+a,t+l);this.pixels[n+0]=e.pixels[r+0],this.pixels[n+1]=e.pixels[r+1],this.pixels[n+2]=e.pixels[r+2],this.pixels[n+3]=e.pixels[r+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function lw(e,t,i){1===e?t.headerLength=i.readFixed32():2===e?t.x=i.readVarint():3===e?t.y=i.readVarint():4===e?t.z=i.readVarint():5===e&&t.layers.push(function(e,t){return e.readFields(pw,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},t)}(i,i.readVarint()+i.pos))}function cw(e,t,i){1===e?(t.delta_filter=function(e,t){return e.readFields(uw,{blockSize:0},t)}(i,i.readVarint()+i.pos),t.filter="delta_filter"):2===e?(i.readVarint(),t.filter="zigzag_filter"):3===e?(i.readVarint(),t.filter="bitshuffle_filter"):4===e&&(i.readVarint(),t.filter="byteshuffle_filter")}function uw(e,t,i){1===e&&(t.blockSize=i.readVarint())}function hw(e,t,i){1===e?(i.readVarint(),t.codec="gzip_data"):2===e?(i.readVarint(),t.codec="jpeg_image"):3===e?(i.readVarint(),t.codec="webp_image"):4===e&&(i.readVarint(),t.codec="png_image")}function dw(e,t,i){let n=0,r=0;1===e?t.firstByte=i.readFixed64():2===e?t.lastByte=i.readFixed64():3===e?t.filters.push(function(e,t){return e.readFields(cw,{},t)}(i,i.readVarint()+i.pos)):4===e?t.codec=function(e,t){return e.readFields(hw,{},t)}(i,i.readVarint()+i.pos):5===e?r=i.readFloat():6===e?n=i.readFloat():7===e?t.bands.push(i.readString()):8===e?t.offset=i.readDouble():9===e&&(t.scale=i.readDouble()),0===t.offset&&(t.offset=r),0===t.scale&&(t.scale=n)}function pw(e,t,i){1===e?t.version=i.readVarint():2===e?t.name=i.readString():3===e?t.units=i.readString():4===e?t.tileSize=i.readVarint():5===e?t.buffer=i.readVarint():6===e?t.pixelFormat=i.readVarint():7===e&&t.dataIndex.push(function(e,t){return e.readFields(dw,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},t)}(i,i.readVarint()+i.pos))}function fw(e,t,i){if(2===e)!function(e,t,i){e.readFields(mw,i,t)}(i,i.readVarint()+i.pos,t);else if(3===e)throw new Error("Not implemented")}function mw(e,t,i){if(1===e){let e=0;const n=i.readVarint()+i.pos;for(;i.pos<n;)t[e++]=i.readVarint()}}function gw(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let n=2;n>=1;n--){const r=1===n?1:0,s=2===n?1:0;for(let n=0;n<t[0];n++){const o=t[1]*n;for(let n=r;n<t[1];n++){const r=t[2]*(n+o);for(let n=s;n<t[2];n++){const s=t[3]*(n+r);for(let n=0;n<t[3];n++){const t=s+n;e[t]+=e[t-i]}}}}i*=t[n]}return e}function _w(e){for(let t=0,i=e.length;t<i;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function yw(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t<e.length;t+=2){const i=e[t],n=e[t+1];e[t]=(240&i)>>4|(61440&i)>>8|(240&n)<<4|61440&n,e[t+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4}return e;case"uint8":for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],r=e[t+2],s=e[t+3];e[t+0]=(192&i)>>6|(192&n)>>4|(192&r)>>2|192&s,e[t+1]=(48&i)>>4|(48&n)>>2|48&r|(48&s)<<2,e[t+2]=(12&i)>>2|12&n|(12&r)<<2|(12&s)<<4,e[t+3]=3&i|(3&n)<<2|(3&r)<<4|(3&s)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}lo(aw,"DEMData"),lo(tw,"DemMinMaxQuadTree",{omit:["dem"]});var vw=Uint8Array,xw=Uint16Array,bw=Int32Array,ww=new vw([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tw=new vw([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Sw=new vw([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ew=function(e,t){for(var i=new xw(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new bw(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},Aw=Ew(ww,2),Mw=Aw.b,Iw=Aw.r;Mw[28]=258,Iw[258]=28;for(var Cw=Ew(Tw,0).b,Pw=new xw(32768),Lw=0;Lw<32768;++Lw){var Rw=(43690&Lw)>>1|(21845&Lw)<<1;Pw[Lw]=((65280&(Rw=(61680&(Rw=(52428&Rw)>>2|(13107&Rw)<<2))>>4|(3855&Rw)<<4))>>8|(255&Rw)<<8)>>1}var Ow=function(e,t,i){for(var n=e.length,r=0,s=new xw(t);r<n;++r)e[r]&&++s[e[r]-1];var o,a=new xw(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;o=new xw(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],h=a[e[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[Pw[h]>>l]=c;return o},Dw=new vw(288);for(Lw=0;Lw<144;++Lw)Dw[Lw]=8;for(Lw=144;Lw<256;++Lw)Dw[Lw]=9;for(Lw=256;Lw<280;++Lw)Dw[Lw]=7;for(Lw=280;Lw<288;++Lw)Dw[Lw]=8;var Bw=new vw(32);for(Lw=0;Lw<32;++Lw)Bw[Lw]=5;var Fw=Ow(Dw,9),Nw=Ow(Bw,5),kw=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},zw=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},Uw=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Vw=function(e){return(e+7)/8|0},jw=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Gw=function(e,t,i){var n=new Error(t||jw[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Gw),!i)throw n;return n},Hw=new vw(0),Ww="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ww.decode(Hw,{stream:!0})}catch(e){}const qw={gzip_data:"gzip"};class Xw extends Error{constructor(e){super(e),this.name="MRTError"}}const $w={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Zw={uint32:1,uint16:2,uint8:4},Yw={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Jw;class Kw{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new Xw(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Xw("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length<i)throw new Xw(`Expected header with length >= ${i} but got buffer of length ${t.length}`);const n=new Jw(t.subarray(0,i)).readFields(lw,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xw(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new Qw(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let n of e.blockIndices){const r=i.dataIndex[n],s=r.firstByte-e.firstByte,o=r.lastByte-e.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:s,lastByte:o,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map(e=>e.filter)};i._blocksInProgress.add(n),t.push(a)}return new eT(t,()=>{t.forEach(e=>i._blocksInProgress.delete(e.blockIndex))},(e,n)=>{if(t.forEach(e=>i._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e)})})}}class Qw{constructor({version:e,name:t,units:i,tileSize:n,pixelFormat:r,buffer:s,dataIndex:o},a){if(this.version=e,1!==this.version)throw new Xw(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=n,this.buffer=s,this.pixelFormat=$w[r],this.dataIndex=o,this.bandShape=[n+2*s,n+2*s,Zw[this.pixelFormat]],this._decodedBlocks=new Pb(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Zw[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,s]of n.bands.entries())if(s===e)return{bandIndex:t+r,blockIndex:i,blockBandIndex:r};t+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(e>=t&&e<t+n.bands.length)return{bandIndex:e,blockIndex:i,blockBandIndex:e-t};t+=n.bands.length}break;default:throw new Xw(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,i=-1/0;const n=[],r=new Set;for(const s of e){const{blockIndex:e}=this.getBlockForBand(s);if(e<0)throw new Xw(`Invalid band: ${JSON.stringify(s)}`);const o=this.dataIndex[e];n.includes(e)||n.push(e),r.add(e),t=Math.min(t,o.firstByte),i=Math.max(i,o.lastByte)}if(r.size>this.cacheSize)throw new Xw(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e);if(t<0)throw new Xw(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new Xw(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[t],s=this.bandShape.reduce((e,t)=>e*t,1),o=i*s,a=n.subarray(o,o+s);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:r.offset,scale:r.scale}}}Kw.setPbf=function(e){Jw=e};class eT{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}Kw.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:r,pixelFormat:s,blockShape:o,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(n,r+1),h=new Uint32Array(o[0]*o[1]*o[2]);let d;if("gzip_data"!==c)throw new Xw(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Gw(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(i=e),o+8>i.length&&Gw(6,"invalid gzip data"),function(e,t,i,n){var r=e.length;if(!r||t.f&&!t.l)return i||new vw(0);var s=!i,o=s||2!=t.i,a=t.i;s&&(i=new vw(3*r));var l=function(e){var t=i.length;if(e>t){var n=new vw(Math.max(2*t,e));n.set(i),i=n}},c=t.f||0,u=t.p||0,h=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,g=8*r;do{if(!d){c=zw(e,u,1);var _=zw(e,u+1,3);if(u+=3,!_){var y=e[(C=Vw(u)+4)-4]|e[C-3]<<8,v=C+y;if(v>r){a&&Gw(0);break}o&&l(h+y),i.set(e.subarray(C,v),h),t.b=h+=y,t.p=u=8*v,t.f=c;continue}if(1==_)d=Fw,p=Nw,f=9,m=5;else if(2==_){var x=zw(e,u,31)+257,b=zw(e,u+10,15)+4,w=x+zw(e,u+5,31)+1;u+=14;for(var T=new vw(w),S=new vw(19),E=0;E<b;++E)S[Sw[E]]=zw(e,u+3*E,7);u+=3*b;var A=kw(S),M=(1<<A)-1,I=Ow(S,A);for(E=0;E<w;){var C,P=I[zw(e,u,M)];if(u+=15&P,(C=P>>4)<16)T[E++]=C;else{var L=0,R=0;for(16==C?(R=3+zw(e,u,3),u+=2,L=T[E-1]):17==C?(R=3+zw(e,u,7),u+=3):18==C&&(R=11+zw(e,u,127),u+=7);R--;)T[E++]=L}}var O=T.subarray(0,x),D=T.subarray(x);f=kw(O),m=kw(D),d=Ow(O,f),p=Ow(D,m)}else Gw(1);if(u>g){a&&Gw(0);break}}o&&l(h+131072);for(var B=(1<<f)-1,F=(1<<m)-1,N=u;;N=u){var k=(L=d[Uw(e,u)&B])>>4;if((u+=15&L)>g){a&&Gw(0);break}if(L||Gw(2),k<256)i[h++]=k;else{if(256==k){N=u,d=null;break}var z=k-254;k>264&&(z=zw(e,u,(1<<(j=ww[E=k-257]))-1)+Mw[E],u+=j);var U=p[Uw(e,u)&F],V=U>>4;if(U||Gw(3),u+=15&U,D=Cw[V],V>3){var j=Tw[V];D+=Uw(e,u)&(1<<j)-1,u+=j}if(u>g){a&&Gw(0);break}o&&l(h+131072);var G=h+z;if(h<D){var H=0-D,W=Math.min(D,G);for(H+h<0&&Gw(3);h<W;++h)i[h]=n[H+h]}for(;h<G;++h)i[h]=i[h-D]}}t.l=d,t.p=N,t.b=h,t.f=c,d&&(c=1,t.m=f,t.d=p,t.n=m)}while(!c);return h!=i.length&&s?function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new vw(e.subarray(0,i))}(i,0,h):i.subarray(0,h)}(i.subarray(o,-8),{i:2},new vw(((r=i)[(s=r.length)-4]|r[s-3]<<8|r[s-2]<<16|r[s-1]<<24)>>>0),n)));var i,n,r,s,o;const a=qw[t];if(!a)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(a);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(u,c).then(e=>(function(e,t){e.readFields(fw,t)}(new Jw(e),h),new Yw[s](h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":gw(e,o);break;case"zigzag_filter":_w(e);break;case"bitshuffle_filter":yw(e,s);break;default:throw new Xw(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},lo(eT,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),lo(Kw,"MapboxRasterTile"),lo(Qw,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const tT=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class iT{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=tT[15&i];if(!r)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new iT(o,s,r,e)}constructor(e,t=64,i=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const r=tT.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return nT(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:s,nodeSize:o}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let o=h;o<=u;o++){const a=s[2*o],c=s[2*o+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[o])}continue}const d=h+u>>1,p=s[2*d],f=s[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:s}=this,o=[0,n.length-1,0],a=[],l=i*i;for(;o.length;){const c=o.pop()||0,u=o.pop()||0,h=o.pop()||0;if(u-h<=s){for(let i=h;i<=u;i++)aT(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];aT(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(o.push(h),o.push(d-1),o.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(o.push(d+1),o.push(u),o.push(1-c))}return a}}function nT(e,t,i,n,r,s){if(r-n<=i)return;const o=n+r>>1;rT(e,t,o,n,r,s),nT(e,t,i,n,o-1,1-s),nT(e,t,i,o+1,r,1-s)}function rT(e,t,i,n,r,s){for(;r>n;){if(r-n>600){const o=r-n+1,a=i-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(a-o/2<0?-1:1);rT(e,t,i,Math.max(n,Math.floor(i-a*c/o+u)),Math.min(r,Math.floor(i+(o-a)*c/o+u)),s)}const o=t[2*i+s];let a=n,l=r;for(sT(e,t,n,i),t[2*r+s]>o&&sT(e,t,n,r);a<l;){for(sT(e,t,a,l),a++,l--;t[2*a+s]<o;)a++;for(;t[2*l+s]>o;)l--}t[2*n+s]===o?sT(e,t,n,l):(l++,sT(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function sT(e,t,i,n){oT(e,i,n),oT(t,2*i,2*n),oT(t,2*i+1,2*n+1)}function oT(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function aT(e,t,i,n){const r=e-i,s=t-n;return r*r+s*s}t.$=un,t.A=Zi,t.B=2,t.C=bi,t.D=Xy,t.E=mi,t.F=Vy,t.G=cn,t.H=wa,t.I=gi,t.J=ln,t.K=hn,t.L=Pb,t.M=Gs,t.N=Us,t.O=js,t.P=Ae,t.Q=Qs,t.R=Ht,t.S=Ta,t.T=Bm,t.U=eo,t.V=no,t.W=Pr,t.X=Ir,t.Y=Cr,t.Z=_n,t._=dn,t.a=function(e){return pt.API_CDN_URL_REGEX.test(e)},t.a$=Ab,t.a0=vi,t.a1=Sa,t.a2=/^(.*)-use-theme$/,t.a3=/^(.*)-transition$/,t.a4=Hs,t.a5=Vs,t.a6=ba,t.a7=ha,t.a8=xa,t.a9=_a,t.aA=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const s of e)t=Math.min(t,s.x),i=Math.min(i,s.y),n=Math.max(n,s.x),r=Math.max(r,s.y);return{min:new Ae(t,i),max:new Ae(n,r)}},t.aB=ze,t.aC=d,t.aD=te,t.aE=Rc,t.aF=Ku,t.aG=Hc,t.aH=nu,t.aI=jc,t.aJ=Wc,t.aK=Ge,t.aL=class{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,n){const r=this.entries[e]=this.entries[e]||{callbacks:[]};if(r.result){const[e,i]=r.result;return this.scheduler?this.scheduler.add(()=>{n(e,i)},t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,n)},t):e(i,n);setTimeout(()=>delete this.entries[e],3e3)})),()=>{r.result||(r.callbacks=r.callbacks.filter(e=>e!==n),r.callbacks.length||(r.cancel(),delete this.entries[e]))}}},t.aM=function(e){if("provider"in e&&!e.provider)return null;let t=e.provider;if(!t&&"url"in e&&e.url&&(t=function(e){try{const t=new URL(e).pathname.split("/").pop()||"",i=t.lastIndexOf(".");return i>=0?t.slice(i+1):""}catch{return""}}(e.url)),!t)return null;const i=pt.TILE_PROVIDER_URLS[t];if(!i)return null;let n;try{n=new URL(i,pt.API_URL).href}catch(e){return new Error(`TileProvider "${t}" has an invalid URL: "${i}"`)}return{name:t,url:n}},t.aN=function(e,t,i,n,r){const s=function(i,n){if(i)return r(i);if(n){e.url&&n.tiles&&e.tiles&&delete e.tiles;const i=Xb(e,n,t);if(i instanceof Error)return r(i);r(null,i)}},o=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const s=n.every(e=>e===t),o=r.every(e=>e===i);return s&&o?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(e.data,i,n);return o?At.frame(()=>s(null,o)):e.url?Jt(t.transformRequest(t.normalizeSourceURL(e.url,null,i,n),Ht.Source),s):At.frame(()=>{const{data:t,...i}=e;s(null,i)})},t.aO=function(e,t){const i=e.url&&!e.tiles?t.transformRequest(e.url,Ht.Source):void 0;return{request:i,options:i?Object.assign({},e,{url:i.url}):e}},t.aP=function(e,t,i){return t?Xb(e,t,i):e.tiles&&e.tiles.length>0?{tiles:e.tiles}:new Error('TileJSON is missing required "tiles" property')},t.aQ=function(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom},t=>{const n=Kt(e.request,(e,n,r)=>{e?qt(e)?t(null,null):t(e):n&&t(null,{rawData:n,vectorTile:i?void 0:new gu(new Z_(n)),responseHeaders:new Map(r.entries())})});return()=>{n.cancel(),t(null,null)}},t)},t.aR=function(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}},t.aS=function(e){Ft++,Ft>Lt&&(e.getActor().send("enforceCacheSizeLimit",Pt),Ft=0)},t.aT=async function(e,t){const i=Zb.get(e);if(i)return i;const n=$b.get(e);if(void 0!==n)return n;const r=import(t).catch(t=>{throw new Error(`TileProvider "${e}" failed to load: ${t instanceof Error?t.message:String(t)}`)}).then(t=>{const i=t.default;if("function"!=typeof i)throw new Error(`TileProvider "${e}" module must default-export a class`);if("function"!=typeof i.prototype.loadTile)throw new Error(`TileProvider "${e}" class must have a loadTile method`);return Zb.set(e,i),i}).finally(()=>{$b.delete(e)});return $b.set(e,r),r},t.aU=hh,t.aV=Jx,t.aW=sb,t.aX=Vc,t.aY=$x,t.aZ=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t<e.length;t++){const n=document.createElement("source");Qt(e[t])||(i.crossOrigin="Anonymous"),n.src=e[t],i.appendChild(n)}return{cancel:()=>{}}},t.a_=Fm,t.aa=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return it(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xi(e.x,t.x,i),y:xi(e.y,t.y,i),z:xi(e.z,t.z,i),azimuthal:xi(e.azimuthal,t.azimuthal,i),polar:xi(e.polar,t.polar,i)}}},t.ab=la,t.ac=io,t.ad=tu,t.ae=H,t.af=A,t.ag=Ue,t.ah=ga,t.ai=kh,t.aj=xi,t.ak=Qn,t.al=Ei,t.am=Oe,t.an=We,t.ao=je,t.ap=class{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},Xe(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new qb}send(e,t,i,n,r=!1,s){const o=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=s,this.callbacks[o]=i);const a=new Set;return this.target.postMessage({id:o,type:e,hasCallback:!!i,targetMapId:n,mustQueue:r,sourceMapId:this.mapId,data:uo(t,a)},a),{cancel:()=>{i&&delete this.callbacks[o],this.target.postMessage({id:o,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||nt(self)){const e=this.callbacks[i],n=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],"<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(ho(t.error)):i(null,ho(t.data)))}else{const i=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?uo(t):null,data:uo(n,i)},i)}:()=>{},r=ho(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:s}=r;this.parent.getWorkerSource(t.sourceMapId,{type:e[0],source:i,scope:s,uid:0})[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.aq=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=it([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xi(e.x,t.x,i),y:xi(e.y,t.y,i),z:xi(e.z,t.z,i)}}},t.ar=function(e,t,i=0,n=!0){const r=new Ae(i,i),s=e.sub(r),o=t.add(r),a=[s,new Ae(o.x,s.y),o,new Ae(s.x,o.y)];return n&&a.push(s.clone()),a},t.as=function(e,t){const i=[];for(let n=0;n<e.length;n++){const r=Ve(n-1,-1,e.length-1),s=Ve(n+1,-1,e.length-1),o=e[n],a=e[s],l=e[r].sub(o).unit(),c=a.sub(o).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));i.push(o.add(h))}return i},t.at=Kv,t.au=Qu,t.av=function(e,t,i=0){return M(((t.x-i)*e.scale-e.x)*Qn,(t.y*e.scale-e.y)*Qn,Zc(t.z,t.y))},t.aw=Z,t.ax=U,t.ay=Au,t.az=m_,t.b=function(e){return pt.API_FONTS_REGEX.test(e)},t.b$=cc,t.b0=Xe,t.b1=Kw,t.b2=Z_,t.b3=class{constructor(e,t,i,n,r,s){this.tileID=e,this.uid=We(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection),this.worldview=s,this._hasAppearances=null}registerFadeDuration(e){const t=e+this.timeAdded;t<At.now()||void 0!==this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Jv(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=Fb(e.buckets,t.style),this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!e.hasTunnelGeometry;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Rx){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Rx&&t.hasRTLText){this.hasRTLText=!0,aa();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e],n=t.style.getOwnLayer(e);if(!n)continue;const r=n.queryRadius(i)||0;this.queryPadding=Math.max(this.queryPadding,r)}e.imageAtlas&&(this.imageAtlas=t.style.imageManager.imageAtlasCache.getOrCache(e.imageAtlas)),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new kl}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets=Object.assign({},this.buckets,Fb(e.buckets,t.style)),e.featureIndex&&(this.latestFeatureIndex=e.featureIndex))}getBucket(e){return this.buckets[e.fqid]}upload(e,t){for(const i in this.buckets){const n=this.buckets[i];if(n.uploadPending()){let i={},r=[],s={zoom:0,pitch:0,brightness:0,worldview:""};if(t){if(t.style){r=t.style.listImages();const e=n.layers[0],s=e.sourceLayer||"_geojsonTileLayer",o=t.style.getLayerSourceCache(e);o&&(i=o._state.getState(s,void 0))}s={zoom:t.transform.zoom||0,pitch:t.transform.pitch||0,brightness:t.style.getBrightness()||0,worldview:t.worldview||""}}n.upload(e,this.tileID.canonical,i,r,s)}}const i=e.gl,n=this.imageAtlas;!n||this.imageAtlasTexture&&n.uploaded||(this.imageAtlasTexture=null,this.imageAtlasTexture=t.style.imageManager.imageAtlasCache.getTextureForAtlas(n,e,i.RGBA8),n.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Bm(e,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Bm(e,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&t){const n=t.style.getLut(i);this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i,n)}if(!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=t.style.getBrightness(),r=t.style.listImages(),s=r.length,o=t.style._changes.getUpdatedPaintProperties(),a=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>o.has(e.fqid))),l=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>e.hasTransition&&e.hasTransition())),c=this._firstPrepareComplete&&s!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t));const u=this._lastUpdatedBrightness!==n;this._lastAvailableImagesCount=s,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||n||this._hasAppearances||a||l||c)&&(!(this._hasAppearances||a||l||c)&&this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)<.001||(this.updateBuckets(t,u,void 0,c||a||l,o,r),this._lastUpdatedBrightness=n))}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const i=this.buckets[t];i.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,i.evaluateQueryRenderedFeaturePadding()))}return e}queryRenderedFeatures(e,t,i,n,r,s,o){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const a=this.evaluateQueryRenderedFeaturePadding(),l=function(e,t){const i=v([],[.5*e.width,.5*-e.height,1]);return p(i,i,[1,-1,0]),d(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}(r,this.tileID);return this.latestFeatureIndex.query(e,{tilespaceGeometry:t,pixelPosMatrix:l,transform:n,availableImages:i,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:a,scope:o})}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),r=t?t.sourceLayer:"",s=n._geojsonTileLayer||n[r];if(!s)return;const o=Ea(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;t<s.length;t++){const n=s.feature(t);if(o.needGeometry){const e=uu(n,!0);if(!o.filter(new la(this.tileID.overscaledZ,{worldview:this.worldview}),e,this.tileID.canonical))continue}else if(!o.filter(new la(this.tileID.overscaledZ,{worldview:this.worldview}),n))continue;const h=i.getId(n,r),d=new Eb(n,a,l,c,h);d.tile=u,e.push(d)}}loaded(){return"loaded"===this.state||"errored"===this.state}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=rt(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const n=this.expirationTime-t;n?this.expirationTime=e+Math.max(n,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-Date.now(),Math.pow(2,31)-1)}refreshFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!e)return;const i=e.style.listImages();this.updateBuckets(e,!1,t,void 0,void 0,i)}hasAppearances(e){for(const t in this.buckets)if(e.style.hasLayer(t)&&this.buckets[t].layers.some(e=>e.appearances&&e.appearances.length>0))return!0;return!1}updateBuckets(e,t,i,n,r,s){if(!this.latestFeatureIndex)return;if(!e.style)return;const o=s||e.style.listImages(),a=e.style.getBrightness(),l=r||new Set;for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const s=this.buckets[r],c=s.layers[0],u=c.sourceLayer||"_geojsonTileLayer",h=e.style.getLayerSourceCache(c),d=s.layers.some(e=>l.has(e.fqid)),p=(n||d)&&s instanceof Rx?e.style.getOwnLayer(r):void 0;let f=i&&i[u]||{};h&&!i&&(f=h._state.getState(u,void 0));const m=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},g=Object.keys(f).length>0&&!t;s.hasAppearances=s.layers.some(e=>e.appearances&&e.appearances.length>0);const _=g?s.stateDependentLayers:s.layers;if(g&&0!==s.stateDependentLayers.length||t||d||n){const i=this.latestFeatureIndex.loadVTLayers()[u];if(s.update(f,i,o,m,_,t,a,this.tileID.canonical),(n||d)&&(!t||t&&s instanceof Rx&&(!s.text.uboBinder||s.text.uboBinder.isLightConstant||!s.icon.uboBinder||s.icon.uboBinder.isLightConstant))&&s instanceof Rx&&p&&"symbol"===p.type){const e=s;e.text&&e.text.uboBinder&&e.text.uboBinder.updateDynamicExpressions(p,i,this.tileID.canonical,o,f,a),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.updateDynamicExpressions(p,i,this.tileID.canonical,o,f,a)}if(s instanceof Rx){const t=s,i=e.context;t.text&&t.text.uboBinder&&t.text.uboBinder.upload(i),t.icon&&t.icon.uboBinder&&t.icon.uboBinder.upload(i)}}if(g&&0!==s.stateDependentLayers.length||t||s.hasAppearances){const t={zoom:e.transform.zoom,pitch:e.transform.pitch,brightness:e.style.getBrightness()||0,worldview:e.worldview},i=s.updateAppearances(this.tileID.canonical,f,o,t,e.imageManager,g&&0!==s.stateDependentLayers.length);if(i&&i.hasUboChanges){const t=e.context;s instanceof Rx&&s.text&&s.text.uboBinder&&s.text.uboBinder.upload(t),s instanceof Rx&&s.icon&&s.icon.uboBinder&&s.icon.uboBinder.upload(t)}}(s instanceof h_||s instanceof Op)&&e._terrain&&e._terrain.enabled&&h&&s.uploadPending()&&e._terrain._clearRenderCacheForTile(h.id,this.tileID);const y=e&&e.style&&e.style.getOwnLayer(r);y&&(this.queryPadding=Math.max(this.queryPadding,y.queryRadius(s)||0))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<At.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=At.now()+e}setTexture(e,t){const i=t.context,n=i.gl;this.texture=this.texture||t.getTileTexture(e.width),this.texture&&this.texture instanceof Bm?this.texture.update(e):(this.texture=new Bm(i,e,n.RGBA8,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=cu(Wb,this.tileID.canonical,this.tileTransform)[0],n=new el,r=new Rl;for(let e=0;e<i.length;e++){const{x:t,y:s}=i[e];n.emplaceBack(t,s),r.emplaceBack(e)}r.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(r),this._tileDebugBuffer=e.createVertexBuffer(n,_h.members),this._tileDebugSegments=Ql.simpleSegment(0,0,n.length,r.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=cu(Wb,this.tileID.canonical,this.tileTransform)[0];let n,r;if(this.isRaster){const e=function(e,t){const i=Jv(e,t),n=Math.pow(2,e.z);for(let r=0;r<kb;r++)for(let s=0;s<kb;s++){const o=Xc((e.x+(s+Gb(s))/Nb)/n),a=$c((e.y+(r+Gb(r))/Nb)/n),l=t.project(o,a),c=r*kb+s;Ub[2*c+0]=Math.round((l.x*i.scale-i.x)*Qn),Ub[2*c+1]=Math.round((l.y*i.scale-i.y)*Qn)}Vb.fill(0),jb.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=zb[t+0],n=zb[t+1],r=zb[t+2],s=zb[t+3],o=i+r>>1,a=n+s>>1,l=o+a-n,c=a+i-o,u=n*kb+i,h=s*kb+r,d=a*kb+o,p=Math.hypot((Ub[2*u+0]+Ub[2*h+0])/2-Ub[2*d+0],(Ub[2*u+1]+Ub[2*h+1])/2-Ub[2*d+1])>=16;Vb[d]=Vb[d]||(p?1:0),e<1022&&(Vb[d]=Vb[d]||Vb[(n+c>>1)*kb+(i+l>>1)]||Vb[(s+c>>1)*kb+(r+l>>1)])}const r=new il,s=new wl;let o=0;function a(e,t){const i=t*kb+e;return 0===jb[i]&&(r.emplaceBack(Ub[2*i+0],Ub[2*i+1],e*Qn/Nb,t*Qn/Nb),jb[i]=++o),jb[i]-1}function l(e,t,i,n,r,o){const c=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-o)>1&&Vb[u*kb+c])l(r,o,e,t,c,u),l(i,n,r,o,c,u);else{const l=a(e,t),c=a(i,n),u=a(r,o);s.emplaceBack(l,c,u)}}return l(0,0,Nb,Nb,Nb,0),l(Nb,Nb,0,0,0,Nb),{vertices:r,indices:s}}(this.tileID.canonical,t);n=e.vertices,r=e.indices}else{n=new il,r=new wl;for(const{x:e,y:t}of i)n.emplaceBack(e,t,0,0);const e=pd(n.int16.subarray(0,4*n.length),void 0,4);for(let t=0;t<e.length;t+=3)r.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(n,Hx.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(r),this._tileBoundsSegments=Ql.simpleSegment(0,0,n.length,r.length)}_makeGlobeTileDebugBuffers(e,t){const i=t.projection;if(!i||"globe"!==i.name||t.freezeTileCoverage)return;const n=this.tileID.canonical,r=Oh(Eh(n,t)),s=kh(t.zoom);let o;s>0&&(o=h(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,n,t,r,o,s),this._makeGlobeTileDebugTextBuffer(e,n,t,r,o,s)}_globePoint(e,t,i,n,r,s,o){let a=Ph(e,t,i);if(s){const r=1<<i.z,l=Hc(n.center.lng),c=Wc(n.center.lat),u=(i.x+.5)/r-l;let h=0;u>.5?h=-1:u<-.5&&(h=1);let d=(e/Qn+i.x)/r+h,p=(t/Qn+i.y)/r;d=(d-l)*n._pixelsPerMercatorPixel+l,p=(p-c)*n._pixelsPerMercatorPixel+c;const f=[d*n.worldSize,p*n.worldSize,0];H(f,f,s),a=Sh(a,f,o)}return H(a,a,r)}_makeGlobeTileDebugBorderBuffer(e,t,i,n,r,s){const o=new el,a=new Rl,l=new tl,c=(e,c,u,h,d)=>{const p=(u-e)/(d-1),f=(h-c)/(d-1),m=o.length;for(let u=0;u<d;u++){const h=e+u*p,d=c+u*f;o.emplaceBack(h,d);const g=this._globePoint(h,d,t,i,n,r,s);l.emplaceBack(g[0],g[1],g[2]),a.emplaceBack(m+u)}},u=Qn;c(0,0,u,0,16),c(u,0,u,u,16),c(u,u,0,u,16),c(0,u,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(a),this._tileDebugBuffer=e.createVertexBuffer(o,_h.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(l,gh.members),this._tileDebugSegments=Ql.simpleSegment(0,0,o.length,a.length)}_makeGlobeTileDebugTextBuffer(e,t,i,n,r,s){const o=new el,a=new wl,l=new tl,c=25;a.reserve(32),o.reserve(c),l.reserve(c);const u=(e,t)=>c*e+t;for(let e=0;e<c;e++){const a=2048*e;for(let e=0;e<c;e++){const c=2048*e;o.emplaceBack(c,a);const u=this._globePoint(c,a,t,i,n,r,s);l.emplaceBack(u[0],u[1],u[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=u(e,t),n=u(e,t+1),r=u(e+1,t),s=u(e+1,t+1);a.emplaceBack(i,n,r),a.emplaceBack(r,n,s)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(a),this._tileDebugTextBuffer=e.createVertexBuffer(o,_h.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(l,gh.members),this._tileDebugTextSegments=Ql.simpleSegment(0,0,c,32)}destroy(e=!0){for(const t in this.buckets)this.buckets[t].destroy(e);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),e&&this.texture&&this.texture instanceof Bm&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof Bm&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}},t.b4=Kt,t.b5=qt,t.b6=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i},t.b7=Hb,t.b8=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.b9=Me,t.bA=u,t.bB=p,t.bC=V_,t.bD=Jp,t.bE=cf,t.bF=af,t.bG=lf,t.bH=uu,t.bI=K,t.bJ=by,t.bK=Ev,t.bL=kv,t.bM=iT,t.bN=D,t.bO=J,t.bP=ne,t.bQ=function(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=s*l+o*a,e[3]=o*l-s*a,e},t.bR=re,t.bS=at,t.bT=v,t.bU=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.bV=w,t.bW=function(e,t,i,n,r){var s=1/Math.tan(t/2);if(e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var o=1/(n-r);e[10]=(r+n)*o,e[14]=2*r*n*o}else e[10]=-1,e[14]=-2*n;return e},t.bX=function(e,t,i,n,r,s,o){var a=1/(t-i),l=1/(n-r),c=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(o+s)*c,e[15]=1,e},t.bY=qc,t.bZ=$c,t.b_=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},t.ba=h,t.bb=c,t.bc=_,t.bd=l,t.be=function(e,t){const{x:i,y:n}=e.point,r=Nh(i,n,e.worldSize/e._pixelsPerMercatorPixel,0,0);return d(r,r,Dh(Th(t)))},t.bf=r,t.bg=X,t.bh=F,t.bi=B,t.bj=j,t.bk=V,t.bl=Ry,t.bm=uy,t.bn=Ly,t.bo=function(e,t,i,n,r){const s=5*t+2;e.float32[s+0]=i,e.float32[s+1]=n,e.float32[s+2]=r},t.bp=Mx,t.bq=oo,t.br=de,t.bs=ge,t.bt=fe,t.bu=we,t.bv=Ve,t.bw=function(e,t,i,r){var s=new n(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s},t.bx=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,n=1<<i,r=Math.floor(e.x),s=Math.floor((e.x-r)*n),o=Math.floor(e.y*n),a=this.findDEMTileFor(new hh(i,r,i,s,o));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const n=this._source();if(!n)return t;if(e.y<0||e.y>1)return t;const r=n.getSource().maxzoom,s=1<<r,o=Math.floor(e.x),a=e.x-o,l=new hh(r,o,r,Math.floor(a*s),Math.floor(e.y*s)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,d=(a*h-c.tileID.canonical.x)*u.dim,p=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(d),m=Math.floor(p);return(i?this.exaggeration():1)*xi(xi(u.get(f,m),u.get(f,m+1),p-m),xi(u.get(f+1,m),u.get(f+1,m+1),p-m),d-f)}static getAtTileOffset(e,t,i,n){const r=1<<e.canonical.z;return n?n.pointElevation(t):i?i.getAtPointOrZero(new tu(e.wrap+(e.canonical.x+t.x/Qn)/r,(e.canonical.y+t.y/Qn)/r)):0}static getAtTileOffsetFunc(e,t,i,n){return(r,s,o)=>{const a=this.getAtTileOffset(e,r,s,o),l=n.upVector(e.canonical,r.x,r.y);return D(l,l,a*n.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,n){if(this.isUsingMockSource())return!1;const r=hb.create(this,e,n);return!!r&&(t.forEach(e=>{e[2]=this.exaggeration()*r.getElevationAt(e[0],e[1],i,!0)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,n=t.tileID,r=1<<e.canonical.z-n.canonical.z;let s=e.canonical.x/r-n.canonical.x,o=e.canonical.y/r-n.canonical.y,a=0;for(let t=0;t<e.canonical.z-n.canonical.z&&!i.leaves[a];t++){s*=2,o*=2;const e=2*Math.floor(o)+Math.floor(s);a=i.childOffsets[a]+e,s%=1,o%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,i=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const r of e){const e=this.getMinMaxForTile(r.tileID);e&&(i=Math.min(i,e.min),n=Math.max(n,e.max),t=!0)}return t?{min:i,max:n}:null}},t.by=Qf,t.bz=Vu,t.c=yt,t.c$=Rm,t.c0=dc,t.c1=uc,t.c2=hc,t.c3=gc,t.c4=vx,t.c5=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},t.c6=$,t.c7=function(e){var t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)},t.c8=ce,t.c9=q,t.cA=qm,t.cB=T,t.cC=Hm,t.cD=function(e){const t=Hm(e,!0);return r([],[t[0],t[1],t[4],t[5]])},t.cE=f,t.cF=Mu,t.cG=m,t.cH=function(e,t){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},t.cI=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return Nh(t,i,e.worldSize,n,r)},t.cJ=L,t.cK=y,t.cL=De,t.cM=eh,t.cN=5,t.cO=function(e,t,i){let n=0;for(let i=0;i<2;++i){const r=0;e[i]>r&&(n+=(e[i]-r)*(e[i]-r)),t[i]<r&&(n+=(r-t[i])*(r-t[i]))}return n},t.cP=function(e){return e*e*e*e*e},t.cQ=Gc,t.cR=45,t.cS=fc,t.cT=function(e,t,i){const n=Math.sqrt(e*e+t*t+i*i),r=n>0?Math.acos(i/n)*Ce:0;let s=0!==e||0!==t?Math.atan2(-t,-e)*Ce+90:0;return s<0&&(s+=360),[n,s,r]},t.cU=M,t.cV=it,t.cW=eu,t.cX=C,t.cY=Du,t.cZ=P,t.c_=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},t.ca=uh,t.cb=3,t.cc=2,t.cd=7,t.ce=6,t.cf=G,t.cg=S,t.ch=E,t.ci=0,t.cj=1,t.ck=4,t.cl=5,t.cm=dh,t.cn=Ou,t.co=Wm,t.cp=ch,t.cq=Mh,t.cr=function(e,t,i,n,r,s,o,a,l){if("globe"===l.name)return Mh(e,t,new ch(i,n,r),!1);const c=Jv({z:i,x:n,y:r},l);return new Du([(s+c.x/c.scale)*t,t*(c.y/c.scale),o],[(s+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},t.cs=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e[3]=Math.min(t[3],i[3]),e},t.ct=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e},t.cu=function(e){const t=Math.round((e+45+360)%360/90)%4;return Be[t]},t.cv=Yc,t.cw=Q,t.cx=6,t.cy=function(e){const t=u(new Float64Array(16));d(t,e.pixelMatrix,e.globeMatrix);const i=[0,Bc,0],n=[0,Fc,0];return H(i,i,t),H(n,n,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Uh(e,new Vc(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Uh(e,new Vc(e.center.lat,-90))]},t.cz=function(e,t){const{scale:i}=e.tileTransform,n=i*Qn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z)),r=t.inverseAdjustmentMatrix;return new Float32Array([r[0]*n,r[1]*n,r[2]*n,r[3]*n])},t.d=function(e){return pt.API_TILEJSON_REGEX.test(e)},t.d$=qe,t.d0=Sg,t.d1=rg,t.d2=Gu,t.d3=class{static calculate(e,t,i){const n=new Set,r=new Map,s=new Set,o=new Set;for(const i of Object.values(e))for(const[e,a]of Object.entries(i.floors)){s.add(e),a.isDefault&&o.add(e),a.conflicts&&r.set(e,a.conflicts);const i=e===t,l=a.connections&&t&&a.connections.has(t);(i||l)&&n.add(e)}const a=e=>{const t=r.get(e)||new Set;for(const i of n)if((r.get(i)||new Set).has(e)||t.has(i))return!0;return!1};if(i)for(const e of i)s.has(e)&&(a(e)||n.add(e));for(const e of o)n.has(e)||a(e)||n.add(e);return n}},t.d4=av,t.d5=ov,t.d6=Xt,t.d7=function(){return{API_URL:pt.API_URL,DRACO_URL:pt.DRACO_URL,MESHOPT_URL:pt.MESHOPT_URL,MESHOPT_SIMD_URL:pt.MESHOPT_SIMD_URL,BUILDING_GEN_URL:pt.BUILDING_GEN_URL}},t.d8=ta,t.d9=It,t.dA=_h,t.dB=Ql,t.dC=ad,t.dD=yh,t.dE=el,t.dF=wl,t.dG=function(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},t.dH=s,t.dI=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},t.dJ=W,t.dK=Fh,t.dL=ut,t.dM=ht,t.dN=Zx,t.dO=function(e,t){const i=[0,0,0];return H(i,i,Oh(Th(t.canonical))),H(i,i,e),i},t.dP=e=>({u_matrix:new gc(e),u_texsize:new hc(e),u_pixels_to_tile_units:new _c(e),u_device_pixel_ratio:new uc(e),u_width_scale:new uc(e),u_floor_width_scale:new uc(e),u_image:new cc(e),u_units_to_pixels:new hc(e),u_tile_units_to_pixels:new uc(e),u_alpha_discard_threshold:new uc(e),u_trim_offset:new hc(e),u_trim_fade_range:new hc(e),u_trim_gradient_mix_range:new hc(e),u_trim_color:new fc(e),u_zbias_factor:new uc(e),u_tile_to_meter:new uc(e),u_ground_shadow_factor:new dc(e),u_pattern_transition:new uc(e)}),t.dQ=e=>({u_matrix:new gc(e),u_pixels_to_tile_units:new _c(e),u_device_pixel_ratio:new uc(e),u_width_scale:new uc(e),u_floor_width_scale:new uc(e),u_units_to_pixels:new hc(e),u_dash_image:new cc(e),u_gradient_image:new cc(e),u_image_height:new uc(e),u_texsize:new hc(e),u_tile_units_to_pixels:new uc(e),u_alpha_discard_threshold:new uc(e),u_trim_offset:new hc(e),u_trim_fade_range:new hc(e),u_trim_gradient_mix_range:new hc(e),u_trim_color:new fc(e),u_zbias_factor:new uc(e),u_tile_to_meter:new uc(e),u_ground_shadow_factor:new dc(e)}),t.dR=e=>({u_camera_to_center_distance:new uc(e),u_extrude_scale:new _c(e),u_device_pixel_ratio:new uc(e),u_matrix:new gc(e),u_inv_rot_matrix:new gc(e),u_merc_center:new hc(e),u_tile_id:new dc(e),u_zoom_transition:new uc(e),u_up_dir:new dc(e),u_emissive_strength:new uc(e)}),t.dS=xl,t.dT=F_,t.dU=class{constructor(e,t,i,n){this.context=e,this.format=n,this.size=i,this.texture=e.gl.createTexture();const[r,s,o]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,r,s,o,0,Om(this.format),Dm(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},t.dV=Wh,t.dW=(e,t,i,n,r,s)=>{const o=e.transform,a="globe"===o.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(a){const e=Fh(o.zoom,t.canonical)*o._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=o.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([o.pixelsToGLUnits[0],0,0,o.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(o.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:At.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Hh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=kh(o.zoom);const e=r[0]*Qn,i=r[1]*Qn;c.u_up_dir=o.projection.upVector(new ch(0,0,0),e,i)}return c},t.dX=v_,t.dY=Yi,t.dZ=(e,t,i,n,r,s,o,a,l,c)=>{const u=e.transform,h=u.pitch<15?g_(.07,.7,ze((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:y_(e,t,i,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:r,u_width_scale:s,u_floor_width_scale:o,u_image:0,u_tile_units_to_pixels:__(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:eu(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}},t.d_=(e,t,i,n,r,s,o,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?g_(.07,.7,ze((14-u.zoom)/5,0,1)):.07;return{u_matrix:y_(e,t,i,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:s,u_width_scale:o,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:x_(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:__(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:p,u_tile_to_meter:eu(t.tileID.canonical,0),u_ground_shadow_factor:c}},t.da=ui,t.db=Ye,t.dc=function(e){const t=e.indexOf(Na);return t>=0?e.slice(0,t):e},t.dd=Jg,t.de=function(e){return e.includes(Na)},t.df=function(e){const t=e.lastIndexOf(Na);return t>=0?e.slice(t+1):""},t.dg=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},t.dh=function(e,t,i,n){return"custom"===e.type?new ob(e,t):new Cb[e.type](e,t,i,n)},t.di=Ze,t.dj=Ea,t.dk=za,t.dl=class extends Eb{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer)}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},t.dm=na,t.dn=function(e){return e({pluginStatus:Qo,pluginURL:ea}),na.on("pluginStateChange",e),e},t.dp=mc,t.dq=class extends lc{constructor(e){super(e),this.current=new Float32Array(9)}set(e,t,i){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<9;e++)if(i[e]!==n[e]){n.set(i),this.gl.uniformMatrix3fv(this.location,!1,n);break}}},t.dr=Fe,t.ds=function(e,t,i){const n=kh(i.zoom),r=e.style.map._antialias,s=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!s},t.dt=function(e){const t=e.pixelsPerMeter,i=t/qc(1,e.center.lat),n=u(new Float64Array(16));return p(n,n,[e.point.x,e.point.y,0]),f(n,n,[i,i,t]),Float32Array.from(n)},t.du=Ih,t.dv=function(e){const t=80.051129;e=ze(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Oe(e))),3);return Math.round(i*(Dc.length-1))},t.dw=function(e,t,i,n){const r=t.getNorth(),s=t.getSouth(),o=t.getWest(),l=t.getEast(),c=1<<e.z,u=l-o,h=r-s,d=u/Oc,p=-h/Dc[i],f=[0,d,0,p,0,0,r,o,0];if(e.z>0){const e=180/n;a(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.dx=Oh,t.dy=Th,t.dz=function(e,t,i){const n=u(new Float64Array(16)),r=(t/(1<<e)-.5)*Math.PI*2;return g(n,i.globeMatrix,r),Float32Array.from(n)},t.e=function(e){return 0===e.indexOf("mapbox:")},t.e$=$m,t.e0=ld,t.e1=Zc,t.e2=ph,t.e3=Of,t.e4=jf,t.e5=yf,t.e6=450,t.e7=7,t.e8=Kc,t.e9=function(e,t){if(e===t){var i=t[1],n=t[2],r=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=r,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},t.eA=function(e,t){var n=2*Math.acos(t[3]),r=Math.sin(n/2);return r>i?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},t.eB=Mb,t.eC=ng,t.eD=Qm,t.eE=[1,1,1],t.eF=hb,t.eG=function(e,t,i,n){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=s+n*(i[1]-s),e[2]=o+n*(i[2]-o),e[3]=a+n*(i[3]-a),e},t.eH=ig,t.eI=_l,t.eJ=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ae(1/0,1/0),max:new Ae(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=nf(new Ae(0,0),new Ae(Qn,Qn),e),n=[];if(t&&!ef(i,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!ef(i,t))continue;const r=rf(t.min,t.max,e);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(i).buckets[e.layer];n&&n.updateFootprints(i.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),n=e.getClipMask(),r=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=nf(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Kp(e.min,t.min)||Kp(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[t];e=i.priority!==n.priority||!Qp(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Me(i.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Zp&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e<t.length&&t[e].priority===i;)++e;return e};if(this._sourceIds.length>1){let t=0,i=e(t);for(;t!==i;){let n=t;const r=t;for(;n!==i;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t<r;t++){const i=this._activeRegions[t];if(!i.hiddenByOverlap&&e.order===Zp&&ef(e,i)&&(e.hiddenByOverlap=of(e.footprint,e.tileId,i.footprint,i.tileId),e.hiddenByOverlap))break}++n}t=i,i=e(t)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement()}},t.eK=il,t.eL=Hx,t.eM=Rl,t.eN=Zp,t.eO=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const i=new el,n=new wl,r=[],s=e+1+2,o=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let n=e===s-1?e-2:0===e?e:e-1;return n+=i?24575:0,[n,t]};for(let e=0;e<s;++e)i.emplaceBack(...l(e,0,!0));for(let e=0;e<o;++e)for(let t=0;t<s;++t)i.emplaceBack(...l(t,e,(0===t||t===s-1)&&!0));for(let e=0;e<t.length;++e){const n=t[e];for(let e=0;e<s;++e)i.emplaceBack(...l(e,n,!0))}for(let e=0;e<t.length;++e){const o=n.length,l=t[e]+1+2,c=new wl;for(let i=0;i<l-1;i++){const r=i===l-2,o=r?s*(a-t.length+e-i):s;for(let e=0;e<s-1;e++){const t=i*s+e;0===i||r||0===e||e===s-2?(c.emplaceBack(t+1,t,t+o),c.emplaceBack(t+o,t+o+1,t+1)):(n.emplaceBack(t+1,t,t+o),n.emplaceBack(t+o,t+o+1,t+1))}}const u=Ql.simpleSegment(0,o,i.length,n.length-o);for(let e=0;e<c.uint16.length;e+=3)n.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const h=Ql.simpleSegment(0,o,i.length,n.length-o);r.push({withoutSkirts:u,withSkirts:h})}return{vertices:i,indices:n,segments:r}}_createGrid(e){const t=this._fillGridMeshWithLods(Oc,Dc);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,_h.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0)}_createPoles(e){const t=new wl;for(let e=0;e<=Oc;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new Al,n=new Al,r=new Al,s=new Al;this._poleSegments=[];for(let e=0,t=0;e<6;e++){const o=360/(1<<e);i.emplaceBack(0,-Rc,0,.5,0),n.emplaceBack(0,-Rc,0,.5,1),r.emplaceBack(0,-Rc,0,.5,.5),s.emplaceBack(0,-Rc,0,.5,.5);for(let e=0;e<=Oc;e++){let t=e/Oc,a=0;const l=xi(0,o,t),[c,u,h]=Nc(jh,Gh,l,Rc);i.emplaceBack(c,u,h,t,a),n.emplaceBack(c,u,h,t,1-a);const d=Oe(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),r.emplaceBack(c,u,h,t,a),s.emplaceBack(c,u,h,t,1-a)}this._poleSegments.push(Ql.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,mh,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(n,mh,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(r,mh,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(s,mh,!1)}getGridBuffers(e,t){return[this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return[t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},t.eP=Yp,t.eQ=Ne,t.eR=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},t.eS=ke,t.eT=Qc,t.eU=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},t.eV=Y,t.eW=kc,t.eX=k,t.eY=I,t.eZ=function([e,t,i]){const n=Math.hypot(e,t,i),r=Math.atan2(e,i),s=.5*Math.PI-Math.acos(-t/n);return new Vc(De(r),De(s))},t.e_=ee,t.ea=Ka,t.eb=Bl,t.ec=256,t.ed=function(e){return e>>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296},t.ee=Pl,t.ef=Is,t.eg=zc,t.eh=Cl,t.ei=Il,t.ej=Yx,t.ek=Eh,t.el=Dh,t.em=cl,t.en=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-i,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=i,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.eo=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=i,e[7]=0,e[8]=0,e[9]=-i,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.ep=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},t.eq=Al,t.er=Ml,t.es=function(e,t,i,n,r){return ze((e-t)/(i-t)*(r-n)+n,n,r)},t.et=se,t.eu=function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=-u*s+a*l,p=c*s-o*l,f=i*h+n*d+r*p;return f?(e[0]=h*(f=1/f),e[1]=(-u*n+r*c)*f,e[2]=(a*n-r*o)*f,e[3]=d*f,e[4]=(u*i-r*l)*f,e[5]=(-a*i+r*s)*f,e[6]=p*f,e[7]=(-c*i+n*l)*f,e[8]=(o*i-n*s)*f,e):null},t.ev=2,t.ew=z,t.ex=ie,t.ey=b,t.ez=function(e,t){var i=new n(3);b(i,t);var r=1/i[0],s=1/i[1],o=1/i[2],a=t[0]*r,l=t[1]*s,c=t[2]*o,u=t[4]*r,h=t[5]*s,d=t[6]*o,p=t[8]*r,f=t[9]*s,m=t[10]*o,g=a+h+m,_=0;return g>0?(_=2*Math.sqrt(g+1),e[3]=.25*_,e[0]=(d-f)/_,e[1]=(p-c)/_,e[2]=(l-u)/_):a>h&&a>m?(_=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/_,e[0]=.25*_,e[1]=(l+u)/_,e[2]=(p+c)/_):h>m?(_=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/_,e[0]=(l+u)/_,e[1]=.25*_,e[2]=(d+f)/_):(_=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/_,e[0]=(p+c)/_,e[1]=(d+f)/_,e[2]=.25*_),e},t.f=_t,t.f0=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==ot){const t=e.navigator?e.navigator.userAgent:null;ot=!!e.safari||!(!t||!(Le.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ot}(e)&&!(!t||!(t.match("Version/15.4")||t.match("Version/15.5")||t.match(Re)))},t.f1=function(e,t){Pt=e,Lt=t},t.f2=Uh,t.f3=zh,t.f4=function(e){const t=[0,0,0],i=u(new Float64Array(16));return d(i,e.pixelMatrix,e.globeMatrix),H(t,t,i),new Ae(t[0],t[1])},t.f5=function(e,t){if(!e||!t)throw new Error("TileProvider name and URL are required");pt.TILE_PROVIDER_URLS[e]=At.resolveURL(t)},t.f6=ra,t.f7=function(e,t,i=!1){if(Qo===Jo.deferred||Qo===Jo.loading||Qo===Jo.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");ea=At.resolveURL(e),Qo=Jo.deferred,Ko=t,ia(),i||sa()},t.f8=gt,t.f9=mt,t.fA=h_,t.fB=gu,t.fC=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},t.fD=aw,t.fE=hu,t.fF=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Em){const i=new Uint32Array(e,0,7),[,,n,r,s,o]=i;t=i.byteLength+r+s+o+s,(n!==e.byteLength||t>=e.byteLength)&&Qe("Invalid b3dm header information.")}return Lm(e,t)},t.fG=function(e,t){const i=e.json.extensionsUsed&&e.json.extensionsUsed.includes("mbx_bvh"),n=Sg(e);for(const e of n){if(!i)for(const t of e.meshes)Eg(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(Mg(e.lights,t)))}return n},t.fH=xb,t.fI=nt,t.fJ=oa,t.fK=Jo,t.fL=function(e){Bt(),null!=Ot&&Ot.then(t=>{t.keys().then(i=>{for(let n=0;n<i.length-e;n++)t.delete(i[n]).catch(e=>Qe(e.message))}).catch(e=>Qe(e.message))}).catch(e=>Qe(e.message))},t.fa=ft,t.fb=function(e){const t=Dt();if(!t)return;const i=t.delete(Ct);e&&i.then(()=>e()).catch(e)},t.fc=lo,t.fd=sd,t.fe=2,t.ff=ur,t.fg=Jv,t.fh=kl,t.fi=Rb,t.fj=Ob,t.fk=a_,t.fl=yu,t.fm="hd_road_elevation",t.fn=Nu,t.fo=$e,t.fp=Op,t.fq=Hd,t.fr=$y,t.fs=1,t.ft=Rx,t.fu=function(e,t,i,n,r,s,o,a=1,l,c,u,h){e.createArrays(),e.tilePixelRatio=Qn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const d=e.layers[0].layout,p=e.layers[0]._unevaluatedLayout._values,f={};f.scaleFactor=a,f.textSizeScaleRange=d.get("text-size-scale-range"),f.iconSizeScaleRange=d.get("icon-size-scale-range");const[m,g]=f.textSizeScaleRange,[_,y]=f.iconSizeScaleRange;f.textScaleFactor=ze(f.scaleFactor,m,g),f.iconScaleFactor=ze(f.scaleFactor,_,y);const v=p["text-size"],x=p["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;f.compositeTextSizes=[v.possiblyEvaluate(new la(t,{worldview:u}),s),v.possiblyEvaluate(new la(i,{worldview:u}),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;f.compositeIconSizes=[x.possiblyEvaluate(new la(t,{worldview:u}),s,h),x.possiblyEvaluate(new la(i,{worldview:u}),s,h)]}f.layoutTextSize=v.possiblyEvaluate(new la(o+1,{worldview:u}),s),f.layoutIconSize=x.possiblyEvaluate(new la(o+1,{worldview:u}),s,h),f.textMaxSize=v.possiblyEvaluate(new la(18,{worldview:u}),s);const b=d.get("symbol-placement"),w="map"===d.get("text-rotation-alignment")&&"point"!==b,T=d.get("text-size");let S=!1;const E=[];for(const o of e.features){const a=d.get("text-font").evaluate(o,{},s).join(","),m=T.evaluate(o,{},s)*f.textScaleFactor,g=f.layoutTextSize.evaluate(o,{},s)*f.textScaleFactor,_=f.layoutIconSize.evaluate(o,{},s,h)*f.iconScaleFactor,y={horizontal:{},vertical:void 0},v=o.text;let x,A=[0,0];if(v){const n=v.toString(),c=d.get("text-letter-spacing").evaluate(o,{},s)*V_,u=d.get("text-line-height").evaluate(o,{},s)*V_,h=Vo(n)?c:0,p=d.get("text-anchor").evaluate(o,{},s),_=d.get("text-variable-anchor");if(!_){const e=d.get("text-radial-offset").evaluate(o,{},s);if(e)A=Ev(p,[e*V_,wv]);else{const e=d.get("text-offset").evaluate(o,{},s);A=[e[0]*V_,e[1]*V_]}}let x=w?"center":d.get("text-justify").evaluate(o,{},s);const T="point"===b,S=T?d.get("text-max-width").evaluate(o,{},s)*V_:1/0,E=s=>{e.allowVerticalPlacement&&Uo(n)&&(y.vertical=py(v,t,i,r,a,S,u,p,s,h,A,uy.vertical,!0,g,m,l,f.textScaleFactor))};if(!w&&_){const e="auto"===x?_.map(e=>kv(e)):[x];let n=!1;for(let s=0;s<e.length;s++){const o=e[s];if(!y.horizontal[o])if(n)y.horizontal[o]=y.horizontal[0];else{const e=py(v,t,i,r,a,S,u,"center",o,h,A,uy.horizontal,!1,g,m,l,f.textScaleFactor);e&&(y.horizontal[o]=e,n=1===e.positionedLines.length)}}E("left")}else{if("auto"===x&&(x=kv(p)),T||d.get("text-writing-mode").includes("horizontal")||!Uo(n)){const e=py(v,t,i,r,a,S,u,p,x,h,A,uy.horizontal,!1,g,m,l,f.textScaleFactor);e&&(y.horizontal[x]=e)}E(T?"left":x)}}let M,I,C,P,L,R,O=!1;const D=d.get("icon-text-fit").evaluate(o,{},s);if(o.icon&&o.icon.hasPrimary()){const t=Ov(o.icon,e.iconSizeData,p["icon-size"],s,e.zoom,o,l,f.iconScaleFactor,u,h);M=t.iconPrimary,C=t.iconSecondary;const i=M.toString();if(I=n.get(i),I&&(L=d.get("icon-offset").evaluate(o,{},s),R=d.get("icon-anchor").evaluate(o,{},s),x=Sy(r.get(i),C?r.get(C.toString()):void 0,L,R),O=I.sdf,void 0===e.sdfIcons?e.sdfIcons=I.sdf:e.sdfIcons!==I.sdf&&Qe("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(I.pixelRatio!==e.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),C){const e=C.toString();P=n.get(e)}}S=S||!(!o.icon||!o.icon.hasSecondary());const B=qv(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!B&&B.iconsInText);const F=g*f.textScaleFactor/V_,{defaultShapedIcon:N,verticallyShapedIcon:k}=zv(e,x,d,o,s,y,F,L,D);"none"!==D&&x&&(Ay(x)||My(x))&&(Lv(0,I,M,x,N,D,c,n,r),Lv(0,P,C,x,N,D,c,n,r),k&&(Lv(0,I,M,x,k,D,c,n,r),Lv(0,P,C,x,k,D,c,n,r))),x=N;const{iconBBox:z,iconVerticalBBox:U,textBBox:V,textVerticalBBox:j}=Av(e,x,k,d,o,s,_,L,f,r,R,y,g,A,h);E.push({feature:o,shapedTextOrientations:y,shapedText:B,shapedIcon:x,iconPrimary:M,iconSecondary:C,iconOffset:L,iconAnchor:R,verticallyShapedIcon:k,layoutTextSize:g,layoutIconSize:_,textOffset:A,isSDFIcon:O,iconTextFit:D,iconCollisionBounds:z,iconVerticalCollisionBounds:U,textCollisionBounds:V,textVerticalCollisionBounds:j})}return{featureData:E,sizes:f,hasAnySecondaryIcon:S,textAlongLine:w,symbolPlacement:b}},t.fv=Zy,t.fw=qy,t.fx=Yy,t.fy=Jy,t.fz=function(e,t,i,n,r,s,o,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of u){const{shapedIcon:i,verticallyShapedIcon:s,feature:u,shapedTextOrientations:m,shapedText:g,layoutTextSize:_,textOffset:y,isSDFIcon:v,iconPrimary:x,iconSecondary:b,iconTextFit:w,iconOffset:T,iconCollisionBounds:S,iconVerticalCollisionBounds:E,textCollisionBounds:A}=t;Bv(i,c.iconPositions,x,b),Bv(s,c.iconPositions,x,b),Fv(m,c.iconPositions),Dv(x,b,c.iconPositions),(g||i)&&Vv(e,u,m,i,s,l,d,_,0,y,v,n,r,o,a,h,w,T,p,f,S,E,A)}i&&e.generateCollisionDebugBuffers(s,e.collisionBoxArray,d.textScaleFactor)},t.g=pt,t.h=function(e,t){return Yt(Object.assign(e,{method:"GET"}),t)},t.i=function(e){return pt.API_STYLE_REGEX.test(e)&&!yt(e)},t.j=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},t.k=Nt,t.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},t.m=Jt,t.n=ii,t.o=At,t.p=function(e,t){return Yt(Object.assign(e,{method:"POST"}),t)},t.q=od,t.r=Et,t.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},t.t=ka,t.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},t.v=function(e){return!!e&&Pe.test(e)},t.w=Qe,t.x=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const i=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=i,e.uploaded=!1}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[i]of this.textures.entries()){const n=this.textureAccessTimes.get(i)||0;n<t&&(t=n,e=i)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(e){const t=this.cache.get(e.hash);if(t){const i=t.deref();if(i&&i.contentDescriptor&&this.isMipmapCompatible(e,i.contentDescriptor))return i}for(const[,t]of this.cache.entries()){const i=t.deref();if(i&&i.contentDescriptor){const t=e.subsetOf(i.contentDescriptor),n=this.isMipmapCompatible(e,i.contentDescriptor);if(t&&n)return i}}}getTextureForAtlas(e,t,i){this.textureAccessTimes.set(e,performance.now());let n=this.textures.get(e);if(n)return n;if(e.image){const r=this.calculateTextureMemory(e);return this.evictTexturesIfNeeded(r),n=new Bm(t,e.image,i,{useMipmap:!!e.patternPositions.size}),this.textures.set(e,n),this.textureMemoryUsed+=r,n}return null}clearExpiredTextures(){for(const[e]of this.textures.entries())if(!this.isAtlasCached(e)){const t=this.textures.get(e);if(t){const i=this.calculateTextureMemory(e);t.destroy(),this.textureMemoryUsed-=i}this.textures.delete(e),this.textureAccessTimes.delete(e)}}isAtlasCached(e){if(!e.contentDescriptor)return!1;const t=this.cache.get(e.contentDescriptor.hash);return!!t&&t.deref()===e}getOrCache(e){if(!("image"in e)){const t=this.cache.get(e.sourceAtlasHash);if(t){const e=t.deref();if(e)return e}return Qe("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!e.contentDescriptor)return e;const t=e.contentDescriptor,i=t.hash,n=this.cache.get(i);if(n){const e=n.deref();if(e&&e.contentDescriptor&&this.isMipmapCompatible(t,e.contentDescriptor))return e}return this.cache.set(i,new WeakRef(e)),this.finalizationRegistry.register(e,i,e),e}isMipmapCompatible(e,t){return!e.requiresMipMaps||t.requiresMipMaps}destroyTextures(){for(const e of this.textures.values())e&&e.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(const e of this.textures.values())e&&e.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}},t.y=di,t.z=hi}),n(["require","./shared"],function(e,t){function i(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function n(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${n(i)},`;return`${t}]`}let t="{";for(const i of Object.keys(e).sort())t+=`${i}:${n(e[i])},`;return`${t}}`}function r(e){let i="";for(const r of t.b8)i+=`/${n(e[r])}`;return i}function s(e,t){return function e(i){return"string"==typeof i&&i===t||(Array.isArray(i)?i.some(e):!(!i||"object"!=typeof i)&&Object.values(i).some(e))}(e)}class o{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e)}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t)}update(e,i,o){this._options=o;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.dh(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const a=function(e,t){const i=Object.create(null);for(let o=0;o<e.length;o++){const a=e[o];let l=t&&t[a.id];l||("symbol"===a.type?l=a.id:(l=r(a),"line"===a.type&&a.paint&&s(a.paint["line-width"],"line-progress")&&(l+=`/${n(a.paint["line-width"])}`))),t&&(t[a.id]=l);let c=i[l];c||(c=i[l]=[]),c.push(a)}const o=[];for(const e in i)o.push(i[e]);return o}(Object.values(this._layerConfigs),this.keyCache);for(const e of a){const t=e.map(e=>this._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]=Object.create(null));const s=i.sourceLayer||"_geojsonTileLayer";let o=r[s];o||(o=r[s]=[]),o.push(t)}}}const a=1*t.fe;class l{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?a:1,o={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};n.push(o),s[e]=o}}const{w:r,h:s}=t.F(n),o=new t.fd({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?a:1;t.fd.copy(s.bitmap,o,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=o,this.positions=i}}function c(e,t,i){e[t]?i&&(e[t].center=i):e[t]={floorIds:new Set,center:i||[0,0],floors:{}}}function u(e,t,i,n){for(const r of t)c(e,r),e[r].floors[i]=n,e[r].floorIds.add(i)}function h(e){return{id:e.properties.id.toString(),center:[e.properties.center_lon||0,e.properties.center_lat||0]}}function d(e,i){const n=e.properties.id.toString(),r=!!e.properties.is_default&&e.properties.is_default,s=e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,o=e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,a=e.properties.structure_ids?new Set(e.properties.structure_ids.toString().split(";")):new Set,l=e.properties.name.toString(),c=e.properties.z_index,u=function(e,i){const n=e.loadGeometry();if(!n||0===n.length)return;const r=n.map(n=>n.map(n=>t.ff(n,i,e.extent)));return 0===r.length?void 0:{type:"Polygon",coordinates:[r[0]]}}(e,i);return{id:n,isDefault:r,connections:s,conflicts:o,buildings:a,name:l,zIndex:c,geometry:u}}function p(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function f(e){return p(e,["type","id","name"])&&"structure"===e.properties.type}function m(e){return p(e,["type","id","name","z_index"])&&"floor"===e.properties.type}t.fc(l,"GlyphAtlas");class g{constructor(e){this.tileID=new t.aU(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.collectResourceTiming=!!e.request&&e.request.collectResourceTiming,this.promoteId=e.promoteId,this.renderSourceType=e.renderSourceType,this.tileTransform=t.fg(e.tileID.canonical,e.projection),this.projection=e.projection,this.worldview=e.worldview,this.localizableLayerIds=e.localizableLayerIds,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep,this.scaleFactor=e.scaleFactor,this.worldview=e.worldview,this.indoor=e.indoor}parse(e,i,n,r,s,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.fh;const a=new t.fi(Object.keys(e.layers).sort()),p=new t.fj(this.tileID,this.promoteId);p.bucketLayerIDs=[];const g={},y=new t.fk(256,256),v={featureIndex:p,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:y,availableImages:n,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(v.activeFloors=function(e,i,n,r){const s=i.indoorState.activeFloorsVisible;if(!i.sourceLayers)return s?i.indoorState.activeFloors:void 0;const o=function(e,i){if(!e)return t.w("No source layers defined in indoor specification"),i;if(0===e.size)return i;const n=e.difference(i);for(const e of n)t.w(`Missing source layer required in indoor specification: ${e}`);return i.intersection(i)}(i.sourceLayers,new Set(Object.keys(e.layers))),a=i.indoorState,l=function(e,i,n,r,s){const o={};for(const n of i){const i=e.layers[n];if(i)for(let e=0;e<i.length;e++){const t=i.feature(e);if(f(t)){const{id:e,center:i}=h(t);c(o,e,i);continue}if(m(t)){const e=d(t,s);u(o,e.buildings,e.id,e)}}else t.w(`indoor source layer not found: ${n}`)}return{buildings:o,activeFloors:t.d3.calculate(o,r,n)}}(e,o,a.activeFloors,a.selectedFloorId,r);return n.send("setIndoorData",l),s?l.activeFloors:void 0}(e,this.indoor,s,this.canonical));const x=[],b=i.familiesBySource[this.source];for(const i in b){const s=e.layers[i];if(!s)continue;let o=!1,l=!1,c=!1,u=!1;for(const e of b[i])"symbol"===e[0].type?o=!0:"fill-extrusion"===e[0].type?l=!0:c=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(this.renderSourceType===t.b7.Symbol&&!o)continue;if(this.renderSourceType===t.b7.FillExtrusion&&!l)continue;if(this.renderSourceType===t.b7.Other&&!c)continue;1===s.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=a.encode(i),d=[],f=this.localizableLayerIds&&this.localizableLayerIds.has(i);let m=!1;for(let e=0,n=0;e<s.length;e++){const r=s.feature(e),o=p.getId(r,i),a=r.properties?r.properties.worldview:null;if(f&&this.worldview&&"string"==typeof a)if("all"===a)r.properties.$localized=!0;else{if(!a.split(",").includes(this.worldview))continue;r.properties.$localized=!0,r.properties.worldview=this.worldview}!m&&r.properties&&Object.hasOwn(r.properties,t.fl)&&(m=!0),d.push({feature:r,id:o,index:n,sourceLayerIndex:h}),n++}m&&!v.elevationFeatures&&Object.hasOwn(e.layers,t.fm)&&(v.elevationFeatures=t.fn.parseFrom(e.layers[t.fm],this.canonical));for(const e of b[i]){const i=e[0];if(this.extraShadowCaster&&(!i.is3D()||"model"===i.type))continue;if(this.renderSourceType===t.b7.Symbol&&"symbol"!==i.type)continue;if(this.renderSourceType===t.b7.FillExtrusion&&"fill-extrusion"!==i.type)continue;if(this.renderSourceType===t.b7.Other&&("symbol"===i.type||"fill-extrusion"===i.type))continue;if(i.minzoom&&this.zoom<Math.floor(i.minzoom))continue;if(i.maxzoom&&this.zoom>=i.maxzoom)continue;if("none"===i.visibility)continue;_(e,this.zoom,v.brightness,n,this.worldview,v.activeFloors);const s=()=>{const s=g[i.id]=i.createBucket({index:p.bucketLayerIDs.length,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:r,worldview:this.worldview,localizable:f,availableImages:n,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});p.bucketLayerIDs.push(e.map(e=>t.t(e.id,e.scope))),s.populate(d,v,this.tileID.canonical,this.tileTransform)};if("prepare"in i){const e=i.prepare().then(()=>s());x.push(e)}else s()}}const w=()=>{y.trim();const i=!(!v.elevationFeatures||!v.elevationFeatures.some(e=>e.heightRange.min<0));let r,c,u,h,d,f,m;const x={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},b=()=>{if(r)return this.status="done",o(r);if(this.extraShadowCaster)this.status="done",o(null,{buckets:Object.values(g).filter(e=>!e.isEmpty()),featureIndex:p,collisionBoxArray:null,hasTunnelGeometry:i,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:v.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(c&&u&&h&&m){const e=void 0,i=new l(c),r=new Map;for(const[e,i]of u.entries()){const{imagePosition:n}=t.fr(e,i,t.fs);r.set(e,n)}const o={};for(const e in g){const s=g[e];s instanceof t.ft&&(_(s.layers,this.zoom,v.brightness,n,this.worldview,v.activeFloors),o[e]=t.fu(s,c,i.positions,u,r,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,d,this.worldview,n))}d.size||f.size?this.rasterizeTask=s.send("rasterizeImages",{scope:this.scope,iconTasks:d,patternTasks:f},(t,n)=>{if(!t)for(const[e,t]of n.entries())u.has(e)&&u.set(e,Object.assign(u.get(e),{data:t})),h.has(e)&&h.set(e,Object.assign(h.get(e),{data:t}));w(o,i,e,m)}):w(o,i,e,m)}},w=(e,r,a,l)=>{const c=u.size>0||h.size>0,d=Object.keys(e).length>0;if(!c&&!d)return this.status="done",void o(null,{buckets:Object.values(g).filter(e=>!e.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:i,glyphAtlasImage:r.image,lineAtlas:y,imageAtlas:null,brightness:v.brightness});const f=(s,a)=>{for(const i in g){const r=g[i];if(i in e)t.fz(r,e[i],this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,u,a);else if(r.hasPattern&&(r instanceof t.fA||r instanceof t.fp||r instanceof t.e3)){_(r.layers,this.zoom,v.brightness,n,this.worldview,v.activeFloors);const e=Object.fromEntries(a.patternPositions);r.addFeatures(v,this.tileID.canonical,e,n,this.tileTransform,this.brightness)}}this.status="done",o(null,{buckets:Object.values(g).filter(e=>!e.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:i,glyphAtlasImage:r.image,lineAtlas:y,imageAtlas:s,brightness:v.brightness})};if(c){const e=new Map,i=t.fv(u,e),n=t.fv(h,e),r=new t.fw(i,n,l,this.lut,e);s.send("checkAtlasCache",{descriptor:r,scope:this.scope},(e,i)=>{let n,r;if(e&&t.w(`[Worker] Error checking atlas cache: ${e.message}`),i)n=new t.fx(i.sourceHash),r=i;else{const e=new t.fy(u,h,this.lut,l);n=e,r=e}f(n,r)})}else f(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const e=t.fo(v.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?s.send("getGlyphs",{uid:this.uid,stacks:e},(e,t)=>{r||(r=e,c=t,b())},void 0,!1,x):c={},m=new Map;const i=Array.from(v.iconDependencies.keys()).map(e=>t.I.parse(e)),n=Array.from(v.patternDependencies.keys()).map(e=>t.I.parse(e));i.length||n.length?s.send("getImages",{icons:i,patterns:n,source:this.source,scope:this.scope,tileID:this.tileID},(e,t)=>{if(!r){r=e,u=new Map,h=new Map,d=this.updateImageMapAndGetImageTaskQueue(u,t.images,v.iconDependencies),f=this.updateImageMapAndGetImageTaskQueue(h,t.images,v.patternDependencies);for(const[e,i]of t.versions.entries())m.set(e,i);b()}},void 0,!1,x):(u=new Map,h=new Map,d=new Map,f=new Map)}if(v.elevationFeatures&&v.elevationFeatures.length>0){const i=[];for(const e of Object.values(g))if(e instanceof t.fp){const t=e.getUnevaluatedPortalGraph();t&&i.push(t)}const n=t.fq.evaluate(i);for(const i of Object.values(g))if(i instanceof t.fp){const t=e.layers[a.decode(i.sourceLayerIndex)];i.setEvaluatedPortalGraph(n,t,this.tileID.canonical,v.availableImages,v.brightness)}}b()};x.length>0?Promise.allSettled(x).then(w).catch(o):w()}updateParameters(e){this.scaleFactor=e.scaleFactor,this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.projection=e.projection,this.brightness=e.brightness,this.tileTransform=t.fg(e.tileID.canonical,e.projection),this.extraShadowCaster=e.extraShadowCaster,this.lut=e.lut,this.worldview=e.worldview,this.indoor=e.indoor}updateImageMapAndGetImageTaskQueue(e,t,i){const n=new Map;for(const r of t.keys()){const s=i.get(r)||[];for(const i of s){const r=i.toString(),s=t.get(i.id.toString());s.usvg?n.has(r)||(n.set(r,i),e.set(r,Object.assign({},s))):e.set(r,s)}}return n}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function _(e,i,n,r,s,o){const a=new t.ab(i,{brightness:n,worldview:s,activeFloors:o});for(const t of e)t.recalculate(a,r)}class y extends t.E{constructor({actor:e,layerIndex:i,availableImages:n,availableModels:r,isSpriteLoaded:s,tileProvider:o,brightness:a,maxUniformBufferBindings:l,maxUniformBlockSizeDwords:c,disableSymbolUBO:u}){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.availableModels=r,this.loadVectorData=t.aQ,this.tileProvider=o,this.loading={},this.loaded={},this.deduped=new t.aL(e.scheduler),this.isSpriteLoaded=s,this.scheduler=e.scheduler,this.brightness=a,this.maxUniformBufferBindings=l,this.maxUniformBlockSizeDwords=c,this.disableSymbolUBO=u}loadTileData(e,t){if(!this.tileProvider)return this.loadVectorData(e,t);const i=new AbortController;return this.loadTileWithProvider(this.tileProvider,e,i,t),()=>i.abort()}async loadTileWithProvider(e,t,i,n){const{z:r,x:s,y:o}=t.tileID.canonical;try{const a=await e.loadTile({z:r,x:s,y:o},{request:t.request,signal:i.signal});if(i.signal.aborted)return;if(null==a){const e=new Error("Tile not found");return e.status=404,n(e)}if(null==a.data)return n(null,null);const l=new Map;a.expires&&l.set("expires",a.expires),a.cacheControl&&l.set("cache-control",a.cacheControl),n(null,{rawData:a.data,responseHeaders:l})}catch(e){if(i.signal.aborted)return;n(e instanceof Error?e:new Error(String(e)))}}loadTile(e,n){const r=e.uid,s=e&&e.request,o=s&&s.collectResourceTiming,a=this.loading[r]=new g(e);a.maxUniformBufferBindings=this.maxUniformBufferBindings,a.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,a.disableSymbolUBO=this.disableSymbolUBO,a.abort=this.loadTileData(e,(l,c)=>{const u=!this.loading[r];if(delete this.loading[r],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[r]=a),n(l);const h=c.rawData,d={},p=t.aR(c.responseHeaders);p&&p.expires&&(d.expires=p.expires),p&&p.cacheControl&&(d.cacheControl=p.cacheControl),a.vectorTile=c.vectorTile||new t.fB(new t.b2(h));const f=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,t)=>{if(e||!t)return n(e);const r={};if(o){const e=i(s);e.length>0&&(r.resourceTiming=JSON.parse(JSON.stringify(e)))}n(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},t,d,r))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom}):f()}),this.loaded=this.loaded||{},this.loaded[r]=a})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.updateParameters(e);const s=(e,i)=>{const n=r.reloadCallback;n&&(delete r.reloadCallback,r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n)),t(e,i)};"parsing"===r.status?r.reloadCallback=s:"done"===r.status&&(r.vectorTile?r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,s):s())}else t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class v{constructor(e){this.tileProvider=e.tileProvider,this.loading={}}loadTile(e,i){const n=e.uid;if(this.tileProvider){const t=new AbortController;return this.loading[n]={cancel:()=>t.abort()},void this.loadTileWithProvider(this.tileProvider,n,e,t,i)}const{cancel:r}=t.b4(e.request,(r,s,o)=>{const a=!this.loading[n];if(delete this.loading[n],a||r||!s)return i(r);this.decodeTile(n,s,e.encoding).then(e=>{const{expires:n,cacheControl:r}=t.aR(o);i(null,Object.assign(e,{expires:n,cacheControl:r}))}).catch(e=>i(e))});this.loading[n]={cancel:r}}async decodeTile(e,i,n){const r=await createImageBitmap(new Blob([new Uint8Array(i)],{type:"image/png"})),s=1-(r.width-t.fC(r.width))/2,o=s<1,a=this.getImageData(r,s);return r.close(),{dem:new t.fD(e,a,n,o),borderReady:o}}async loadTileWithProvider(e,t,i,n,r){const{z:s,x:o,y:a}=i.tileID.canonical;try{const l=await e.loadTile({z:s,x:o,y:a},{request:i.request,signal:n.signal});if(n.signal.aborted)return r(null,null);if(null==l){const e=new Error("Tile not found");return e.status=404,r(e)}if(null==l.data)return r(null,null);const c=await this.decodeTile(t,l.data,i.encoding);if(n.signal.aborted)return r(null,null);r(null,Object.assign(c,{expires:l.expires,cacheControl:l.cacheControl}))}catch(e){if(n.signal.aborted)return r(null,null);if(e instanceof DOMException&&"AbortError"===e.name)return r(null,null);r(e instanceof Error?e:new Error(String(e)))}finally{delete this.loading[t]}}reloadTile(e,t){t(null,null)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.cancel(),delete this.loading[i]),t()}removeTile(e,t){t()}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}t.b1.setPbf(t.b2);class x{constructor(e){this._mrt=new t.b1(e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=e.uid,this.tileID=e.tileID,this.source=e.source}parse(e,i){const n=this._mrt;this.status="parsing",this._entireBuffer=e;try{n.parseHeader(e),this._isHeaderLoaded=!0;const r=[];for(const i in n.layers){const s=n.getLayer(i),o=s.getDataRange(s.getBandList()),a=n.createDecodingTask(o),l=e.slice(o.firstByte,o.lastByte+1),c=t.b1.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));r.push(c)}Promise.allSettled(r).then(()=>i(null,n)).catch(e=>i(e))}catch(e){i(e)}}}class b{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={}}loadTile(e,i){const n=e.uid,r=e.request,s=this.loading[n]=new x(e),{cancel:o}=t.b4(r,(e,t,r)=>{const o=!this.loading[n];if(delete this.loading[n],o||e||!t)return s.status="done",o||(this.loaded[n]=s),i(e);s.parse(t,(e,t)=>{if(e||!t)return i(e);i(null,t,r)}),this.loaded[n]=s});s.abort=o}reloadTile(e,t){t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=e.uid;this.loaded[i]&&delete this.loaded[i],t()}decodeRasterArray(e,i){t.b1.performDecoding(e.buffer,e.task).then(e=>i(null,e)).catch(e=>i(e))}}const w=t.fE.prototype.toGeoJSON;class T{constructor(e){this._feature=e,this.extent=t.ak,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(e,t,i){return w.call(this,e,t,i)}}class S{constructor(e,i){this.name=e,this.extent=t.ak,this.length=i.length,this._jsonFeatures=i}feature(e){return new T(this._jsonFeatures[e])}}class E{constructor(e){this.layers={},this.extent=t.ak;for(const t of Object.keys(e))this.layers[t]=new S(t,e[t])}}const A=64/4096;class M{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let n=this.features.get(e);n&&this.updateCache(n,t),i.geometry?(n=C(i),this.updateCache(n,t),this.features.set(e,n)):this.features.delete(e),this.updateCache(n,t)}}updateCache(e,t){for(const{canonical:i,uid:n}of Object.values(t)){const{z:r,x:s,y:o}=i;I(e,Math.pow(2,r),s,o)&&delete t[n]}}getTile(e,t,i){const n=Math.pow(2,e),r=[];for(const e of this.features.values())I(e,n,t,i)&&r.push(O(e,n,t,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function I({minX:e,minY:t,maxX:i,maxY:n},r,s,o){return e<(s+1+A)/r&&t<(o+1+A)/r&&i>(s-A)/r&&n>(o-A)/r}function C(e){const{id:t,geometry:i,properties:n}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:s}=i,o={id:t,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=o.geometry;if("Point"===r)P(s,a,o);else if("MultiPoint"===r)for(const e of s)P(e,a,o);else if("LineString"===r)o.type=2,L(s,a,o);else if("MultiLineString"===r)o.type=2,R(s,a,o);else if("Polygon"===r)o.type=3,R(s,a,o,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");o.type=3;for(const e of s)R(e,a,o,!0)}return o}function P([e,i],n,r){const s=t.aG(e);let o=t.aJ(i);o=o<0?0:o>1?1:o,n.push(s,o),r.minX=Math.min(r.minX,s),r.minY=Math.min(r.minY,o),r.maxX=Math.max(r.maxX,s),r.maxY=Math.max(r.maxY,o)}function L(e,t,i,n=!1,r=!1){const s=[];for(const t of e)P(t,s,i);t.push(s),n&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t<n;r=t,t+=2)i+=(e[t]-e[r])*(e[t+1]+e[r+1]);if(i>0===t)for(let t=0,i=e.length;t<i/2;t+=2){const n=e[t],r=e[t+1];e[t]=e[i-2-t],e[t+1]=e[i-1-t],e[i-2-t]=n,e[i-1-t]=r}}(s,r)}function R(e,t,i,n=!1){for(let r=0;r<e.length;r++)L(e[r],t,i,n,0===r)}function O(e,i,n,r){const{id:s,type:o,geometry:a,tags:l}=e,c=[];if(1===o)!function(e,i,n,r,s){for(let o=0;o<e.length;o+=2){const a=Math.round(t.ak*(e[o+0]*i-n)),l=Math.round(t.ak*(e[o+1]*i-r));s.push([a,l])}}(a,i,n,r,c);else if(2===o)for(const e of a)D(e,i,n,r,c);else if(3===o)for(const e of a)B(e,i,n,r,c);return{id:s,type:o,geometry:c,tags:l}}function D(e,i,n,r,s){const o=-128,a=t.ak+128;let l;for(let c=0;c<e.length-2;c+=2){let u=Math.round(t.ak*(e[c+0]*i-n)),h=Math.round(t.ak*(e[c+1]*i-r)),d=Math.round(t.ak*(e[c+2]*i-n)),p=Math.round(t.ak*(e[c+3]*i-r));const f=d-u,m=p-h;u<o&&d<o||(u<o?(h+=Math.round(m*((o-u)/f)),u=o):d<o&&(p=h+Math.round(m*((o-u)/f)),d=o),h<o&&p<o||(h<o?(u+=Math.round(f*((o-h)/m)),h=o):p<o&&(d=u+Math.round(f*((o-h)/m)),p=o),u>=a&&d>=a||(u>=a?(h+=Math.round(m*((a-u)/f)),u=a):d>=a&&(p=h+Math.round(m*((a-u)/f)),d=a),h>=a&&p>=a||(h>=a?(u+=Math.round(f*((a-h)/m)),h=a):p>=a&&(d=u+Math.round(f*((a-h)/m)),p=a),l&&u===l.at(-1)[0]&&h===l.at(-1)[1]||(l=[[u,h]],s.push(l)),l.push([d,p])))))}}function B(e,i,n,r,s){const o=(n-A)/i,a=(r-A)/i,l=(n+1+A)/i,c=(r+1+A)/i;function u(e,t){let i=0;return e<o?i|=1:e>l&&(i|=2),t<a?i|=4:t>c&&(i|=8),i}let h=[];for(let t=1;t<=8;t*=2){let i=e[e.length-2],n=e.at(-1),r=!(u(i,n)&t);for(let s=0;s<e.length;s+=2){const d=e[s],p=e[s+1],f=!(u(d,p)&t);f!==r&&(8&t?h.push(i+(d-i)*(c-n)/(p-n),c):4&t?h.push(i+(d-i)*(a-n)/(p-n),a):2&t?h.push(l,n+(p-n)*(l-i)/(d-i)):1&t&&h.push(o,n+(p-n)*(o-i)/(d-i))),f&&h.push(d,p),i=d,n=p,r=f}if(!(e=h).length||8===t)break;h=[]}const d=[];for(let e=0;e<h.length;e+=2)d.push([Math.round(t.ak*(h[e]*i-n)),Math.round(t.ak*(h[e+1]*i-r))]);d.length&&s.push(d)}function F({name:e,features:i},n){n.writeStringField(1,e),n.writeVarintField(5,t.ak);const r=new Map,s=new Map,o={keys:r,values:s,feature:null};for(const e of i)o.feature=e,n.writeMessage(2,N,o);for(const e of r.keys())n.writeStringField(3,e);for(const e of s.keys())n.writeMessage(4,j,e)}function N(e,t){const i=e.feature;void 0!==i.id&&Number.isSafeInteger(+i.id)&&t.writeVarintField(1,+i.id),i.tags&&t.writeMessage(2,k,e),t.writeVarintField(3,i.type),t.writeMessage(4,V,i)}function k({keys:e,values:t,feature:i},n){for(const r of Object.keys(i.tags)){let s=i.tags[r];if(null===s)continue;let o=e.get(r);void 0===o&&(o=e.size,e.set(r,o)),n.writeVarint(o);const a=typeof s;"string"!==a&&"boolean"!==a&&"number"!==a&&(s=JSON.stringify(s));let l=t.get(s);void 0===l&&(l=t.size,t.set(s,l)),n.writeVarint(l)}}function z(e,t){return(t<<3)+(7&e)}function U(e){return e<<1^e>>31}function V(e,t){const{geometry:i,type:n}=e;let r=0,s=0;if(1===n){t.writeVarint(z(1,i.length));for(const e of i){const i=e[0]-r,n=e[1]-s;t.writeVarint(U(i)),t.writeVarint(U(n)),r+=i,s+=n}}else for(const e of i){if(0===e.length)continue;t.writeVarint(z(1,1));const i=e.length-(3===n?1:0);for(let n=0;n<i;n++){1===n&&t.writeVarint(z(2,i-1));const o=e[n][0]-r,a=e[n][1]-s;t.writeVarint(U(o)),t.writeVarint(U(a)),r+=o,s+=a}3===n&&t.writeVarint(z(7,1))}}function j(e,t){const i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}const G={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},H=Math.fround||(W=new Float32Array(1),e=>(W[0]=+e,W[0]));var W;class q{constructor(e){this.options=Object.assign(Object.create(G),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{minZoom:t,maxZoom:i}=this.options;this.points=e;const n=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,s]=i.geometry.coordinates,o=H(Z(r)),a=H(Y(s));n.push(o,a,1/0,t,-1,1),this.options.reduce&&n.push(0)}let r=this.trees[i+1]=this._createTree(n);for(let e=i;e>=t;e--)r=this.trees[e]=this._createTree(this._cluster(r,e));return this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,s],t),o=this.getClusters([-180,n,r,s],t);return e.concat(o)}const o=this.trees[this._limitZoom(t)],a=o.range(Z(i),Y(s),Z(r),Y(n)),l=o.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?X(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const s=r.data;if(t*this.stride>=s.length)throw new Error(n);const o=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],o),l=[];for(const t of a){const i=t*this.stride;s[i+4]===e&&l.push(s[i+5]>1?X(s,i,this.clusterProps):this.points[s[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:o}=this.options,a=o/s,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=n?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,i,n,r):r<n?r++:e.push(t),e.length===i)break}return r}_createTree(e){const i=new t.bM(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)i.add(e[t],e[t+1]);return i.finish(),i.data=e,i}_addTileFeatures(e,t,i,n,r,s){for(const o of e){const e=o*this.stride,a=t[e+5]>1;let l,c,u;if(a)l=$(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=Z(n),u=Y(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),s.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:s}=this.options,o=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=t)continue;a[i+2]=t;const n=a[i],u=a[i+1],h=e.within(a[i],a[i+1],o),d=a[i+5];let p=d;for(const e of h){const i=e*c;a[i+2]>t&&(p+=a[i+5])}if(p>d&&p>=s){let e,s=n*d,o=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];s+=a[l]*u,o+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(s/p,o/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[i+e]);if(p>1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e<c;e++)l.push(a[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function X(e,t,i){return{type:"Feature",id:e[t+3],properties:$(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),J(e[t+1])]}};var n}function $(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,s=e[t+6],o=-1===s?{}:Object.assign({},i[s]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function Z(e){return e/360+.5}function Y(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function K(e,t,i,n){let r=n;const s=t+(i-t>>1);let o,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;n<i;n+=3){const t=Q(e[n],e[n+1],l,c,u,h);if(t>r)o=n,r=t;else if(t===r){const e=Math.abs(n-s);e<a&&(o=n,a=e)}}r>n&&(o-t>3&&K(e,t,o,n),e[o+2]=r,i-o>3&&K(e,o,i,n))}function Q(e,t,i,n,r,s){let o=r-i,a=s-n;if(0!==o||0!==a){const l=((e-i)*o+(t-n)*a)/(o*o+a*a);l>1?(i=r,n=s):l>0&&(i+=o*l,n+=a*l)}return o=e-i,a=t-n,o*o+a*a}function ee(e,t,i,n){const r={id:e??null,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)te(r,i);else if("Polygon"===t)te(r,i[0]);else if("MultiLineString"===t)for(const e of i)te(r,e);else if("MultiPolygon"===t)for(const e of i)te(r,e[0]);return r}function te(e,t){for(let i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function ie(e,t,i,n){if(!t.geometry)return;const r=t.geometry.coordinates;if(r&&0===r.length)return;const s=t.geometry.type,o=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);let a=[],l=t.id;if(i.promoteId?l=t.properties[i.promoteId]:i.generateId&&(l=n||0),"Point"===s)ne(r,a);else if("MultiPoint"===s)for(const e of r)ne(e,a);else if("LineString"===s)re(r,a,o,!1);else if("MultiLineString"===s){if(i.lineMetrics){for(const i of r)a=[],re(i,a,o,!1),e.push(ee(l,"LineString",a,t.properties));return}se(r,a,o,!1)}else if("Polygon"===s)se(r,a,o,!0);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(const r of t.geometry.geometries)ie(e,{id:l,geometry:r,properties:t.properties},i,n);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of r){const t=[];se(e,t,o,!0),a.push(t)}}e.push(ee(l,s,a,t.properties))}function ne(e,t){t.push(oe(e[0]),ae(e[1]),0)}function re(e,t,i,n){let r,s,o=0;for(let i=0;i<e.length;i++){const a=oe(e[i][0]),l=ae(e[i][1]);t.push(a,l,0),i>0&&(o+=n?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l}const a=t.length-3;t[2]=1,K(t,0,a,i),t[a+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function se(e,t,i,n){for(let r=0;r<e.length;r++){const s=[];re(e[r],s,i,n),t.push(s)}}function oe(e){return e/360+.5}function ae(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function le(e,t,i,n,r,s,o,a){if(n/=t,s>=(i/=t)&&o<n)return e;if(o<i||s>=n)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const o=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(o>=i&&c<n){l.push(t);continue}if(c<i||o>=n)continue;let u=[];if("Point"===s||"MultiPoint"===s)ce(e,u,i,n,r);else if("LineString"===s)ue(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===s)de(e,u,i,n,r,!1);else if("Polygon"===s)de(e,u,i,n,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];de(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(ee(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(ee(t.id,s,u,t.tags))}}return l.length?l:null}function ce(e,t,i,n,r){for(let s=0;s<e.length;s+=3){const o=e[s+r];o>=i&&o<=n&&pe(t,e[s],e[s+1],e[s+2])}}function ue(e,t,i,n,r,s,o){let a=he(e);const l=0===r?fe:me;let c,u,h=e.start;for(let d=0;d<e.length-3;d+=3){const p=e[d],f=e[d+1],m=e[d+2],g=e[d+3],_=e[d+4],y=0===r?p:f,v=0===r?g:_;let x=!1;o&&(c=Math.sqrt(Math.pow(p-g,2)+Math.pow(f-_,2))),y<i?v>i&&(u=l(a,p,f,g,_,i),o&&(a.start=h+c*u)):y>n?v<n&&(u=l(a,p,f,g,_,n),o&&(a.start=h+c*u)):pe(a,p,f,m),v<i&&y>=i&&(u=l(a,p,f,g,_,i),x=!0),v>n&&y<=n&&(u=l(a,p,f,g,_,n),x=!0),!s&&x&&(o&&(a.end=h+c*u),t.push(a),a=he(e)),o&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&pe(a,p,f,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&pe(a,a[0],a[1],a[2]),a.length&&t.push(a)}function he(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function de(e,t,i,n,r,s){for(const o of e)ue(o,t,i,n,r,s,!1)}function pe(e,t,i,n){e.push(t,i,n)}function fe(e,t,i,n,r,s){const o=(s-t)/(n-t);return pe(e,s,i+(r-i)*o,1),o}function me(e,t,i,n,r,s){const o=(s-i)/(r-i);return pe(e,t+(n-t)*o,s,1),o}function ge(e,t){const i=[];for(let n=0;n<e.length;n++){const r=e[n],s=r.type;let o;if("Point"===s||"MultiPoint"===s||"LineString"===s)o=_e(r.geometry,t);else if("MultiLineString"===s||"Polygon"===s){o=[];for(const e of r.geometry)o.push(_e(e,t))}else if("MultiPolygon"===s){o=[];for(const e of r.geometry){const i=[];for(const n of e)i.push(_e(n,t));o.push(i)}}i.push(ee(r.id,s,o,r.tags))}return i}function _e(e,t){const i=[];i.size=e.size,void 0!==e.start&&(i.start=e.start,i.end=e.end);for(let n=0;n<e.length;n+=3)i.push(e[n]+t,e[n+1],e[n+2]);return i}function ye(e,t){if(e.transformed)return e;const i=1<<e.z,n=e.x,r=e.y;for(const s of e.features){const e=s.geometry,o=s.type;if(s.geometry=[],1===o)for(let o=0;o<e.length;o+=2)s.geometry.push(ve(e[o],e[o+1],t,i,n,r));else for(let o=0;o<e.length;o++){const a=[];for(let s=0;s<e[o].length;s+=2)a.push(ve(e[o][s],e[o][s+1],t,i,n,r));s.geometry.push(a)}}return e.transformed=!0,e}function ve(e,t,i,n,r,s){return[Math.round(i*(e*n-r)),Math.round(i*(t*n-s))]}function xe(e,t,i,n,r){const s=t===r.maxZoom?0:r.tolerance/((1<<t)*r.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:i,y:n,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const t of e)be(o,t,s,r);return o}function be(e,t,i,n){const r=t.geometry,s=t.type,o=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),"Point"===s||"MultiPoint"===s)for(let t=0;t<r.length;t+=3)o.push(r[t],r[t+1]),e.numPoints++,e.numSimplified++;else if("LineString"===s)we(o,r,e,i,!1,!1);else if("MultiLineString"===s||"Polygon"===s)for(let t=0;t<r.length;t++)we(o,r[t],e,i,"Polygon"===s,0===t);else if("MultiPolygon"===s)for(let t=0;t<r.length;t++){const n=r[t];for(let t=0;t<n.length;t++)we(o,n[t],e,i,!0,0===t)}if(o.length){let i=t.tags||null;if("LineString"===s&&n.lineMetrics){i={};for(const e in t.tags)i[e]=t.tags[e];i.mapbox_clip_start=r.start/r.size,i.mapbox_clip_end=r.end/r.size}const a={geometry:o,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:i};null!==t.id&&(a.id=t.id),e.features.push(a)}}function we(e,t,i,n,r,s){const o=n*n;if(n>0&&t.size<(r?o:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;e<t.length;e+=3)(0===n||t[e+2]>o)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t<n;r=t,t+=2)i+=(e[t]-e[r])*(e[t+1]+e[r+1]);if(i>0===t)for(let t=0,i=e.length;t<i/2;t+=2){const n=e[t],r=e[t+1];e[t]=e[i-2-t],e[t+1]=e[i-1-t],e[i-2-t]=n,e[i-1-t]=r}}(a,s),e.push(a)}const Te={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Se{constructor(e,t){const i=(t=this.options=function(e,t){for(const i in t)e[i]=t[i];return e}(Object.create(Te),t)).debug;if(t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n<e.features.length;n++)ie(i,e.features[n],t,n);else ie(i,"Feature"===e.type?e:{geometry:e},t);return i}(e,t);this.tiles={},this.tileCoords=[],i&&(this.stats={},this.total=0),n=function(e,t){const i=t.buffer/t.extent;let n=e;const r=le(e,1,-1-i,i,0,-1,2,t),s=le(e,1,1-i,2+i,0,-1,2,t);return(r||s)&&(n=le(e,1,-i,1+i,0,-1,2,t)||[],r&&(n=ge(r,1).concat(n)),s&&(n=n.concat(ge(s,-1)))),n}(n,t),n.length&&this.splitTile(n,0,0,0)}splitTile(e,t,i,n,r,s,o){const a=[e,t,i,n],l=this.options,c=l.debug;for(;a.length;){n=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();const u=1<<t,h=Ee(t,i,n);let d=this.tiles[h];if(!d&&(d=this.tiles[h]=xe(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==s>>e||n!==o>>e)continue}}if(d.source=null,0===e.length)continue;const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,y=null,v=null,x=null,b=le(e,u,i-p,i+m,0,d.minX,d.maxX,l),w=le(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,b&&(_=le(b,u,n-p,n+m,1,d.minY,d.maxY,l),y=le(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),w&&(v=le(w,u,n-p,n+m,1,d.minY,d.maxY,l),x=le(w,u,n+f,n+g,1,d.minY,d.maxY,l),w=null),a.push(_||[],t+1,2*i,2*n),a.push(y||[],t+1,2*i,2*n+1),a.push(v||[],t+1,2*i+1,2*n),a.push(x||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r}=n;if(e<0||e>24)return null;const s=1<<e,o=Ee(e,t=t+s&s-1,i);if(this.tiles[o])return ye(this.tiles[o],r);let a,l=e,c=t,u=i;for(;!a&&l>0;)l--,c>>=1,u>>=1,a=this.tiles[Ee(l,c,u)];return a&&a.source?(this.splitTile(a.source,l,c,u,e,t,i),this.tiles[o]?ye(this.tiles[o],r):null):null}}function Ee(e,t,i){return 32*((1<<e)*i+t)+e}function Ae(e,i){const n=e.tileID.canonical;if(!this._geoJSONIndex)return void i(null,null);const r=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!r)return void i(null,null);const s=e=>e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,o=r.features.filter(e=>s(e));let a={_geojsonTileLayer:r.features};o.length>0&&(a={_geojsonTileLayer:r.features.filter(e=>!s(e)),hd_road_elevation:o});const l=new E(a),c=function(e){const i=new t.b2;for(const t of Object.keys(e))i.writeMessage(3,F,{name:t,features:e[t]});return i.finish()}(a).buffer;i(null,{vectorTile:l,rawData:c})}class Me extends y{constructor(e){super(e),this.loadVectorData=Ae,this._dynamicIndex=new M}loadData(e,n){const r=e&&e.request,s=r&&r.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(e,(o,a)=>{if(o||!a)return n(o);if("object"!=typeof a)return n(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{try{if(e.filter){const i=t.U(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>i.value.evaluate({zoom:0},e))}e.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),e.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=e.cluster?new q(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const n={},r={},s={accumulated:null,zoom:0},o={properties:null},a=Object.keys(i);for(const e of a){const[s,o]=i[e],a=t.U(o),l=t.U("string"==typeof s?[s,["accumulated"],["get",e]]:s);n[e]=a.value,r[e]=l.value}return e.map=e=>{o.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(s,o);return t},e.reduce=(e,t)=>{o.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,o)},e}(e)).load(a.features):e.dynamic?this._dynamicIndex:function(e,t){return new Se(e,t)}(a,e.geojsonVtOptions)}catch(e){return n(e)}const o={};if(s){const t=i(r);t&&(o.resourceTiming={},o.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}n(null,o)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(e,i){if(e.request)t.m(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class Ie{constructor(e,i,n){this.tileID=new t.aU(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=e.projection,this.brightness=i,this.worldview=n}parse(e,i,n,r){this.status="parsing";const s=new t.aU(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),o=[],a=i.familiesBySource[n.source],l=new t.fj(s,n.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,t.fF(e).then(e=>{const i=e.json.extensionsUsed&&e.json.extensionsUsed.includes("MAPBOX_mesh_features")||e.json.asset.extras&&e.json.asset.extras.MAPBOX_mesh_features,c=e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new t.ab(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const r in a)for(const h of a[r]){const r=h[0];l.bucketLayerIDs.push(h.map(e=>t.t(e.id,e.scope))),r.recalculate(u,[]);const a=t.fG(e,1/t.cW(n.tileID.canonical)),d=new t.fH(h,a,s,i,c,this.brightness,l,this.worldview);i||(d.needsUpload=!0),o.push(d),d.evaluate(r)}this.status="done",r(null,{buckets:o,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>r(new Error(e.message)))}}class Ce{constructor({actor:e,layerIndex:t,availableImages:i,availableModels:n,brightness:r,worldview:s}){this.actor=e,this.layerIndex=t,this.availableImages=i,this.availableModels=n,this.brightness=r,this.loading={},this.loaded={},this.worldview=s}loadTile(e,i){const n=e.uid,r=this.loading[n]=new Ie(e,this.brightness,this.worldview);t.b4(e.request,(t,s)=>{const o=!this.loading[n];return delete this.loading[n],o||t?(r.status="done",o||(this.loaded[n]=r),i(t)):s&&0!==s.byteLength?void r.parse(s,this.layerIndex,e,(e,t)=>{r.status="done",this.loaded=this.loaded||{},this.loaded[n]=r,e||!t?i(e):i(null,t)}):(r.status="done",this.loaded[n]=r,i())})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.projection=e.projection,r.brightness=e.brightness;const s=(i,n)=>{r.reloadCallback&&(delete r.reloadCallback,this.loadTile(e,t)),t(i,n)};"parsing"===r.status?r.reloadCallback=s:"done"===r.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class Pe{constructor(e){this.self=e,this.actor=new t.ap(e,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=t.c4({name:"mercator"}),this.workerSourceTypes={vector:y,geojson:Me,"raster-dem":v,"raster-array":b,"batched-model":Ce},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=e=>{if(t.fJ.isParsed())throw new Error("RTL text plugin already registered.");t.fJ.setState({pluginStatus:t.fK.parsed,pluginURL:t.fJ.getPluginURL()}),t.fJ.applyArabicShaping=e.applyArabicShaping,t.fJ.processBidirectionalText=e.processBidirectionalText,t.fJ.processStyledBidirectionalText=e.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(e,i){this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={});const{scope:n,isLoaded:r}=i;if(this.isSpriteLoaded[e][n]=r,this.workerSources[e]&&this.workerSources[e][n])for(const i in this.workerSources[e][n]){const s=this.workerSources[e][n][i];for(const e in s){const i=s[e];i instanceof y&&(i.isSpriteLoaded=r,i.fire(new t.z("isSpriteLoaded")))}}}setImages(e,t,i){this.availableImages[e]||(this.availableImages[e]={});const{scope:n,images:r}=t;if(this.availableImages[e][n]=r,this.workerSources[e]&&this.workerSources[e][n]){for(const t in this.workerSources[e][n]){const i=this.workerSources[e][n][t];for(const e in i)i[e].availableImages=r}i()}else i()}setModels(e,{scope:t,models:i},n){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const n in this.workerSources[e][t]){const r=this.workerSources[e][t][n];for(const e in r)r[e].availableModels=i}n()}else n()}setProjection(e,i){this.projections[e]=t.c4(i)}setBrightness(e,t,i){this.brightness=t,i()}setContextParams(e,t,i){this.maxUniformBufferBindings=t.maxBindingPoints,this.maxUniformBlockSizeDwords=t.maxUniformBlockSizeDwords,this.disableSymbolUBO=t.disableSymbolUBO,i()}setWorldview(e,t,i){this.worldview=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).loadTile(t,i)}decodeRasterArray(e,t,i){this.getWorkerSource(e,t).decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const n=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadTileProvider(e,i,n){t.aT(i.name,i.url).then(t=>{const n=new t(i.options);return this.getWorkerSource(e,{type:i.type,source:i.source,scope:i.scope},n),n.load&&i.request?n.load({request:i.request}):null}).then(e=>n(null,e)).catch(e=>n(e instanceof Error?e:new Error(String(e))))}async syncRTLPluginState(e,i,n){if(t.fJ.isParsed())return void n(null,!0);if(t.fJ.isParsing())return void this.rtlPluginParsingListeners.push(n);t.fJ.setState(i);const r=t.fJ.getPluginURL();if(!t.fJ.isLoaded()||t.fJ.isParsed()||t.fJ.isParsing())n(null,!1);else{t.fJ.setState({pluginStatus:t.fK.parsing,pluginURL:r});try{await import(r),t.fJ.isParsed()?n(null,!0):this.rtlPluginParsingListeners.push(n)}catch(e){t.fJ.setState({pluginStatus:t.fK.error,pluginURL:r}),n(e);for(const t of this.rtlPluginParsingListeners)t(e);this.rtlPluginParsingListeners=[]}}}setConfig(e,i){Object.assign(t.g,i)}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let i=this.availableModels[e][t];return i||(i={}),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new o,i.scope=t),i}getWorkerSource(e,t,i){const{type:n,source:r,scope:s}=t,o=this.workerSources;if(o[e]||(o[e]={}),o[e][s]||(o[e][s]={}),o[e][s][n]||(o[e][s][n]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),o[e][s][n][r])i&&(o[e][s][n][r].tileProvider=i);else{const t={send:(t,i,n,r,s,o)=>this.actor.send(t,i,n,e,s,o),scheduler:this.actor.scheduler},a=this.workerSourceTypes[n];if(!a)throw new Error(`Unknown worker source type "${n}".`);o[e][s][n][r]=new a({actor:t,layerIndex:this.getLayerIndex(e,s),availableImages:this.getAvailableImages(e,s),availableModels:this.getAvailableModels(e,s),isSpriteLoaded:this.isSpriteLoaded[e][s],tileProvider:i,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return o[e][s][n][r]}enforceCacheSizeLimit(e,i){t.fL(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return t.fI(self)&&(self.worker=new Pe(self)),Pe}),n(["./shared"],function(e){var t="3.24.1";const i={create:"create",load:"load",fullLoad:"fullLoad"},n={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function r(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var s,o={},a=function(){if(s)return o;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(i);try{t=new Worker(n),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(n),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[n=t&&t.failIfMajorPerformanceCaveat]&&(i[n]=function(t){var i,n=function(t){var i=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",n)}(t);if(!n)return!1;try{i=n.createShader(n.VERTEX_SHADER)}catch(e){return!1}return!(!i||n.isContextLost())&&(n.shaderSource(i,"void main() {}"),n.compileShader(i),!0===n.getShaderParameter(i,n.COMPILE_STATUS))}(n)),i[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var n}s=1,o.supported=e,o.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},o}();const l=/firefox/i,c=/macintosh/i;function u(e,t,i){const n=document.createElement(e);return null!=t&&(n.className=t),i&&i.appendChild(n),n}function h(e,t,i){const n=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))n.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(n),n}const d="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,p=d&&void 0!==d.userSelect?"userSelect":"WebkitUserSelect";let f;function m(){d&&p&&(f=d[p],d[p]="none")}function g(){d&&p&&(d[p]=f)}function _(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",_,!0)}function y(){window.addEventListener("click",_,!0),window.setTimeout(()=>{window.removeEventListener("click",_,!0)},0)}function v(e,t){const i=e.getBoundingClientRect();return w(e,i,t)}function x(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;r<t.length;r++)n.push(w(e,i,t[r]));return n}function b(e){return l.test(navigator.userAgent)&&c.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function w(t,i,n){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((n.clientX-i.left)*r,(n.clientY-i.top)*r)}const T="01",S=/(\.(png|jpg)\d*)(?=$)/,E=/^.+\/v4\//,A=/\.[\w]+$/,M=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,I=/^access_token=(.*)$/,C="NO_ACCESS_TOKEN";class P{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",T,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,n){if(!e.e(i))return i;const r=R(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||n)}normalizeGlyphsURL(t,i){if(!e.e(t))return t;const n=R(t);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.e(t))return t;const n=R(t);return n.path=`/models/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeSourceURL(t,i,n,r){if(!e.e(t))return t;const s=R(t);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),n&&s.params.push(`language=${n}`),r&&s.params.push(`worldview=${r}`),this._makeAPIURL(s,this._customAccessToken||i)}normalizeIconsetURL(t,i){const n=R(t);return e.e(t)?(n.path=`/styles/v1${n.path}/iconset.pbf`,this._makeAPIURL(n,this._customAccessToken||i)):O(n)}normalizeSpriteURL(t,i,n,r){const s=R(t);return e.e(t)?(s.path=`/styles/v1${s.path}/sprite${i}${n}`,this._makeAPIURL(s,this._customAccessToken||r)):(s.path+=`${i}${n}`,O(s))}normalizeTileURL(t,i,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.e(t))return t;const r=R(t);r.path=r.path.replace(S,`${i||n&&"raster"!==r.authority&&512===n?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.g.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.g.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.g.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(E,"/"),r.path=`/${e.g.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(e){for(const t of e){const e=t.match(I);if(e)return e[1]}return null}(r.params)||e.g.ACCESS_TOKEN;return e.g.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,i){const n=R(t);if(!M.test(n.path)||!A.test(n.path))return t;let r="mapbox://";n.path.startsWith("/raster/v1/")?r+=`raster/${n.path.replace(`/${e.g.RASTER_URL_PREFIX}/`,"")}`:n.path.startsWith("/rasterarrays/v1/")?r+=`rasterarrays/${n.path.replace(`/${e.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${n.path.replace(`/${e.g.TILE_URL_VERSION}/`,"")}`;let s=n.params;return i&&(s=s.filter(e=>!e.match(I))),s.length&&(r+=`?${s.join("&")}`),r}canonicalizeTileset(t,i){const n=!!i&&e.e(i),r=[];for(const i of t.tiles||[])e.f(i)?r.push(this.canonicalizeTileURL(i,n)):r.push(i);return r}_makeAPIURL(t,i){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=R(e.g.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!e.g.REQUIRE_ACCESS_TOKEN)return O(t);if(i=i||e.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return t.params=t.params.filter(e=>!e.includes("access_token")),t.params.push(`access_token=${i||""}`),O(t)}}const L=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function R(e){const t=e.match(L);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function O(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const D="mapbox.eventData";function B(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}function F(t){return!(!e.g.EVENTS_URL||!t&&!e.g.ACCESS_TOKEN)}class N{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=B(e.g.ACCESS_TOKEN);let n="";return n=i&&i.u?e.j(i.u):e.g.ACCESS_TOKEN||"",t?`${D}.${t}:${n}`:`${D}:${n}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(n);t&&(this.anonId=t);const s=localStorage.getItem(r);s&&(this.anonIdTimestamp=Number(s));const o=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<o)&&this.refreshUUID()}catch(t){e.w("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=e.u(),this.anonIdTimestamp=Date.now()}saveEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp"),s=this.anonId,o=this.anonIdTimestamp;if(t&&s)try{localStorage.setItem(n,s),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),o&&localStorage.setItem(r,o.toString())}catch(t){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(t,i,n,r){if(!e.g.EVENTS_URL)return;const s=R(e.g.EVENTS_URL);s.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(o,i):o,l={url:O(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}class k extends N{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(t){if(!F(t))return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}const z=new class extends N{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(t,i){F(i)&&Array.isArray(t)&&t.some(t=>e.e(t)||e.f(t))&&this.queueRequest(Date.now(),i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=B(e.g.ACCESS_TOKEN),r=n?n.u:e.g.ACCESS_TOKEN;let s=r!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),s=!0);const o=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(o),i=(o-this.eventData.lastSuccess)/864e5;s=s||i>=1||i<-1||e.getDate()!==t.getDate()}else s=!0;s?this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:T,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=o,this.eventData.tokenU=r)},i):this.processRequests()}},U=z.postTurnstileEvent.bind(z),V=new class extends N{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,n,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&(n||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(C)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:n,timestamp:r}=this.queue.shift();n&&this.success[n]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:T,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):n&&(this.success[n]=!0)},i))}remove(){this.errorCb=null}},j=V.postMapLoadEvent.bind(V),G=new class extends N{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:n,importedStyles:r}=t;if(!F(e))return;const s=this.getMapInstanceId(i),o={mapInstanceId:s,eventId:this.getEventId(s),style:n};r.length&&(o.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:o},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},H=G.postStyleLoadEvent.bind(G),W=new k({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),q=W.postMetricsEvent.bind(W),X=new k({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),$=X.postMetricsEvent.bind(X),Z=new class extends N{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){F(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(n){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:s,performanceData:o}=this.queue.shift(),a=function(n){const s=performance.getEntriesByType("resource"),o=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const n of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,s=`${i}RequestCount`,o=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,n.startTime),t[r]=Math.max(t[r]||-1/0,n.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==n.transferSize&&0===n.transferSize&&a(o),a(s)}return t}(function(e,t){const i={};if(e)for(const n of e){const e=t(n);void 0===i[e]&&(i[e]=[]),i[e].push(n)}return i}(s,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,u=c?c.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in a)d(h.counters,e,a[e]);if(n.interactionRange[0]!==1/0&&n.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",n.interactionRange[0]),d(h.counters,"interactionRangeMax",n.interactionRange[1])),o)for(const e of Object.values(i)){const t=o.find(t=>t.name===e);t&&d(h.counters,e,t.startTime)}return d(h.counters,"visibilityHidden",n.visibilityHidden),d(h.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(s)),d(h.attributes,"terrainEnabled",n.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",n.fogEnabled?"true":"false"),d(h.attributes,"projection",n.projection),d(h.attributes,"zoom",n.zoom),d(h.metadata,"devicePixelRatio",l),d(h.metadata,"connectionEffectiveType",u),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",n.width/l),d(h.metadata,"mapHeight",n.height/l),d(h.metadata,"webglRenderer",n.renderer),d(h.metadata,"webglVendor",n.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(o);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(s,a,()=>{},n)}},Y=Z.postPerformanceEvent.bind(Z),J=new class extends N{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,n,r){if(!e.g.API_URL||!e.g.SESSION_PATH)return;const s=R(e.g.API_URL+e.g.SESSION_PATH);s.params.push(`sku=${i||""}`),s.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const o={url:O(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.h(o,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(t,i,n,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&e.g.SESSION_PATH&&e.g.API_URL&&(n||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(C)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}remove(){this.errorCb=null}},K=J.getSessionAPI.bind(J),Q=new Set;function ee(e,t){t?Q.add(e):Q.delete(e)}class te{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty()}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function ie(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const ne=new e.C(0,0,0);function re(e,t,i){1===e&&t.icons.push(function(e,t){return function(e){if(e.usvg_tree.height||(e.usvg_tree.height=e.usvg_tree.width),!e.metadata)return e;const{metadata:t}=e;if(t.content_area){const{content_area:i}=t;null==i.left&&(i.left=0),null==i.top&&(i.top=i.left),null==i.width&&(i.width=e.usvg_tree.width),null==i.height&&(i.height=i.width)}if(t.text_placeholder){const{text_placeholder:e}=t;null==e.top&&(e.top=e.left),null==e.height&&(e.height=e.width)}return t.stretch_x&&t.stretch_x.length&&se(t,"x"),t.stretch_y&&t.stretch_y.length&&se(t,"y"),e}(e.readFields(oe,{name:void 0},t))}(i,i.readVarint()+i.pos))}function se(e,t){const i=[],n=e[`stretch_${t}`];let r=null;for(let e=0;e<n.length;e++)null===r?r=0===i.length?n[0]:i.at(-1)[1]+n[e]:(i.push([r,r+n[e]]),r=null);e[`stretch_${t}_areas`]=i}function oe(e,t,i){1===e?t.name=i.readString():2===e?t.metadata=function(e,t){return e.readFields(ae,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},t)}(i,i.readVarint()+i.pos):3===e&&(t.usvg_tree=function(e,t){return e.readFields(he,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},t)}(i,i.readVarint()+i.pos),t.data="usvg_tree")}function ae(e,t,i){1===e?t.stretch_x=i.readPackedVarint():2===e?t.stretch_y=i.readPackedVarint():3===e?t.content_area=le(i,i.readVarint()+i.pos):4===e?t.variables.push(function(e,t){return e.readFields(ue,{name:void 0},t)}(i,i.readVarint()+i.pos)):5===e&&(t.text_placeholder=le(i,i.readVarint()+i.pos))}function le(e,t){return e.readFields(ce,{},t)}function ce(e,t,i){1===e?t.left=i.readVarint():2===e?t.width=i.readVarint():3===e?t.top=i.readVarint():4===e&&(t.height=i.readVarint())}function ue(e,t,i){1===e?t.name=i.readString():2===e&&(t.rgb_color=ve(i.readVarint()),t.value="rgb_color")}function he(e,t,i){1===e?t.width=t.height=i.readVarint():2===e?t.height=i.readVarint():3===e?t.children.push(de(i,i.readVarint()+i.pos)):4===e?t.linear_gradients.push(function(e,t){return e.readFields(be,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},t)}(i,i.readVarint()+i.pos)):5===e?t.radial_gradients.push(function(e,t){return e.readFields(Se,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},t)}(i,i.readVarint()+i.pos)):7===e?t.clip_paths.push(function(e,t){return e.readFields(Ee,{children:[]},t)}(i,i.readVarint()+i.pos)):8===e&&t.masks.push(function(e,t){const i=e.readFields(Ae,{left:0,width:20,mask_type:1,children:[]},t);return null==i.height&&(i.height=i.width),null==i.top&&(i.top=i.left),i}(i,i.readVarint()+i.pos))}function de(e,t){return e.readFields(pe,{},t)}function pe(e,t,i){1===e?(t.group=function(e,t){return e.readFields(fe,{opacity:255,children:[]},t)}(i,i.readVarint()+i.pos),t.node="group"):2===e&&(t.path=function(e,t){return e.readFields(_e,{paint_order:1,commands:[],step:1,diffs:[],rule:1},t)}(i,i.readVarint()+i.pos),t.node="path")}function fe(e,t,i){1===e?t.transform=me(i,i.readVarint()+i.pos):2===e?t.opacity=i.readVarint():5===e?t.clip_path_idx=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(de(i,i.readVarint()+i.pos))}function me(e,t){return e.readFields(ge,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function ge(e,t,i){1===e?t.sx=i.readFloat():2===e?t.ky=i.readFloat():3===e?t.kx=i.readFloat():4===e?t.sy=i.readFloat():5===e?t.tx=i.readFloat():6===e&&(t.ty=i.readFloat())}function _e(e,t,i){1===e?t.fill=function(e,t){return e.readFields(ye,{rgb_color:ne,paint:"rgb_color",opacity:255},t)}(i,i.readVarint()+i.pos):2===e?t.stroke=function(e,t){return e.readFields(xe,{rgb_color:ne,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},t)}(i,i.readVarint()+i.pos):3===e?t.paint_order=i.readVarint():5===e?i.readPackedVarint(t.commands):6===e?t.step=i.readFloat():7===e?i.readPackedSVarint(t.diffs):8===e&&(t.rule=i.readVarint())}function ye(e,t,i){1===e?(t.rgb_color=ve(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e&&(t.opacity=i.readVarint())}function ve(t){return new e.C((t>>16&255)/255,(t>>8&255)/255,(255&t)/255,1)}function xe(e,t,i){1===e?(t.rgb_color=ve(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function be(e,t,i){1===e?t.transform=me(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(we(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function we(e,t){return e.readFields(Te,{offset:0,opacity:255,rgb_color:ne},t)}function Te(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=ve(i.readVarint()))}function Se(e,t,i){1===e?t.transform=me(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(we(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function Ee(e,t,i){1===e?t.transform=me(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(de(i,i.readVarint()+i.pos))}function Ae(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(de(i,i.readVarint()+i.pos))}class Me{static calculate(t={},i=[]){const n=new Map,r=new Map;if(0===Object.keys(t).length)return n;i.forEach(t=>{r.set(t.name,t.rgb_color||new e.C(0,0,0))});for(const[e,i]of Object.entries(t))r.has(e)&&n.set(r.get(e).toString(),i);return n}}function Ie(e,t=255,i){const n=i.get(e.toString())||e;if(255===t)return n.toString();const r=n.clone();return r.a*=t/255,r.toString()}const Ce=[];let Pe=0;function Le(t,i){if(Pe>=Ce.length){const n=e.r()?new OffscreenCanvas(t,i):document.createElement("canvas");Ce.push(n.getContext("2d",{willReadFrequently:!0}))}const n=Ce[Pe++];return n.canvas.width=t,n.canvas.height=i,n}function Re(){Pe--}function Oe(e,t,i,n,r){for(const s of n.children)De(e,t,i,s,r)}function De(e,t,i,n,r){n.group?(e.save(),function(e,t,i,n,r){const s=null!=n.mask_idx?i.masks[n.mask_idx]:null,o=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=Ge(n.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(n,null!=o,null!=s))return void Oe(e,t,i,n,r);const a=Le(e.canvas.width,e.canvas.height);Oe(a,t,i,n,r),o&&Ve(a,t,i,o),s&&je(a,t,i,s,r),e.globalAlpha=n.opacity/255,e.drawImage(a.canvas,0,0),Re()}(e,t,i,n.group,r),e.restore()):n.path&&(e.save(),function(e,t,i,n,r){e.setTransform(t),1===n.paint_order?(Be(e,i,n,r),Ne(e,i,n,r)):(Ne(e,i,n,r),Be(e,i,n,r))}(e,t,i,n.path,r),e.restore())}function Be(e,t,i,n){const r=i.fill;if(!r)return;const s=r.opacity/255;switch(e.save(),e.beginPath(),He(i,e),r.paint){case"rgb_color":e.fillStyle=Ie(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Ge(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ke(e,i,s,n);break}case"radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Ge(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ze(e,i,s,n)}}e.fill(Fe(i)),e.restore()}function Fe(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function Ne(e,t,i,n){const r=i.stroke;if(!r)return;const s=We(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const o=r.opacity/255;switch(r.paint){case"rgb_color":e.strokeStyle=Ie(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":e.strokeStyle=ke(e,t.linear_gradients[r.linear_gradient_idx],o,n,!0);break;case"radial_gradient_idx":e.strokeStyle=ze(e,t.radial_gradients[r.radial_gradient_idx],o,n,!0)}switch(r.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel"}switch(r.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square"}e.stroke(s)}function ke(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return Ie(e.rgb_color,e.opacity*i,n)}const{x1:s,y1:o,x2:a,y2:l}=t;let c=new DOMPoint(s,o),u=new DOMPoint(a,l);if(r){const e=Ge(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,Ie(e.rgb_color,e.opacity*i,n));return h}function ze(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return Ie(e.rgb_color,e.opacity*i,n)}const s=Ge(t.transform),{fx:o,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(o,a),p=new DOMPoint(c,u),f=l,m=h;if(r){d=s.transformPoint(d),p=s.transformPoint(p);const e=(s.a+s.d)/2;f=l*e,m=t.r*e}const g=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)g.addColorStop(e.offset,Ie(e.rgb_color,e.opacity*i,n));return g}function Ue(e,t,i,n){const r=n.transform?Ge(n.transform).preMultiplySelf(t):t,s=Le(e.canvas.width,e.canvas.height);for(const e of n.children)if(e.group)Ue(s,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(We(t),r),s.fill(i,Fe(t))}const o=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;o&&Ve(s,r,i,o),e.globalCompositeOperation="source-over",e.drawImage(s.canvas,0,0),Re()}function Ve(e,t,i,n){const r=Le(e.canvas.width,e.canvas.height);Ue(r,t,i,n),e.globalCompositeOperation="destination-in",e.drawImage(r.canvas,0,0),Re()}function je(e,t,i,n,r){if(0===n.children.length)return;const s=null!=n.mask_idx?i.masks[n.mask_idx]:null;s&&je(e,t,i,s,r);const o=e.canvas.width,a=e.canvas.height,l=Le(o,a),c=n.width,u=n.height,h=n.left,d=n.top,p=new Path2D,f=new Path2D;f.rect(h,d,c,u),p.addPath(f,t),l.clip(p);for(const e of n.children)De(l,t,i,e,r);const m=l.getImageData(0,0,o,a),g=m.data;if(1===n.mask_type)for(let e=0;e<g.length;e+=4)g[e+3]=g[e+3]/255*(.2126*g[e]+.7152*g[e+1]+.0722*g[e+2]);l.putImageData(m,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l.canvas,0,0),Re()}function Ge(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function He(e,t){const i=e.step;let n=e.diffs[0]*i,r=e.diffs[1]*i;t.moveTo(n,r);for(let s=0,o=2;s<e.commands.length;s++)switch(e.commands[s]){case 1:n+=e.diffs[o++]*i,r+=e.diffs[o++]*i,t.moveTo(n,r);break;case 2:n+=e.diffs[o++]*i,r+=e.diffs[o++]*i,t.lineTo(n,r);break;case 3:{const s=n+e.diffs[o++]*i,a=r+e.diffs[o++]*i;n=s+e.diffs[o++]*i,r=a+e.diffs[o++]*i,t.quadraticCurveTo(s,a,n,r);break}case 4:{const s=n+e.diffs[o++]*i,a=r+e.diffs[o++]*i,l=s+e.diffs[o++]*i,c=a+e.diffs[o++]*i;n=l+e.diffs[o++]*i,r=c+e.diffs[o++]*i,t.bezierCurveTo(s,a,l,c,n,r);break}case 5:t.closePath()}return t}function We(e){return He(e,new Path2D)}class qe{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new e.q(t,t.data)}getFromCache(t,i,n){return this.cacheMap.has(n)||this.cacheMap.set(n,new e.L(150)),this.cacheMap.get(n).get(e.t(t.toString(),i))}setInCache(t,i,n,r){this.cacheDependenciesMap.has(r)||this.cacheDependenciesMap.set(r,new Map),this.cacheMap.has(r)||this.cacheMap.set(r,new e.L(150));const s=this.cacheDependenciesMap.get(r),o=e.t(t.id.toString(),n);s.get(o)||s.set(o,new Set);const a=this.cacheMap.get(r),l=t.toString();s.get(o).add(l),a.put(e.t(t.toString(),n),i)}removeImagesFromCacheByIds(t,i,n=0){if(!this.cacheMap.has(n)||!this.cacheDependenciesMap.has(n))return;const r=this.cacheMap.get(n),s=this.cacheDependenciesMap.get(n);for(const n of t){const t=e.t(n.toString(),i);if(s.has(t)){for(const e of s.get(t))r.delete(e);s.delete(t)}}}rasterize(e,t,i,n){const r=this.getFromCache(e,i,n);if(r)return r.clone();const s=function(e,t){const i=Me.calculate(t.params,e.metadata?e.metadata.variables:[]),n=e.usvg_tree,r=n.width,s=n.height,o=Math.max(1,Math.round(r*t.sx)),a=Math.max(1,Math.round(s*t.sy)),l=new DOMMatrix([o/r,0,0,a/s,0,0]),c=Le(o,a);Oe(c,l,n,n,i);const u=c.getImageData(0,0,o,a);return Re(),u}(t.icon,e),o=qe._getImage(s);return this.setInCache(e,o,i,n),o.clone()}}class Xe extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new e.x,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new qe}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({width:1,height:1}))}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.imageVersions.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e))}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e)}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e)}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return!1;return!0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(t,e),e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images.get(t).get(e.toString())}addImage(e,t,i){if(this._validate(e,i)){this.images.get(t).set(e.toString(),i);const n=this.imageVersions.get(t),r=n.get(e.toString())||0;n.set(e.toString(),r+1)}}_validate(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]<i||n[1]<n[0]||t<n[1])return!1;i=n[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;if(!t.usvg){if(e[0]<0||t.data.width<e[0])return!1;if(e[1]<0||t.data.height<e[1])return!1;if(e[2]<0||t.data.width<e[2])return!1;if(e[3]<0||t.data.height<e[3])return!1}return!(e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i){const n=this.images.get(t).get(e.toString());i.version=n.version+1,this.images.get(t).set(e.toString(),i),this.updatedImages.get(t).add(e);const r=this.imageVersions.get(t),s=r.get(e.toString())||0;r.set(e.toString(),s+1),this.removeFromImageRasterizerCache(e,t)}clearUpdatedImages(e){this.updatedImages.get(e).clear()}removeFromImageRasterizerCache(e,t){"raster"!==this.spriteFormat&&this.imageRasterizer.removeImagesFromCacheByIds([e],t)}removeImage(e,t){const i=this.images.get(t),n=i.get(e.toString());i.delete(e.toString());const r=this.imageVersions.get(t),s=r.get(e.toString())||0;r.set(e.toString(),s+1),this.patterns.get(t).delete(e.toString()),this.removeFromImageRasterizerCache(e,t),n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(t){return Array.from(this.images.get(t).keys()).map(t=>e.I.from(t))}getImageVersions(e){const t=this.imageVersions.get(e);if(t)return t}getImages(e,t,i){const n=[],r=[],s=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){n.push(i);continue}const e=s.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i))}if(0===n.length)return void this._notify(r,t,i);let o=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of n)l.has(e.toString())||(o=!1);a||o?this._notify(n,t,i):this.requestors.push({ids:n,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{iconTasks:n,patternTasks:r,scope:s}=e;for(const e of[n,r])for(const[t,n]of e.entries()){const e=this.getImage(n.id,s);e&&i.set(t,{image:e,imageVariant:n})}t(null,this._rasterizeImages(s,i))}_rasterizeImages(e,t){const i=new Map;for(const[n,{image:r,imageVariant:s}]of t.entries())i.set(n,this.imageRasterizer.rasterize(s,r,e,0));return i}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,n){const r=this.images.get(i),s=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.z("styleimagemissing",{id:i.name}))}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const n={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(n,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),s.set(e.I.toString(i),n)}n(null,{images:s,versions:this.getImageVersions(i)})}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(t,i,n){const r=t.toString(),s=this.patterns.get(i),o=s.get(r),a=this.getImage(t,i);if(!a)return null;if(o){if(o.position.version===a.version)return o.position;o.position.version=a.version}else{if(a.usvg&&!a.data){const s=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(s))return null;this.patternsInFlight.add(s);const o=new e.A(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[o.toString(),{image:a,imageVariant:o}]]),c=this._rasterizeImages(i,l);return this.storePatternImage(o,i,a,n,c),null}this.storePattern(t,i,a)}return this._updatePatternAtlas(i,n),s.get(r).position}getPatternInFlightId(t,i){return e.t(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,n,r){const s=e.toString(),o=r?r.get(s):void 0;o&&(i.data=o,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,n),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(t,i,n){const r={w:n.data.width+2*e.B,h:n.data.height+2*e.B,x:0,y:0},s=new e.D(r,n,e.B);this.patterns.get(i).set(t.toString(),{bin:r,position:s})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(t,i){const n=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),n.RGBA8),this.atlasTexture.set(i,r)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const n=this.patterns.get(t),r=Array.from(n.values()).map(({bin:e})=>e),{w:s,h:o}=e.F(r),a=this.atlasImage.get(t);a.resize({width:s||1,height:o||1});const l=this.images.get(t);for(const[t,{bin:r,position:s}]of n.entries()){let n=s.padding;const o=r.x+n,c=r.y+n,u=l.get(t).data,h=u.width,d=u.height;n=n>1?n-1:n,e.q.copy(u,a,{x:0,y:0},{x:o,y:c},{width:h,height:d},i),e.q.copy(u,a,{x:0,y:d-n},{x:o,y:c-n},{width:h,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:o,y:c+d},{width:h,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:o-n,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:0,y:0},{x:o+h,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:h-n,y:d-n},{x:o-n,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:d-n},{x:o+h,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:o+h,y:c+d},{width:n,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:o-n,y:c+d},{width:n,height:n},i)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const n of e){if(this.callbackDispatchedThisFrame.get(t).has(n.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(n.toString());const e=i.get(n.toString());ie(e)&&this.updateImage(n,t,e)}}}class $e{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}class Ze extends $e{}function Ye(t){const i=t.value,n=t.valueSpec,r=t.style,s=t.styleSpec,o=t.key,a=t.arrayElementValidator||bt;if(!Array.isArray(i))return[new $e(o,i,`array expected, ${e.J(i)} found`)];if(n.length&&i.length!==n.length)return[new $e(o,i,`array length ${n.length} expected, length ${i.length} found`)];if(n["min-length"]&&i.length<n["min-length"])return[new $e(o,i,`array length at least ${n["min-length"]} expected, length ${i.length} found`)];let l={type:n.value,values:n.values,minimum:n.minimum,maximum:n.maximum,function:void 0};s.$version<7&&(l.function=n.function),e.G(n.value)&&(l=n.value);let c=[];for(let e=0;e<i.length;e++)c=c.concat(a({array:i,arrayIndex:e,value:i[e],valueSpec:l,style:r,styleSpec:s,key:`${o}[${e}]`},!0));return c}function Je(t){const i=t.key,n=t.value,r=t.valueSpec;if(!e.K(n))return[new $e(i,n,`number expected, ${e.J(n)} found`)];if(n!=n)return[new $e(i,n,"number expected, NaN found")];if("minimum"in r){let e=r.minimum;if(Array.isArray(r.minimum)&&(e=r.minimum[t.arrayIndex]),n<e)return[new $e(i,n,`${n} is less than the minimum value ${e}`)]}if("maximum"in r){let e=r.maximum;if(Array.isArray(r.maximum)&&(e=r.maximum[t.arrayIndex]),n>e)return[new $e(i,n,`${n} is greater than the maximum value ${e}`)]}return[]}function Ke(t){const i=t.key,n=t.value;if(!e.G(n))return[new $e(i,n,`object expected, ${e.J(n)} found`)];const r=t.valueSpec,s=e.H(n.type);let o,a,l,c={};const u="categorical"!==s&&void 0===n.property,h=!u,d=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.G(i[0][0])}(n),p=wt({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(e){if("identity"===s)return[new $e(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(Ye({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),Array.isArray(i)&&0===i.length&&t.push(new $e(e.key,i,"array must have at least one stop")),t},default:function(e){return bt({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===s&&u&&p.push(new $e(t.key,t.value,'missing required property "property"')),"identity"===s||n.stops||p.push(new $e(t.key,t.value,'missing required property "stops"')),"exponential"===s&&r.expression&&!e.M(r)&&p.push(new $e(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!e.N(r)?p.push(new $e(t.key,t.value,"property functions not supported")):u&&!e.O(r)&&p.push(new $e(t.key,t.value,"zoom functions not supported"))),"categorical"!==s&&!d||void 0!==n.property||p.push(new $e(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const n=t.value,s=t.key;if(!Array.isArray(n))return[new $e(s,n,`array expected, ${e.J(n)} found`)];if(2!==n.length)return[new $e(s,n,`array length 2 expected, length ${n.length} found`)];if(d){if(!e.G(n[0]))return[new $e(s,n,`object expected, ${e.J(n[0])} found`)];const r=n[0];if(void 0===r.zoom)return[new $e(s,n,"object stop key must have zoom")];if(void 0===r.value)return[new $e(s,n,"object stop key must have value")];const o=e.H(r.zoom);if("number"!=typeof o)return[new $e(s,r.zoom,"stop zoom values must be numbers")];if(l&&l>o)return[new $e(s,r.zoom,"stop zoom values must appear in ascending order")];o!==l&&(l=o,a=void 0,c={}),i=i.concat(wt({key:`${s}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Je,value:m}}))}else i=i.concat(m({key:`${s}[0]`,value:n[0],style:t.style,styleSpec:t.styleSpec},n));return e.Q(e.S(n[1]))?i.concat([new $e(`${s}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(bt({key:`${s}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const n=e.J(t.value),l=e.H(t.value),u=null!==t.value?t.value:i;if(o){if(n!==o)return[new $e(t.key,u,`${n} stop domain type must match previous stop domain type ${o}`)]}else o=n;if("number"!==n&&"string"!==n&&"boolean"!==n&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new $e(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==n&&"categorical"!==s){let i=`number expected, ${n} found`;return e.N(r)&&void 0===s&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $e(t.key,u,i)]}return"categorical"!==s||"number"!==n||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==s&&"number"===n&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&l<a?[new $e(t.key,u,"stop domain values must appear in ascending order")]:(a=l,"categorical"===s&&l in c?[new $e(t.key,u,"stop domain values must be unique")]:(c[l]=!0,[])):[new $e(t.key,u,`integer expected, found ${String(l)}`)]}}function Qe(t){const i=("property"===t.expressionContext?e.V:e.U)(e.S(t.value),t.valueSpec);if("error"===i.result)return i.value.map(e=>new $e(`${t.key}${e.key}`,t.value,e.message));const n=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new $e(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.Y(n))return[new $e(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return et(n,t);if("appearance"===t.expressionContext)return tt(n,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.W(n,["zoom","feature-state"]))return[new $e(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.X(n))return[new $e(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function et(t,i){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.delete(e);if(0===n.size)return[];const r=[];return t instanceof e.Z&&n.has(t.name)?[new $e(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...et(e,i))}),r)}function tt(t,i){const n=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.add(e);if(0===n.size)return[];const r=[];return t instanceof e.Z&&!n.has(t.name)?[new $e(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{r.push(...tt(e,i))}),r)}function it(t){const i=t.key,n=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?r.values.includes(e.H(n))||s.push(new $e(i,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):Object.keys(r.values).includes(e.H(n))||s.push(new $e(i,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),s}function nt(t){return e.a1(e.S(t.value))?Qe(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):rt(t)}function rt(t){const i=t.value,n=t.key;if(!Array.isArray(i))return[new $e(n,i,`array expected, ${e.J(i)} found`)];if(i.length<1)return[new $e(n,i,"filter array must have at least 1 element")];const r=t.styleSpec;let s=it({key:`${n}[0]`,value:i[0],valueSpec:r.filter_operator});const o=()=>{i.length>=2&&(e.$(i[1])||s.push(new $e(`${n}[1]`,i[1],`string expected, ${e.J(i[1])} found`)));for(let t=2;t<i.length;t++)"$type"===e.H(i[1])?s=s.concat(it({key:`${n}[${t}]`,value:i[t],valueSpec:r.geometry_type})):e.$(i[t])||e.K(i[t])||e._(i[t])||s.push(new $e(`${n}[${t}]`,i[t],`string, number, or boolean expected, ${e.J(i[t])} found.`))};switch(e.H(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.H(i[1])&&s.push(new $e(n,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&s.push(new $e(n,i,`filter array for operator "${i[0]}" must have 3 elements`)),o();break;case"==":case"!=":3!==i.length&&s.push(new $e(n,i,`filter array for operator "${i[0]}" must have 3 elements`)),o();break;case"in":case"!in":o();break;case"any":case"all":case"none":for(let e=1;e<i.length;e++)s=s.concat(rt({key:`${n}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":2!==i.length?s.push(new $e(n,i,`filter array for "${i[0]}" operator must have 2 elements`)):e.$(i[1])||s.push(new $e(`${n}[1]`,i[1],`string expected, ${e.J(i[1])} found`))}return s}const st=/^{([^}]+)}$/;function ot(t,i){const n=t.key,r=t.style,s=t.layer,o=t.styleSpec,a=t.value,l=t.objectKey,c=o[`${i}_${t.layerType}`];if(!c)return[];const u=l.match(e.a2);if(u&&c[u[1]])return e.Q(e.S(a))?[].concat(bt({key:n,value:a,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:r,styleSpec:o,expressionContext:"property",propertyType:i,propertyKey:l})):bt({key:n,value:a,valueSpec:{type:"string"},style:r,styleSpec:o});const h=l.match(e.a3);if("paint"===i&&h&&c[h[1]]&&c[h[1]].transition)return bt({key:n,value:a,valueSpec:o.transition,style:r,styleSpec:o});const d=t.valueSpec||c[l];if(!d)return[new Ze(n,a,`unknown property "${l}"`)];let p;if(e.$(a)&&e.N(d)&&!d.tokens&&(p=st.exec(a))){const e=`\`{ "type": "identity", "property": ${p?JSON.stringify(p[1]):'"_"'} }\``;return[new $e(n,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${e}.`)]}const f=[];if("symbol"===t.layerType)"text-field"!==l||!r||r.glyphs||r.imports||f.push(new $e(n,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.a4(e.S(a))&&"identity"===e.H(a.type)&&f.push(new $e(n,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&s&&s.layout&&Object.hasOwn(s.layout,"model-id")&&e.N(d)&&(e.a5(d)||e.O(d))){const t=e.V(e.S(a),d).value,i="expression"in t&&t.expression||"_styleExpression"in t&&t._styleExpression&&t._styleExpression.expression;i&&!e.W(i,["measure-light"])&&("model-emissive-strength"===l&&e.X(i)&&e.Y(i)||f.push(new $e(n,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return f.concat(bt({key:t.key,value:a,valueSpec:d,style:r,styleSpec:o,expressionContext:"property",propertyType:i,propertyKey:l}))}function at(e){return ot(e,"paint")}function lt(e){return ot(e,"layout")}function ct(t){let i=[];const n=t.value,r=t.key,s=t.style,o=t.styleSpec;if(!e.G(n))return[new $e(r,n,"object expected")];n.type||n.ref||i.push(new $e(r,n,'either "type" or "ref" is required'));let a=e.H(n.type);const l=e.H(n.ref);if(n.id){const o=e.H(n.id);for(let a=0;a<t.arrayIndex;a++){const t=s.layers[a];e.H(t.id)===o&&i.push(new $e(r,n.id,`duplicate layer id "${o}", previously used at line ${t.id.__line__}`))}}if("ref"in n){let t;["type","source","source-layer","filter","layout"].forEach(e=>{e in n&&i.push(new $e(r,n[e],`"${e}" is prohibited for ref layers`))}),s.layers.forEach(i=>{e.H(i.id)===l&&(t=i)}),t?t.ref?i.push(new $e(r,n.ref,"ref cannot reference another ref layer")):a=e.H(t.type):"string"==typeof l&&i.push(new $e(r,n.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(n.source)if(e.$(n.source)){const t=s.sources&&s.sources[n.source],o=t&&e.H(t.type);t?"vector"===o&&"raster"===a?i.push(new $e(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?i.push(new $e(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?i.push(new $e(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==o||["raster","raster-particle"].includes(a)?"line"===a&&n.paint&&n.paint["line-gradient"]&&"geojson"===o&&!t.lineMetrics?i.push(new $e(r,n,`layer "${n.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"line"===a&&n.paint&&n.paint["line-trim-offset"]&&"geojson"===o&&!t.lineMetrics?i.push(new $e(r,n,`layer "${n.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==o&&i.push(new $e(r,n.source,`layer "${n.id}" requires a 'raster-array' source.`)):i.push(new $e(r,n.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new $e(r,n,`layer "${n.id}" must specify a "source-layer"`)):i.push(new $e(r,n.source,`source "${n.source}" not found`))}else i.push(new $e(`${r}.source`,n.source,'"source" must be a string'));else i.push(new $e(r,n,'missing required property "source"'));return i=i.concat(wt({key:r,value:n,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bt({key:`${r}.type`,value:n.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"}),filter:e=>nt(Object.assign({layerType:a},e)),layout:e=>wt({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>lt(Object.assign({layerType:a},e))}}),paint:e=>wt({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>at(Object.assign({layerType:a,layer:n},e))}}),appearances(t){const i=Ye({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:n,layerType:r}=t,s=e.H(t.value),o=e.H(s.name),a=e.H(s.condition),l=wt({key:i,value:s,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...Qe({key:t.key,value:t.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:n,layerType:r},t)),properties:e=>function(e){const t=[],{styleSpec:i,layer:n,layerType:r}=e,s=i[`paint_${r}`],o=i[`layout_${r}`],a=e.object[e.objectKey];for(const i in a){const l=i in s?"paint":i in o?"layout":void 0;if(!l){t.push(new $e(e.key,i,`unknown property "${i}" for layer type "${r}"`));continue}const c=Object.assign({},e,{key:`${e.key}.${i}`,object:a,objectKey:i,layer:n,layerType:r,value:a[i],valueSpec:"paint"===l?s[i]:o[i]});t.push(...ot(c,l))}return t}(Object.assign({layer:n,layerType:r},e))}});return"hidden"!==o&&void 0===a&&l.push(new $e(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:n},t))}),r=Array.isArray(t.value)?t.value:[],s=new Set;return r.forEach((r,o)=>{const a=e.H(r.name);if(a)if(s.has(a)){const r=e.H(n.id);i.push(new $e(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`))}else s.add(a)}),i}}})),i}function ut({key:t,value:i}){return e.$(i)?[]:[new $e(t,i,`string expected, ${e.J(i)} found`)]}const ht={promoteId:function t({key:i,value:n}){if(e.$(n))return ut({key:i,value:n});if(Array.isArray(n)){const t=[],r=e.S(n),s=e.U(r);return"error"===s.result?(s.value.forEach(e=>{t.push(new $e(`${i}${e.key}`,null,`${e.message}`))}),t):(e.W(s.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new $e(`${i}`,null,"promoteId expression should be only feature dependent")),t)}if(!e.G(n))return[new $e(i,n,`string, expression or object expected, "${e.J(n)}" found`)];const r=[];for(const e in n)r.push(...t({key:`${i}.${e}`,value:n[e]}));return r}};function dt(t){const i=t.value,n=t.key,r=t.styleSpec,s=t.style;if(!e.G(i))return[new $e(n,i,`object expected, ${e.J(i)} found`)];if(!("type"in i))return[new $e(n,i,'"type" is required')];const o=e.H(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(o)&&("url"in i||"tiles"in i||a.push(new Ze(n,i,'Either "url" or "tiles" is required.'))),o){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(wt({key:n,value:i,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ht})),a;case"geojson":if(a=wt({key:n,value:i,valueSpec:r.source_geojson,style:s,styleSpec:r,objectElementValidators:ht}),"cluster"in i&&"clusterProperties"in i){if(!e.G(i.clusterProperties))return[new $e(`${n}.clusterProperties`,i,`object expected, ${e.J(i)} found`)];for(const e in i.clusterProperties){const t=i.clusterProperties[e];if(!Array.isArray(t))return[new $e(`${n}.clusterProperties.${e}`,t,"array expected")];const[r,s]=t,o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Qe({key:`${n}.${e}.map`,value:s,expressionContext:"cluster-map"})),a.push(...Qe({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}}return a;case"video":return wt({key:n,value:i,valueSpec:r.source_video,style:s,styleSpec:r});case"image":return wt({key:n,value:i,valueSpec:r.source_image,style:s,styleSpec:r});case"canvas":return[new $e(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return it({key:`${n}.type`,value:i.type,valueSpec:{values:pt(r)}})}}function pt(e){return e.source.reduce((t,i)=>{const n=e[i];return"enum"===n.type.type&&(t=t.concat(Object.keys(n.type.values||{}))),t},[])}function ft(e,t){const i=!e.includes("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return!1}}function mt(t){const i=t.value;return i?e.$(i)?ft(i,!0)?[]:[new $e(t.key,i,`invalid url "${i}"`)]:[new $e(t.key,i,`string expected, "${e.J(i)}" found`)]:[]}function gt(t){const i=t.value,n=t.styleSpec,r=n.light,s=t.style;if(void 0===i)return[];if(!e.G(i))return[new $e("light",i,`object expected, ${e.J(i)} found`)];let o=[];for(const t in i){const a=t.match(e.a3),l=t.match(e.a2);o=o.concat(l&&r[l[1]]?bt({key:t,value:i[t],valueSpec:{type:"string"},style:s,styleSpec:n}):a&&r[a[1]]&&r[a[1]].transition?bt({key:t,value:i[t],valueSpec:n.transition,style:s,styleSpec:n}):r[t]?bt({key:t,value:i[t],valueSpec:r[t],style:s,styleSpec:n}):[new $e(t,i[t],`unknown property "${t}"`)])}return o}function _t(t){const i=t.value;if(!i)return[];const n=t.key;if(!e.G(i))return[new $e(n,i,`object expected, ${e.J(i)} found`)];let r=[];const s=t.styleSpec,o=s["light-3d"],a=t.style,l=t.style.lights;for(const e of["type","id"])if(!(e in i))return r=r.concat([new $e(n,i,`missing property "${e}"`)]),r;if(!e.$(i.type))return r=r.concat([new $e(`${n}.type`,i.type,"string expected")]),r;if(l)for(let s=0;s<t.arrayIndex;s++){const t=e.H(i.type),o=l[s];e.H(o.type)===t&&r.push(new $e(n,i.id,`duplicate light type "${i.type}", previously defined at line ${o.id.__line__}`))}const c=`properties_light_${i.type}`;if(!(c in s))return r=r.concat([new $e(`${n}.type`,i,`Invalid light type ${i.type}`)]),r;const u=s[c];for(const n in i)if("properties"===n){const o=i[n];if(!e.G(o))return r=r.concat([new $e("properties",o,`object expected, ${e.J(o)} found`)]),r;for(const l in o){const c=l.match(e.a3),h=l.match(e.a2);r=r.concat(h&&u[h[1]]?bt({key:n,value:o[l],valueSpec:{type:"string"},style:a,styleSpec:s}):c&&u[c[1]]&&u[c[1]].transition?bt({key:n,value:i[n],valueSpec:s.transition,style:a,styleSpec:s}):u[l]?bt({key:l,value:o[l],valueSpec:u[l],style:a,styleSpec:s}):[new Ze(t.key,o[l],`unknown property "${l}"`)])}}else r=r.concat(o[n]?bt({key:n,value:i[n],valueSpec:o[n],style:a,styleSpec:s}):[new Ze(n,i[n],`unknown property "${n}"`)]);return r}function yt(t){const i=t.value,n=t.key,r=t.style,s=t.styleSpec,o=s.terrain;if(null==i)return[];if(!e.G(i))return[new $e("terrain",i,`object expected, ${e.J(i)} found`)];let a=[];for(const t in i){const n=t.match(e.a3),l=t.match(e.a2);a=a.concat(l&&o[l[1]]?bt({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:s}):n&&o[n[1]]&&o[n[1]].transition?bt({key:t,value:i[t],valueSpec:s.transition,style:r,styleSpec:s}):o[t]?bt({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:s}):[new Ze(t,i[t],`unknown property "${t}"`)])}if(i.source)if(e.$(i.source)){const t=r.sources&&r.sources[i.source],s=t&&e.H(t.type);t?"raster-dem"!==s&&a.push(new $e(`${n}.source`,i.source,`terrain cannot be used with a source of type ${s}, it only be used with a "raster-dem" source type`)):a.push(new $e(`${n}.source`,i.source,`source "${i.source}" not found`))}else a.push(new $e(`${n}.source`,i.source,"source must be a string"));else a.push(new $e(n,i,'terrain is missing required property "source"'));return a}function vt(t){const i=t.value,n=t.style,r=t.styleSpec,s=r.fog;if(void 0===i)return[];if(!e.G(i))return[new $e("fog",i,`object expected, ${e.J(i)} found`)];let o=[];for(const t in i){const a=t.match(e.a3),l=t.match(e.a2);o=o.concat(l&&s[l[1]]?bt({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:r}):a&&s[a[1]]&&s[a[1]].transition?bt({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):s[t]?bt({key:t,value:i[t],valueSpec:s[t],style:n,styleSpec:r}):[new Ze(t,i[t],`unknown property "${t}"`)])}return o}const xt={"*":()=>[],array:Ye,boolean:function(t){const i=t.value,n=t.key;return e._(i)?[]:[new $e(n,i,`boolean expected, ${e.J(i)} found`)]},number:Je,color:function({key:t,value:i}){return e.$(i)?null===e.a0.parseCSSColor(i)?[new $e(t,i,`color expected, "${i}" found`)]:[]:[new $e(t,i,`color expected, ${e.J(i)} found`)]},enum:it,filter:nt,function:Ke,layer:ct,object:wt,source:dt,model:mt,light:gt,"light-3d":_t,terrain:yt,fog:vt,string:ut,formatted:function(e){return 0===ut(e).length?[]:Qe(e)},resolvedImage:function(e){return 0===ut(e).length?[]:Qe(e)},projection:function(t){const i=t.value,n=t.styleSpec,r=n.projection,s=t.style;if(e.G(i)){let e=[];for(const t in i)e=e.concat(bt({key:t,value:i[t],valueSpec:r[t],style:s,styleSpec:n}));return e}return e.$(i)?[]:[new $e("projection",i,`object or string expected, ${e.J(i)} found`)]},import:function(t){const i=t.key,{value:n,styleSpec:r}=t;if(!e.G(n))return[new $e(i,n,"import must be an object")];const{data:s,...o}=n;Object.defineProperty(o,"__line__",{value:n.__line__,enumerable:!1});let a=wt(Object.assign({},t,{value:o,valueSpec:r.import}));return""===e.H(o.id)&&a.push(new $e(`${t.key}.id`,o,"import id can't be an empty string")),s&&(a=a.concat(St(s,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,n=t.key,r=t.styleSpec,s=t.style;if(!e.G(i))return[new $e(n,i,"object expected")];if(!i.type)return[new $e(n,i,'"type" is required')];const o=e.H(i.type);let a=[];if(a=a.concat(wt({key:n,value:i,valueSpec:r[`iconset_${o}`],style:s,styleSpec:r})),function(e,t){return!("source"!==e||!t.source)}(o,i)){const t=s.sources&&s.sources[i.source],r=t&&e.H(t.type);t?"raster-array"!==r&&a.push(new $e(n,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new $e(n,i.source,`source "${i.source}" not found`))}return a}};function bt(t,i=!1){const n=t.value,r=t.valueSpec,s=t.styleSpec;if(r.expression){if(e.a4(e.H(n)))return Ke(t);if(e.Q(e.S(n)))return Qe(t)}if(r.type&&xt[r.type]){const e=xt[r.type](t);return!0===i&&e.length>0&&Array.isArray(t.value)?Qe(t):e}return wt(Object.assign({},t,{valueSpec:r.type?s[r.type]:r}))}function wt(t){const i=t.key,n=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},o=t.style,a=t.styleSpec;if(!e.G(n))return[new $e(i,n,`object expected, ${e.J(n)} found`)];let l=[];for(const e in n){const t=e.split(".")[0];let c;s[t]?c=s[t]:r[t]?c=bt:s["*"]?c=s["*"]:r["*"]&&(c=bt),c?l=l.concat(c({key:(i?`${i}.`:i)+e,value:n[e],valueSpec:r[t]||r["*"],style:o,styleSpec:a,object:n,objectKey:e},n)):l.push(new Ze(i,n[e],`unknown property "${e}"`))}for(const e in r){if(s[e])continue;const t=r[e];t.required&&void 0===t.default&&void 0===n[e]&&l.push(new $e(i,n,`missing required property "${e}"`))}return l}function Tt({key:e,value:t}){const i=ut({key:e,value:t});if(i.length)return i;const n=t;return n.includes("{fontstack}")||i.push(new $e(e,t,'"glyphs" url must include a "{fontstack}" token')),n.includes("{range}")||i.push(new $e(e,t,'"glyphs" url must include a "{range}" token')),i}function St(t,i=e.a6,n={}){return wt({key:n.key||"",value:t,valueSpec:Object.assign({},i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:Tt}})}function Et(t,i=e.a6){return kt(St(t,i))}const At=e=>kt(dt(e)),Mt=e=>kt(gt(e)),It=e=>kt(_t(e)),Ct=e=>kt(yt(e)),Pt=e=>kt(vt(e)),Lt=t=>kt(function(t){const i=t.value,n=t.style,r=t.styleSpec,s=r.snow;if(void 0===i)return[];if(!e.G(i))return[new $e("snow",i,`object expected, ${e.J(i)} found`)];let o=[];for(const t in i){const a=t.match(e.a3);o=o.concat(a&&s[a[1]]&&s[a[1]].transition?bt({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):s[t]?bt({key:t,value:i[t],valueSpec:s[t],style:n,styleSpec:r}):[new Ze(t,i[t],`unknown property "${t}"`)])}return o}(t)),Rt=t=>kt(function(t){const i=t.value,n=t.style,r=t.styleSpec,s=r.rain;if(void 0===i)return[];if(!e.G(i))return[new $e("rain",i,`object expected, ${e.J(i)} found`)];let o=[];for(const t in i){const a=t.match(e.a3);o=o.concat(a&&s[a[1]]&&s[a[1]].transition?bt({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):s[t]?bt({key:t,value:i[t],valueSpec:s[t],style:n,styleSpec:r}):[new Ze(t,i[t],`unknown property "${t}"`)])}return o}(t)),Ot=e=>kt(ct(e)),Dt=e=>kt(nt(e)),Bt=e=>kt(at(e)),Ft=e=>kt(lt(e)),Nt=e=>kt(mt(e));function kt(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function zt(t,i){let n=!1;if(i&&i.length)for(const r of i)r instanceof Ze?e.w(r.message):(t.fire(new e.y(new Error(r.message))),n=!0);return n}const Ut=e.a6.light;let Vt;class jt extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a7(Vt||(Vt=new e.a8({anchor:new e.a9(Ut.anchor),position:new e.aa(Ut.position),color:new e.a9(Ut.color),intensity:new e.a9(Ut.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Mt,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&zt(this,t.call(Et,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}const Gt=e.a6.terrain;let Ht=class extends e.E{constructor(t,i,n,r,s){super(),this.scope=n,this._transitionable=new e.a7(new e.a8({source:new e.a9(Gt.source),exaggeration:new e.a9(Gt.exaggeration)}),n,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=s}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.ab(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let n=-1,r=-1,s=1;for(const t of i.zoomStops)s=i.evaluate(new e.ab(t,{worldview:this.worldview})),s>.01?(n=t,r=-1):r=t;return s<.01&&n>0&&r>n?[n,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ac}};const Wt=.05;function qt(t,i,n){const r=e.ag(45,65,n),[s,o]=t.range;let a=1-Math.min(1,Math.exp((i-s)/(o-s)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*r*t.alpha}function Xt(t,i,n,r,s){const o=e.ae([],[i,n,r],s.mercatorFogMatrix);return qt(t,e.af(o),s.pitch)}function $t(t,i,n,r,s,o,a){const l=[[n,r,0],[s,r,0],[s,o,0],[n,o,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const n=e.ae([],t,i),r=e.af(n);c=Math.min(c,r),u=Math.max(u,r)}return[qt(t,c,a.pitch),qt(t,u,a.pitch)]}const Zt=e.a6.fog;class Yt extends e.E{constructor(t,i,n,r){super();const s=new e.a8({range:new e.a9(Zt.range),color:new e.a9(Zt.color),"color-use-theme":new e.a9({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.a9(Zt["high-color"]),"high-color-use-theme":new e.a9({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.a9(Zt["space-color"]),"space-color-use-theme":new e.a9({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.a9(Zt["horizon-blend"]),"star-intensity":new e.a9(Zt["star-intensity"]),"vertical-range":new e.a9(Zt["vertical-range"])});this._transitionable=new e.a7(s,n,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ah(s),this.scope=n}get state(){const t=this._transform,i="globe"===t.projection.name,n=e.ai(t.zoom),r=this.properties.get("range"),s=[2,4.5],o=.5/Math.tan(.5*t._fov),a=[r[0]+o,r[1]+o];return{range:i?[e.aj(s[0],a[0],n),e.aj(s[1],a[1],n)]:a,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Pt,e,i))return;const n=Object.assign({},e);for(const e of Object.keys(Zt))void 0===n[e]&&(n[e]=Zt[e].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,t)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.ag(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,n){const r=e.ad.fromLngLat(i),s=n.elevation?n.elevation.getAtPointOrZero(r):0;return Xt(t,r.x,r.y,s,n)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return $t(this.state,i,0,0,e.ak,e.ak,this._transform)}getOpacityForBounds(e,t,i,n,r){return this._transform.projection.supportsFog?$t(this.state,e,t,i,n,r,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const n of i){const i=t.points[n];let r;if(i[2]>=0)r=i;else{const s=t.points[n-4];r=e.al(s,i,s[2]/(s[2]-i[2]))}if(Xt(this.state,r[0],r[1],0,this._transform)>=Wt)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&zt(this,t.call(Et,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let Jt,Kt,Qt=class extends e.E{constructor(t,i,n,r){super();const s=Jt||(Jt=new e.a8({density:new e.a9(e.a6.snow.density),intensity:new e.a9(e.a6.snow.intensity),color:new e.a9(e.a6.snow.color),opacity:new e.a9(e.a6.snow.opacity),vignette:new e.a9(e.a6.snow.vignette),"vignette-color":new e.a9(e.a6.snow["vignette-color"]),"center-thinning":new e.a9(e.a6.snow["center-thinning"]),direction:new e.a9(e.a6.snow.direction),"flake-size":new e.a9(e.a6.snow["flake-size"])}));this._transitionable=new e.a7(s,n,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ah(s),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.am(n[0]),s=-Math.max(e.am(n[1]),.01),o=[Math.cos(r)*Math.cos(s),Math.sin(r)*Math.cos(s),Math.sin(s)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:o,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Lt,t,n))return;const r=Object.assign({},t),s=e.a6.snow;for(const e of Object.keys(s))void 0===r[e]&&(r[e]=s[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&zt(this,t.call(Et,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},ei=class extends e.E{constructor(t,i,n,r){super();const s=Kt||(Kt=new e.a8({density:new e.a9(e.a6.rain.density),intensity:new e.a9(e.a6.rain.intensity),color:new e.a9(e.a6.rain.color),opacity:new e.a9(e.a6.rain.opacity),vignette:new e.a9(e.a6.rain.vignette),"vignette-color":new e.a9(e.a6.rain["vignette-color"]),"center-thinning":new e.a9(e.a6.rain["center-thinning"]),direction:new e.a9(e.a6.rain.direction),"droplet-size":new e.a9(e.a6.rain["droplet-size"]),"distortion-strength":new e.a9(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a7(s,n,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ah(s),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.am(n[0]),s=-Math.max(e.am(n[1]),.01),o=[Math.cos(r)*Math.cos(s),Math.sin(r)*Math.cos(s),Math.sin(s)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:o,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Rt,t,n))return;const r=Object.assign({},t),s=e.a6.rain;for(const e of Object.keys(s))void 0===r[e]&&(r[e]=s[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&zt(this,t.call(Et,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};const ti={workerUrl:"",workerClass:null,workerParams:void 0};function ii(e){return null!=ti.workerClass?new ti.workerClass:new self.Worker(ti.workerUrl,Object.assign({name:e},ti.workerParams))}const ni="mapboxgl_preloaded_worker_pool";class ri{constructor(e){this.active={},this.name=e}acquire(e,t=ri.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;){const t=ii(`${this.name||""}WorkerPool: ${e}-${this.workers.length}`);this.workers.push(t)}return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach(e=>{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ni]}numActive(){return Object.keys(this.active).length}}ri.workerCount=2;class si{constructor(t,i,n="Worker",r=ri.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.an();const s=this.workerPool.acquire(this.id,r);for(let e=0;e<s.length;e++){const t=new si.Actor(s[e],i,this.id);t.name=`${n} ${e}`,this.actors.push(t)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(t,i,n){e.ao(this.actors,(e,n)=>{e.send(t,i,n)},n=n||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}si.Actor=e.ap;class oi extends e.E{constructor(t,i,n,r){super(),this.scope=n,this._options=t,this.properties=new e.ah(i),this._transitionable=new e.a7(i,n,r),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}let ai;const li=()=>ai||(ai=new e.a8({color:new e.a9(e.a6.properties_light_ambient.color),"color-use-theme":new e.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a9(e.a6.properties_light_ambient.intensity)}));let ci;const ui=()=>ci||(ci=new e.a8({direction:new e.aq(e.a6.properties_light_directional.direction),color:new e.a9(e.a6.properties_light_directional.color),"color-use-theme":new e.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a9(e.a6.properties_light_directional.intensity),"cast-shadows":new e.a9(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.a9(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.a9(e.a6.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.a9(e.a6.properties_light_directional["shadow-draw-before-layer"])}));class hi{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,i){let n,r;if(t instanceof e.P||"number"==typeof t[0]){const s=e.P.convert(t);n=[s],r=i.isPointAboveHorizon(s)}else{const s=e.P.convert(t[0]),o=e.P.convert(t[1]),a=s.add(o)._div(2);n=[s,o],r=e.ar(s,o).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a)}return new hi(n,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.ar(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.ar(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<n.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.as(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.ar(i,n,t),s=this.cameraPoint.clone(),o=Number(s.x>i.x)+Number(s.x>n.x);switch(3*(Number(s.y>i.y)+Number(s.y>n.y))+o){case 0:r[0]=s,r[4]=s.clone();break;case 1:r.splice(1,0,s);break;case 2:r[1]=s;break;case 3:r.splice(4,0,s);break;case 5:r.splice(2,0,s);break;case 6:r[3]=s;break;case 7:r.splice(3,0,s);break;case 8:r[2]=s}return r}containsTile(t,i,n,r=0){const s=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,o=n?this._bufferedCameraMercator(s,i):this._bufferedScreenMercator(s,i);let a=t.tileID.wrap+(o.unwrapped?r:0);const l=o.polygon.map(i=>e.at(t.tileTransform,i,a));if(!e.au(l,0,0,e.ak,e.ak))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.av(t.tileTransform,i,a)),u=c.map(t=>new e.P(t[0],t[1])),h=i.getFreeCameraOptions().position||new e.ad(0,0,0),d=e.av(t.tileTransform,h,a),p=c.map(t=>{const i=e.aw(t,t,d);return e.ax(i,i),new e.ay(d,i)}),f=e.az(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.aA(l),m.min.x=e.aB(m.min.x,0,e.ak),m.min.y=e.aB(m.min.y,0,e.ak),m.max.x=e.aB(m.max.x,0,e.ak),m.max.y=e.aB(m.max.y,0,e.ak),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=fi(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=fi(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.aC([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aE,0,1],s=[0,e.aE,0,1],o=[0,0,0,1];e.aD(r,r,n),e.aD(s,s,n),e.aD(o,o,n);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(s[0]/s[3],s[1]/s[3]),c=e.aF(t,a)&&r[3]<o[3],u=e.aF(t,l)&&s[3]<o[3];if(!c&&!u)return null;const h=function(e,t,i){for(let n=1;n<e.length;n++){const r=pi(t.pointCoordinate3D(e[n-1]).x),s=pi(t.pointCoordinate3D(e[n]).x);if(i<0){if(r<s)return{idx:n,t:-r/(s-1-r)}}else if(s<r)return{idx:n,t:(1-r)/(s+1-r)}}return null}(t,i,c?-1:1);if(!h)return null;const{idx:d,t:p}=h;let f=d>1?di(t.slice(0,d),i):[],m=d<t.length?di(t.slice(d),i):[];f=f.map(t=>new e.P(pi(t.x),t.y)),m=m.map(t=>new e.P(pi(t.x),t.y));const g=[...f];0===g.length&&g.push(m.at(-1));const _=g.at(-1),y=e.aj(_.y,(0===m.length?f[0]:m[0]).y,p);let v;return v=c?[new e.P(0,y),new e.P(0,0),new e.P(1,0),new e.P(1,y)]:[new e.P(1,y),new e.P(1,1),new e.P(0,1),new e.P(0,y)],g.push(...v),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map(t=>new e.ad(t.x,t.y)),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,s=0;for(let e=0;e<t.length-1;e++)t[e].x>r&&(r=t[e].x,s=e);for(let e=0;e<t.length-1;e++){const i=(s+e)%(t.length-1),r=t[i],o=t[i+1];Math.abs(r.x-o.x)>.5&&(r.x<o.x?(r.x+=1,0===i&&(t.at(-1).x+=1)):(o.x+=1,i+1===t.length-1&&(t[0].x+=1)),n=!0)}const o=e.aG(i.center.lng);return n&&o<Math.abs(o-1)&&t.forEach(e=>{e.x-=1}),{polygon:t,unwrapped:n}}(di(t,i).map(t=>new e.P(pi(t.x),t.y)),i);return{polygon:r.polygon.map(t=>new e.ad(t.x,t.y)),unwrapped:r.unwrapped}}}function di(t,i){return e.aH(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function pi(e){return e<0?1+e%1:e%1}function fi(e){return 100*e|0}function mi(t,i){const n=Math.pow(2,i.z),r=Math.floor(e.aG(t.getWest())*n),s=Math.floor(e.aJ(t.getNorth())*n),o=Math.ceil(e.aG(t.getEast())*n),a=Math.ceil(e.aJ(t.getSouth())*n);return i.x>=r&&i.x<o&&i.y>=s&&i.y<a}class gi{constructor(t,i,n){this.bounds=t?e.aI.convert(this.validateBounds(t)):null,this.minzoom=i||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t){this.extraBounds||(this.extraBounds=[]);for(const i of t)this.extraBounds.push(e.aI.convert(this.validateBounds(i)))}}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom)return!1;if(this.bounds&&!mi(this.bounds,e))return!1;if(!this.extraBounds)return!0;for(const t of this.extraBounds)if(mi(t,e))return!0;return!1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;const t=new gi(e.bounds,e.minzoom,e.maxzoom);return t.addExtraBounds(e.extra_bounds),t}}class _i extends e.E{constructor(t,i,n,r){if(super(),this.id=t,this.dispatcher=n,this.type="vector",this.provider=i.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,e.aK(i,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.aL}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview(),r=(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(this._setTileJSON(n),U(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)};this.provider=this._options.provider;const s=e.aM(this._options);return s instanceof Error?(this._loaded=!0,this.fire(new e.y(s)),void(t&&t())):this.provider&&!s?(this._loaded=!0,this.fire(new e.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=s?this.loadTileJSONWithProvider(s,r):e.aN(this._options,this.map._requestManager,i,n,r))}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:n,options:r}=e.aO(this._options,this.map._requestManager),s=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:r,request:n},(t,n)=>{if(s.signal.aborted)return;if(t)return void i(t);const r=n?n.find(e=>null!=e):null,o=e.aP(this._options,r,this.map._requestManager);o instanceof Error?i(o):i(null,o)}),{cancel:()=>s.abort()}}_setTileJSON(e){if(Object.assign(this,e),this.hasWorldviews=!!e.worldview_options,e.worldview_default&&(this.worldviewDefault=e.worldview_default),e.vector_layers){this.vectorLayers=e.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const t of e.vector_layers)this.vectorLayerIds.push(t.id),e.worldview&&e.worldview[t.source]&&this.localizableLayerIds.add(t.id)}this.tileBounds=gi.fromTileJSON(e)}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(t,i){const n=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(n),s=this.map._requestManager.transformRequest(r,e.R.Tile),o=this.map.style?this.map.style.getLut(this.scope):null,a=o?{image:o.image.clone()}:null,l={request:s,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.e(n)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aQ.call({deduped:this._deduped},l,(i,n)=>{if(i||!n)c.call(this,i);else{const i=e.aR(n.responseHeaders);l.data={rawData:n.rawData.slice(0),expires:i.expires,cacheControl:i.cacheControl},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0)}},!0);t.request={cancel:i}}function c(n,r){return delete t.request,t.aborted?i(null):n?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.aS(this.dispatcher),i(null,r),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,t){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class yi extends e.E{constructor(t,i,n,r){super(),this.id=t,this.dispatcher=n,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},i),Object.assign(this,e.aK(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=this.map.getWorldview(),n=(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(Object.assign(this,n),n.raster_layers&&(this.rasterLayers=n.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=gi.fromTileJSON(n),U(n.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)};this.provider="string"==typeof this._options.provider?this._options.provider:void 0,this._tileProvider=void 0;const r=e.aM(this._options);return r instanceof Error?(this._loaded=!0,this.fire(new e.y(r)),void(t&&t())):this.provider&&!r?(this._loaded=!0,this.fire(new e.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=r?this.loadTileJSONWithProvider(r,n):e.aN(this._options,this.map._requestManager,null,i,n))}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:n,options:r}=e.aO(this._options,this.map._requestManager),s=new AbortController;return e.aT(t.name,t.url).then(e=>{if(s.signal.aborted)return;const t=new e(r);return t.load&&n?t.load({request:n}).then(e=>(this._tileProvider=t,e)):(this._tileProvider=t,null)}).then(t=>{if(s.signal.aborted)return;const n=e.aP(this._options,t,this.map._requestManager);n instanceof Error?i(n):i(null,n)}).catch(e=>{s.signal.aborted||i(e instanceof Error?e:new Error(String(e)))}),{cancel:()=>s.abort()}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.o.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize),s=this.map._requestManager.transformRequest(r,e.R.Tile);if(this._tileProvider){const e=new AbortController;t.request={cancel:()=>e.abort()},this.loadTileWithProvider(t,this._tileProvider,s,e,i)}else t.request=e.n(s,(n,r,s)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n)return t.state="errored",i(n);if(!r)return i(null);const o=e.aR(s);this.map._refreshExpiredTiles&&t.setExpiryData(o),t.setTexture(r,this.map.painter),t.state="loaded",e.aS(this.dispatcher),i(null)})}async loadTileWithProvider(e,t,i,n,r){const{z:s,x:o,y:a}=e.tileID.canonical;try{const l=await t.loadTile({z:s,x:o,y:a},{request:i,signal:n.signal});if(n.signal.aborted)return e.state="unloaded",r(null);if(null==l){const t=new Error("Tile not found");return t.status=404,e.state="errored",r(t)}if(null==l.data)return e.state="loaded",r(null);const c=await createImageBitmap(new Blob([l.data]));if(n.signal.aborted)return e.state="unloaded",r(null);e.setTexture(c,this.map.painter),e.state="loaded",this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires}),r(null)}catch(t){if(n.signal.aborted)return e.state="unloaded",r(null);if(t instanceof DOMException&&"AbortError"===t.name)return e.state="unloaded",r(null);e.state="errored",r(t instanceof Error?t:new Error(String(t)))}finally{delete e.request}}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function vi([t,i],n,r,{scaled:s=!0}={}){const{tileSize:o,buffer:a}=r,{x:l,y:c,z:u}=n;if(!isFinite(l)||!isFinite(c)||!isFinite(u))throw new Error("Invalid MRT header");const h=2**u,d=h*e.aG(t),p=h*e.aJ(i);return function([e,t],i,{scaled:n=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:s,buffer:o,offset:a,scale:l,dimension:c}=i;if(e<-o||e>s+o||t<-o||t>s+o)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${s}, buffer=${o}`);const u=(t+o)*(s+2*o)+(e+o);if(4294967295===new Uint32Array(r.buffer)[u])return null;let h=[];h=n?[]:new i.data.constructor(c);for(let e=0;e<c;e++)h[e]=Math.round(1e12*(r[c*u+e]*l+a))/1e12;return h}([Math.min(Math.max(-a,Math.floor((d-l)*o)),o-1+a),Math.min(Math.max(-a,Math.floor((p-c)*o)),o-1+a)],r,{scaled:s})}class xi extends yi{constructor(e,t,i,n){super(e,t,i,n),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},t)}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint()}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile),s={request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.source=this.id,t.scope=this.scope,t.requestParams=r,t.actor||(t.actor=this.dispatcher.getActor());const o=(n,r,s)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n){if("AbortError"===n.name)return;return t.state="errored",i(n)}if(this.map._refreshExpiredTiles&&r){const i=e.aR(s);t.setExpiryData(i)}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r}i(null)};t.request=this.partial?t.fetchHeader(void 0,o.bind(this)):t.actor.send("loadTile",s,o.bind(this),void 0,!0)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e)}else e.destroy()}prepareTile(t,i,n,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,n,r,(i,r)=>{i?(t.state="errored",this.fire(new e.y(i))):r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(n,r,this.map.painter),t.state="loaded"),this.triggerRepaint(t)}))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,n=i&&i.bands&&i.bands;return n?n[0]:0}getTextureDescriptor(t,i,n){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let s=null;i instanceof e.aV?s=i.paint.get("raster-array-band"):i instanceof e.aW&&(s=i.paint.get("raster-particle-array-band"));const o=s||this.getInitialBand(r);if(null==o)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,o);if(t.updateNeeded(i.id,o)&&!n)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const n=new Map;for(const r of t)for(const t of i){const[i,s]=t.split("/"),o=r.getLayer(i);if(!o)continue;if(!o.hasBand(s)||!o.hasDataForBand(s))continue;const{bytes:a,tileSize:l,buffer:c}=o.getBandView(s),u=l+2*c,h={data:new e.q({width:u,height:u},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};n.set(t,h)}return n}queryRasterArrayValueByBandId(t,i,n){const r=i._mrt;return new Promise(s=>{const o={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(n.layerName&&l!==n.layerName)continue;const u={};o[l]=u;for(const{bands:h}of c.dataIndex)for(const d of h)n.bands&&!n.bands.includes(d)||(a.add(e.t(l,d)),i.fetchBand(l,null,d,i=>{e.o.frame(()=>{u[d]=i?null:vi([t.lng,t.lat],r,c.getBandView(d)),a.delete(e.t(l,d)),0===a.size&&s(o)})},!1))}0===a.size&&s(o)})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,n,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!n)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&n){const i=e.aR(r);t.setExpiryData(i)}t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,n)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise((n,r)=>{this._loadTileForQuery(t,(s,o)=>{s?r(s):n(o?this.queryRasterArrayValueByBandId(e,t,i):null)})})}queryRasterArrayValue(t,i){const n=e.aX.convert(t),r=this.findLoadedParent(n);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(n,r,i):this.queryRasterArrayValueByAllBands(n,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ad.fromLngLat(t,this.map.transform.tileSize),n=this.maxzoom+1,r=1<<n,s=Math.floor(i.x),o=Math.floor((i.x-s)*r),a=Math.floor(i.y*r),l=this.map.style.getSourceCache(this.id),c=new e.aU(n,s,n,o,a);return l.findLoadedParent(c,this.minzoom)}}const bi={vector:_i,raster:yi,"raster-dem":class extends yi{constructor(e,t,i,n){super(e,t,i,n),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:n,options:r}=e.aO(this._options,this.map._requestManager),s=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:r,request:n},(t,n)=>{if(s.signal.aborted)return;if(t)return void i(t);const r=n?n.find(e=>null!=e):null,o=e.aP(this._options,r,this.map._requestManager);o instanceof Error?i(o):i(null,o)}),{cancel:()=>s.abort()}}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile),s={uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:r,encoding:this.encoding};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",s,function(e,n){return delete t.request,t.aborted?(t.state="unloaded",i(null)):e?(t.state="errored",i(e)):(n&&(this.map._refreshExpiredTiles&&t.setExpiryData(n),n.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=n.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0),t.state="loaded",void i(null))}.bind(this),void 0,!0))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),t&&t()}_getNeighboringTiles(t){const i=t.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,s=0===i.x?t.wrap-1:t.wrap,o=(i.x+1+n)%n,a=i.x+1===n?t.wrap+1:t.wrap,l={};return l[new e.aU(t.overscaledZ,s,i.z,r,i.y).key]={backfilled:!1},l[new e.aU(t.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aU(t.overscaledZ,s,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aU(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aU(t.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1<n&&(l[new e.aU(t.overscaledZ,s,i.z,r,i.y+1).key]={backfilled:!1},l[new e.aU(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.aU(t.overscaledZ,a,i.z,o,i.y+1).key]={backfilled:!1}),l}},"raster-array":xi,geojson:class extends e.E{constructor(t,i,n,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=n.getActor(),this.setEventedParent(r),this._data=i.data,this._options=Object.assign({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const s=e.ak/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*s,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*s,extent:e.ak,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.ak,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*s,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic},i.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new e.y(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new e.y(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const e=new Map;for(const t of this._data.features)e.set(t.id,t);for(const i of t.features)e.set(i.id,i);this._data.features=[...e.values()]}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,i,n){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},n),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.z("dataloading",{dataType:"source"})),this._loaded=!1;const i=Object.assign({append:t},this.workerOptions);i.scope=this.scope;const n=this._data;"string"==typeof n?(i.request=this.map._requestManager.transformRequest(e.o.resolveURL(n),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(n),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,(i,n)=>{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(i.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const t=e.t(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){const n=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,s=r?{image:r.image.clone()}:null,o=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:s,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:o,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.send(n,a,(e,r)=>o&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aY{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aZ(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.y(new $e(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aY,model:e.a$,"batched-model":class extends e.E{constructor(e,t,i,n){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(n)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=e.aN(this._options,this.map._requestManager,i,n,(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new gi(n.bounds,this.minzoom,this.maxzoom)),U(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,s.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this),void 0,!0);function s(e,n){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadModelData(n,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aY{constructor(t,i,n,r){super(t,i,n,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.y(new $e(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new $e(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new $e(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.y(new $e(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.y(new $e(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(e){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.a_||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,i,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new gi(this._implementation.bounds,this.minzoom,this.maxzoom));const s=i;s.update=this._update.bind(this),s.clearTiles=this._clearTiles.bind(this),s.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aK(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aK(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:n,z:r}=e.tileID.canonical,s=new AbortController,o=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:r},{signal:s.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i))});o.cancel=()=>s.abort(),e.request=o}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:n}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:n})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.t(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},wi=function(t,i,n,r){const s=new bi[i.type](t,i,n,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return e.b0(["load","abort","unload","serialize","prepare"],s),s};function Ti(e,t,i=""){return`${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return`layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return`featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function Si(e,t,i,n=""){if(e.uniqueFeatureID){const r=Ti(e,t,n);if(i.has(r))return!0;i.add(r)}return!1}function Ei(e,t,i,n,r=!1,s=void 0){const o=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,r);a.sort(Ii);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,n,o,r,s);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a})}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,n);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i})}}return 0===l.length?{}:function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,s=i[r]=i[r]||{};for(const i in e){const n=e[i],r=s[i]=s[i]||{},o=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,o.push(e))}}return t}(l)}function Ai(e,t,i,n,r,s){const o={},a=n.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(Ii);for(const e of l){const n=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,s);for(const t in n){const i=o[t]=o[t]||[],r=n[t];r.sort((t,i)=>{const n=e.featureSortOrder;if(n){const e=n.indexOf(t.featureIndex);return n.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e)}}return o}function Mi(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;e<i.length;e++){const s=i[e],o=s.tileID.canonical.key;r[o]||(r[o]=!0,s.querySourceFeatures(n,t))}return n}function Ii(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}e.b1.setPbf(e.b2);class Ci extends e.b3{constructor(e,t,i,n,r){super(e,t,i,n,r),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(e){return this._mrt&&this._mrt.getLayer(e)}setTexturePerLayer(t,i,n){const r=n.context,s=r.gl;let o=this.texturePerLayer.get(t)||n.getTileTexture(i.width);o&&o instanceof e.T?o.update(i,{premultiply:!1}):o=new e.T(r,i,s.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,o)}flushQueues(e){const t=this._workQueuePerLayer.get(e)||[],i=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();for(;i.length;)i.pop()()}flushAllQueues(){for(const e of this._workQueuePerLayer.keys()){const t=this._workQueuePerLayer.get(e)||[];for(;t.length;)t.pop()()}for(const e of this._fetchQueuePerLayer.keys()){const t=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()()}}fetchHeader(t=16384,i){const n=this._mrt=new e.b1(30),r=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.b4(r,(e,r,s)=>{if(e)i(e);else try{const e=n.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));n.parseHeader(r),this._isHeaderLoaded=!0;let o=0;for(const e of Object.values(n.layers))o=Math.max(o,e.dataIndex.at(-1).lastByte);r.byteLength>=o&&(this.entireBuffer=r),i(null,this.entireBuffer||r,s)}catch(e){i(e)}}),this.request}fetchBandForRender(e,t,i,n){this.fetchBand(e,t,i,r=>{if(r)return void n(r);this.updateTextureDescriptor(e,t,i);const s=this.textureDescriptorPerLayer.get(t);n(null,s?s.img:null)})}fetchBand(t,i,n,r,s=!0){const o=this._mrt;if(!this._isHeaderLoaded||!o)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.t(String(n),e.t(this.tileID.key,t));let u=this._taskQueue.get(c);u?u.add(r):(u=new Set,u.add(r),this._taskQueue.set(c,u));const h=(e,t)=>{l.complete(e,t),e?r(e):(u.forEach(e=>e(null,t)),this._taskQueue.delete(c))},d=(e,t)=>{if(e)return r(e);const n=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},h,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{n&&n.cancel(),l.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e)}};let p;try{p=o.getLayer(t)}catch(e){if("reloading"===this.state)return;throw e}if(!p)return void r(new Error(`Unknown sourceLayer "${t}"`));if(p.hasDataForBand(n))return u.forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=p.getDataRange([n]);if(l=o.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),n=e.b4(t,d);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{n.cancel(),l.cancel()}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e)}}}updateNeeded(e,t){return(!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,n){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(n)||!r.hasDataForBand(n))return;const{bytes:s,tileSize:o,buffer:a,offset:l,scale:c}=r.getBandView(n),u=o+2*a,h=new e.q({width:u,height:u},s),d=this.texturePerLayer.get(i);d&&d instanceof e.T&&d.update(h,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:n,img:h,buffer:a,offset:l,tileSize:o,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class Pi{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Li{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const n=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},Object.assign(this.stateChanges[e][n],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])i[t]||(this.deletedStates[e][n][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},n=this.stateChanges[e]||{},r=this.deletedStates[e];if(null===r)return{};if(void 0!==t){const e=String(t),s=Object.assign({},i[e],n[e]);if(r){const e=r[t];if(null===e)return{};for(const t in e)delete s[t]}return s}const s=Object.assign({},i,n);if(r)for(const e in r)delete s[e];return s}initializeTileState(e,t){e.refreshFeatureState(t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},Object.assign(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in e)e[n].refreshFeatureState(t,i)}}class Ri extends e.E{constructor(e,t,i){super(),this.id=e,this._renderSourceType=i,this._maxzoomOverride=null,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Pi(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Li,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles)if(!this._tiles[e].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(e){this._maxzoomOverride=e}_loadTile(e,t){return e.renderSourceType=this._renderSourceType,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Oi).map(e=>e.key)}getRenderableIds(t,i){const n=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&n.push(this._tiles[e]);return t?n.sort((t,i)=>{const n=t.tileID,r=i.tileID,s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||o.y-s.y||o.x-s.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(Oi).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(t,i,n,r,s){if(r){if(t.state="errored",e.b5(r)){if(this._source.fire(new e.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new e.y(r,{tile:t}));return}t.timeAdded=e.o.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let o=new Map;s&&s.responseHeaders&&(o=s.responseHeaders),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:o}))}_hasTunnelGeometry(){for(const e in this._tiles){const t=this._tiles[e];if(t&&t.hasTunnelGeometry)return!0}return!1}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n<t.length;n++){const r=t[n];if(e.neighboringTiles&&e.neighboringTiles[r]){const t=this.getTileByID(r);i(e,t),i(t,e)}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const n=t.tileID.canonical.y-e.tileID.canonical.y,r=Math.pow(2,e.tileID.canonical.z),s=t.tileID.key;0===i&&0===n||Math.abs(n)>1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),e.neighboringTiles&&e.neighboringTiles[s]&&(e.neighboringTiles[s].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,n){for(const r in this._tiles){let s=this._tiles[r];if(n[r]||!s.hasData()||s.tileID.overscaledZ<=t||s.tileID.overscaledZ>i)continue;let o=s.tileID;for(;s&&s.tileID.overscaledZ>t+1;){const e=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[e.key],s&&s.hasData()&&(o=e)}let a=o;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){n[o.key]=o;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),n=this._getLoadedTile(t);if(n)return n}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),s="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(o)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,i,n,r,s){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const o="batched-model"===this._source.type;let a,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t)}const u=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aU(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:u,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aU(1,0,1,0,0)),a.push(new e.aU(1,0,1,1,0)),a.push(new e.aU(1,0,1,0,1)),a.push(new e.aU(1,0,1,1,1)))}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:u,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t))}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),c=Math.min(e,l);if(o){const e=t.extendTileCover(a,c);for(const t of e)a.push(t)}else if(s){const e=this.transform.getFrustum(c),i=t.extendTileCoverToNearPlane(a,e,c);for(const e of i)a.push(e);if(c>=18&&this._hasTunnelGeometry()){const i=t.extendTileCoverForTunnels(a,e,c,20);for(const e of i)a.push(e)}}else if(this.castsShadows&&r){const e=t.extendTileCover(a,c,r,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t)}}const h=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},n=e.o.now(),r=Object.keys(h);for(const e of r){const r=h[e],s=this._tiles[e];if(!s||void 0!==s.fadeEndTime&&s.fadeEndTime<=n)continue;const o=this.findLoadedParent(r,Math.max(r.overscaledZ-Ri.maxOverzooming,this._source.minzoom));o&&(this._addTile(o.tileID),t[o.tileID.key]=o.tileID),i[e]=r}const s=a.at(-1).overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(h[e]||!t.hasData())continue;let n=t.tileID;for(;n.overscaledZ>s;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&i[n.key]){h[e]=t.tileID;break}}}for(const e in t)h[e]||(this._coveredTiles[e]=!0,h[e]=t[e])}for(const e in h)this._tiles[e].clearFadeHold();const d=e.b6(this._tiles,h);for(const e of d){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._renderSourceType===e.b7.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},n=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,s=Math.max(r-Ri.maxOverzooming,this._source.minzoom),o=Math.max(r+Ri.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,n,o,t);for(const n of e){let e=this._tiles[n.key];if(e.hasData())continue;if(n.canonical.z>=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let o=n.overscaledZ-1;o>=s;--o){const s=n.scaledTo(o);if(i[s.key])break;if(i[s.key]=!0,e=this.getTile(s),!e&&r&&(e=this._addTile(s)),e&&(t[s.key]=s,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const n=Boolean(i);if(!n){const n=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Ci(t,r,this.transform.tileZoom,n,this._isRaster):new e.b3(t,r,this.transform.tileZoom,n,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state))}return i.uses++,this._tiles[t.key]=i,n||this._source.fire(new e.z("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,i,n){const r=[],s=this.transform;if(!s)return r;const o="globe"===s.projection.name,a=e.aG(s.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(n&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(o){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aB(a,...Di(t,-1))-a),Math.abs(e.aB(a,...Di(t,1))-a)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aB(a,...Di(t,-1))-a),Math.abs(e.aB(a,...Di(t,0))-a),Math.abs(e.aB(a,...Di(t,1))-a)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(const e of u){const n=t.containsTile(c,s,i,e);n&&r.push(n)}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),n="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=n?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<<e.canonical.z);r[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*n[0]+((e.canonical.y+.5)*t-i[1])*n[1]-i[2]*n[2]}return t.sort((e,t)=>r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const t=e.o.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return!0}}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const n=this._tiles[e];n&&n.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t))}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i))};return void this._source.on("data",e)}const n=new Map,r=Array.isArray(t)?t:[t],s=this.map.painter.terrain,o=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(n.values());e.ao(a,(t,i)=>{const n=new e.b3(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(n,e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),i(e,n)})},i)}}function Oi(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Di(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}Ri.maxOverzooming=10,Ri.maxUnderzooming=3;class Bi{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const i in this.style._mergedLayers){const n=this.style._mergedLayers[i];if("fill-extrusion"===n.type||"building"===n.type)this.layers.push({layer:n,visible:e,visibilityChanged:t});else if("model"===n.type){const i=this.style.getLayerSource(n);i&&"batched-model"===i.type&&this.layers.push({layer:n,visible:e,visibilityChanged:t})}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let n=!1;"fill-extrusion"===i.type?n=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"building"===i.type?n=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(n=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!n&&t.visible,t.visible=n}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,n=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let s=n?n.getTile(t):null;if(!s&&n)for(const e in n._tiles){const i=n._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){s=i;break}}this.currentBuildingBuckets.push({bucket:s?s.getBucket(i):null,tileID:s?s.tileID:t,verticalScale:r})}e.hasAnyZOffset=!1;let i=!1;for(let n=0;n<e.symbolInstances.length;n++){const r=e.symbolInstances.get(n),s=r.zOffset,o=this._getHeightAtTileOffset(t,r.tileAnchorX,r.tileAnchorY);r.zOffset=o!==Number.NEGATIVE_INFINITY?o:s,i||s===r.zOffset||(i=!0),e.hasAnyZOffset||0===r.zOffset||(e.hasAnyZOffset=!0)}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,i,n,r){let s=i,o=n;if(t.canonical.z!==r.canonical.z){const a=r.canonical,l=1/(1<<t.canonical.z-a.z);s=(i+t.canonical.x*e.ak)*l-a.x*e.ak|0,o=(n+t.canonical.y*e.ak)*l-a.y*e.ak|0}return{tileX:s,tileY:o}}_getHeightAtTileOffset(e,t,i){let n,r;for(let s=0;s<this.layers.length;++s){const o=this.layers[s].layer;if("fill-extrusion"!==o.type&&"building"!==o.type)continue;const{bucket:a,tileID:l,verticalScale:c}=this.currentBuildingBuckets[s];if(!a)continue;const{tileX:u,tileY:h}=this._mapCoordToOverlappingTile(e,t,i,l),d=a.getHeightAtTileCoord(u,h);d&&void 0!==d.height&&(d.hidden?n=d.height:r=Math.max(d.height*c,r||0))}if(void 0!==r)return r;for(let r=0;r<this.layers.length;++r){const s=this.layers[r];if("model"!==s.layer.type||!s.visible)continue;const{bucket:o,tileID:a}=this.currentBuildingBuckets[r];if(!o)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,a),u=o.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return void 0===u.height&&void 0!==n?Math.min(u.maxHeight,n)*u.verticalScale:u.height?u.height*u.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let Fi;function Ni(){return Fi||(Fi=new ri),Fi}function ki(t,i){const n={};for(const e in t)"ref"!==e&&(n[e]=t[e]);return e.b8.forEach(e=>{e in i&&(n[e]=i[e])}),n}function zi(e){e=e.slice();const t=Object.create(null);for(const i of e)t[i.id]=i;for(let i=0;i<e.length;i++){const n=e[i];if(n&&"ref"in n){const r=t[n.ref];r&&(e[i]=ki(n,r))}}return e}const Ui={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function Vi(e,t,i){i.push({command:Ui.addSource,args:[e,t[e]]})}function ji(e,t,i){t.push({command:Ui.removeSource,args:[e]}),i[e]=!0}function Gi(e,t,i,n){ji(e,i,n),Vi(e,t,i)}function Hi(t,i,n){let r;for(r in t[n])if(Object.hasOwn(t[n],r)&&"data"!==r&&!e.b9(t[n][r],i[n][r]))return!1;for(r in i[n])if(Object.hasOwn(i[n],r)&&"data"!==r&&!e.b9(t[n][r],i[n][r]))return!1;return!0}function Wi(t,i,n,r,s,o){let a;for(a in i=i||{},t=t||{})Object.hasOwn(t,a)&&(e.b9(t[a],i[a])||n.push({command:o,args:[r,a,i[a],s]}));for(a in i)Object.hasOwn(i,a)&&!Object.hasOwn(t,a)&&(e.b9(t[a],i[a])||n.push({command:o,args:[r,a,i[a],s]}))}function qi(e){return e.id}function Xi(e,t){return e[t.id]=t,e}function $i(t,i,n){const r=i.createTileMatrix(t,t.worldSize,n.toUnwrapped());return e.aC(new Float32Array(16),t.projMatrix,r)}function Zi(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const n=i.clone();return n.setProjection(t.projection),$i(n,t.getProjection(),e)}function Yi(e,t,i){return t.name===i.projection.name?e.projMatrix:$i(i,t,e)}class Ji{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances.at(-1),this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.aB(t,0,1);let i=1,n=this._distances[i];const r=t*this.paddedLength+this.padding;for(;n<r&&i<this._distances.length;)n=this._distances[++i];const s=i-1,o=this._distances[s],a=n-o,l=a>0?(r-o)/a:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}const Ki=Math.tan(85*Math.PI/180);function Qi(t,i,n,r,s,o,a){const l=e.bd();if(n)if("globe"===o.name){const t=e.be(s,i);e.aC(l,l,t)}else{const t=e.bf([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.bc(l,l,s.angle)}else e.aC(l,s.labelPlaneMatrix,t);return l}function en(e,t,i,n,r,s,o){const a=Qi(e,t,i,n,r,s,o);return"globe"===s.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function tn(t,i,n,r,s,o,a){if(n){if("globe"===o.name){const l=Qi(t,i,n,r,s,o,a);return e.ba(l,l),e.aC(l,t,l),l}{const i=e.bb(t),[n,o,l,c]=a,[u,h,d,p,f,m,g,_]=i;return i[0]=n*u+o*f,i[1]=n*h+o*m,i[2]=n*d+o*g,i[3]=n*p+o*_,i[4]=l*u+c*f,i[5]=l*h+c*m,i[6]=l*d+c*g,i[7]=l*p+c*_,r||e.bc(i,i,-s.angle),i}}return s.glCoordMatrix}function nn(t,i,n,r){const s=[t,i,n,1];n?e.aD(s,s,r):fn(s,s,r);const o=s[3];return s[0]/=o,s[1]/=o,s[2]/=o,s}function rn(e,t){return Math.min(.5+e/t*.5,1.5)}function sn(e,t){const i=e[0]/e[3],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function on(t,i,n,r,s,o,a,l,c,u,h=1){const d=n.transform,p=r?t.textSizeData:t.iconSizeData,f=e.bl(p,n.transform.zoom,h),m="globe"===d.projection.name,g=[256/n.width*2+1,256/n.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let y=null;m&&(y=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=n.transform.width/n.transform.height;let w,T=!1;for(let r=0;r<x.length;r++){const h=x.get(r),{numGlyphs:m,writingMode:S}=h;if(S!==e.bm.vertical||T||w===e.bm.horizontal||(T=!0),w=S,(h.hidden||S===e.bm.vertical)&&!T){pn(m,_);continue}T=!1;const E=new e.P(h.tileAnchorX,h.tileAnchorY),A="road"===t.elevationType,M=!!d.elevation||A;let{x:I,y:C,z:P}=d.projection.projectTilePoint(E.x,E.y,u.canonical),L=null;if(M){const e=A?t.getElevationFeatureForText(r):null;L={getElevation:c,elevation:d.elevation,elevationFeature:e};const[i,n,s]=c(E,d.elevation,e);I+=i,C+=n,P+=s}const R=[I,C,P,1];if(e.aD(R,R,i),!sn(R,g)){pn(m,_);continue}const O=R[3],D=rn(n.transform.getCameraToCenterDistance(d.projection),O),B=e.bn(p,f,h),F=a?B/D:B*D,N=nn(I,C,P,s);if(N[3]<=0){pn(m,_);continue}let k={};const z=e.am(t.layers[0].layout.get("text-max-angle")),U=Math.cos(z),V=a?null:L,j=cn(h,F,!1,l,i,s,o,t.glyphOffsetArray,v,_,y,N,E,k,b,V,d.projection,u,a,U);T=j.useVertical,V&&j.needsFlipping&&(k={}),(j.notEnoughRoom||T||j.needsFlipping&&cn(h,F,!0,l,i,s,o,t.glyphOffsetArray,v,_,y,N,E,k,b,V,d.projection,u,a,U).notEnoughRoom)&&pn(m,_)}r?(t.text.dynamicLayoutVertexBuffer.updateData(_),y&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(y)):(t.icon.dynamicLayoutVertexBuffer.updateData(_),y&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(y))}function an(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g){const{lineStartIndex:_,glyphStartIndex:y,segment:v}=a,x=y+a.numGlyphs,b=_+a.lineLength,w=t.getoffsetX(y),T=t.getoffsetX(x-1),S=dn(e*w,i,n,r,s,o,v,_,b,l,c,u,h,d,!0,p,f,m,g);if(!S)return null;const E=dn(e*T,i,n,r,s,o,v,_,b,l,c,u,h,d,!0,p,f,m,g);return E?{first:S,last:E}:null}function ln(t,i,n,r){return t===e.bm.horizontal&&Math.abs(r)>Math.abs(n)?{useVertical:!0}:t===e.bm.vertical?r>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>Ki}(n,r)?1===i?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function cn(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x){const b=i/24,w=t.lineOffsetX*b,T=t.lineOffsetY*b,{lineStartIndex:S,glyphStartIndex:E,numGlyphs:A,segment:M,writingMode:I,flipState:C}=t,P=S+t.lineLength,L=t=>{if(h){const[i,n,r]=t.up,s=u.length;e.bo(h,s+0,i,n,r),e.bo(h,s+1,i,n,r),e.bo(h,s+2,i,n,r),e.bo(h,s+3,i,n,r)}const[i,n,r]=t.point;e.bp(u,i,n,r,t.angle)};if(A>1){const e=an(b,l,w,T,n,d,p,t,c,o,f,g,!1,_,y,v,x);if(!e)return{notEnoughRoom:!0};if(r&&!n){let[i,n,r]=e.first.point,[s,o,l]=e.last.point;[i,n]=nn(i,n,r,a),[s,o]=nn(s,o,l,a);const c=ln(I,C,(s-i)*m,o-n);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}L(e.first);for(let e=E+1;e<E+A-1;e++){const t=dn(b*l.getoffsetX(e),w,T,n,d,p,M,S,P,c,o,f,g,!1,!1,_,y,v,x);if(!t)return u.length-=4*(e-E),{notEnoughRoom:!0};L(t)}L(e.last)}else{if(r&&!n){const i=nn(p.x,p.y,0,s),n=S+M+1,r=new e.P(c.getx(n),c.gety(n)),o=nn(r.x,r.y,0,s),a=o[3]>0?o:hn(p,r,i,1,s,void 0,_,y.canonical),l=ln(I,C,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=dn(b*l.getoffsetX(E),w,T,n,d,p,M,S,P,c,o,f,g,!1,!1,_,y,v,x);if(!i)return{notEnoughRoom:!0};L(i)}return{}}function un(e,t,i,n,r){const{x:s,y:o,z:a}=n.projectTilePoint(e.x,e.y,t);if(!r)return nn(s,o,a,i);const[l,c,u]=r.getElevation(e,r.elevation,r.elevationFeature);return nn(s+l,o+c,a+u,i)}function hn(t,i,n,r,s,o,a,l){const c=un(t.sub(i)._unit()._add(t),l,s,a,o);return e.aw(c,n,c),e.ax(c,c),e.bi(c,n,c,r)}function dn(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v){const x=r?t-i:t+i;let b=x>0?1:-1,w=0;r&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=l+a+(b>0?0:1)|0,S=s,E=s,A=0,M=0;const I=Math.abs(x),C=[],P=[];let L=o,R=L,O=e.bg([]);const D=()=>hn(R,L,E,I-A+1,h,p,g,_.canonical);for(;A+M<=I;){if(T+=b,T<l||T>=c)return null;if(E=S,R=L,C.push(E),f&&P.push(R),L=new e.P(u.getx(T),u.gety(T)),S=d[T],!S){const e=un(L,_.canonical,h,g,p);S=e[3]>0?d[T]=e:D()}A+=M;const t=e.aw([],S,E),i=e.bh(E,S);if(n&&i>0&&M>0&&e.bk(O,t)/(M*i)<v)return null;M=i,O=t}m&&p&&(d[T]&&(S=D(),M=e.bh(E,S),O=e.aw([],S,E)),d[T]=S);const B=(I-A)/M,F=L.sub(R)._mult(B)._add(R),N=e.bi([],E,O,B);let k=[0,0,1],z=O[0],U=O[1];if(y&&(k=g.upVector(_.canonical,F.x,F.y),0!==k[0]||0!==k[1]||1!==k[2])){const t=[k[2],0,-k[0]],i=e.bj([],k,t);e.ax(t,t),e.ax(i,i),z=e.bk(O,t),U=e.bk(O,i)}if(n){const t=e.bj([],k,O);e.ax(t,t),e.bi(N,N,t,n*b)}const V=w+Math.atan2(U,z);return C.push(N),f&&P.push(F),{point:N,angle:V,path:C,tilePath:P,up:k}}function pn(e,t){const i=t.length,n=i+4*e;t.resize(n),t.float32.fill(-1/0,4*i,4*n)}function fn(e,t,i){const n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e[3]=i[3]*n+i[7]*r+i[15],e}const mn=100;class gn{constructor(t,i,n=new e.bq(t.width+200,t.height+200,25),r=new e.bq(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=r,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+mn,this.screenBottomBoundary=t.height+mn,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=i,this.clippedSymbols=new Map}clearClippedSymbolsForBucket(e){this.clippedSymbols.delete(e)}markSymbolAsClipped(e,t){let i=this.clippedSymbols.get(e);i||(i=new Set,this.clippedSymbols.set(e,i)),i.add(t)}placeCollisionBox(t,i,n,r,s,o,a,l,c,u,h){let d=n.projectedAnchorX,p=n.projectedAnchorY,f=n.projectedAnchorZ;const m=n.tileAnchorX,g=n.tileAnchorY,_=n.elevation,y=n.tileID,v=t.getProjection();if(_&&y){const[e,t,i]=v.upVector(y.canonical,n.tileAnchorX,n.tileAnchorY),r=v.upVectorScale(y.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;d+=e*_*r,p+=t*_*r,f+=i*_*r}const x="globe"===t.projection.name,b="globe"===t.projection.name?e.ai(this.transform.zoom):0;if(y&&x&&b<1&&!o){const t=1<<y.canonical.z,i=e.br(m,g);e.bs(i,i,1/e.ak),e.bt(i,i,e.br(y.canonical.x,y.canonical.y)),e.bs(i,i,1/t),e.bu(i,i,e.br(r[0],r[1])),i[0]=e.bv(i[0],-.5,.5),e.bs(i,i,e.ak);const n=e.bw(i[0],i[1],e.ak/(2*Math.PI),1);e.aD(n,n,s),d=e.aj(d,n[0],b),p=e.aj(p,n[1],b),f=e.aj(f,n[2],b)}const w=this.projectAndGetPerspectiveRatio(u,d,p,f,n.tileID,"globe"===v.name||!!_||this.transform.pitch>0,v),T=c*w.perspectiveRatio,S=(n.x1*i+a.x-n.padding)*T+w.point.x,E=(n.y1*i+a.y-n.padding)*T+w.point.y,A=(n.x2*i+a.x+n.padding)*T+w.point.x,M=(n.y2*i+a.y+n.padding)*T+w.point.y,I=w.perspectiveRatio<=.55||w.occluded;return!this.isInsideGrid(S,E,A,M)||!l&&this.grid.hitTest(S,E,A,M,h)||I?{box:[],offscreen:!1,occluded:w.occluded}:{box:[S,E,A,M],offscreen:this.isOffscreen(S,E,A,M),occluded:!1}}placeCollisionCircles(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g){const _=[],y=this.transform.elevation,v=t.getProjection(),x="road"===t.elevationType,b=!!y||x,w=e.bx.getAtTileOffsetFunc(g,this.transform.center.lat,this.transform.worldSize,v),T=new e.P(n.tileAnchorX,n.tileAnchorY),S=new e.P(n.tileAnchorX,n.tileAnchorY);let{x:E,y:A,z:M}=v.projectTilePoint(S.x,S.y,g.canonical),I=null;if(b){const e=x?t.getElevationFeatureForText(r):null;I={getElevation:w,elevation:y,elevationFeature:e};const[i,n,s]=w(T,y,e);E+=i,A+=n,M+=s}const C="globe"===v.name,P=this.projectAndGetPerspectiveRatio(l,E,A,M,g,C||!!y||this.transform.pitch>0,v),{perspectiveRatio:L}=P,R=(d?a/L:a*L)/e.bC,O=nn(E,A,M,c),D=n.lineOffsetX*R,B=n.lineOffsetY*R,F=e.am(t.layers[0].layout.get("text-max-angle")),N=Math.cos(F),k=P.signedDistanceFromCamera>0?an(R,o,D,B,x&&1===n.flipState,O,S,n,s,c,{},b&&!d?I:null,d&&b,v,g,d,N):null;let z=!1,U=!1,V=!0;if(k&&!P.occluded){const t=.5*f*L+m,n=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),s=new Ji,{first:o,last:a}=k,l=o.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(o.path[e]);for(let e=1;e<a.path.length;e++)c.push(a.path[e]);const d=2.5*t;u&&(c=c.map(([e,t,i],n)=>(b&&!C&&(i=w(n<l-1?o.tilePath[l-1-n]:a.tilePath[n-l+2],y,I.elevationFeature)[2]),nn(e,t,i,u))),c.some(e=>e[3]<=0)&&(c=[]));let g=[];if(c.length>0){let t=1/0,i=-1/0,s=1/0,o=-1/0;for(const e of c)t=Math.min(t,e[0]),s=Math.min(s,e[1]),i=Math.max(i,e[0]),o=Math.max(o,e[1]);i>=n.x&&t<=r.x&&o>=n.y&&s<=r.y&&(g=[c.map(t=>new e.P(t[0],t[1]))],(t<n.x||i>r.x||s<n.y||o>r.y)&&(g=e.by(g,n.x,n.y,r.x,r.y)))}for(const e of g){s.reset(e,.25*t);let n=0;n=s.length<=.5*t?1:Math.ceil(s.paddedLength/d)+1;for(let e=0;e<n;e++){const r=e/Math.max(n-1,1),o=s.lerp(r),a=o.x+mn,l=o.y+mn;_.push(a,l,t,0);const c=a-t,u=l-t,d=a+t,f=l+t;if(V=V&&this.isOffscreen(c,u,d,f),U=U||this.isInsideGrid(c,u,d,f),!i&&this.grid.hitTestCircle(a,l,t,p)&&(z=!0,!h))return{circles:[],offscreen:!1,collisionDetected:z,occluded:!1}}}}return{circles:!h&&z||!U?[]:_,offscreen:V,collisionDetected:z,occluded:P.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let n=1/0,r=1/0,s=-1/0,o=-1/0;for(const a of t){const t=new e.P(a.x+mn,a.y+mn);n=Math.min(n,t.x),r=Math.min(r,t.y),s=Math.max(s,t.x),o=Math.max(o,t.y),i.push(t)}const a=this.grid.query(n,r,s,o).concat(this.ignoredGrid.query(n,r,s,o)),l={},c={};for(const t of a){const n=t.key;if(void 0===l[n.bucketInstanceId]&&(l[n.bucketInstanceId]={}),l[n.bucketInstanceId][n.featureIndex])continue;const r=this.clippedSymbols.get(n.bucketInstanceId);if(r&&r.has(n.featureIndex))continue;const s=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.bz(i,s)&&(l[n.bucketInstanceId][n.featureIndex]=!0,void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]=[]),c[n.bucketInstanceId].push(n.featureIndex))}return c}insertCollisionBox(e,t,i,n,r){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:n,collisionGroupID:r},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r){const s=t?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:n,collisionGroupID:r};for(let t=0;t<e.length;t+=4)s.insertCircle(o,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,i,n,r,s,o,a){const l=[i,n,r,1];let c=!1;if(r||this.transform.pitch>0){if(e.aD(l,l,t),this.fogState&&s&&"globe"!==a.name){const t=function(t,i,n,r,s,o){const a=o.calculateFogTileMatrix(s),l=[i,n,r];return e.ae(l,l,a),qt(t,e.af(l),o.pitch)}(this.fogState,i,n,r,s.toUnwrapped(),this.transform);c=t>.9}}else fn(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+mn,(-l[1]/u+1)/2*this.transform.height+mn),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:o&&l[2]>u||c}}isOffscreen(e,t,i,n){return i<mn||e>=this.screenRightBoundary||n<mn||t>this.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e<this.gridRightBoundary&&n>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.bA([]);return e.bB(t,t,[-100,-100,0]),t}}class _n{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class yn{constructor(e,t,i,n,r,s=!1){this.text=new _n(e?e.text:null,t,i,r),this.icon=new _n(e?e.icon:null,t,n,r),this.clipped=s}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class vn{constructor(e,t,i,n=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=n}}class xn{constructor(){this.invProjMatrix=e.bd(),this.viewportMatrix=e.bd(),this.circles=[]}}class bn{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class wn{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Tn(t,i,n,r,s){const{horizontalAlign:o,verticalAlign:a}=e.bJ(t),l=-(o-.5)*i,c=-(a-.5)*n,u=e.bK(t,r);return new e.P(l+u[0]*s,c+u[1]*s)}function Sn(t,i,n,r,s){const o=new e.P(t,i);return n&&o._rotate(r?s:-s),o}class En{constructor(e,t,i,n,r,s){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new gn(this.transform,r),this.buildingIndex=s,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new wn(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(t,i,n,r,s=1){const o=n.getBucket(i),a=n.latestFeatureIndex;if(!o||!a||i.fqid!==o.layerIds[0])return;const l=o.layers[0].layout,c=o.layers[0].paint,u=n.collisionBoxArray,h=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),d=n.tileSize/e.ak,p=n.tileID.toUnwrapped();this.transform.setProjection(o.projection);const f=(m=n.tileID,g=o.getProjection(),_=this.transform,g.name===this.projection?_.calculateProjMatrix(m.toUnwrapped()):$i(_,g,m));var m,g,_;const y="map"===l.get("text-pitch-alignment"),v="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const x=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(n),S=en(f,n.tileID.canonical,y,v,this.transform,o.getProjection(),T);let E=null;const A=o.getProjection().createInversionMatrix(this.transform,n.tileID.canonical);if(y){const t=tn(f,n.tileID.canonical,y,v,this.transform,o.getProjection(),T);E=e.aC([],this.transform.labelPlaneMatrix,t)}let M=null;x&&n.latestFeatureIndex&&(M={unwrappedTileID:p,dynamicFilter:x,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[o.bucketInstanceId]=new bn(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,n.tileID);const[I,C]=o.layers[0].layout.get("text-size-scale-range"),P=e.aB(s,I,C),[L,R]=l.get("icon-size-scale-range"),O=e.aB(s,L,R),D={bucket:o,layout:l,paint:c,posMatrix:f,invMatrix:A,mercatorCenter:[e.aG(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:S,labelToScreenMatrix:E,clippingData:M,scale:h,textPixelRatio:d,holdingForFade:n.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bl(o.textSizeData,this.transform.zoom,P),partiallyEvaluatedIconSize:e.bl(o.iconSizeData,this.transform.zoom,O),collisionGroup:this.collisionGroups.get(o.sourceID),latestFeatureIndex:n.latestFeatureIndex};if(r)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:D})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:D})}attemptAnchorPlacement(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x){const{textOffset0:b,textOffset1:w,crossTileID:T}=f,S=[b,w],E=Tn(e,s,o,S,a),A=this.collisionIndex.placeCollisionBox(g,a,t,i,n,r,Sn(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate);if(y){const e=g.getSymbolInstanceIconSize(x,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,y,i,n,r,Sn(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(A.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[T]&&this.prevPlacement.placements[T]&&this.prevPlacement.placements[T].text&&(t=this.prevPlacement.variableOffsets[T].anchor),this.variableOffsets[T]={textOffset:S,width:s,height:o,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(g,e,f,_),g.allowVerticalPlacement&&(this.markUsedOrientation(g,_,f),this.placedOrientations[T]=_),{shift:E,placedGlyphBoxes:A}}}placeLayerBucketPart(t,i,n,r,s=1){const{bucket:o,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:g,collisionBoxArray:_,partiallyEvaluatedTextSize:y,partiallyEvaluatedIconSize:v,collisionGroup:x,latestFeatureIndex:b}=t.parameters,w=a.get("text-optional"),T=a.get("icon-optional"),S=a.get("text-allow-overlap"),E=a.get("icon-allow-overlap"),A="map"===a.get("text-rotation-alignment"),M="map"===a.get("icon-rotation-alignment"),I="map"===a.get("text-pitch-alignment"),C=l.get("symbol-z-offset"),P="sea"===a.get("symbol-elevation-reference"),L=a.get("symbol-placement"),[R,O]=a.get("text-size-scale-range"),[D,B]=a.get("icon-size-scale-range"),F=e.aB(s,R,O),N=e.aB(s,D,B),k=a.get("text-variable-anchor"),z=A&&"point"!==L,U=M&&"point"!==L,V=k&&o.hasTextData(),j=o.hasIconTextFit()&&V&&o.hasIconData();this.transform.setProjection(o.projection);const G=V||z,H=U||j;let W=S&&(E||!o.hasIconData()||T),q=E&&(S||!o.hasTextData()||w);const X=!C.isConstant();!o.collisionArrays&&_&&o.deserializeCollisionBoxes(_),n&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,_,F,N);const $=(t,r,s)=>{const{crossTileID:l,numVerticalGlyphVertices:_}=t;let M=null;if(d&&d.dynamicFilterNeedsFeature||X){const i=this.retainedQueryData[o.bucketInstanceId],n=b.loadFeature({featureIndex:t.featureIndex,bucketIndex:i.bucketIndex,sourceLayerIndex:i.sourceLayerIndex,layoutVertexArrayOffset:0}),r=n.properties?n.properties.worldview:null;if(o.localizable&&o.worldview&&"string"==typeof r)if("all"===r)n.properties.$localized=!0;else{if(!r.split(",").includes(o.worldview))return;n.properties.$localized=!0,n.properties.worldview=o.worldview}M=d&&d.needGeometry?e.bH(n,!0):n}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:o.worldview},M,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[l]=new vn(!1,!1,!1,!0),void i.add(l);const L=C.evaluate(M,{});if((t.zOffset||0)+(L||0)>0&&this.frontCutoffStart>0){const n=2*this.frontCutoffStart-1,r=[t.tileAnchorX,t.tileAnchorY,0,1],s=e.aD(e.bI(),r,c);if(s[1]/s[3]<n)return this.placements[l]=new vn(!1,!1,!1,!0),void i.add(l)}if(i.has(l))return;if(g)return void(this.placements[l]=new vn(!1,!1,!1));let R=!1,O=!1,D=!0,B=!1,F=!1,N=null,z={box:null,offscreen:null,occluded:null},U={box:null},V=null,j=null,$=null,Z=0,Y=0,J=0;s.textFeatureIndex?Z=s.textFeatureIndex:t.useRuntimeCollisionCircles&&(Z=t.featureIndex),s.verticalTextFeatureIndex&&(Y=s.verticalTextFeatureIndex);const K=o.elevationFeatures?o.elevationFeatures[t.elevationFeatureIndex]:void 0,Q=i=>{i.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const n=this.transform.elevation;i.elevation=P?L:L+e.bx.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),n,K),i.elevation+=t.zOffset},ee=s.textBox;if(ee){Q(ee);const i=i=>{let n=e.bm.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,n=e,this.markUsedOrientation(o,n,t))}return n},n=(t,i)=>{if(o.allowVerticalPlacement&&_>0&&s.verticalTextBox){for(const n of o.writingModes)if(n===e.bm.vertical?(z=i(),U=z):z=t(),z&&z.box&&z.box.length)break}else z=t()};if(k){let a=k;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor))}const u=(e,i,n)=>{const s=o.getSymbolInstanceTextSize(y,t,this.transform.zoom,r),l=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,h=t.hasIconTextFit&&!E?i:null;h&&Q(h);let d={box:[],offscreen:!1,occluded:!1};const g=S?2*a.length:a.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(a[i%a.length],e,f,m,G,l,u,s,A,I,p,c,x,i>=a.length,t,r,o,n,h,y,v);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){R=!0,N=g.shift;break}}return d};n(()=>u(ee,s.iconBox,e.bm.horizontal),()=>{const t=s.verticalTextBox;return t&&Q(t),o.allowVerticalPlacement&&!(z&&z.box&&z.box.length)&&_>0&&t?u(t,s.verticalIconBox,e.bm.vertical):{box:null,offscreen:null,occluded:null}}),z&&(R=z.box,D=z.offscreen,B=z.occluded);const h=i(!(!z||!z.box));if(!R&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(o,e.anchor,t,h))}}else{const a=(i,n)=>{const s=o.getSymbolInstanceTextSize(y,t,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(o,s,i,f,m,G,new e.P(0,0),S,p,c,x.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(o,n,t),this.placedOrientations[l]=n),a};n(()=>a(ee,e.bm.horizontal),()=>{const t=s.verticalTextBox;return o.allowVerticalPlacement&&_>0&&t?(Q(t),a(t,e.bm.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(z&&z.box&&z.box.length))}}if(V=z,R=V&&V.box&&V.box.length>0,D=V&&V.offscreen,B=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,r=o.text.placedSymbolArray.get(i),s=e.bn(o.textSizeData,y,r),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(o,S,r,i,o.lineVertexArray,o.glyphOffsetArray,s,c,u,h,n,I,x.predicate,t.collisionCircleDiameter*s/e.bC,l,this.retainedQueryData[o.bucketInstanceId].tileID),R=S||j.circles.length>0&&!j.collisionDetected,D=D&&j.offscreen,B=j.occluded}if(s.iconFeatureIndex&&(J=s.iconFeatureIndex),s.iconBox){const i=i=>{Q(i);const n=t.hasIconTextFit&&N?Sn(N.x,N.y,A,I,this.transform.angle):new e.P(0,0),r=o.getSymbolInstanceIconSize(v,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,r,i,f,m,H,n,E,p,c,x.predicate)};U&&U.box&&U.box.length&&s.verticalIconBox?($=i(s.verticalIconBox),O=$.box.length>0):($=i(s.iconBox),O=$.box.length>0),D=D&&$.offscreen,F=$.occluded}const te=w||0===t.numHorizontalGlyphVertices&&0===_,ie=T||0===t.numIconVertices;if(te||ie?ie?te||(O=O&&R):R=O&&R:O=R=O&&R,R&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),o.bucketInstanceId,U&&U.box&&Y?Y:Z,x.ID),O&&$&&this.collisionIndex.insertCollisionBox($.box,a.get("icon-ignore-placement"),o.bucketInstanceId,J,x.ID),j&&(R&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),o.bucketInstanceId,Z,x.ID),n)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new xn);for(let e=0;e<j.circles.length;e+=4)t.circles.push(j.circles[e+0]),t.circles.push(j.circles[e+1]),t.circles.push(j.circles[e+2]),t.circles.push(j.collisionDetected?1:0)}const ne="globe"!==o.projection.name;W=W&&(ne||!B),q=q&&(ne||!F),this.placements[l]=new vn(R||W,O||q,D||o.justReloaded),i.add(l)},Z=this.retainedQueryData[o.bucketInstanceId].tileID;if("offset"===o.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(o,Z),"road"===o.elevationType&&o.updateRoadElevation(Z.canonical),o.updateZOffset(),o.sortFeaturesByY){const t=o.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];$(o.symbolInstances.get(i),i,o.collisionArrays[i])}o.hasAnyZOffset&&e.w(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];$(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)$(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(n&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.ba(t.invProjMatrix,c),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,i,n,r){const{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=n,u=e.bL(i),h=r===e.bm.vertical?l:"left"===u?s:"center"===u?o:"right"===u?a:-1;s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,n){const r=i===e.bm.horizontal||i===e.bm.horizontalOnly?i:0,s=i===e.bm.vertical?i:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray;o>=0&&(u.get(o).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=s)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},s=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],s=r[e];s?(this.opacities[e]=new yn(s,n,t.text,t.icon,null,t.clipped),i=i||t.text!==s.text.placed||t.icon!==s.icon.placed):(this.opacities[e]=new yn(null,n,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new yn(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed)}}for(const e in s)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=s[e]);for(const e in o)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=o[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t,i,n){n&&(this.lastReplacementSourceUpdateTime=n.updateTime);const r=new Set;for(const s of t){const t=s.getBucket(e);t&&s.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,s,s.collisionBoxArray,i,n,s.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,s.tileID),"road"===t.elevationType&&t.updateRoadElevation(s.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(t,i,n,r,s,o,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,u=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),d=new yn(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),g="map"===c.get("text-rotation-alignment"),_="map"===c.get("text-pitch-alignment"),y=u.get("symbol-z-offset"),v="sea"===c.get("symbol-elevation-reference"),x=!y.isConstant(),b=new yn(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let n=0;n<t/4;n++)e.opacityVertexArray.emplaceBack(i)};let T=0;o&&t.updateReplacement(a,o),this.collisionIndex.clearClippedSymbolsForBucket(t.bucketInstanceId);for(let r=0;r<t.symbolInstances.length;r++){const c=t.symbolInstances.get(r),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:p,crossTileID:f,numIconVertices:S,tileAnchorX:E,tileAnchorY:A}=c;let M=null;const I=this.retainedQueryData[t.bucketInstanceId];x&&c&&I&&(M=n.latestFeatureIndex.loadFeature({featureIndex:c.featureIndex,bucketIndex:I.bucketIndex,sourceLayerIndex:I.sourceLayerIndex,layoutVertexArrayOffset:0}));const C=y.evaluate(M,{}),P=i.has(f);let L=this.opacities[f];P?L=d:L||(L=b,this.opacities[f]=L),i.add(f);const R=u>0||p>0,O=S>0,D=this.placedOrientations[f],B=D===e.bm.vertical,F=D===e.bm.horizontal||D===e.bm.horizontalOnly;!R&&!O||L.isHidden()||T++;let N=!1;if((R||O)&&o)for(const i of t.activeReplacements){if(e.bD(i,s,e.bE.Symbol,l))continue;if(i.min.x>E||E>i.max.x||i.min.y>A||A>i.max.y)continue;const t=e.bF(E,A,a.canonical,i.footprintTileId.canonical);if(N=e.bG(t,i.footprint),N)break}if(N&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,c.featureIndex),R){const e=N?Bn:Dn(L.text);w(t.text,u,B?Bn:e),w(t.text,p,F?Bn:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:o}=c,a=t.text.placedSymbolArray,l=i||B?1:0;n>=0&&(a.get(n).hidden=l),r>=0&&(a.get(r).hidden=l),s>=0&&(a.get(s).hidden=l),o>=0&&(a.get(o).hidden=i||F?1:0);const h=this.variableOffsets[f];h&&this.markUsedJustification(t,h.anchor,c,D);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(O){const e=N?Bn:Dn(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=c,r=t.icon.placedSymbolArray,s=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,S,B?Bn:e),r.get(i).hidden=s),n>=0&&(w(t.icon,c.numVerticalIconVertices,F?Bn:e),r.get(n).hidden=s)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let n=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(n=Tn(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&n._rotate(_?this.transform.angle:-this.transform.angle)):r=!1}h&&(r=!L.clipped),i.textBox&&An(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||B,C,v,n.x,n.y),i.verticalTextBox&&An(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||F,C,v,n.x,n.y)}const s=r&&Boolean(!F&&i.verticalIconBox);i.iconBox&&An(t.iconCollisionBox.collisionVertexArray,L.icon.placed,s,C,v,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0),i.verticalIconBox&&An(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!s,C,v,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0)}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}isStale(){return this.stale}setStale(){this.stale=!0}}function An(e,t,i,n,r,s,o){e.emplaceBack(t?1:0,i?1:0,s||0,o||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,o||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,o||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,o||0,n,r?1:0)}const Mn=Math.pow(2,25),In=Math.pow(2,24),Cn=Math.pow(2,17),Pn=Math.pow(2,16),Ln=Math.pow(2,9),Rn=Math.pow(2,8),On=Math.pow(2,1);function Dn(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Mn+t*In+i*Cn+t*Pn+i*Ln+t*Rn+i*On+t}const Bn=0;class Fn{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,i,n,r,s){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,n,e[this._currentTileIndex],this._sortAcrossTiles,s),this._currentTileIndex++,r())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart,s),this._currentPartIndex++,r())return!0}return!1}}class Nn{startNewPlacement(e,t,i,n,r,s,o,a){return this.placement=new En(e,n,r,s,o,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=i,this._fadeDuration=n,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,i,n,r,s){const o=e.o.now(),a=()=>{const t=e.o.now()-o;return!this.isFullPlacementRequested()&&0!==this._fadeDuration&&t>2};for(;this._currentPlacementIndex>=0;){const o=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&"none"!==o.visibility&&(!o.minzoom||o.minzoom<=l)&&(!o.maxzoom||o.maxzoom>l)){const t=o,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),u="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),h=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=u&&h,p=this._inProgressLayer=this._inProgressLayer||new Fn(t),f=e.t(o.source,o.scope);if(p.continuePlacement(i||d?r[f]:n[f],this.placement,this._showCollisionBoxes,o,a,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const kn=512/e.ak/2;class zn{constructor(t,i,n){this.tileID=t,this.bucketInstanceId=n,this.index=new e.bM(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.ak,s=t.canonical.y*e.ak;for(let e=0;e<i.length;e++){const{key:t,crossTileID:n,tileAnchorX:o,tileAnchorY:a}=i.get(e),l=Math.floor((r+o)*kn),c=Math.floor((s+a)*kn);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(n)}this.index.finish()}findMatches(t,i,n){const r=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),s=kn/Math.pow(2,i.canonical.z-this.tileID.canonical.z),o=i.canonical.x*e.ak,a=i.canonical.y*e.ak;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:u}=i,h=Math.floor((o+c)*s),d=Math.floor((a+u)*s),p=this.index.range(h-r,d-r,h+r,d+r).sort((e,t)=>e-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!n.has(t)){n.add(t),i.crossTileID=t;break}}}}}class Un{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Vn{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const n=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const r=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in r){const s=r[i];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,n)}else{const s=r[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,n)}}for(let e=0;e<t.symbolInstances.length;e++){const r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=i.generate(),n.add(r.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new zn(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i)}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const n=this.indexes[i];for(const r in n)e[n[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,n[r]),delete n[r],t=!0)}return t}}class jn{constructor(){this.layerIndexes={},this.crossTileIDs=new Un,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,n){let r=this.layerIndexes[e.fqid];void 0===r&&(r=this.layerIndexes[e.fqid]=new Vn);let s=!1;const o={};"globe"!==n.name&&r.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(s=!0),o[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(s=!0),s}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Gn=770,Hn=771;class Wn{constructor(e,t,i,n){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=n}}Wn.Replace=[1,0,1,0],Wn.disabled=new Wn(Wn.Replace,e.C.transparent,[!1,!1,!1,!1]),Wn.unblended=new Wn(Wn.Replace,e.C.transparent,[!0,!0,!0,!0]),Wn.alphaBlended=new Wn([1,Hn,1,Hn],e.C.transparent,[!0,!0,!0,!0]),Wn.alphaBlendedNonPremultiplied=new Wn([Gn,Hn,Gn,Hn],e.C.transparent,[!0,!0,!0,!0]),Wn.multiply=new Wn([774,0,774,0],e.C.transparent,[!0,!0,!0,!0]),Wn.multiplyAccumulateAlpha=new Wn([774,0,1,Hn],e.C.transparent,[!0,!0,!0,!0]),Wn.additive=new Wn([1,1,1,1],e.C.transparent,[!0,!0,!0,!0]),Wn.additiveAlphaWeighted=new Wn([Gn,1,773,1],e.C.transparent,[!0,!0,!0,!0]),Wn.additiveAlphaWeightedUnboundedAlpha=new Wn([Gn,1,1,1],e.C.transparent,[!0,!0,!0,!0]);class qn{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}qn.ReadOnly=!1,qn.ReadWrite=!0,qn.disabled=new qn(519,qn.ReadOnly,[0,1]);const Xn=7680;class $n{constructor(e,t,i,n,r,s){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=s}}$n.disabled=new $n({func:519,mask:0},0,0,Xn,Xn,Xn);const Zn=1029,Yn=2305;class Jn{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function Kn(t,i){const n=e.bS(t,3);e.bV(t,i),e.b_(t,3,n)}function Qn(t,i){const n=e.bP([]);return e.bQ(n,n,-i),e.bR(n,n,-t),n}function er(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.af(n)>=1e-15){const t=e.ax([],n);e.bN(r,t,e.bk(r,t)),i[0]=r[0],i[1]=r[1]}const s=e.bj([],i,t);if(e.bO(s)<1e-15)return null;const o=Math.atan2(-s[1],s[0]);return Qn(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),o)}Jn.disabled=new Jn(!1,Zn,Yn),Jn.backCCW=new Jn(!0,Zn,Yn),Jn.backCW=new Jn(!0,Zn,2304),Jn.frontCW=new Jn(!0,1028,2304),Jn.frontCCW=new Jn(!0,1028,Yn);class tr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ad?t:new e.ad(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bv(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,n){if(this.orientation=null,!this.position)return;const r=this.position,s=n||(this._elevation?this._elevation.getAtPointOrZero(e.ad.fromLngLat(t)):0),o=e.ad.fromLngLat(t,s),a=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=er(a,i)}setPitchBearing(t,i){this.orientation=Qn(e.am(t),e.am(-i))}}class ir{constructor(t,i){this._transform=e.bA([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.ad(t[0],t[1],t[2])}get position(){const t=e.bS(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.b_(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bP([]),t&&Kn(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Qn(e,t),Kn(this._transform,this._orientation)}forward(){const t=e.bS(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bS(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bS(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.ba(n,this.getWorldToCamera(t,i)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,n){const r=this.position;e.bN(r,r,-t);const s=new Float64Array(16);return e.bT(s,[n,n,n]),e.bB(s,s,r),s[10]*=i,s}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),s=this.position;return e.bU(r,this._orientation),e.bN(s,s,-t),e.bV(n,r),e.bB(n,n,s),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const s=new Float64Array(16);return e.bW(s,t,i,n,r),s}getCameraToClipOrthographic(t,i,n,r,s,o){const a=new Float64Array(16);return e.bX(a,t,i,n,r,s,o),a}getDistanceToElevation(t,i=!1){const n=0===t?0:e.bY(t,i?e.bZ(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new ir([...this.position],[...this.orientation])}}const nr=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t});class rr{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.aj(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.aj(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.aj(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.aj(t.right,i.right,n)),this}getCenter(t,i){const n=e.aB((this.left+t-this.right)/2,0,t),r=e.aB((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new rr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const sr=15;class or{constructor(t,i,n,r,s,o,a){this.tileSize=512,this._renderWorldCopies=void 0===s||s,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=n??0,this._maxPitch=r??60,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aX(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new rr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ir,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatrix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){const e=new or(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._nearClipOffset=this._nearClipOffset,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<sr}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(e){this._nearClipOffset=e,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.aK(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.c4(this.projectionOptions);const n=this.getProjection(),r=!e.b9(i,n);return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.c4({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bY(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bv(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;if(this.angle===t)return;this._unmodified=!1,this.angle=t,this._calcMatrices();const i=Math.sin(this.angle),n=Math.cos(this.angle);this.rotationMatrix=[n,i,-i,n]}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.aB(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.am(t),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e)}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,s=0;for(let o=0;o<i.length;o++){const a=new e.P(i[o][0]*this.width,n+i[o][1]*(this.height-n)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);r+=l[3]*c,s+=c}return 0===s?NaN:r/s}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,n=this._mercatorZfromZoom(e),r=this._mercatorZfromZoom(this._maxZoom),s=Math.max(n-i,r);this._setZoom(this._zoomFromMercatorZ(s))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}equals(e){const t=this.elevation,i=e.elevation,n=null!=t!=(null!=i)||t&&i&&t.exaggeration()!==i.exaggeration();return this.width===e.width&&this.height===e.height&&this.center.lng===e.center.lng&&this.center.lat===e.center.lat&&this.zoom===e.zoom&&this.bearing===e.bearing&&this.pitch===e.pitch&&this.fov===e.fov&&this.projection.name===e.projection.name&&this._edgeInsets.equals(e.padding)&&!n}computeZoomRelativeTo(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let n;n=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const r=e.af(e.aw([],this._camera.position,n));return e.aB(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.c5(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const n=[t.position.x,t.position.y,t.position.z];e.c6(n,this._camera.position)||(this._setCameraPosition(n),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new tr;return i.position=new e.ad(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.c7(t))return!1;e.c8(t,t);const i=e.c9([],[0,0,-1],t),n=e.c9([],[0,-1,0],t);if(n[2]<0)return!1;const r=er(i,n);return!!r&&(this._camera.orientation=r,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,n=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;t[2]=e.aB(t[2],r/n,r/i),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new e.ca(0,t)];if(this.renderWorldCopies){const n=this.pointCoordinate(new e.P(0,0)),r=this.pointCoordinate(new e.P(this.width,0)),s=this.pointCoordinate(new e.P(this.width,this.height)),o=this.pointCoordinate(new e.P(0,this.height)),a=Math.floor(Math.min(n.x,r.x,s.x,o.x)),l=Math.floor(Math.max(n.x,r.x,s.x,o.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new e.ca(n,t))}return i}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,i,n,r){let s=[];const o=null!=n,a=!o;if(a&&this.zoom<i)return s;if(o&&0===n[0]&&0===n[1])return s;const l=new Set,c=(t,i,n,r,o)=>{const a=e.cm(i,t,n,r,o);l.has(a)||(s.push(new e.aU(t,i,n,r,o)),l.add(a))};for(let e=0;e<t.length;e++){const s=t[e];if(a&&s.canonical.z!==i)continue;if(o&&void 0!==r&&r>s.canonical.z)continue;const l=s.canonical,u=s.overscaledZ,h=s.wrap,d=1<<l.z,p=l.x+1<d,f=l.x>0,m=l.y+1<d,g=l.y>0,_=s.wrap-(f?0:1),y=s.wrap+(p?0:1),v=f?l.x-1:d-1,x=p?l.x+1:0;if(o)n[0]<0?(c(u,y,l.z,x,l.y),n[1]<0&&m&&(c(u,h,l.z,l.x,l.y+1),c(u,y,l.z,x,l.y+1)),n[1]>0&&g&&(c(u,h,l.z,l.x,l.y-1),c(u,y,l.z,x,l.y-1))):n[0]>0?(c(u,_,l.z,v,l.y),n[1]<0&&m&&(c(u,h,l.z,l.x,l.y+1),c(u,_,l.z,v,l.y+1)),n[1]>0&&g&&(c(u,h,l.z,l.x,l.y-1),c(u,_,l.z,v,l.y-1))):n[1]<0&&m?c(u,h,l.z,l.x,l.y+1):g&&c(u,h,l.z,l.x,l.y-1);else{const e=s.visibleQuadrants;1&e&&(c(u,_,l.z,v,l.y),g&&(c(u,h,l.z,l.x,l.y-1),c(u,_,l.z,v,l.y-1))),2&e&&(c(u,y,l.z,x,l.y),g&&(c(u,h,l.z,l.x,l.y-1),c(u,y,l.z,x,l.y-1))),4&e&&(c(u,_,l.z,v,l.y),m&&(c(u,h,l.z,l.x,l.y+1),c(u,_,l.z,v,l.y+1))),8&e&&(c(u,y,l.z,x,l.y),m&&(c(u,h,l.z,l.x,l.y+1),c(u,y,l.z,x,l.y+1)))}}const u=[];for(const e of s)s.some(t=>e.isChildOf(t))||u.push(e);if(s=u.filter(e=>!t.some(t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))),a){const e=1<<i,t="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),n=[e*t.x,e*t.y],r=4,o=r*r;s=s.filter(e=>{const t=e.canonical.x+.5-n[0],i=e.canonical.y+.5-n[1];return t*t+i*i<o})}return s}extendTileCoverToNearPlane(t,i,n){const r=[],s=new Set;for(const e of t)s.add(e.key);const o=(t,i,n,o,a)=>{const l=e.cm(i,t,n,o,a);s.has(l)||(r.push(new e.aU(t,i,n,o,a)),s.add(l))},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),n),l=1<<n,c=[new e.P(0,0),new e.P(e.ak,0),new e.P(e.ak,e.ak),new e.P(0,e.ak)],u=new e.P(0,0),h=new e.P(0,0),d=(t,i)=>{const r=Math.floor(t[0]),s=Math.floor(t[1]),d=(t[0]-r)*e.ak,p=(t[1]-s)*e.ak,f=Math.floor(i[0]),m=Math.floor(i[1]),g=(i[0]-f)*e.ak,_=(i[1]-m)*e.ak;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){u.x=d-t*e.ak,h.x=g-(i-f)*e.ak;for(let t=-1;t<=1;t++){const r=s+t;u.y=p-t*e.ak,h.y=_-(r-m)*e.ak,e.cM(u,h,c)&&o(a,0,n,i,r)}}}},p=i.points,f=p[e.cb],m=p[e.cc],g=this._projectToGround(f,p[e.cd]),_=this._projectToGround(m,p[e.ce]);return d(f,g),d(m,_),r}_projectToGround(t,i){return e.cf(e.cg(),t,i,t[2]/(t[2]-i[2]))}_projectToZ(t,i,n){const r=t[2]-i[2];return Math.abs(r)<1e-6?e.ch(t):e.cf(e.cg(),t,i,(t[2]-n)/r)}extendTileCoverForTunnels(t,i,n,r){if(n<18)return[];const s=i.points,o=s[e.ci],a=s[e.cj],l=s[e.ck],c=s[e.cl];if(l[2]>=0&&c[2]>=0||o[2]<=0||a[2]<=0)return[];const u=l[2]<0?this._projectToZ(o,l,0):l,h=c[2]<0?this._projectToZ(a,c,0):c,d=-r,p=l[2]<d?this._projectToZ(o,l,d):l,f=c[2]<d?this._projectToZ(a,c,d):c,m=this._findExtensionTilesInQuad(t,n,[f,p,h,u],[.5*(u[0]+h[0]),.5*(u[1]+h[1])]);return m.length>3&&(m.length=3),m}_findExtensionTilesInQuad(t,i,n,r){const s=[],o=new Set;for(const e of t)o.add(e.key);const a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),i),l=1<<i,c=[new e.P(n[0][0],n[0][1]),new e.P(n[1][0],n[1][1]),new e.P(n[3][0],n[3][1]),new e.P(n[2][0],n[2][1]),new e.P(n[0][0],n[0][1])],u=n[0][0],h=n[1][0],d=n[2][0],p=n[3][0],f=n[0][1],m=n[1][1],g=n[2][1],_=n[3][1],y=Math.max(0,Math.floor(Math.min(u,h,d,p))),v=Math.min(l-1,Math.ceil(Math.max(u,h,d,p))-1),x=Math.max(0,Math.floor(Math.min(f,m,g,_))),b=Math.min(l-1,Math.ceil(Math.max(f,m,g,_))-1);for(let t=x;t<=b;t++)for(let n=y;n<=v;n++){if(!e.au(c,n,t,n+1,t+1))continue;const r=e.cm(0,a,i,n,t);o.has(r)||(s.push(new e.aU(a,0,i,n,t)),o.add(r))}const w=r[0],T=r[1];return s.sort((e,t)=>{const i=e.canonical.x+.5-w,n=e.canonical.y+.5-T,r=t.canonical.x+.5-w,s=t.canonical.y+.5-T;return i*i+n*n-(r*r+s*s)||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y}),s}coveringTiles(t){let i=this.coveringZoomLevel(t);const n=i,r=this.elevation&&this.elevation.exaggeration(),s=r&&!t.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return[];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<i,u=[c*a.x,c*a.y,0],h="globe"===this.projection.name,d=!h,p=e.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,d),f=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*e.bY(1,this.center.lat),g=this._camera.position[2]/e.bY(1,this.center.lat),_=[c*f.x,c*f.y,g*(d?1:m)],y=h||r,v=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),x=this.isLODDisabled(!0)?i:0;let b;if(this._elevation&&t.isTerrainDEM)b=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();b=e?e.max:this._centerAltitude}else b=this._centerAltitude;const w=t.isTerrainDEM?-b:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?e.co(this):1,S=t=>{const i=1/4e4,n=new e.ad(t.x+i,t.y,t.z),r=new e.ad(t.x,t.y+i,t.z),s=t.toLngLat(),o=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(s),c=this.locationCoordinate(o),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*T/i},E=t=>{const i=b,n=w;return{aabb:e.cr(this,c,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},A=[];let M=[];const I=i,C=t.reparseOverscaled?n:i,P=(g-this._centerAltitude)*m,L=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=O(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=(e,t)=>{if(.707*t<e)return 1;const i=t/e;return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)},O=t=>{if(t.zoom<x)return!0;if(t.zoom===I)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(_),r=t.aabb.distanceY(_);let a=P,c=1;if(h){a=t.aabb.distanceZ(_);const i=Math.pow(2,t.zoom),n=e.bZ((t.y+1)/i),r=e.bZ(t.y/i),s=Math.min(Math.max(l,n),r),o=e.cQ(s)/e.cQ(l);if(c=s===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,o/this._mercatorScaleRatio),this.zoom<=e.cN&&t.zoom===I-1&&o>=.9)return!0}else if(s&&(a=t.aabb.distanceZ(_)*m),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=S(new e.ad((t.x+.5)/i,(t.y+.5)/i));c=n>.85?1:n}if(!o&&!h){const e=Math.sqrt(i*i+r*r+a*a);let n=(1<<I-t.zoom)*v*c;return n*=R(Math.max(a,P),e),e<n}let d=Number.MAX_VALUE,p=0;const f=t.aabb.getCorners(),g=[0,0,0];for(const t of f){e.aw(g,t,_),h||(s?g[2]*=m:g[2]=P);const i=e.bk(g,this._camera.forward());i<d&&(d=i,p=Math.abs(g[2]))}let y=(1<<I-t.zoom)*v*c;if(y*=R(Math.max(p,P),d),d<y)return!0;const b=t.aabb.closestPoint(u);return b[0]===u[0]&&b[1]===u[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)A.push(E(-e)),A.push(E(e));for(A.push(E(0));A.length>0;){const n=A.pop(),r=n.x,a=n.y;let l=n.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<<n.zoom)-1);if(!l){let t=y?n.aabb.intersects(p):n.aabb.intersectsFlat(p);if(0===t&&d()){const i=new e.cp(n.zoom,r,a);t=e.cq(this,c,i,!0).intersects(p)}if(0===t)continue;l=2===t}if(n.zoom===I||!O(n)){const s=n.zoom===I?C:n.zoom;if(t.minzoom&&t.minzoom>s)continue;let o=0;if(!l){let i=y?n.aabb.intersectsPrecise(p):n.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.cp(n.zoom,r,a);i=e.cq(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(n.aabb.center))o=15;else for(let e=0;e<4;e++)0!==n.aabb.quadrant(e).intersects(p)&&(o|=1<<e)}const h=u[0]-(.5+r+(n.wrap<<n.zoom))*(1<<i-n.zoom),f=u[1]-.5-a,m=n.tileID?n.tileID:new e.aU(s,n.wrap,n.zoom,r,a);t.calculateQuadrantVisibility&&(m.visibleQuadrants=o),M.push({tileID:m,distanceSq:h*h+f*f});continue}for(let t=0;t<4;t++){const i=(r<<1)+t%2,u=(a<<1)+(t>>1),d={aabb:o?n.aabb.quadrant(t):e.cr(this,c,n.zoom+1,i,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:u,wrap:n.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};s&&!h&&(d.tileID=new e.aU(n.zoom+1===I?C:n.zoom+1,n.wrap,n.zoom+1,i,u),L(d)),A.push(d)}}if(this.fogCullDistSq){const i=this.fogCullDistSq,n=this.horizonLineFromTop();M=M.filter(r=>{const s=[0,0,0,1],o=[e.ak,e.ak,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aD(s,s,a),e.aD(o,o,a);const l=e.cs([],s,o),c=e.ct([],s,o),u=e.cO(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let s;t.isTerrainDEM||(s=d.getMinMaxForTile(r.tileID)),s||(s={min:w,max:b});const o=e.cu(this.rotation),a=[o[0]*e.ak,o[1]*e.ak,s.max];e.ae(a,a,i),h=(1-a[1])*this.height*.5<n}return u<i||h})}return M.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(t){const i=e.aB(t.lat,-e.cv,e.cv),n=this.projection.project(t.lng,i);return new e.P(n.x*this.worldSize,n.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bY(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let n,r;const s=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-s.x)/e,r=(i.y-s.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(s);n=e.x-t.x,r=e.y-t.y}const o=this.locationCoordinate(t);this.setLocation(new e.ad(o.x-n,o.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const n=i?e.bY(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ad(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.aD(r,r,this.pixelMatrixInverse),e.aD(s,s,this.pixelMatrixInverse);const o=s[3];e.cw(r,r,1/r[3]),e.cw(s,s,1/o);const a=r[2],l=s[2];return{p0:r,p1:s,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.aD(i,i,this.pixelMatrixInverse),e.aD(n,n,this.pixelMatrixInverse),e.cw(i,i,1/i[3]),e.cw(n,n,1/n[3]),i[2]=e.bY(i[2],this._center.lat)*this.worldSize,n[2]=e.bY(n[2],this._center.lat)*this.worldSize,e.cw(i,i,1/this.worldSize),e.cw(n,n,1/this.worldSize),new e.ay([i[0],i[1],i[2]],e.ax([],e.aw([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,s=e.bY(i[2],this._center.lat),o=e.bY(n[2],this._center.lat);return new e.ad(e.aj(i[0],n[0],r)/this.worldSize,e.aj(i[1],n[1],r)/this.worldSize,e.aj(s,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.ad(n[0],n[1],n[2]);let r=0,s=this.horizonLineFromTop();if(t.y>s)return this.pointCoordinate(t,i);const o=.02*s,a=t.clone();for(let t=0;t<10&&s-r>o;t++){a.y=e.aj(r,s,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(s=a.y,n=t):r=a.y}return n?new e.ad(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.cx)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.aD(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,s=this.pointLocation3D(new e.P(i,t)),o=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,n)),l=this.pointLocation3D(new e.P(i,n));let c=Math.min(s.lng,o.lng,a.lng,l.lng),u=Math.max(s.lng,o.lng,a.lng,l.lng),h=Math.min(s.lat,o.lat,a.lat,l.lat),d=Math.max(s.lat,o.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,n,r,s)=>{const o=(t+n)/2,a=(i+r)/2,l=new e.P(o,a),{lng:g,lat:_}=this.pointLocation3D(l),y=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(s<f||y>p)&&(m(t,i,o,a,s+1),m(o,a,n,r,s+1))};if(m(i,t,r,t,1),m(r,t,r,n,1),m(r,n,i,n,1),m(i,n,i,t,1),"globe"===this.projection.name){const[t,i]=e.cy(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.aI(new e.aX(c,h),new e.aX(u,d))}_getBoundsRectangular(t,i){const{top:n,left:r}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,a=new e.P(r,n),l=new e.P(o,n),c=new e.P(o,s),u=new e.P(r,s);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.ad((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.ad(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.ad((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.ad(-p.y/m(p,d)+p.x,0)),(new e.aI).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.cv,this.maxLat=e.cv,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.aG(this.minLng)*this.tileSize,this.worldMaxX=e.aG(this.maxLng)*this.tileSize,this.worldMinY=e.aJ(this.maxLat)*this.tileSize,this.worldMaxY=e.aJ(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const i=t.key,n=this._distanceTileDataCache;if(n[i])return n[i];const r=t.canonical,s=1/this.height,o=this.cameraWorldSize,a=o/this.zoomScale(r.z),l=(r.x+Math.pow(2,r.z)*t.wrap)*a,c=r.y*a,u=this.point;u.x*=o/this.worldSize,u.y*=o/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return n[i]={bearing:[d,p],center:[(u.x-l)*s,(u.y-c)*s],scale:a/e.ak*s},n[i]}calculateFogTileMatrix(t){const i=t.key,n=this._fogTileMatrixCache;if(n[i])return n[i];const r=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.aC(r,this.worldToFogMatrix,r),n[i]=new Float32Array(r),n[i]}calculateProjMatrix(t,i=!1,n=!1){const r=t.key;let s;if(s=n?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache,s[r])return s[r];const o=this.calculatePosMatrix(t,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.aC(o,a,o),s[r]=new Float32Array(o),s[r]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,n=this._pixelsToTileUnitsCache;if(n[i])return n[i];const r=e.cz(t,this);return n[i]=r,n[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,i=e.bT([],[t,t,t]);return e.aC(i,i,this.globeMatrix),i}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const i=e.bY(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),r=this._camera.forward(),s=e.bY(1,this._center.lat);n[2]/=s,r[2]/=s,e.ax(r,r);const o=t.raycast(n,r,t.exaggeration());if(o){const t=e.bi([],n,r,o),i=new e.ad(t[0],t[1],e.bY(t[2],e.bZ(t[1]))),a=(i.z+e.af([i.x-n[0],i.y-n[1],i.z-n[2]*s]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;const i=this._elevation,n=e.bY(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(n),s=i.getAtPointOrZero(new e.ad(...r)),o=this.pixelsPerMeter/this.worldSize*s,a=this._minimumHeightOverTerrain(),l=r[2]-o;if(l<=a)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[r[0],r[1],t.z-r[2]],n=e.af(i);i[2]-=(a-l)/this._pixelsPerMercatorPixel;const s=e.af(i);if(0===s)return;e.bN(i,i,n/s*this._pixelsPerMercatorPixel),this._camera.position=[r[0],r[1],t.z*this._pixelsPerMercatorPixel-i[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const i=this.center;return i.lat=e.aB(i.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(i.lng=e.aB(i.lng,this.minLng,this.maxLng)),this.center=i,void(this._constraining=!1)}const i=this._unmodified,{x:n,y:r}=this.point;let s=0,o=n,a=r;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(r-c<u&&(a=u+c),r+c>h&&(a=h-c),h-u<this.height&&(s=Math.max(s,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,i=this.worldSize/2-(e+t)/2;o=(n+i+this.worldSize)%this.worldSize-i,o-l<e&&(o=e+l),o+l>t&&(o=t-l),t-e<this.width&&(s=Math.max(s,this.width/(t-e)),o=(t+e)/2)}o===n&&a===r||this._allowWorldUnderZoom||(this.center=this.unproject(new e.P(o,a))),s&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(s)),this._constrainCamera(),this._unmodified=i,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i="globe"===this.projection.name,n=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bY(1,this.center.lat)/e.bY(1,e.cR));const r=e.cA(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,r),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const s="meters"===this.projection.zAxisUnit?n:1,o=this._camera.getWorldToCamera(this.worldSize,s);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let i=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),n=i*this.aspect,r=-n,s=-i;n-=t.x,r-=t.x,i+=t.y,s+=t.y,a=this._camera.getCameraToClipOrthographic(r,n,s,i,this._nearZ+this._nearClipOffset,this._farZ),((t,i,n,r)=>{for(let s=0;s<16;s++)t[s]=e.aj(i[s],n[s],r)})(a,a,l,e.cP(this.pitch>=sr?1:this.pitch/sr))}else a=l;const c=e.cB([],l,o),u=e.cB([],a,o);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center);e.bA(this._mat4Scratch);const i=this._mat4Scratch;e.bB(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aC(i,i,e.cC(this)),e.bB(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aC(u,u,i),e.aC(c,c,i),this.inverseAdjustmentMatrix=e.cD(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(e.cE(this.mercatorMatrix,u,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=u,e.ba(this.invProjMatrix,this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,e.cB(this._expandedFarZProjMatrixBuf,i,o),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;e.ba(this._mat4Scratch,a),this.frustumCorners=e.cF.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i),e.bT(this.skyboxMatrix,[1,-1,1]),e.cG(this.skyboxMatrix,this.skyboxMatrix,this._pitch),e.bc(this.skyboxMatrix,this.skyboxMatrix,this.angle),e.bW(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const h=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;e.cH(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+h)/this.height,e.aC(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const d=this.point,p=d.x,f=d.y,m=this.width%2/2,g=this.height%2/2,_=Math.cos(this.angle),y=Math.sin(this.angle),v=p-Math.round(p)+_*m+y*g,x=f-Math.round(f)+_*g+y*m;if(e.cH(this.alignedProjMatrix,u),e.bB(this.alignedProjMatrix,this.alignedProjMatrix,[v>.5?v-1:v,x>.5?x-1:x,0]),e.bT(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),e.bB(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),e.bT(this.glCoordMatrix,[1,-1,1]),e.bB(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),e.cE(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),e.aC(this.pixelMatrix,this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},!e.ba(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if("globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cI(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.ae(t,t,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,s=[t,t,i];e.bN(s,s,r),e.bN(n,n,-1),e.cJ(n,n,s),e.cK(this.mercatorFogMatrix,n),e.cE(this.mercatorFogMatrix,this.mercatorFogMatrix,s),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=t[2];let s=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(s=Math.min((i-n)/r,1)),this._camera.position=e.bi([],this._camera.position,t,s),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),s=e.bY(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.am(this._maxPitch)),a=Math.max((t[2]-s)/Math.cos(n),o),l=this._zoomFromMercatorZ(a);e.bi(t,t,i,a),this._pitch=e.aB(n,e.am(this.minPitch),e.am(this.maxPitch)),this.angle=e.bv(r,-Math.PI,Math.PI),this._setZoom(e.aB(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ad(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,n=e.cx,r=0,s=1/0;for(;n-i>1e-6&&n>i;){const e=i+.5*(n-i),o=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,o),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);c<s&&(s=c,r=e),e<l?i=e:n=e}return r}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const n=Math.min(t.x,i.x),r=Math.max(t.x,i.x),s=Math.min(t.y,i.y),o=Math.max(t.y,i.y);if(s<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.P(n,s),new e.P(r,o),new e.P(n,o),new e.P(r,s)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cL(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.af(e.aw([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,n],r){const s=[t,i,n,1];e.aD(s,s,r);const o=s[3]=Math.max(s[3],1e-6);return s[0]/=o,s[1]/=o,s[2]/=o,s}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,n=this.worldSize){const r=e.cA(t,i,this.width,this.height,1024),s=t.pixelSpaceConversion(this.center.lat,n,r);let o=.5/Math.tan(.5*this._fov)*this.height*s;return this.isOrthographic&&(o=e.aj(1,o,e.cP(this.pitch>=sr?1:this.pitch/sr))),o}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aC(t,t,this.globeMatrix),t}getFrustum(t){return e.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const ar=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const n=t.transform,r=n.pitch,s=n.isLODDisabled(!1)?60:30;if(r<s-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=n._farZ-n._nearZ,a=i*n.height*1.3,l=Math.pow(2,.85*Math.max(n._zoom-t.minCutoffZoom,0)),c=1.4*n.cameraToCenterDistance*l,u=e.ag(s-15,s,r),h=(1-(d=u))*(n._farZ+a)+d*c;var d;const p=Math.min(a,h-n._nearZ);return{shouldRenderCutoff:u>0,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(h-n._nearZ)/o,(h-p-n._nearZ)/o]}}},lr=[];function cr(e){return lr[e]=lr[e]||new Float64Array(16)}class ur{constructor(e,t){this.aabb=e,this.lastCascade=t}}class hr{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new ur(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,n){const r=e.cY.fromPoints(t.points);let s=0;for(const t in this.receivers){const o=this.receivers[t];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const a=o.aabb.getCorners();for(let t=0;t<n.length;t++){let r=!0;for(const s of a){const o=[s[0]*i,s[1]*i,s[2]];if(e.ae(o,o,n[t].matrix),o[0]<-1||o[0]>1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=t,s=Math.max(s,t),r)break}}return s+1}}class dr{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new hr,this._depthMode=new qn(e.context.gl.LEQUAL,qn.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048}}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const n=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity"),s=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||r<=0)return;let o=-1,a=0;for(const e of n.style.order){const i=n.style._mergedLayers[e];i.hasShadowPass()&&!i.isHidden(t.zoom)&&(o=a),!s||s!==e&&s!==i.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1}if(this._enabled=o>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=o);const l=n.context,c=this._shadowParameters.shadowMapResolution,u=this._shadowParameters.shadowMapResolution;if(0===this._cascades.length||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<this._shadowParameters.cascadeCount;++t){const t=l.gl,i=l.createFramebuffer(c,u,0,"texture"),n=new e.T(l,{width:c,height:u,data:null},t.DEPTH_COMPONENT16);i.depthAttachment.set(n.texture),this._cascades.push({framebuffer:i,texture:n,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.cn,scale:0})}}this.shadowDirection=fr(i);let h=0;if(t.elevation){const e=t.elevation,i=[1e4,-1e4];e.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0])}),1e4!==i[0]&&(h=(i[1]-i[0])*e.exaggeration())}const d=1.5*t.cameraToCenterDistance,p=3*d,f=new Float64Array(16);for(let i=0;i<this._cascades.length;++i){const n=this._cascades[i];let r=t.height/50,s=1;1===this._shadowParameters.cascadeCount?s=p:0===i?s=d:(r=d,s=p);const[o,a]=gr(t,this.shadowDirection,r,s,this._shadowParameters.shadowMapResolution,h);n.scale=t.scale,n.matrix=o,n.boundingSphereRadius=a,e.ba(f,n.matrix),n.frustum=e.cn.fromInvProjectionMatrix(f,1,0,!0),n.far=s}const m=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[m].far,this._cascades[m].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=n.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const g=n.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(g){const i=g.getMinMaxForTile(e);i&&(t=i)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e}drawShadowPass(t,i){if(!this.enabled)return;const n=this.painter,r=n.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(n.transform.getFrustum(0),n.transform.worldSize,this._cascades),r.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let s=0;s<this._numCascadesToRender;++s){n.currentShadowCascade=s,r.bindFramebuffer.set(this._cascades[s].framebuffer.framebuffer),r.clear({color:e.C.white,depth:1});for(const e of t.order){const r=t._mergedLayers[e];if(!r.hasShadowPass()||r.isHidden(n.transform.zoom))continue;const s=t.getLayerSourceCache(r),o=s?i[s.id]:void 0;("model"===r.type||o&&o.length)&&n.renderLayer(n,s,r,o)}}n.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,n=i.gl,r=t.directionalLight,s=t.ambientLight;if(!r||!s)return;const o=[],a=ar(e,e.longestCutoffRange);a.shouldRenderCutoff&&o.push("RENDER_CUTOFF"),o.push("RENDER_SHADOWS"),this.useNormalOffset&&o.push("NORMAL_OFFSET");const l=mr(t,r,s),c=new qn(n.LEQUAL,qn.ReadOnly,e.depthRangeFor3D),u=new $n({func:n.EQUAL,mask:255},0,255,n.KEEP,n.KEEP,n.KEEP);for(const t of this._groundShadowTiles){const r=t.toUnwrapped(),s=e.isTileAffectedByFog(t),h=e.getOrCreateProgram("groundShadow",{defines:o,overrideFog:s});this.setupShadows(r,h),e.uploadCommonUniforms(i,h,r,null,a);const d=nr(e.transform.calculateProjMatrix(r),l);h.draw(e,n.TRIANGLES,c,u,Wn.multiply,Jn.disabled,d,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,null,e.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(t){const i=this.painter.transform,n=i.calculatePosMatrix(t,i.worldSize);return e.aC(n,this._cascades[this.painter.currentShadowCascade].matrix,n),Float32Array.from(n)}calculateShadowPassMatrixFromMatrix(t){const i=e.bb(t);return e.aC(i,this._cascades[this.painter.currentShadowCascade].matrix,t),i}setupShadows(t,i,n){if(!this.enabled)return;const r=this.painter.transform,s=this.painter.context,o=s.gl,a=this._uniformValues,l=r.calculatePosMatrix(t,r.worldSize);for(let t=0;t<this._cascades.length;t++){const i=cr(t);e.aC(i,this._cascades[t].matrix,l),a[0===t?"u_light_matrix_0":"u_light_matrix_1"]=i,s.activeTexture.set(o.TEXTURE0+11+t),this._cascades[t].texture.bindExtraParam(o.LINEAR,o.LINEAR,o.CLAMP_TO_EDGE,o.CLAMP_TO_EDGE,o.GREATER)}if(this.useNormalOffset=!!n,this.useNormalOffset){const i=e.cW(t.canonical),s=2/r.tileSize*e.ak/this._shadowParameters.shadowMapResolution,o=s*this._cascades[0].boundingSphereRadius,l=s*this._cascades.at(-1).boundingSphereRadius,c=("vector-tile"===n?1:3)*function(t){const i=e.aB((t-22)/-22,0,1);return.125*(1-i)+4*i}(r.zoom);a.u_shadow_normal_offset=[i,o*c,l*c],a.u_shadow_bias=[1e-4,.0012,.012]}else a.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(s,a)}setupShadowsFromMatrix(t,i,n=!1){if(!this.enabled)return;const r=this.painter.context,s=r.gl,o=this._uniformValues;for(let i=0;i<this._shadowParameters.cascadeCount;i++){const n=cr(i);e.aC(n,this._cascades[i].matrix,t),o[0===i?"u_light_matrix_0":"u_light_matrix_1"]=n,r.activeTexture.set(s.TEXTURE0+11+i),this._cascades[i].texture.bindExtraParam(s.LINEAR,s.LINEAR,s.CLAMP_TO_EDGE,s.CLAMP_TO_EDGE,s.GREATER)}if(this.useNormalOffset=n,n){const e=this._shadowParameters.normalOffset;o.u_shadow_normal_offset=[1,e,e],o.u_shadow_bias=[6e-5,.0012,.012]}else o.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(r,o)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,i,n,r){if(r[2]>=0)return{};const s=function(t,i,n){const r=n/(1<<t.canonical.z);return new e.cY([t.canonical.x*r+t.wrap*n,t.canonical.y*r+t.wrap*n,0],[(t.canonical.x+1)*r+t.wrap*n,(t.canonical.y+1)*r+t.wrap*n,i])}(t,i,n).getCorners(),o=i/-r[2];r[0]<0?(e.cX(s[0],s[0],[r[0]*o,0,0]),e.cX(s[3],s[3],[r[0]*o,0,0])):r[0]>0&&(e.cX(s[1],s[1],[r[0]*o,0,0]),e.cX(s[2],s[2],[r[0]*o,0,0])),r[1]<0?(e.cX(s[0],s[0],[0,r[1]*o,0]),e.cX(s[1],s[1],[0,r[1]*o,0])):r[1]>0&&(e.cX(s[2],s[2],[0,r[1]*o,0]),e.cX(s[3],s[3],[0,r[1]*o,0]));const a={};return a.vertices=s,a.planes=[pr(s[1],s[0],s[4]),pr(s[2],s[1],s[5]),pr(s[3],s[2],s[6]),pr(s[0],s[3],s[7])],a}addShadowReceiver(t,i,n){this._receivers.add(t,e.cY.fromTileIdAndHeight(t,i,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function pr(t,i,n){const r=e.aw([],n,i),s=e.aw([],t,i),o=e.bj([],r,s),a=e.af(o);return 0===a?[0,0,1,0]:(e.bN(o,o,1/a),[o[0],o[1],o[2],-e.bk(o,i)])}function fr(t){const i=t.properties.get("direction"),n=e.cT(i.x,i.y,i.z);n[2]=e.aB(n[2],0,75);const r=e.cV([n[0],n[1],n[2]]);return e.cU(r.x,r.y,r.z)}function mr(t,i,n){const r="none"===i.properties.get("color-use-theme"),s=i.properties.get("color"),o=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===n.properties.get("color-use-theme"),u=n.properties.get("color"),h=n.properties.get("intensity"),d=Math.max(e.bk([0,0,1],l),0),p=[0,0,0];e.bN(p,u.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),h);const f=[0,0,0];return e.bN(f,s.toPremultipliedRenderColor(r?null:t.getLut(n.scope)).toArray01Linear().slice(0,3),d*o),e.c_([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function gr(t,i,n,r,s,o){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=r-n,m=r+n;let g,_;p>f/m?(g=r,_=r*d):(g=.5*m*(1+p),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*p+m*m*p*p));const y=t.projection.pixelsPerMeter(t.center.lat,c),v=t._camera.getCameraToWorldMercator(),x=[0,0,-g*u];e.ae(x,x,v);let b=_*u;const w=function(i){return i[0]/=l,i[1]/=l,i[2]=e.bY(i[2],t._center.lat),i},T=t._edgeInsets;if(!(0===T.left&&0===T.top&&0===T.right&&0===T.bottom||T.left===T.right&&T.top===T.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),s=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,n,r);s[8]=2*-t.centerOffset.x/t.width,s[9]=2*t.centerOffset.y/t.height;const o=new Float64Array(16);e.cB(o,s,i);const l=new Float64Array(16);e.ba(l,o);const u=e.cn.fromInvProjectionMatrix(l,c,a,!0);for(const t of u.points){const i=w(t);b=Math.max(b,e.bO(e.cZ([],x,i)))}}b*=s/(s-1);const S=Math.acos(i[2]),E=Math.atan2(-i[0],-i[1]),A=new ir;A.position=x,A.setPitchBearing(S,E);const M=A.getWorldToCamera(c,y),I=b*c,C=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*I),P=A.getCameraToClipOrthographic(-I,I,-I,I,C,(I+o*y)/i[2]),L=new Float64Array(16);e.aC(L,P,M);const R=e.cU(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),O=.5*s,D=[0,0,0];e.ae(D,R,L),e.bN(D,D,O);const B=[Math.floor(D[0]),Math.floor(D[1]),Math.floor(D[2])],F=[0,0,0];e.aw(F,D,B),e.bN(F,F,-1/O);const N=new Float64Array(16);return e.bA(N),e.bB(N,N,F),e.aC(L,N,L),[L,I]}class _r extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,i){return e.c$(this.requestManager.transformRequest(i,e.R.Model).url).then(n=>{const r=e.d0(n),s=new e.d1(t,i,void 0,void 0,r);return s.computeBoundsAndApplyParent(),s}).catch(n=>{if(n&&404===n.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${n.message}`)))})}load(t,i,n={forceReload:!1}){this.models[i]||(this.models[i]={});const r=Object.keys(t),s=[],o=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!n.forceReload||(this.modelByURL[r]={modelId:e,scope:i},s.push(this.loadModel(e,r)),o.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length,Promise.allSettled(s).then(t=>{for(let e=0;e<t.length;e++){const{status:n}=t[e];if("rejected"===n)continue;const{value:r}=t[e];this.models[i][o[e]]||(this.models[i][o[e]]={model:null,numReferences:1}),this.models[i][o[e]].model=r}this.numModelsLoading[i]-=o.length,this.fire(new e.z("data",{dataType:"style"}))}).catch(t=>{this.fire(new e.y(new Error(`Could not load models: ${t.message}`)))})}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t,i={exactIdMatch:!1}){return!!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===n)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(n)){const{scope:e,modelId:t}=this.modelByURL[n];this.models[e][t].numReferences++}else this.modelUris[i][e]=n,this.load({[e]:this.modelUris[i][e]},i)}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i={};for(const n of e)this.hasModel(n,t,{exactIdMatch:!0})||this.hasURLBeenRequested(n)?this.models[t][n].numReferences++:this.modelUris[t][n]&&!this.hasURLBeenRequested(n)?i[n]=this.modelUris[t][n]:!this.hasURLBeenRequested(n)&&ft(n,!1)&&(this.modelUris[t][n]=this.requestManager.normalizeModelURL(n),i[n]=this.modelUris[t][n]);this.load(i,t)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,n=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||n)){const n=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[n];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy()}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context)}}const yr=["RENDER_SHADOWS","NORMAL_OFFSET"],vr=new Set(["symbol","circle"]),xr=class t{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(e,t,i){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const n=i.stylesheet,r=!!i.fog,s=!!(i.getTerrain()||n&&n.terrain),o=!(!i.projection||"globe"!==i.projection.name),a=s||o,l=!(!i.directionalLight||!i.directionalLight.shadowsEnabled()),c=i.map&&i.map.painter,u=!c||!c.context.extParallelShaderCompile,h=!!c&&"mrt-fallback"===c.emissiveMode,d=(e,t=[],i={})=>{this._queue.push({programId:e,params:Object.assign({},i.params,{defines:t,overrideFog:!!i.fog,overrideTerrain:!!i.terrain,overrideGlobe:!!i.globe,overrideRtt:!!i.rtt,precompiled:!0})})};for(const n of e){if("none"===n.visibility)continue;const e=n.getProgramIds();if(e)for(const p of e){if(vr.has(p))continue;const e=n.getDefaultProgramParams(p,t.zoom,i._styleColorTheme.lut);if(!e)continue;const f=c?c.getShaderSource(p):null,m=a&&(!f||f.usedDefines.has("RENDER_TO_TEXTURE")),g=h&&m?(e.defines||[]).concat("USE_MRT1"):e.defines;if(u){d(p,e.defines,{params:e}),m&&d(p,g,{params:e,rtt:!0});continue}const _=r&&(!f||f.usedDefines.has("FOG")),y=s&&!n.isDraped()&&(!f||f.usedDefines.has("TERRAIN")),v=o&&(!f||f.usedDefines.has("GLOBE")),x=l&&n.hasElevation()&&(!f||f.usedDefines.has("RENDER_SHADOWS"));for(const t of x?[!1,!0]:[!1]){const i=t?(e.defines||[]).concat(yr):e.defines||[];for(const t of y?[!1,!0]:[!1])for(const n of v?[!1,!0]:[!1])for(const r of _?[!1,!0]:[!1])d(p,i,{params:e,fog:r,terrain:t,globe:n})}m&&d(p,g,{params:e,rtt:!0})}}if(d("clippingMask"),s)for(const e of[!1,!0])d("terrainRaster",e?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:r});if(!u){if(e.some(e=>"hillshade"===e.type)&&d("hillshadePrepare"),l)for(const e of[!1,!0])for(const t of[!1,!0]){const i=[];e&&i.push("RENDER_CUTOFF"),i.push("RENDER_SHADOWS"),t&&i.push("NORMAL_OFFSET"),d("groundShadow",i),r&&d("groundShadow",i,{fog:!0})}if(o){for(const e of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const t of[!1,!0]){const i=[...e,"PROJECTION_GLOBE_VIEW"];t&&i.push("CUSTOM_ANTIALIASING"),d("globeRaster",i,{terrain:s,globe:!0,fog:r})}for(const e of[!1,!0]){const t=e?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];d("globeAtmosphere",t,{fog:!0,terrain:s,globe:e}),d("globeAtmosphere",[...t,"ALPHA_PASS"],{fog:!0,terrain:s,globe:e})}d("stars",[],{fog:r,terrain:s,globe:!0})}}}_executeBatch(i,n,r){if(r.map&&r.map.isMoving())return void(this._idleHandle=e.o.requestIdleCallback(e=>this._executeBatch(e,n,r)));n.context.sweepPendingPrograms();const s=n.context.extParallelShaderCompile?t.DEADLINE_MARGIN_KHR_MS:t.DEADLINE_MARGIN_SYNC_MS;let o=0;for(;this._queue.length>0;){const e=this._queue.shift();if(!e)break;if(n.style=r,n._fogVisible=!!e.params.overrideFog,n.getOrCreateProgram(e.programId,e.params),o++,i.timeRemaining()<=s)break}const a=0===this._queue.length||i.timeRemaining()>s;o>0&&a&&n.context.gl.flush(),this._idleHandle=this._queue.length>0||n.context._pendingPrograms.size>0?e.o.requestIdleCallback(e=>this._executeBatch(e,n,r)):null}processQueue(t,i){0!==this._queue.length&&(null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=e.o.requestIdleCallback(e=>this._executeBatch(e,t,i)))}reset(){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};xr.DEADLINE_MARGIN_KHR_MS=5,xr.DEADLINE_MARGIN_SYNC_MS=25;let br=xr;const wr=e.a6.colorTheme,Tr=new e.a8({data:new e.a9(wr.data)});function Sr(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:n,top:r,width:s,height:o}=t.metadata.content_area,a=n*i,l=r*i;return[a,l,a+s*i,l+o*i]}function Er(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class Ar{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const n=this.sourceCache.getSource();if(!(n instanceof xi))return t;const r=i.map(e=>this.sourceCache.getTile(e)),s=n.getImages(r,Array.from(this.pendingRequests));for(const[i,n]of s)t.set(e.I.from({name:i,iconsetId:this.id}),n),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}class Mr{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(e,t,i,n,r){if(i<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let s=null,o=Number.MAX_VALUE,a=Number.MAX_VALUE,l=!1;const c=this._previousClosestBuildingId?e[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&c&&this._isBuildingVisible(c,n,r)&&(l=!0,a=this._calculateDistance(t,c));for(const[i,a]of Object.entries(e)){if(!this._isBuildingVisible(a,n,r))continue;const e=this._calculateDistance(t,a);e<o&&(o=e,s=i)}return l&&s&&this._previousClosestBuildingId&&s!==this._previousClosestBuildingId?o>a*this._hysteresisRatio&&(s=this._previousClosestBuildingId):l&&!s&&(s=this._previousClosestBuildingId),this._previousClosestBuildingId=s,s}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],n=e.lng-t.center[0];return i*i+n*n}_isBuildingVisible(t,i,n){if(!n)return!1;for(const i of t.floorIds){const r=t.floors[i];if(!r.geometry)continue;const s=r.geometry;if("Polygon"===s.type){const t=this._convertRingToPoints(s.coordinates[0]);if(e.bz(t,n))return!0}else if("MultiPolygon"===s.type){const t=this._convertMultiPolygonToPoints(s.coordinates);if(e.d2(n,t))return!0}}return!1}_convertRingToPoints(t){return t.map(t=>new e.P(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.P(t[0],t[1])))}}class Ir extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Mr,this._initialLoadDone=!1,e.b0(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors())}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector()}setIndoorData(e){let t=!1;for(const[i,n]of Object.entries(e.buildings))if(this._buildings[i])for(const e of n.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],n.floors[e]):(this._buildings[i].floors[e]=n.floors[e],t=!0);else this._buildings[i]=n,t=!0;t&&this._recalculateActiveFloors()}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let n=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){n=e;break}const r=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return{selectedFloorId:n,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:r}}_updateUI(){this._initialLoadDone=!0;const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(e,t),this._updateIndoorSelector()}}_onBuildingTransition(e,t){if(!this._indoorState)return;const i=!!t&&!e;!t&&e?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new e.z("selector-update",this.getControlState()))}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.d3.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry)}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,n=t.height;return[t.pointLocation(new e.P(0,0)),t.pointLocation(new e.P(i,0)),t.pointLocation(new e.P(i,n)),t.pointLocation(new e.P(0,n))].map(t=>new e.P(t.lng,t.lat))}}const Cr=(e,t)=>zt(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Pr=e.aK(Ui,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),Lr=e.aK(Ui,["setCenter","setZoom","setBearing","setPitch"]),Rr=new Set(["background","sky","slot","custom"]),Or=new Set(["building"]),Dr={version:8,layers:[],sources:{}},Br={duration:300,delay:0};class Fr extends e.E{constructor(t,i={}){if(super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},Br),this._buildingIndex=new Bi(this),this.crossTileSymbolIndex=new jn,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new te,this._hasDataDrivenEmissive=!1,this.indoorManager=new Ir(this),this.dispatcher=i.dispatcher?i.dispatcher:new si(Ni(),this),this.map.painter&&this.map.painter.context){const e=this.map.painter.context.maxUniformBufferBindings,t=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:e,maxUniformBlockSizeDwords:t,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new Xe(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.d4(t._requestManager,i.localFontFamily?e.d5.all:i.localIdeographFontFamily?e.d5.ideographs:e.d5.none,i.localFontFamily||i.localIdeographFontFamily,i.fontstackCompositing),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new _r(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new br:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.d6()),this.dispatcher.broadcast("setConfig",e.d7());const n=this;this._rtlTextPluginCallback=Fr.registerForPluginStateChange(t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.d8(t),i&&i.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}})}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.e(t))return t;const i=e.d9(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.da(JSON.stringify(t))}`}_diffStyle(t,i,n){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,n))}catch(e){t(e,!1)}};if("string"==typeof t){const n=this.map._requestManager.normalizeStyleURL(t),s=this.map._requestManager.transformRequest(n,e.R.Style);e.m(s,(t,n)=>{t?this.fire(new e.y(t)):n&&r(n,i)})}else"object"==typeof t&&r(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,n);const s=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(s,(i,r)=>{if(this._request=null,i)this.fire(new e.y(i));else if(r)return this.importsCache.set(t,r),this._load(r,n)})}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Dr,!1)}_loadImports(t,i,n){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const s of t){const t=this._createFragmentStyle(s),o=new Promise(e=>{t.once("style.import.load",e),t.once("error",e)}).then(()=>{this.mergeAll(),this.fire(new e.z("data",{dataType:"style"}))});if(r.push(o),this.resolvedImports.has(s.url)){t.loadEmpty();continue}const a=s.data||this.importsCache.get(s.url);a?(s.data?(t.fire(new e.z("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(a),queueMicrotask(()=>t._load(a,i))):t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):s.url?t.loadURL(s.url,{validate:i}):t.loadEmpty();const l={style:t,id:s.id,config:s.config};if(n){const e=this.fragments.findIndex(({id:e})=>e===n);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e))}else this.fragments.push(l)}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.t(t.id,this.scope):t.id;let n;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(n=Object.assign({},t.config,r));const s=new Fr(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:n,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return s.setEventedParent(this.map,{style:s}),s}_reloadImports(e=!1){this.mergeAll(),this._updateMapProjection(),e||this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),(!e||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(e&&this.isRootStyle()?(this.forEachFragmentStyle(e=>{this.dispatcher.broadcast("setLayers",{layers:e._serializeLayers(e._order),scope:e.scope,options:e.options})}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}))}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Dr,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&Cr(this,Et(t)))return;this._loaded=!0;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});this.stylesheet=e.db(t);const n=()=>{if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const n=zi(this.stylesheet.layers);if(this._order=n.map(e=>e.id),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new jt(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new jt(this.stylesheet.light)),this._layers={};for(const t of n){const i=e.dh(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const n=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&i.canCastShadows()&&r&&(n.castsShadows=!0)}if(this.glyphManager.url){const e=new Set;for(const t in this._layers){const i=this._layers[t];if("symbol"===i.type&&i.layout){const t=i.layout.get("text-font");t&&t.value&&"constant"===t.value.kind&&e.add(t.value.value.join(","))}}for(const t of e)this.glyphManager.prefetchRange(t,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(r,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.z("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(!0),this.fire(new e.z(s?"style.load":"style.import.load"))}).catch(t=>{this.fire(new e.y(new Error("Failed to load imports",t))),this.fire(new e.z(s?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new e.z(s?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{n()}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()})}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,n,r,s,o,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(h=>{if(h.stylesheet){if(h.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);n=this._prioritizeTerrain(n,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(r=h.fog),h.stylesheet.snow&&null!=h.snow&&(s=h.snow),h.stylesheet.rain&&null!=h.rain&&(o=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=s,this.rain=o,this._styleColorThemeForScope=u,null===n?delete this.terrain:this.terrain=n,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Br,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const n=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:n?e:null:null!=t&&(!e||n||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)}),null===e?delete this.terrain:this.terrain=e,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)}),this.projection=e||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){const t={},i={},n={},r={};this.forEachFragmentStyle(s=>{for(const i in s._sourceCaches){const n=e.t(i,s.scope);t[n]=s._sourceCaches[i]}for(const t in s._otherSourceCaches){const n=e.t(t,s.scope);i[n]=s._otherSourceCaches[t]}for(const t in s._symbolSourceCaches){const i=e.t(t,s.scope);n[i]=s._symbolSourceCaches[t]}for(const t in s._fillExtrusionSourceCaches){const i=e.t(t,s.scope);r[i]=s._fillExtrusionSourceCaches[t]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=n,this._mergedFillExtrusionSourceCaches=r}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const n=i,r=e.t(n.sourceId,t.scope);this._mergedIndoor[r]=new Set(n.sourceLayers||[])}})}mergeLayers(){const t={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const s=n._layers[r];if("slot"===s.type){const i=e.dc(r);if(t[i])continue;t[i]=[]}s.slot&&t[s.slot]?t[s.slot].push(s):i.push(s)}}),this._mergedOrder=[];let r=-1;const s=(i=[])=>{for(const o of i)if("slot"===o.type){const i=e.dc(o.id);t[i]&&s(t[i]),this._mergedSlots.push(i)}else{const t=e.t(o.id,o.scope);this._mergedOrder.push(t),n[t]=o,o.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0),"clip"===o.type&&(this._clipLayerPresent=!0)}};if(s(i),this._has3DLayers){const e={};for(let t=0;t<this._mergedOrder.length;++t){const i=this._mergedOrder[t];e[i]=t===r?1:t<r?n[i].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((t,i)=>e[t]-e[i])}this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,n){const r=Object.assign({},i);for(const e of Object.keys(wr))void 0===r[e]&&(r[e]=wr[e].default);const s=new e.a7(Tr,t,new Map(n));return s.setTransitionOrValue(r,n),s.untransitioned().possiblyEvaluate(new e.ab(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((n,r)=>{const s="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void n();let o=t;o.startsWith(s)||(o=s+o);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=o,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void n();this._styleColorTheme.lutLoading=!1;const{width:s,height:o,data:c}=e.o.getImageData(l);if(o>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(s!==o*o)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.q({width:s,height:o},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const u=this.imageManager.getImage(a,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},n()):r(new Error("Missing LUT image."))}})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,n){let r,s,o;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,o||(o=e,r=t,u())}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,o||(o=e,s=t,u())});function u(){if(o)n(o);else if(r&&s){const t=e.o.getImageData(s),i={};for(const n in r){const{width:s,height:o,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=r[n],f=new e.q({width:s,height:o});e.q.copy(t,f,{x:a,y:l},{x:0,y:0},{width:s,height:o},null),i[n]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==c&&c,stretchX:h,stretchY:d,content:p,usvg:!1,version:0}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i){const t=new Map;for(const n in i)t.set(e.I.from(n),i[n]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const n=this.getOwnSourceCache(i.source);if(!n)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=n.getSource();if("raster-array"!==r.type)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const s=new Ar(t,this.scope,n);this.imageManager.addImageProvider(s,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(t){if(!e.e(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var n,r;this._spriteRequest=(r=(n,r)=>{if(this._spriteRequest=null,n)i?this._loadSprite(t):this.fire(new e.y(n));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.b4((n=this.map._requestManager).transformRequest(n.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void r(t);const n={},s=new e.b2(i).readFields(re,{icons:[]},void 0);for(const t of s.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:Sr(t),stretchX:t.metadata?Er(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?Er(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};n[t.name]=i}r(null,n)}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(n))&&this.fire(new e.y(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(this.imageManager.hasPatternsInFlight())return!1;if(!this.modelManager.isLoaded())return!1;if(this._styleColorTheme.lutLoading)return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;if(this.hasSnowTransition())return!0;if(this.hasRainTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.y(new Error(`The source '${t}' does not exist in the map's style.`)))}handleIdle(){const e=this.map.painter;e&&(e.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(e,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const n=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:n}=e[t];(i||n)&&(this._updateWorkerLayers(t,i,n),r=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}const s={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];s[e]=t.used,t.used=!1,t.tileCoverLift=0}const o={};for(const i of this._mergedOrder){const n=this._mergedLayers[i];if(("none"!==n.visibility||n.hasTransition())&&n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){Or.has(n.type)&&e.dd();const t=this.getLayerSourceCache(n);t&&(t.used=!0,t.tileCoverLift=Math.max(t.tileCoverLift,n.tileCoverLift()))}if("fill-extrusion"===n.type){const t=e.t(n.source,n.scope);if(t in this._mergedFillExtrusionSourceCaches){const e=n.layout&&n.layout.get("source-max-zoom");if(null!=e){const i=o[t];o[t]=null==i?e:Math.min(i,e)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const e=this._mergedOrder.map(e=>this._mergedLayers[e]);this._programPrecompiler.buildQueue(e,t,this)}for(const e in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[e].setMaxzoomOverride(null!=o[e]?o[e]:null);this.terrain&&r&&this.mergeLayers();const a=this.imageManager.getPendingImageProviders();for(const e of a)e.sourceCache.used=!0;for(const t in s){const i=this._mergedSourceCaches[t];s[t]!==i.used&&i.getSource().fire(new e.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),n&&this.fire(new e.z("data",{dataType:"style"}))}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e)}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i])}for(const t in e)this._changes.resetUpdatedImages(t)}_updateWorkerLayers(e,t,i){const n=this.getFragmentStyle(e);n&&this.dispatcher.broadcast("updateLayers",{layers:t?n._serializeLayers(t):[],scope:e,removedIds:i||[],options:n.options})}setState(t,i){if(this._checkLoaded(),Cr(this,Et(t)))return!1;(t=e.db(t)).layers=zi(t.layers);const n=function(t,i){if(!t)return[{command:Ui.setStyle,args:[i]}];let n=[];try{if(!e.b9(t.version,i.version))return[{command:Ui.setStyle,args:[i]}];if(e.b9(t.center,i.center)||n.push({command:Ui.setCenter,args:[i.center]}),e.b9(t.zoom,i.zoom)||n.push({command:Ui.setZoom,args:[i.zoom]}),e.b9(t.bearing,i.bearing)||n.push({command:Ui.setBearing,args:[i.bearing]}),e.b9(t.pitch,i.pitch)||n.push({command:Ui.setPitch,args:[i.pitch]}),e.b9(t.sprite,i.sprite)||n.push({command:Ui.setSprite,args:[i.sprite]}),e.b9(t.glyphs,i.glyphs)||n.push({command:Ui.setGlyphs,args:[i.glyphs]}),e.b9(t.imports,i.imports)||function(t=[],i=[],n){i=i||[];const r=(t=t||[]).map(qi),s=i.map(qi),o=t.reduce(Xi,{}),a=i.reduce(Xi,{}),l=r.slice();let c,u,h,d;for(c=0,u=0;c<r.length;c++)h=r[c],Object.hasOwn(a,h)?u++:(n.push({command:Ui.removeImport,args:[h]}),l.splice(l.indexOf(h,u),1));for(c=0,u=0;c<s.length;c++)h=s[s.length-1-c],l[l.length-1-c]!==h&&(Object.hasOwn(o,h)?(n.push({command:Ui.removeImport,args:[h]}),l.splice(l.lastIndexOf(h,l.length-u),1)):u++,d=l[l.length-c],n.push({command:Ui.addImport,args:[a[h],d]}),l.splice(l.length-c,0,h));for(const t of i){const i=o[t.id];i&&(delete i.data,e.b9(i,t)||n.push({command:Ui.updateImport,args:[t.id,t]}))}}(t.imports,i.imports,n),e.b9(t.transition,i.transition)||n.push({command:Ui.setTransition,args:[i.transition]}),e.b9(t.light,i.light)||n.push({command:Ui.setLight,args:[i.light]}),e.b9(t.fog,i.fog)||n.push({command:Ui.setFog,args:[i.fog]}),e.b9(t.snow,i.snow)||n.push({command:Ui.setSnow,args:[i.snow]}),e.b9(t.rain,i.rain)||n.push({command:Ui.setRain,args:[i.rain]}),e.b9(t.projection,i.projection)||n.push({command:Ui.setProjection,args:[i.projection]}),e.b9(t.lights,i.lights)||n.push({command:Ui.setLights,args:[i.lights]}),e.b9(t.camera,i.camera)||n.push({command:Ui.setCamera,args:[i.camera]}),e.b9(t.iconsets,i.iconsets)||function(t,i,n){let r;for(r in i=i||{},t=t||{})Object.hasOwn(t,r)&&(Object.hasOwn(i,r)||n.push({command:Ui.removeIconset,args:[r]}));for(r in i){if(!Object.hasOwn(i,r))continue;const s=i[r];Object.hasOwn(t,r)?e.b9(t[r],s)||(n.push({command:Ui.removeIconset,args:[r]}),n.push({command:Ui.addIconset,args:[r,s]})):n.push({command:Ui.addIconset,args:[r,s]})}}(t.iconsets,i.iconsets,n),!e.b9(t["color-theme"],i["color-theme"]))return[{command:Ui.setStyle,args:[i]}];const r={},s=[];!function(t,i,n,r){let s;for(s in i=i||{},t=t||{})Object.hasOwn(t,s)&&(Object.hasOwn(i,s)||ji(s,n,r));for(s in i){if(!Object.hasOwn(i,s))continue;const o=i[s];Object.hasOwn(t,s)?e.b9(t[s],o)||("geojson"===t[s].type&&"geojson"===o.type&&Hi(t,i,s)?n.push({command:Ui.setGeoJSONSourceData,args:[s,o.data]}):Gi(s,i,n,r)):Vi(s,i,n)}}(t.sources,i.sources,s,r);const o=[];t.layers&&t.layers.forEach(e=>{e.source&&r[e.source]?n.push({command:Ui.removeLayer,args:[e.id]}):o.push(e)});let a=t.terrain;a&&r[a.source]&&(n.push({command:Ui.setTerrain,args:[void 0]}),a=void 0),n=n.concat(s),e.b9(a,i.terrain)||n.push({command:Ui.setTerrain,args:[i.terrain]}),function(t,i,n){i=i||[];const r=(t=t||[]).map(qi),s=i.map(qi),o=t.reduce(Xi,{}),a=i.reduce(Xi,{}),l=r.slice(),c=Object.create(null);let u,h,d,p,f,m,g;for(u=0,h=0;u<r.length;u++)d=r[u],Object.hasOwn(a,d)?h++:(n.push({command:Ui.removeLayer,args:[d]}),l.splice(l.indexOf(d,h),1));for(u=0,h=0;u<s.length;u++)d=s[s.length-1-u],l[l.length-1-u]!==d&&(Object.hasOwn(o,d)?(n.push({command:Ui.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,m=l[l.length-u],n.push({command:Ui.addLayer,args:[a[d],m]}),l.splice(l.length-u,0,d),c[d]=!0);for(u=0;u<s.length;u++)if(d=s[u],p=o[d],f=a[d],!c[d]&&!e.b9(p,f))if(e.b9(p.source,f.source)&&e.b9(p["source-layer"],f["source-layer"])&&e.b9(p.type,f.type)){for(g in Wi(p.layout,f.layout,n,d,null,Ui.setLayoutProperty),Wi(p.paint,f.paint,n,d,null,Ui.setPaintProperty),e.b9(p.slot,f.slot)||n.push({command:Ui.setSlot,args:[d,f.slot]}),e.b9(p.filter,f.filter)||n.push({command:Ui.setFilter,args:[d,f.filter]}),e.b9(p.minzoom,f.minzoom)&&e.b9(p.maxzoom,f.maxzoom)||n.push({command:Ui.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)Object.hasOwn(p,g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&"slot"!==g&&(0===g.indexOf("paint.")?Wi(p[g],f[g],n,d,g.slice(6),Ui.setPaintProperty):e.b9(p[g],f[g])||n.push({command:Ui.setLayerProperty,args:[d,g,f[g]]}));for(g in f)Object.hasOwn(f,g)&&!Object.hasOwn(p,g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&"slot"!==g&&(0===g.indexOf("paint.")?Wi(p[g],f[g],n,d,g.slice(6),Ui.setPaintProperty):e.b9(p[g],f[g])||n.push({command:Ui.setLayerProperty,args:[d,g,f[g]]}))}else n.push({command:Ui.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],n.push({command:Ui.addLayer,args:[f,m]})}(o,i.layers,n)}catch(e){n=[{command:Ui.setStyle,args:[i]}]}return n}(this.serialize(),t).filter(e=>!(e.command in Lr));if(0===n.length)return!1;const r=n.filter(e=>!(e.command in Pr));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const s=[];return n.forEach(e=>{s.push(this[e.command](...e.args))}),i&&Promise.all(s).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(0===t.size)return this;for(const[i,n]of t.entries()){if(this.getImage(i))return this.fire(new e.y(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,n),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.y(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this)}updateImage(t,i,n=!1){this.imageManager.updateImage(t,this.scope,i),n&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})))}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(t,i,n={}){return this._checkLoaded(),this._validate(Nt,`models.${t}`,i,null,n)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,n={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(At,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=wi(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const s=t=>{const i=(t===e.b7.Symbol?"symbol:":t===e.b7.FillExtrusion?"fill-extrusion:":"other:")+r.id,n=e.t(i,this.scope),s=this._sourceCaches[i]=new Ri(n,r,t);t===e.b7.Symbol?this._symbolSourceCaches[r.id]=s:t===e.b7.FillExtrusion?this._fillExtrusionSourceCaches[r.id]=s:this._otherSourceCaches[r.id]=s,s.onAdd(this.map)};s(e.b7.Other),"vector"!==i.type&&"geojson"!==i.type||(s(e.b7.Symbol),"vector"===i.type&&s(e.b7.FillExtrusion)),r.onAdd&&r.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const n=this.getOwnSourceCaches(t);for(const t of n){const i=e.dc(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(It,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i)}else this.ambientLight=new oi(e,li(),this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i)}else this.directionalLight=new oi(e,ui(),this.scope,this.options)}}const n=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ab(this.z||0,n);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const n=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),s=t.properties.get("intensity"),o=t.properties.get("direction"),a=1-e.cT(o.x,o.y,o.z)[2]/90,l=n(r)*s*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity"),h=n(c)*u;return Number(((l+h)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.de(t)){const i=e.df(t),n=this.fragments.find(({id:e})=>e===i);if(!n)return;const r=e.dc(t);return n.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const n in t){const r={},s=this._featuresetSelectors[n]=[];for(const o of t[n].selectors){if(o.featureNamespace){const t=this.getOwnLayer(o.layer);if(!t){e.w(`Layer is undefined for selector: ${o.layer}`);continue}const s=i(t.source,t.sourceLayer);if(s in r&&r[s]!==o.featureNamespace){e.w(`"featureNamespace ${o.featureNamespace} of featureset ${n}'s selector is not associated to the same source, skip this selector`);continue}r[s]=o.featureNamespace}let t;if(o.properties)for(const i in o.properties){const n=e.U(o.properties[i]);"success"===n.result&&(t=t||{},t[i]=n.value)}s.push({layerId:o.layer,namespace:o.featureNamespace,properties:t,uniqueFeatureID:o._uniqueFeatureID})}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return[];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const n=this.getFragmentStyle(i),r=n.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const s=[];for(const e of r[t].selectors){const t=n.getOwnLayer(e.layer);t&&s.push(t)}return s}getConfigProperty(t,i){const n=this.getFragmentStyle(t);if(!n)return null;const r=e.t(i,n.scope),s=n.options.get(r),o=s?s.value||s.default:null;return o?o.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const n=e.t(t,i);return this._mergedIndoor[n]}setIndoorData(e,t){this.indoorManager.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,n){const r=this.getFragmentStyle(t);if(!r)return;const s=r.stylesheet.schema;if(!s||!s[i])return;const o=e.U(n);if("success"!==o.result)return void Cr(this,o.value);const a=o.value.expression,l=e.t(i,r.scope),c=r.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=s[i],g=e.U(s[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,Object.assign({},c,{value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m})),this.updateConfigDependencies(i)):this.fire(new e.y(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const n=i.stylesheet.schema;if(!n)return null;const r={};for(const t in n){const n=e.t(t,i.scope),s=i.options.get(n),o=s?s.value||s.default:null;r[t]=o?o.serialize():null}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const n in i){let r,s;const o=e.U(i[n].default);if("success"===o.result&&(r=o.value.expression),t&&void 0!==t[n]){const i=e.U(t[n]);"success"===i.result&&(s=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[n];if(r){const t=e.t(n,this.scope);this.options.set(t,{default:r,value:s,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.y(new Error(`No schema defined for config option "${n}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty())}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t)}}),this._changes.setDirty()}addLayer(t,i,n={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.y(new Error(`Layer with id "${r}" already exists on this map`)));let s;if("custom"===t.type){if(Cr(this,e.dg(t)))return;s=e.dh(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.db(t),t=Object.assign(t,{source:r})),this._validate(Ot,`layers.${r}`,t,{arrayIndex:-1},n))return;s=e.dh(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}})}const o=e.t(s.source,s.scope);0!==s.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o),s.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));s.slot&&s.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):a=t}this._order.splice(a,0,r),this._handleLayerOrderChange(),this._layers[r]=s;const l=this.getOwnLayerSourceCache(s),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&s.canCastShadows()&&c&&(l.castsShadows=!0);const u=this._changes.getRemovedLayer(s);if(u&&s.source&&l&&"custom"!==s.type){this._changes.discardLayerRemoval(s);const t=e.t(s.source,s.scope);u.type!==s.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),s.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot&&n.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):s=t}this._order.splice(s,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const n=this.getOwnLayerSourceCache(t);if(n&&n.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}n.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const n=this._checkLayer(e);n&&(n.minzoom===t&&n.maxzoom===i||(null!=t&&(n.minzoom=t),null!=i&&(n.maxzoom=i),this._updateLayer(n)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(t,i,n={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.b9(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Dt,`layers.${r.id}.filter`,i,{layerType:r.type},n)||(r.filter=e.db(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.db(i.filter)}setLayoutProperty(t,i,n,r={}){this._checkLoaded();const s=this._checkLayer(t);if(s&&!e.b9(s.getLayoutProperty(i),n)){if(null!=n&&(!r||!1!==r.validate)&&Cr(s,Ft.call(Et,{key:`layers.${t}.layout.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(i,n),0!==s.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s.fqid),s.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s.fqid),this._updateLayer(s)}}setLayerProperty(e,t,i,n={}){this._checkLoaded();const r=this._checkLayer(e);r&&("appearances"===t?(r.setAppearances(i),this._updateLayer(r)):r.isPaintProperty(t)?this.setPaintProperty(e,t,i,n):this.setLayoutProperty(e,t,i,n))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,n,r={}){this._checkLoaded();const s=this._checkLayer(t);if(!s)return;if(e.b9(s.getPaintProperty(i),n))return;if(null!=n&&(!r||!1!==r.validate)&&Cr(s,Bt.call(Et,{key:`layers.${t}.paint.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.a6})))return;const o=s.setPaintProperty(i,n);0!==s.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s.fqid),s.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s.fqid),o&&this._updateLayer(s),this._changes.updatePaintProperties(s)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),s=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of s)r.setFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.setFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=t.sourceLayer,s=this._checkSource(n);if(!s)return;const o=s.type;if("geojson"===o&&r)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.setFeatureState(r,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),s=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of s)r.removeFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.removeFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=this._checkSource(n);if(!r)return;const s=r.type,o="vector"===s?t.sourceLayer:void 0;if("vector"===s&&!o)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.removeFeatureState(o,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:n,importId:r}=t.target,s=this.getFragmentStyle(r),o=s.getFeaturesetLayers(n);for(const{source:n,sourceLayer:r}of o){const o=s.getFeatureState({id:t.id,source:n,sourceLayer:r});if(o&&!i)i=o;else if(!e.b9(i,o))return void this.fire(new e.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);i=this.getFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer})}return i}const i=t.source,n=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(e){e!==this._worldview&&(this._worldview=e,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.di({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t)}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),n=e.t(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[n]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(n,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,n={},r=[];for(let s=i.length-1;s>=0;s--){const o=i[s];if(t(o)){n[o]=s;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const s=[];for(let o=i.length-1;o>=0;o--){const a=i[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&n[t.layer.id]<o)break;s.push(t),r.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)s.push(t.feature)}}return s}queryRasterValue(t,i,n){const r=this.getOwnSource(t);return r?"raster-array"!==r.type?(this.fire(new e.y(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):r.queryRasterArrayValue(i,n):(this.fire(new e.y(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,i,n){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Dt,"queryRenderedFeatures.filter",i.filter,null,i),r=e.dj(i.filter));const s={},o=e=>{if(Rr.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=s[t.id]=s[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.y(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];o(i)}}else for(const e in this._layers)o(this._layers[e]);const a=this._queryRenderedFeatures(t,s,n),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dk(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,n){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Dt,"queryRenderedFeatures.filter",i.filter,null,i),r=e.dj(i.filter));const s="mock",o=[];if(i&&i.target)o.push(Object.assign({},i,{targetId:s,filter:r}));else{const e=this.getFeaturesetDescriptors();for(const t of e)o.push({targetId:s,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)o.push({targetId:s,filter:r,target:e})}}const a=this.queryRenderedTargets(t,o,n),l=[],c=new Set;for(const t of a)for(const i of t.variants[s])Si(i,t,c)||l.push(new e.dl(t,i));return l}queryRenderedTargets(t,i,n){const r={},s=(e,t,i,n)=>{const s=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(s.layers[e.fqid]=s.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(s.has3DLayers=!0),!n)return i.uniqueFeatureID=!1,void s.layers[e.fqid].targets.push(i);s.layers[e.fqid].targets.push(Object.assign({},i,{namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID}))};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:n}=t.target,r=this.getFragmentStyle(n);if(!r||!r._featuresetSelectors)continue;const o=r._featuresetSelectors[i];if(!o){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of o){const i=r.getOwnLayer(e.layerId);i&&!Rr.has(i.type)&&s(i,r.getOwnLayerSourceCache(i),t,e)}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Rr.has(i.type))continue;s(i,this.getLayerSourceCache(i),t)}const o=this._queryRenderedFeatures(t,r,n);return this._flattenAndSortRenderedFeatures(o)}_queryRenderedFeatures(t,i,n){const r=[],s=!!this.map._showQueryGeometry,o=hi.createFromScreenPoints(t,n);for(const e in i){const t=Ei(o,i[e],this._availableImages,n,s,this.getActualScope());Object.keys(t).length&&r.push(t)}if(this.placement)for(const t in i){if(i[t].sourceCache._renderSourceType!==e.b7.Symbol)continue;const n=Ai(o.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(n).length&&r.push(n)}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Dt,"querySourceFeatures.filter",i,null,t);let n=[];const r=this.getOwnSourceCaches(e);for(const e of r)n=n.concat(Mi(e,t));return n}addSourceType(e,t,i){return Fr.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Fr.setSourceType(e,t),i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,n={}){this._checkLoaded();const r=this.light.getLight();let s=!1;for(const i in t)if(!e.b9(t[i],r[i])){s=!0;break}if(!s)return;const o=this._getTransitionParameters();this.light.setLight(t,i,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let n=t;const r=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in n&&"object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.db(n),n=Object.assign(n,{source:t})}const t=Object.assign({},n),i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(Ct,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,r=i.get();for(const t of Object.keys(e.a6.terrain))!Object.hasOwn(n,t)&&e.a6.terrain[t].default&&(n[t]=e.a6.terrain[t].default);for(const n in t)if(!e.b9(t[n],r[n])){i.set(t,this.options),this.stylesheet.terrain=t;const n=this._getTransitionParameters({duration:0});i.updateTransitions(n),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Yt(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createSnow(e){const t=this.snow=new Qt(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createRain(e){const t=this.rain=new ei(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){const i=this.fog;if(!e.b9(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset()}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.b9(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.b9(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const n=this._evaluateColorThemeData(i);this._loadColorTheme(n).then(()=>{this.fire(new e.z("colorthemeset")),t()}).catch(t=>{e.w(`Couldn't set color theme: ${t}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme())}_getTransitionParameters(t){return{now:e.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new Ht(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const n=this._getTransitionParameters({duration:0});i.updateTransitions(n)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,i,n,r,s={}){if(s&&!1===s.validate)return!1;const o=Object.assign({},this.serialize());return Cr(this,t.call(Et,Object.assign({key:i,style:o,value:n,styleSpec:e.a6},r)))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dm.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];t.clearTiles(),t.setEventedParent(null);const i=t.getSource();i&&i.onRemove&&i.onRemove(this.map)}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear()}}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope)})}updateSources(e){let t;this.directionalLight&&(t=fr(this.directionalLight));const i=new Set,n=new Set,r=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?i.add(t.source):"raster"===t.type&&t.paint&&"ground"===t.paint.get("raster-elevation-reference")&&r.add(t.source),t.hasElevation()&&!n.has(t.source)&&n.add(t.source)}for(const s in this._mergedSourceCaches){const o=this._mergedSourceCaches[s],a=n.has(o._source.id);o._isRasterElevatedOverTerrain=r.has(o._source.id),i.has(o._source.id)&&(o._source.reparseOverscaled=!1),o.update(e,void 0,void 0,t,a)}}_reloadSources(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.z("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Nn),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(t,i,n,r,s){this.pauseablePlacement||(this.pauseablePlacement=new Nn);let o=!1,a=!1;const l={},c={};for(const i of this._mergedOrder){const n=this._mergedLayers[i];if("symbol"!==n.type)continue;const r=e.t(n.source,n.scope);let s=l[r];if(!s){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));c[r]=t.slice(),s=l[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const a=this.crossTileSymbolIndex.addLayer(n,s,t.center.lng,t.projection);o=o||a}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const u=Boolean(this.placement&&!t.equals(this.placement.transform)),h=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!s||this.placement.lastReplacementSourceUpdateTime!==s.updateTime)),d=u||h||o,p=(d||this.pauseablePlacement.isStale())&&0===n,f=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),t.zoom)&&0!==n;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||p||f)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,n,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const e=this.map.painter.maxFrontCutoffRawStart;if(e>0){const i=180*t.pitch/Math.PI;if(i>=15){const t=Math.min(1,Math.max(0,(i-15)/5)),n=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-n)+e*n}}}if(this.pauseablePlacement.isDone()?d&&0!==n&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),a=!0),o&&this.pauseablePlacement.setStale()),a||o){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;t<this._mergedOrder.length;t++){const i=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==i.type)continue;if("none"===i.visibility)continue;const n=this.isLayerClipped(i);this.placement.updateLayerOpacities(i,l[e.t(i.source,i.scope)],t,n?s:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(e.o.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,i){this._checkLoaded();const n=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==n.findIndex(({id:e})=>e===t.id))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return n.push(t),this._loadImports([t],!0);const r=n.findIndex(({id:e})=>e===i);return-1===r&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=n.slice(0,r).concat(t).concat(n.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(t);return-1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==n[r].url&&this.setImportUrl(t,i.url),e.b9(i.config,n[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.b9(i.data,n[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const n=this.getImportIndex(e);if(-1===n)return this;const r=this.getImportIndex(t);if(-1===r)return this;const s=i[n],o=this.fragments[n];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(s).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(o).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);if(-1===n)return this;i[n].url=t;const r=this.fragments[n];return r.style=this._createFragmentStyle(i[n]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),n=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete n[i].data,this.setImportUrl(e,n[i].url))}setImportConfig(e,t,i){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const s=this.fragments[n];i&&s.style.stylesheet&&(s.style.stylesheet.schema=i);const o=s.style.stylesheet&&s.style.stylesheet.schema;return s.config=t,s.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return-1===i&&this.fire(new e.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource())}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const n=e.t(t,i);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(t){const i=e.t(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type&&this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),this._mergedFillExtrusionSourceCaches[e]&&t.push(this._mergedFillExtrusionSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e)}getImages(t,i,n){this.imageManager.getImages(i.icons.concat(i.patterns),i.scope,n),this._updateTilesForChangedImages();const r=i.icons.map(t=>e.I.toString(t)),s=i.patterns.map(t=>e.I.toString(t)),o=e=>{e&&(e.setDependencies(i.tileID.key,"icons",r),e.setDependencies(i.tileID.key,"patterns",s))},a=e.t(i.source,i.scope);o(this._mergedOtherSourceCaches[a]),o(this._mergedSymbolSourceCaches[a]),(i.icons.some(e=>e.iconsetId)||i.patterns.some(e=>e.iconsetId))&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}checkAtlasCache(e,t,i){const n=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);i(null,n&&n.contentDescriptor?{iconPositions:n.iconPositions,patternPositions:n.patternPositions,sourceHash:n.contentDescriptor.hash}:null)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:"fill-extrusion"===e.type&&this._fillExtrusionSourceCaches[e.source]||this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),this._fillExtrusionSourceCaches[e]&&t.push(this._fillExtrusionSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return!1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),n="building"===e.type;if(e.is3D(!!this.terrain)){if(i||n||t&&"batched-model"===t.type)return!0;if("model"===e.type)return!0}else if("symbol"===e.type)return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Fr.getSourceType=function(e){return bi[e]},Fr.setSourceType=function(e,t){bi[e]=t},Fr.registerForPluginStateChange=e.dn;var Nr="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",kr="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nconst float DITHER_THRESHOLDS[16]=float[16](\n1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);vec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);\n#else\nreturn 1.0;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}",zr="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Ur="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Vr="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",jr="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",Gr="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Hr="\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif",Wr="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",qr="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",Xr="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const $r=/#include\s+"([^"]+)"/g,Zr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,Yr=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Jr=new Set(["ifdef","ifndef","elif","if","defined"]),Kr=new Set;ls(Nr,Kr),ls(zr,Kr),ls(kr,Kr);const Qr={"_prelude_fog.vertex.glsl":jr,"_prelude_terrain.vertex.glsl":Vr,"_prelude_shadow.vertex.glsl":qr,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":Gr,"_prelude_shadow.fragment.glsl":Xr,"_prelude_lighting.glsl":Hr,"_prelude_raster_array.glsl":Wr},es={},ts="precision highp float;",is="precision mediump float;",ns="\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif",rs={preludeTerrain:us("",Vr),preludeFog:us(Gr,jr),preludeShadow:us(Xr,qr),preludeRasterArray:us(Wr,""),preludeLighting:us(Hr,Hr),preludePrecisionQualifiers:us(is,ts),prelude:us(kr,zr),preludeExtensions:us(ns,"")},ss=[ns,is,Nr,rs.prelude.fragmentSource].join("\n"),os=[ts,Nr,rs.prelude.vertexSource].join("\n");var as={background:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nfloat factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),circle:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:us("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:us('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(vec2(a_pos)*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:us("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:us("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}'),collisionCircle:us("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:us("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:us("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:us("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}"),elevatedStructures:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fill:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:us("uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;\n#define ADDITIVE 1\nvoid main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:us("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);\n#endif\n#endif\n}'),fillExtrusionDepth:us("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}'),fillExtrusionPattern:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:us('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nshadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:us("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:us("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;in vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 v_elevation_id_col;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);\n#ifdef VARIABLE_LINE_WIDTH\nalpha=mix(alpha,1.0,stub_side);\n#endif\nalpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef LINE_BLEND_ADDITIVE\n{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}\n#else\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);\n#else\nglFragColor=out_color;\n#endif\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef DEBUG_ELEVATION_ID\nglFragColor=vec4(v_elevation_id_col,1.0);\n#endif\nif (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 a_elevation_id_col;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nout vec3 v_elevation_id_col;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_z_offset;uniform highp float u_floor_width_scale;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;out vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset=u_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset+=a_z_offset_width.x;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nv_elevation_id_col=a_elevation_id_col;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\nv_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\nv_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\nv_tile_pos=(v_tile_pos+extrude)/EXTENT;\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);  \nfloat tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0);   \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbol:us('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\nin lowp float v_opacity;\n#ifdef RENDER_SDF\nin lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\n#else\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#endif\nvoid main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nlowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;\n#ifdef RENDER_SDF\nfill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;\n#endif\nlowp float emissive_strength=0.0;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\n#else\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 3u\n#define DWORDS_PER_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;\n#ifdef RENDER_SDF\nout lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nPropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color       =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color       =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity             =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width          =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur           =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength   =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity   =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset            =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate           =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color       =header.fill_np_color.isDataDriven     ? readColorProperty(header.fill_np_color,sizeVec4)     : u_spp_fill_np_color;props.halo_np_color       =header.halo_np_color.isDataDriven     ? readColorProperty(header.halo_np_color,sizeVec4)     : u_spp_halo_np_color;props.opacity             =header.opacity.isDataDriven           ? readFloatProperty(header.opacity,sizeVec4)           : u_spp_opacity;props.halo_width          =header.halo_width.isDataDriven        ? readFloatProperty(header.halo_width,sizeVec4)        : u_spp_halo_width;props.halo_blur           =header.halo_blur.isDataDriven         ? readFloatProperty(header.halo_blur,sizeVec4)         : u_spp_halo_blur;props.emissive_strength   =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity   =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset            =header.z_offset.isDataDriven          ? readFloatProperty(header.z_offset,sizeVec4)          : u_spp_z_offset;props.translate           =header.translate.isDataDriven         ? readVec2Property(header.translate,sizeVec4)          : vec2(0.0);return props;}\n#else\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define highp float z_offset\n#endif\nvec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nSymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;\n#ifdef RENDER_SDF\nv_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;\n#else\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize highp float z_offset\n#endif\nvec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);    \n#endif\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);\n#ifdef USE_PAINT_PROPERTIES_UBO\n{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y\n);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:us("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:us('#include "_prelude_fog.fragment.glsl"\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Ur),skyboxGradient:us('#include "_prelude_fog.fragment.glsl"\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Ur),skyboxCapture:us("\nin highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;\n#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M                  vec3(21e-6,21e-6,21e-6)\n#define MIE_G                   0.76\n#define DENSITY_HEIGHT_SCALE_R  8000.0\n#define DENSITY_HEIGHT_SCALE_M  1200.0\n#define PLANET_RADIUS           6360e3\n#define ATMOSPHERE_RADIUS       6420e3\n#define SAMPLE_STEPS            10\n#define DENSITY_STEPS           4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:us('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\ntexColor=vec4(unpremultiplyColor(texColor),1.0);\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:us("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}"),stars:us("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),occlusion:us("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function ls(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(Yr);if(i)for(const e of i)Jr.has(e)||t.add(e)}}function cs(e){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(e)}function us(e,t){const i=new Set,n=[],r=[];e=e.replace($r,(e,t)=>(r.push(t),"")),t=t.replace($r,(e,t)=>(n.push(t),""));let s=new Set(Kr);ls(e,s),ls(t,s);for(const e of[...n,...r])es[e]||(es[e]=new Set,ls(Qr[e],es[e])),s=new Set([...s,...es[e]]);return{fragmentSource:e=e.replace(Zr,(e,t,n,r,s)=>(i.add(s),"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\n${cs(r)?"flat ":""}in ${n} ${r} ${s};\n#else\nuniform ${n} ${r} u_${s};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${s}\n    ${n} ${r} ${s} = u_${s};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n    in ${n} ${r} ${s};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(Zr,(e,t,n,r,s)=>{const o=`MATERIAL_ATTRIBUTE_OFFSET_${s}`,a="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${a}(a_${s}, materialInfo, ${o})`,c=s.includes("color")?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\nin ${n} ${r} a_${s};\n#endif\n`:i.has(s)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\n    #if !defined(${o})\n        in ${n} ${a} a_${s};\n    #endif\n${cs(r)?"flat ":""}out ${n} ${r} ${s};\n#else\nuniform ${n} ${r} u_${s};\n#endif\n`:"initialize"===t?"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${s}\n    ${s} = a_${s};\n#else\n    ${n} ${r} ${s} = u_${s};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${s})\n    #ifdef ${o}\n        ${s} = unpack_mix_${c}(${l}, u_${s}_t);\n    #else\n        ${s} = unpack_mix_${c}(a_${s}, u_${s}_t);\n    #endif\n#else\n    ${n} ${r} ${s} = u_${s};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n    in ${n} ${r} a_${s};\n    out ${n} ${r} ${s};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n    ${s} = a_${s};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\n    #if !defined(${o})\n        in ${n} ${a} a_${s};\n    #endif\n#else\nuniform ${n} ${r} u_${s};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${s}0;\nin vec4 a_${s}1;\nin vec4 a_${s}2;\nin vec4 a_${s}3;\n#else\nuniform ${n} ${r} u_${s};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${n} ${a} a_${s};\n#else\nuniform ${n} ${r} u_${s};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n    ${n} ${r} ${s} = a_${s};\n#endif\n`:"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${s}\n    #ifdef ${o}\n        ${n} ${r} ${s} = ${l};\n    #else\n        ${n} ${r} ${s} = a_${s};\n    #endif\n#else\n    ${n} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n    #ifdef ${o}\n        ${n} ${r} ${s} = unpack_mix_${c}(${l}, u_${s}_t);\n    #else\n        ${n} ${r} ${s} = unpack_mix_${c}(a_${s}, u_${s}_t);\n    #endif\n#else\n    ${n} ${r} ${s} = u_${s};\n#endif\n`}),usedDefines:s,vertexIncludes:n,fragmentIncludes:r}}class hs{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,n,r,s,o,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!l&&e<n.length;e++)this.boundPaintVertexBuffers[e]!==n[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==o.length;for(let e=0;!c&&e<o.length;e++)this.boundDynamicVertexBuffers[e]!==o[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==s)this.freshBind(t,i,n,r,s,o,a);else{e.bindVertexArrayOES.set(this.vao);for(const i of o)i&&(i.bind(),a&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,a));r&&r.dynamicDraw&&r.bind()}}freshBind(e,t,i,n,r,s,o){const a=this.context,l=a.gl;this.vao&&this.destroy(),this.vao=a.gl.createVertexArray(),a.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=r,this.boundDynamicVertexBuffers=s,t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of i)t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of s)t&&(t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r),o&&t.instanceCount&&t.setVertexAttribDivisor(l,e,o));n&&n.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function ds(t,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new e.ad(0,r/n).toLngLat().lat,new e.ad(0,(r+1)/n).toLngLat().lat]}function ps(t,i,n,r,s,o,a){const l=t.context,c=l.gl,u=n.hillshadeFBO;if(!u)return;t.prepareDrawTile();const h=t.isTileAffectedByFog(i),d=[];t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&d.push("USE_MRT1");const p=t.getOrCreateProgram("hillshade",{overrideFog:h,defines:d});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment0.get());const f=((t,i,n,r)=>{const s=n.paint.get("hillshade-shadow-color"),o="none"===n.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=n.paint.get("hillshade-highlight-color"),l="none"===n.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=n.paint.get("hillshade-accent-color"),u="none"===n.paint.get("hillshade-accent-color-use-theme").constantOr("default"),h=n.paint.get("hillshade-emissive-strength");let d=e.am(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),n=e.cT(i.x,i.y,i.z);d=e.am(n[1])}const p=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:ds(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),d],u_shadow:s.toPremultipliedRenderColor(o?null:n.lut),u_highlight:a.toPremultipliedRenderColor(l?null:n.lut),u_emissive_strength:h,u_accent:c.toPremultipliedRenderColor(u?null:n.lut)}})(t,n,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,p,i.toUnwrapped());const{tileBoundsBuffer:m,tileBoundsIndexBuffer:g,tileBoundsSegments:_}=t.getTileBoundsBuffers(n);p.draw(t,c.TRIANGLES,s,o,a,Jn.disabled,f,r.id,m,g,_)}function fs(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,s=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const o=n.getPixels();i.demTexture?i.demTexture.update(o,{premultiply:!1}):i.demTexture=new e.T(r,o,s.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function ms(t,i,n){const r=t.context,s=r.gl;if(!i.dem)return;const o=i.dem;if(r.activeTexture.set(s.TEXTURE1),fs(t,i,o),!i.demTexture)return;i.demTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE);const a=o.dim;r.activeTexture.set(s.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},s.RGBA8);t.bind(s.LINEAR,s.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture)}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&d.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,s.TRIANGLES,qn.disabled,$n.disabled,Wn.unblended,Jn.disabled,((t,i)=>{const n=i.stride,r=e.bd();return e.bX(r,0,e.ak,-e.ak,0,0,1),e.bB(r,r,[0,-e.ak,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ}})(i.tileID,o),n.id,c,u,h),i.needsHillshadePrepare=!1}class gs{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class _s extends gs{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class ys extends gs{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class vs extends gs{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class xs extends gs{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class bs extends gs{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class ws extends gs{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Ts extends gs{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ss extends gs{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class Es extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class As extends gs{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Ms extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class Is extends gs{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Cs extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class Ps extends gs{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Ls extends gs{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Rs extends gs{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class Os extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Ds extends gs{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Bs extends gs{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let Fs=class extends gs{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class Ns extends gs{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ks extends gs{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class zs extends gs{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Us extends gs{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Vs extends gs{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class js extends gs{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Gs extends gs{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Hs extends gs{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Ws extends gs{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class qs extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Xs extends gs{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class $s extends gs{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Zs extends $s{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i}setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ys extends $s{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Js extends $s{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ks extends Ys{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Qs=(e,t,i,n)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:n}),eo=(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:s,u_image0:0,u_image1:1,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:g?Float32Array.from(g):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f,u_emissive_texture_available:m});function to(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const io=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:n,phase:0,duration:r,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}};function no(e,t,i){if(0===t)return 0;const n=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*n}function ro(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}function so(e,t){if(!e.style||!e.style.enable3dLights())return;const i=e.context,n=i.gl;i.activeTexture.set(n.TEXTURE1),t?t.bind(n.LINEAR,n.CLAMP_TO_EDGE):e.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}const oo=e=>({u_matrix:e});function ao(t,i,n,r,s){if(s>0){const o=e.o.now(),a=(o-t.timeAdded)/s,l=i?(o-i.timeAdded)/s:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.aB(h?a:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:a<1}:{opacity:d,mix:0,isFading:a<1}}return{opacity:1,mix:0,isFading:!1}}class lo extends Ri{constructor(e){const t={type:"raster-dem",maxzoom:Math.ceil(e.transform.maxZoom)},i=wi("mock-dem",t,e.style.dispatcher,e.style);super("mock-dem",i,null),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class co extends Ri{constructor(e){const t=wi("proxy",{type:"geojson",maxzoom:Math.ceil(e.transform.maxZoom)},e.style.dispatcher,e.style);super("proxy",t,null),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,i,n){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((i,n)=>{if(i[n.key]="",!this._tiles[n.key]){const i=new e.b3(n,this._source.tileSize*n.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);i.state="loaded",this._tiles[n.key]=i}return i},{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class uo extends e.aU{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class ho extends e.bx{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,s]=function(){const t=new e.dE,i=new e.dF,n=131;t.reserve(17161),i.reserve(33800);const r=e.ak/128,s=e.ak+r/2,o=s+r;for(let i=-r;i<o;i+=r)for(let n=-r;n<o;n+=r){const r=n<0||n>s||i<0||i>s?24575:0,o=e.aB(Math.round(n),0,e.ak),a=e.aB(Math.round(i),0,e.ak);t.emplaceBack(o+r,a)}const a=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t)}),[t,i,32768]}(),o=t.context;this.gridBuffer=o.createVertexBuffer(n,e.dA.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=e.dB.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.dB.simpleSegment(0,0,n.length,s),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new co(i.map),this.orthoMatrix=e.bd(),e.bX(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.ak,0,e.ak,0,1);const a=o.gl;this._overlapStencilMode=new $n({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new lo(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,s=0===t.terrain.drapeRenderMode,o=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=s?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=o?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),i.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,n=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=n;const r=null!=i?n-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const s=t.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(s);let a=s-this._previousZoom;const l=this._previousUpdateTimestamp;let c=s;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(s-c)>.5&&(a=.5*(s-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const u=o.getExaggeration(c),h=u===o.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.aj(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.ad.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(n.x,n.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),s=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),o=r.mult(1<<t.canonical.z);return o.x-=.5,o.y-=.5,o.distSqr(n)-o.distSqr(s)})}(r,this.painter);const s=this.proxyToSource||{};this.proxyToSource={},r.forEach(e=>{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const e in o){const i=o[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],s),i.usedForTerrain)continue;const n=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map(e=>new uo(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(s),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),fs(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,s=Math.pow(2,t.tileID.canonical.z-r.z),o=n||"";return i[`u_dem_tl${o}`]=[r.x*s%1,r.y*s%1],i[`u_dem_scale${o}`]=s,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const n=i.dem.tree.minimums[0];return n>0&&e++,t+n},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.dC({width:1,height:1},new Float32Array([n]));this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(r,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),s}setupElevationDraw(t,i,n){const r=this.painter.context,s=r.gl,o={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};o.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;c=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,o,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,o)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?s.LINEAR:s.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,r.activeTexture.set(s.TEXTURE4),l.demTexture.bind(u(l),s.CLAMP_TO_EDGE),o.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,o)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,r.activeTexture.set(s.TEXTURE2),h&&(o.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),s.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(n&&n.useDepthForOcclusion,i,o),n&&n.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.bY(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=t}if(n&&n.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=n.labelPlaneMatrixInv),i.setTerrainUniformValues(r,o),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,n&&n.useDenormalizedUpVectorScale);i.setGlobeUniformValues(r,e)}}globeUniformValues(t,i,n){const r=t.projection;return{u_tile_tl_up:r.upVector(i,0,0),u_tile_tr_up:r.upVector(i,e.ak,0),u_tile_br_up:r.upVector(i,e.ak,e.ak),u_tile_bl_up:r.upVector(i,0,e.ak),u_tile_up_scale:n?e.dD(1):r.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const i=this.painter,n=this.painter.context;0!==t.length&&(n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,n,r,s){if("globe"===t.transform.projection.name)!function(t,i,n,r,s){const o=t.context,a=o.gl;let l,c;const u=t.transform,h=e.ds(t,o,u),d=(e,i)=>{if(c===i)return;const n=[];1===i&&n.push("TERRAIN_VERTEX_MORPHING"),n.push("PROJECTION_GLOBE_VIEW"),h&&n.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:n,overrideFog:r}),c=i},p=t.colorModeForRenderPass(),f=new qn(a.LEQUAL,qn.ReadWrite,t.depthRangeFor3D);io.update(s);const m=e.dt(u),g=[e.aG(u.center.lng),e.aJ(u.center.lat)],_=t.globeSharedBuffers,y=[u.width*e.o.devicePixelRatio,u.height*e.o.devicePixelRatio],v=Float32Array.from(u.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=no(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of r){const r=n.getTile(c),w=$n.disabled,T=i.prevTerrainTileForTile[c.key],S=i.terrainTileForTile[c.key];to(T,S)&&io.newMorphing(c.key,T,S,s,250),so(t,r.emissiveTexture),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=io.getMorphValuesForProxy(c.key),A=E?1:0;E&&Object.assign(x,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dr(E.phase)}});const M=e.du(c.canonical),I=e.dv(M.getCenter().lat),C=e.dw(c.canonical,M,I,u.worldSize/u._pixelsPerMercatorPixel),P=e.dx(e.dy(c.canonical)),L="mrt-fallback"===t.emissiveMode?1:0,R=eo(u.expandedFarZProjMatrix,v,m,P,e.ai(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,h,u._farZ,L,C);if(d(c,A),l&&(i.setupElevationDraw(r,l,x),t.uploadCommonUniforms(o,l,c.toUnwrapped()),_)){const[e,i,n]=_.getGridBuffers(I,0!==h);l.draw(t,b,f,w,p,Jn.backCCW,R,"globe_raster",e,i,n)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const s=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&s.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:s});for(const s of r){const{x:r,y:c,z:h}=s.canonical,d=0===c,m=c===(1<<h)-1,[v,b,w,T]=_.getPoleBuffers(h,!1);if(T&&(d||m)){const c=n.getTile(s);so(t,c.emissiveTexture),o.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let _=e.dz(h,r,u);const S=e.dx(e.dy(s.canonical)),E="mrt-fallback"===t.emissiveMode?1:0,A=(e,i)=>e.draw(t,a.TRIANGLES,f,$n.disabled,p,Jn.disabled,eo(u.expandedFarZProjMatrix,_,_,S,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,0,u._farZ,E),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,x),t.uploadCommonUniforms(o,l,s.toUnwrapped()),d&&t.renderDefaultNorthPole&&A(l,v),m&&t.renderDefaultSouthPole&&(_=e.cE(e.bd(),_,[1,-1,1]),A(l,b))}}}}(t,i,n,r,s);else{const o=t.context,a=o.gl;let l,c;const u=t.shadowRenderer,h=ar(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];1===e&&i.push("TERRAIN_VERTEX_MORPHING"),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),u&&(i.push("RENDER_SHADOWS"),u.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new qn(a.LEQUAL,qn.ReadWrite,t.depthRangeFor3D);io.update(s);const m=t.transform,g=no(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(_=mr(t.style,e,i))}{c=-1;const y=a.TRIANGLES,[v,x]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),b=$n.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];to(w,T)&&io.newMorphing(c.key,w,T,s,250),so(t,r.emissiveTexture),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=io.getMorphValuesForProxy(c.key),E=S?1:0;let A;S&&(A={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.dr(S.phase)}});const M="mrt-fallback"===t.emissiveMode?1:0,I=Qs(c.projMatrix,ro(c.canonical,m.renderWorldCopies)?g/10:g,_,M);if(d(E),!l)continue;i.setupElevationDraw(r,l,A);const C=c.toUnwrapped();u&&u.setupShadows(C,l),t.uploadCommonUniforms(o,l,C,null,h),l.draw(t,y,f,b,p,Jn.backCCW,I,"terrain_raster",i.gridBuffer,v,x)}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,s=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const u of s){const s=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?r.renderCache[h]:this.pool[c++],p=void 0!==h;if(s.texture=d.tex,s.emissiveTexture=d.emissiveTex,p&&!d.dirty){l.push(s.tileID);continue}n.bindFramebuffer.set(d.fb.framebuffer);const f=n.gl;let m;f.drawBuffers("mrt-fallback"===i.emissiveMode?[f.COLOR_ATTACHMENT0,f.COLOR_ATTACHMENT1]:[f.COLOR_ATTACHMENT0]),this.renderedToTile=!1,d.dirty&&(n.clear({color:e.C.transparent,stencil:0}),d.dirty=!1);for(let e=o.start;e<=o.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[u.key][r.id]:[u];if(!s)continue;const o=s;n.viewport.set([0,0,d.fb.width,d.fb.height]),m!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),m=r?r.id:null),i.renderLayer(i,r,t,o)}if(f.drawBuffers([f.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[u.key][r.id]:[u];if(!s)continue;const o=s;n.viewport.set([0,0,d.fb.width,d.fb.height]),m!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),m=r?r.id:null),i.renderLayer(i,r,t,o)}this.renderedToTile?(d.dirty=!0,l.push(s.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,n=t;for(let r=0;r<t;++r)this._style.isLayerDraped(e._mergedLayers[e.order[r]])?i=Math.max(i,r):n=Math.min(n,r);return n>i}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const n=this._visibleDemTiles.filter(e=>e.dem).map(n=>{const r=n.tileID,s=1<<r.overscaledZ,{x:o,y:a}=r.canonical,l=o/s,c=(o+1)/s,u=a/s,h=(a+1)/s;return{minx:l,miny:u,maxx:c,maxy:h,t:n.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:n}});n.sort((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:n[0],height:n[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const s=t.createFramebuffer(n[0],n[1],1,null);let o;return s.colorAttachment0.set(r.texture),this._emissiveTexture&&(o=new e.T(t,{width:n[0],height:n[1],data:null},i.R8),o.bind(i.LINEAR,i.CLAMP_TO_EDGE),s.createColorAttachment(t,1),s.colorAttachment1.set(o.texture)),s.depthAttachment=new Ks(t,s.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,s.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):s.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:s,tex:r,emissiveTex:o,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e}}_updateFBO(t,i){const n=t.fb,r=this.painter.context,s=r.gl,o=this.drapeBufferSize;if(i){const i=new e.T(r,{width:o[0],height:o[1],data:null},s.R8);i.bind(s.LINEAR,s.CLAMP_TO_EDGE),t.emissiveTex=i,n.createColorAttachment(r,1),n.colorAttachment1.set(i.texture)}else t.emissiveTex=void 0,n.removeColorAttachment(r,1);t.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return!0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return!0;return this._style.order.some(e=>{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof _i){t=!0;break}if(!t)return;const i={};for(let t=0;t<this._style.order.length;++t){const n=this._style._mergedLayers[this._style.order[t]],r=this._style.getLayerSourceCache(n);if(!r||i[r.id])continue;if(n.isHidden(this.painter.transform.zoom)||"line"!==n.type)continue;const s=n.widthExpression(),o=n.emissiveStrengthExpression();if(s instanceof e.ac||o instanceof e.ac){i[r.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t)this._clearRenderCacheForTile(r.id,e)}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof yi){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],n=this._style.getLayerSourceCache(i);if(!n||t[n.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const r=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][n.id];if(t)for(const e of t){const t=ao(n.getTile(e),n.findLoadedParent(e,0),n,this.painter.transform,r);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(n.id,e)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const t=this._style.order,i=t.length;if(0===i)return;const n=[];this._pendingGroundEffectLayers=[];let r,s=0,o=this._style._mergedLayers[t[s]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++s<i;)o=this._style._mergedLayers[t[s]];for(;s<i;++s){const e=this._style._mergedLayers[t[s]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===r&&(r=s):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(s),void 0!==r&&(n.push({start:r,end:s-1}),r=void 0)))}if(void 0!==r&&n.push({start:r,end:s-1}),0!==n.length){const t=n.at(-1);this._pendingGroundEffectLayers.every(e=>e>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=n}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const n=Object.values(e[i]);t.renderCachePool.push(...n)}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,n=this._tilesDirty;for(let r=i.length-1;r>=0;r--){const s=i[r];if(t.getTileByID(s.key),void 0!==t.proxyCachedFBO[s.key]){const i=e[s.key],r=this.proxyToSource[s.key];let o=0;for(const e in r){const t=r[e],s=i[e];if(!s||s.length!==t.length||t.some((t,i)=>t!==s[i]||n[e]&&Object.hasOwn(n[e],t.key))){o=-1;break}++o}for(const e in t.proxyCachedFBO[s.key])t.renderCache[t.proxyCachedFBO[s.key][e]].dirty=o<0||o!==Object.values(i).length}}const r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const n of i){if(t.proxyCachedFBO[n.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,s=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let o;if(i.isTileClipped())o=t.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t.at(-1).overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):$n.disabled}_renderTileClippingMasks(e,t){const i=this.painter,n=this.painter.context,r=n.gl;i._tileClippingMaskIDs={},n.setColorMode(Wn.disabled),n.setDepthMode(qn.disabled);const s=i.getOrCreateProgram("clippingMask");for(const n of e){const e=i._tileClippingMaskIDs[n.key]=--t;s.draw(i,r.TRIANGLES,qn.disabled,new $n({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Wn.disabled,Jn.disabled,oo(n.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const n=[t.x,t.y,1,1];e.aD(n,n,i.pixelMatrixInverse),e.cw(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,s=e.bY(1,i.center.lat),o=[r[0],r[1],r[2]/s,0],a=e.cZ([],n.slice(0,3),o);e.ax(a,a);const l=this.raycast(o,a,this._exaggeration);return null!==l&&l?(e.bi(o,o,a,l),o[3]=o[2],o[2]*=s,o):null}_setupProxiedCoordsForOrtho(t,i,n){if(t.getSource()instanceof e.aY)return this._setupProxiedCoordsForImageSource(t,i,n);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords;for(let e=0;e<s.length;e++){const i=s[e],o=this._findTileCoveringTileID(i,t);if(o){const e=this._createProxiedId(i,o,n[i.key]&&n[i.key][t.id]);r.push(e),this.proxyToSource[i.key][t.id]=[e]}}let o=!1;const a=new Set;for(let e=0;e<i.length;e++){const s=t.getTile(i[e]);if(!s||!s.hasData())continue;const l=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==s.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],i=this._createProxiedId(l.tileID,s,n[l.tileID.key]&&n[l.tileID.key][t.id]);e?e.splice(e.length-1,0,i):this.proxyToSource[l.tileID.key][t.id]=[i];const c=this.proxyToSource[l.tileID.key][t.id];a.has(c)||a.add(c),r.push(i),o=!0}}if(this._sourceTilesOverlap[t.id]=o,o)for(const e of a)e.sort((e,t)=>t.overscaledZ-e.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,n){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords,o=t.getSource(),a=o.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=o.coordinates.map(e.ad.fromLngLat).reduce((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,i)=>{const n=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),s=e.ak/(1<<t.canonical.z),o=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return n+s<o+c.min.x||n>o+c.max.x||r+s<a+c.min.y||r>a+c.max.y};for(let e=0;e<s.length;e++){const o=s[e];for(let e=0;e<i.length;e++){const s=t.getTile(i[e]);if(!s||!s.hasData())continue;if(u(o,s.tileID))continue;const a=this._createProxiedId(o,s,n[o.key]&&n[o.key][t.id]),l=this.proxyToSource[o.key][t.id];l?l.push(a):this.proxyToSource[o.key][t.id]=[a],r.push(a)}}}_createProxiedId(t,i,n){let r=this.orthoMatrix;if(n){const e=n.find(e=>e.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let s,o,a;r=e.bd();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;n>0?(s=e.ak>>n,o=s*((i.tileID.canonical.x<<n)-t.canonical.x+l),a=s*((i.tileID.canonical.y<<n)-t.canonical.y)):(s=e.ak<<-n,o=e.ak*(i.tileID.canonical.x-(t.canonical.x+l<<-n)),a=e.ak*(i.tileID.canonical.y-(t.canonical.y<<-n))),e.bX(r,0,s,0,s,0,1),e.bB(r,r,[o,a,0])}return new uo(i.tileID,t.key,r)}_findTileCoveringTileID(t,i){let n=i.getTile(t);if(n&&n.hasData())return n;const r=this._findCoveringTileCache[i.id],s=r[t.key];if(n=s?i.getTileByID(s):null,n&&n.hasData()||null===s)return n;let o=n?n.tileID:t,a=o.overscaledZ;const l=i.getSource().minzoom,c=[];if(!s){const r=i.getSource().maxzoom;if(t.canonical.z>=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),o=new e.aU(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,o=new e.aU(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}o.key!==t.key&&(c.push(o.key),n=i.getTile(o))}const u=e=>{c.forEach(t=>{r[t]=e}),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=o.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}}function po(t,i,n){const r=function(t,i,n){const r=e.bk(i,t),s=e.bk(n,[.2126,.7152,.0722]),o=(e,t,i)=>(1-i)*e+i*t,a=o(1-.3*Math.min(s,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(e.aB(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),s=[0,0,0];e.bN(s,n.slice(0,3),r);const o=[0,0,0];e.bN(o,i.slice(0,3),t[2]);const a=[0,0,0];return e.cX(a,s,o),e.c_(a)}const fo=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],mo=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class go{static cacheKey(e,t,i,n){const r=[t];n&&r.push(n.cacheKey);for(const t of i)("string"==typeof t&&t.includes(" ")||e.usedDefines.has(t))&&r.push(t);return r.join("/")}constructor(e,t,i,n,r,s,o=!1){const a=e.gl;this.program=a.createProgram(),this._context=e,this._fixedUniformsFn=r,this._pending=!0,this._precompiled=o,this.attributes={},this.configuration=n,this.name=t,this.fixedDefines=[...s],o?e._compileStats.precompiled++:e._compileStats.onDemand++;const l=`#version 300 es\n${(n?n.defines():[]).concat(s.map(e=>`#define ${e}`)).join("\n")}`,c=[l,ss];for(const e of i.fragmentIncludes)c.push(Qr[e]);c.push(i.fragmentSource);const u=c.join("\n"),h=[l,os];for(const e of i.vertexIncludes)h.push(Qr[e]);this.forceManualRenderingForInstanceIDShaders=e.forceManualRenderingForInstanceIDShaders&&i.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&h.push("uniform int u_instanceID;"),h.push(i.vertexSource);let d=h.join("\n");this.forceManualRenderingForInstanceIDShaders&&(d=d.replaceAll("gl_InstanceID","u_instanceID"));const p=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(p,u),a.compileShader(p),a.attachShader(this.program,p);const f=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f),a.linkProgram(this.program),this._fragmentShader=p,this._vertexShader=f,e.extParallelShaderCompile?e._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;const t=this._context,i=t.gl;t._pendingPrograms.delete(this);const n=e.o.now(),r=i.getProgramParameter(this.program,i.LINK_STATUS),s=e.o.now()-n,o=t._compileStats;if(o.totalStallMs+=s,s>o.maxStallMs&&(o.maxStallMs=s),s>1){o.framesMissed+=Math.floor(60*s/1e3);const e=this.fixedDefines.join(",");o.stalls.push({name:`${this.name}${e?"/":""}${e}`,ms:s,timestamp:n})}if(this._fragmentShader&&(r||e.w(`Fragment shader '${this.name}': ${i.getShaderInfoLog(this._fragmentShader)}`),i.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(r||e.w(`Vertex shader '${this.name}': ${i.getShaderInfoLog(this._vertexShader)}`),i.deleteShader(this._vertexShader),this._vertexShader=null),!r)return e.w(`Failed to link program '${this.name}': ${i.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.b$(t)}))(t));const a=this.fixedDefines,l=this.name;(a.includes("TERRAIN")||a.includes("ELEVATED")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.b$(t),u_dem_prev:new e.b$(t),u_dem_tl:new e.c2(t),u_dem_scale:new e.c1(t),u_dem_tl_prev:new e.c2(t),u_dem_scale_prev:new e.c1(t),u_dem_size:new e.c1(t),u_dem_lerp:new e.c1(t),u_exaggeration:new e.c1(t),u_depth:new e.b$(t),u_depth_size_inv:new e.c2(t),u_depth_range_unpack:new e.c2(t),u_occluder_half_size:new e.c1(t),u_occlusion_depth_offset:new e.c1(t),u_meter_to_dem:new e.c1(t),u_label_plane_matrix_inv:new e.c3(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.c0(t),u_tile_tr_up:new e.c0(t),u_tile_br_up:new e.c0(t),u_tile_bl_up:new e.c0(t),u_tile_up_scale:new e.c1(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.c3(t),u_fog_range:new e.c2(t),u_fog_color:new e.cS(t),u_fog_horizon_blend:new e.c1(t),u_fog_vertical_limit:new e.c2(t),u_fog_temporal_offset:new e.c1(t),u_frustum_tl:new e.c0(t),u_frustum_tr:new e.c0(t),u_frustum_br:new e.c0(t),u_frustum_bl:new e.c0(t),u_globe_pos:new e.c0(t),u_globe_radius:new e.c1(t),u_globe_transition:new e.c1(t),u_is_globe:new e.b$(t),u_viewport:new e.c2(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.cS(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.c0(t),u_lighting_directional_dir:new e.c0(t),u_lighting_directional_color:new e.c0(t),u_ground_radiance:new e.c0(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.c3(t),u_light_matrix_1:new e.c3(t),u_fade_range:new e.c2(t),u_shadow_normal_offset:new e.c0(t),u_shadow_intensity:new e.c1(t),u_shadow_texel_size:new e.c1(t),u_shadow_map_resolution:new e.c1(t),u_shadow_direction:new e.c0(t),u_shadow_bias:new e.c0(t),u_shadowmap_0:new e.b$(t),u_shadowmap_1:new e.b$(t)}))(t))}maybeFinalize(){if(!this._pending)return;const e=this._context.extParallelShaderCompile;e&&!this._context.gl.getProgramParameter(this.program,e.COMPLETION_STATUS_KHR)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(e,t){this._ensureReady();let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(this._ensureReady(),!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(this._ensureReady(),!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(this._ensureReady(),!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(this._ensureReady(),!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(this._ensureReady(),!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}_drawDebugWireframe(t,i,n,r,s,o,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!fo.includes(this.name))||!(!h.layers3D||!mo.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,s,d);if(!f)return;const m=[...this.fixedDefines,"DEBUG_WIREFRAME"],g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});g._ensureReady(),d.program.set(g.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const n in t[e])i[e][n]&&i[e][n].set(i.program,n,t[e][n].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,a,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),f.bind(),d.setColorMode(new Wn([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.C.transparent,[!0,!0,!0,!1])),d.setDepthMode(new qn(i.func===p.LESS?p.LEQUAL:i.func,qn.ReadOnly,i.range)),d.setStencilMode($n.disabled);const y=3*o.primitiveLength*2,v=3*o.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=u||1;for(let t=0;t<e;++t)g.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",t),p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,v)}else u&&u>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,v,u):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,v);s.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(n),d.setColorMode(r)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const n of Object.keys(i))if(!i[n].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${n} not set but required by ${t} being defined`)}draw(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){const g=e.context,_=g.gl;if(this._ensureReady(),this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(n),g.setColorMode(r),g.setCullFace(s);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,o[e]);p&&p.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const y={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const v=f||[],x=p?p.getPaintVertexBuffers():[],b=t===_.TRIANGLES&&c,w=m&&m>0?1:void 0;for(const s of u.get()){const o=s.vaos||(s.vaos={});if((o[a]||(o[a]=new hs)).bind(g,this,l,x,c,s.vertexOffset,v,w),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i<e;++i)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),c?_.drawElements(t,s.primitiveLength*y,_.UNSIGNED_SHORT,s.primitiveOffset*y*2):_.drawArrays(t,s.vertexOffset,s.vertexLength)}else m&&m>1?_.drawElementsInstanced(t,s.primitiveLength*y,_.UNSIGNED_SHORT,s.primitiveOffset*y*2,m):c?_.drawElements(t,s.primitiveLength*y,_.UNSIGNED_SHORT,s.primitiveOffset*y*2):_.drawArrays(t,s.vertexOffset,s.vertexLength);b&&this._drawDebugWireframe(e,i,n,r,c,s,h,d,p,m)}}}function _o(t,i,n=0){const r=Math.pow(2,i.tileID.overscaledZ),s=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,o=s*(i.tileID.canonical.x+i.tileID.wrap*r),a=s*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.az(i,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a],u_pattern_transition:n}}const yo={terrain:0,flat:1},vo=e.bd(),xo=(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v=[0,0,1])=>{const x=i.style.light,b=x.properties.get("position"),w=[b.x,b.y,b.z],T=e.dH();"viewport"===x.properties.get("anchor")&&(e.dI(T,-i.transform.angle),e.dJ(w,w,T));const S=x.properties.get("color").toPremultipliedRenderColor(null),E=i.transform,A={u_matrix:t,u_lightpos:w,u_lightintensity:x.properties.get("intensity"),u_lightcolor:[S.r,S.g,S.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:vo,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:yo[u],u_base_type:yo[h],u_ao:s,u_edge_radius:o,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:_,u_ground_shadow_factor:y,u_front_cutoff_params:v};return"globe"===E.projection.name&&(A.u_tile_id=[l.canonical.x,l.canonical.y,1<<l.canonical.z],A.u_zoom_transition=d,A.u_inv_rot_matrix=f,A.u_merc_center=p,A.u_up_dir=E.projection.upVector(new e.cp(0,0,0),p[0]*e.ak,p[1]*e.ak),A.u_height_lift=c),A},bo=(e,t,i,n,r,s)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:n,u_height_type:yo[r],u_base_type:yo[s]}),wo=(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_)=>{const y=xo(e,t,i,n,r,s,o,a,c,u,h,d,p,f,m,g,1,[0,0,0]),v={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(y,_o(t,l,_),v)},To=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),So=(e,t,i,n,r,s=0)=>Object.assign(To(e,t,r),_o(i,n,s)),Eo=(e,t,i,n)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:n}),Ao=(e,t,i,n,r,s,o=0)=>Object.assign(So(e,t,i,n,s,o),{u_world:r}),Mo=(e,t)=>({u_matrix:e,u_depth_bias:t}),Io=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),Co=(e,t,i,n,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:n,u_reset_depth:r}),Po=(e,t,i)=>({u_image:e,u_texel_size:t,u_first_pass:i?1:0}),Lo=(t,i,n,r,s,o,a,l)=>{const c=e.ak/o.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:n.getCameraToCenterDistance(l),u_extrude_scale:[n.pixelsToGLUnits[0]/c,n.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:s}},Ro=(e,t,i,n)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(n),u_viewport_size:[i.width,i.height]}),Oo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Do=e.bd(),Bo=(t,i,n,r,s,o,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.dK(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.az(n,1,o),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Do,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=r,h.u_merc_center=s,h.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],h.u_zoom_transition=e.ai(l.zoom);const t=s[0]*e.ak,n=s[1]*e.ak;h.u_up_dir=l.projection.upVector(new e.cp(0,0,0),t,n)}return h};function Fo(e,[t,i,n,r],[s,o]){if(s===o)return[0,0,0,0];const a=255*(e-1)/(e*(o-s));return[t*a,i*a,n*a,r*a]}function No(e,t,[i,n]){return i===n?0:.5/e+(t-i)*(e-1)/(e*(n-i))}function ko(t){const i=t.terrain?t.terrain.exaggeration():1;var n;return(t.transform.pitch<15?.07*(1-(n=e.aB((14-t.transform.zoom)/5,0,1)))+.7*n:.07)*i}const zo=(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w)=>({u_matrix:i,u_normalize_matrix:n,u_globe_matrix:r,u_merc_matrix:s,u_grid_matrix:o,u_tl_parent:a,u_scale_parent:h,u_fade_t:d.mix,u_opacity:d.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:e.dM(p.paint.get("raster-saturation")),u_contrast_factor:e.dL(p.paint.get("raster-contrast")),u_spin_weights:Uo(p.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:m,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:u,u_colorization_mix:Fo(e.dN,_,v),u_colorization_offset:No(e.dN,y,v),u_color_ramp:g,u_texture_offset:[b/(x+2*b),x/(x+2*b)],u_texture_res:[x+2*b,x+2*b],u_emissive_strength:w,u_zbias_factor:ko(t)});function Uo(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Vo=e.bd(),jo=(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S)=>{const E=s.transform,A={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:E.getCameraToCenterDistance(v),u_rotate_symbol:+n,u_aspect_ratio:E.width/E.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:h,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Vo,u_up_vector:[0,-1,0],u_color_adj_mat:w,u_icon_transition:T||0,u_gamma_scale:r?s.transform.getCameraToCenterDistance(v)*Math.cos(s.terrain?0:s.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:S||1,u_ground_shadow_factor:x,u_inv_matrix:e.ba(e.bd(),a),u_normal_scale:b,u_lutTexture:10,u_zoom:E.zoom-Math.floor(E.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return"globe"===v.name&&(A.u_tile_id=[f.canonical.x,f.canonical.y,1<<f.canonical.z],A.u_zoom_transition=m,A.u_inv_rot_matrix=_,A.u_merc_center=g,A.u_camera_forward=E._camera.forward(),A.u_ecef_origin=e.dO(E.globeMatrix,f.toUnwrapped()),A.u_tile_matrix=E.globeMatrix,A.u_up_vector=y),A},Go=(e,t,i,n)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:n}),Ho=(t,i,n,r,s,o,a,l,c)=>Object.assign(function(t,i,n,r,s,o){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,o.tileID.overscaledZ),u=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(o.tileID.canonical.x+o.tileID.wrap*c),d=u*o.tileID.canonical.y;return{u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[a,l],u_pattern_size:n.displaySize,u_pattern_units_to_pixels:s?[r.transform.width,-1*r.transform.height]:[1/e.az(o,1,r.transform.tileZoom),1/e.az(o,1,r.transform.tileZoom)],u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(0,o,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:n}),Wo=new Float32Array(e.bA([])),qo=(t,i,n,r,s,o,a,l,c,u,h,d,p,f=[0,0,0],m,g,_,y=1)=>{const v=s.style.light,x=v.properties.get("position"),b=[-x.x,-x.y,x.z],w=e.dH();"viewport"===v.properties.get("anchor")&&(e.dI(w,-s.transform.angle),e.dJ(b,b,w));const T="MASK"===h.alphaMode,S=v.properties.get("color").toNonPremultipliedRenderColor(null),E=p.paint.get("model-ambient-occlusion-intensity"),A=p.paint.get("model-color").constantOr(e.C.white).toNonPremultipliedRenderColor(null);return A.a=p.paint.get("model-color-mix-intensity").constantOr(0),_&&(A.r=_[0],A.g=_[1],A.b=_[2],A.a=_[3]),g&&(A.r=g.color.r,A.g=g.color.g,A.b=g.color.b,A.a=g.colorMix,d=g.emissionStrength,o*=g.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:n,u_node_matrix:r||Wo,u_lightpos:b,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[S.r,S.g,S.b],u_camera_pos:f,u_opacity:o,u_baseTextureIsAlpha:0,u_alphaMask:+T,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:A.toArray01(),u_aoIntensity:E,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0],u_dithered_discard_threshold:y}},Xo=(e,t=Wo,i=Wo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),$o={fillExtrusion:t=>({u_matrix:new e.c3(t),u_lightpos:new e.c0(t),u_lightintensity:new e.c1(t),u_lightcolor:new e.c0(t),u_vertical_gradient:new e.c1(t),u_opacity:new e.c1(t),u_edge_radius:new e.c1(t),u_width_scale:new e.c1(t),u_ao:new e.c2(t),u_height_type:new e.b$(t),u_base_type:new e.b$(t),u_tile_id:new e.c0(t),u_zoom_transition:new e.c1(t),u_inv_rot_matrix:new e.c3(t),u_merc_center:new e.c2(t),u_up_dir:new e.c0(t),u_height_lift:new e.c1(t),u_flood_light_color:new e.c0(t),u_vertical_scale:new e.c1(t),u_flood_light_intensity:new e.c1(t),u_ground_shadow_factor:new e.c0(t),u_front_cutoff_params:new e.c0(t)}),fillExtrusionDepth:t=>({u_matrix:new e.c3(t),u_edge_radius:new e.c1(t),u_width_scale:new e.c1(t),u_vertical_scale:new e.c1(t),u_height_type:new e.b$(t),u_base_type:new e.b$(t)}),fillExtrusionPattern:t=>({u_matrix:new e.c3(t),u_lightpos:new e.c0(t),u_lightintensity:new e.c1(t),u_lightcolor:new e.c0(t),u_vertical_gradient:new e.c1(t),u_height_factor:new e.c1(t),u_edge_radius:new e.c1(t),u_width_scale:new e.c1(t),u_ao:new e.c2(t),u_height_type:new e.b$(t),u_base_type:new e.b$(t),u_tile_id:new e.c0(t),u_zoom_transition:new e.c1(t),u_inv_rot_matrix:new e.c3(t),u_merc_center:new e.c2(t),u_up_dir:new e.c0(t),u_height_lift:new e.c1(t),u_image:new e.b$(t),u_texsize:new e.c2(t),u_pixel_coord_upper:new e.c2(t),u_pixel_coord_lower:new e.c2(t),u_tile_units_to_pixels:new e.c1(t),u_opacity:new e.c1(t),u_pattern_transition:new e.c1(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.c3(t),u_opacity:new e.c1(t),u_ao_pass:new e.c1(t),u_meter_to_tile:new e.c1(t),u_ao:new e.c2(t),u_flood_light_intensity:new e.c1(t),u_flood_light_color:new e.c0(t),u_attenuation:new e.c1(t),u_edge_radius:new e.c1(t),u_fb:new e.b$(t),u_fb_size:new e.c1(t),u_dynamic_offset:new e.c1(t)}),fill:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_ground_shadow_factor:new e.c0(t)}),fillPattern:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_image:new e.b$(t),u_texsize:new e.c2(t),u_pixel_coord_upper:new e.c2(t),u_pixel_coord_lower:new e.c2(t),u_tile_units_to_pixels:new e.c1(t),u_ground_shadow_factor:new e.c0(t),u_pattern_transition:new e.c1(t)}),fillOutline:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_world:new e.c2(t),u_ground_shadow_factor:new e.c0(t)}),fillOutlinePattern:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_world:new e.c2(t),u_image:new e.b$(t),u_texsize:new e.c2(t),u_pixel_coord_upper:new e.c2(t),u_pixel_coord_lower:new e.c2(t),u_tile_units_to_pixels:new e.c1(t),u_ground_shadow_factor:new e.c0(t),u_pattern_transition:new e.c1(t)}),lineBlendComposite:t=>({u_image:new e.b$(t),u_opacity:new e.c1(t),u_blend_mode:new e.b$(t),u_max_density:new e.c1(t)}),lineBlendReduce:t=>({u_image:new e.b$(t),u_texel_size:new e.c2(t),u_first_pass:new e.b$(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.c3(t),u_depth_bias:new e.c1(t)}),elevatedStructures:t=>({u_matrix:new e.c3(t),u_ground_shadow_factor:new e.c0(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.c3(t),u_camera_pos:new e.c0(t),u_depth_bias:new e.c1(t),u_height_scale:new e.c1(t),u_reset_depth:new e.c1(t)}),circle:e.dR,collisionBox:t=>({u_matrix:new e.c3(t),u_inv_rot_matrix:new e.c3(t),u_camera_to_center_distance:new e.c1(t),u_extrude_scale:new e.c2(t),u_zoom_transition:new e.c1(t),u_merc_center:new e.c2(t),u_tile_id:new e.c0(t)}),collisionCircle:t=>({u_matrix:new e.c3(t),u_inv_matrix:new e.c3(t),u_camera_to_center_distance:new e.c1(t),u_viewport_size:new e.c2(t)}),debug:t=>({u_color:new e.dp(t),u_matrix:new e.c3(t),u_overlay:new e.b$(t),u_overlay_scale:new e.c1(t)}),clippingMask:t=>({u_matrix:new e.c3(t)}),heatmap:t=>({u_extrude_scale:new e.c1(t),u_intensity:new e.c1(t),u_matrix:new e.c3(t),u_inv_rot_matrix:new e.c3(t),u_merc_center:new e.c2(t),u_tile_id:new e.c0(t),u_zoom_transition:new e.c1(t),u_up_dir:new e.c0(t)}),heatmapTexture:t=>({u_image:new e.b$(t),u_color_ramp:new e.b$(t),u_opacity:new e.c1(t)}),hillshade:t=>({u_matrix:new e.c3(t),u_image:new e.b$(t),u_latrange:new e.c2(t),u_light:new e.c2(t),u_shadow:new e.dp(t),u_highlight:new e.dp(t),u_emissive_strength:new e.c1(t),u_accent:new e.dp(t)}),hillshadePrepare:t=>({u_matrix:new e.c3(t),u_image:new e.b$(t),u_dimension:new e.c2(t),u_zoom:new e.c1(t)}),line:e.dQ,linePattern:e.dP,raster:t=>({u_matrix:new e.c3(t),u_normalize_matrix:new e.c3(t),u_globe_matrix:new e.c3(t),u_merc_matrix:new e.c3(t),u_grid_matrix:new e.dq(t),u_tl_parent:new e.c2(t),u_scale_parent:new e.c1(t),u_fade_t:new e.c1(t),u_opacity:new e.c1(t),u_image0:new e.b$(t),u_image1:new e.b$(t),u_brightness_low:new e.c1(t),u_brightness_high:new e.c1(t),u_saturation_factor:new e.c1(t),u_contrast_factor:new e.c1(t),u_spin_weights:new e.c0(t),u_perspective_transform:new e.c2(t),u_raster_elevation:new e.c1(t),u_zoom_transition:new e.c1(t),u_merc_center:new e.c2(t),u_cutoff_params:new e.cS(t),u_colorization_mix:new e.cS(t),u_colorization_offset:new e.c1(t),u_color_ramp:new e.b$(t),u_texture_offset:new e.c2(t),u_texture_res:new e.c2(t),u_emissive_strength:new e.c1(t),u_zbias_factor:new e.c1(t)}),symbol:t=>({u_is_size_zoom_constant:new e.b$(t),u_is_size_feature_constant:new e.b$(t),u_size_t:new e.c1(t),u_size:new e.c1(t),u_camera_to_center_distance:new e.c1(t),u_rotate_symbol:new e.b$(t),u_aspect_ratio:new e.c1(t),u_fade_change:new e.c1(t),u_matrix:new e.c3(t),u_label_plane_matrix:new e.c3(t),u_coord_matrix:new e.c3(t),u_is_text:new e.b$(t),u_elevation_from_sea:new e.b$(t),u_pitch_with_map:new e.b$(t),u_texsize:new e.c2(t),u_texsize_icon:new e.c2(t),u_texture:new e.b$(t),u_texture_icon:new e.b$(t),u_gamma_scale:new e.c1(t),u_device_pixel_ratio:new e.c1(t),u_tile_id:new e.c0(t),u_zoom_transition:new e.c1(t),u_inv_rot_matrix:new e.c3(t),u_merc_center:new e.c2(t),u_camera_forward:new e.c0(t),u_tile_matrix:new e.c3(t),u_up_vector:new e.c0(t),u_ecef_origin:new e.c0(t),u_is_halo:new e.b$(t),u_icon_transition:new e.c1(t),u_color_adj_mat:new e.c3(t),u_scale_factor:new e.c1(t),u_ground_shadow_factor:new e.c0(t),u_inv_matrix:new e.c3(t),u_normal_scale:new e.c1(t),u_lutTexture:new e.b$(t),u_zoom:new e.c1(t),u_spp_fill_np_color:new e.cS(t),u_spp_halo_np_color:new e.cS(t),u_spp_opacity:new e.c1(t),u_spp_halo_width:new e.c1(t),u_spp_halo_blur:new e.c1(t),u_spp_emissive_strength:new e.c1(t),u_spp_occlusion_opacity:new e.c1(t),u_spp_z_offset:new e.c1(t),u_spp_translate_rotation:new e.c2(t)}),background:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_opacity:new e.c1(t),u_color:new e.dp(t)}),backgroundPattern:t=>({u_matrix:new e.c3(t),u_emissive_strength:new e.c1(t),u_opacity:new e.c1(t),u_image:new e.b$(t),u_pattern_tl:new e.c2(t),u_pattern_br:new e.c2(t),u_texsize:new e.c2(t),u_pattern_size:new e.c2(t),u_pixel_coord_upper:new e.c2(t),u_pixel_coord_lower:new e.c2(t),u_pattern_units_to_pixels:new e.c2(t)}),terrainRaster:t=>({u_matrix:new e.c3(t),u_image0:new e.b$(t),u_image1:new e.b$(t),u_skirt_height:new e.c1(t),u_ground_shadow_factor:new e.c0(t),u_emissive_texture_available:new e.c1(t)}),skybox:t=>({u_matrix:new e.c3(t),u_sun_direction:new e.c0(t),u_cubemap:new e.b$(t),u_opacity:new e.c1(t),u_temporal_offset:new e.c1(t)}),skyboxGradient:t=>({u_matrix:new e.c3(t),u_color_ramp:new e.b$(t),u_center_direction:new e.c0(t),u_radius:new e.c1(t),u_opacity:new e.c1(t),u_temporal_offset:new e.c1(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dq(t),u_sun_direction:new e.c0(t),u_sun_intensity:new e.c1(t),u_color_tint_r:new e.cS(t),u_color_tint_m:new e.cS(t),u_luminance:new e.c1(t)}),globeRaster:t=>({u_proj_matrix:new e.c3(t),u_globe_matrix:new e.c3(t),u_normalize_matrix:new e.c3(t),u_merc_matrix:new e.c3(t),u_zoom_transition:new e.c1(t),u_merc_center:new e.c2(t),u_image0:new e.b$(t),u_image1:new e.b$(t),u_grid_matrix:new e.dq(t),u_skirt_height:new e.c1(t),u_far_z_cutoff:new e.c1(t),u_frustum_tl:new e.c0(t),u_frustum_tr:new e.c0(t),u_frustum_br:new e.c0(t),u_frustum_bl:new e.c0(t),u_globe_pos:new e.c0(t),u_globe_radius:new e.c1(t),u_viewport:new e.c2(t),u_emissive_texture_available:new e.c1(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.c0(t),u_frustum_tr:new e.c0(t),u_frustum_br:new e.c0(t),u_frustum_bl:new e.c0(t),u_horizon:new e.c1(t),u_transition:new e.c1(t),u_fadeout_range:new e.c1(t),u_atmosphere_fog_color:new e.cS(t),u_high_color:new e.cS(t),u_space_color:new e.cS(t),u_temporal_offset:new e.c1(t),u_horizon_angle:new e.c1(t)}),model:t=>({u_matrix:new e.c3(t),u_lighting_matrix:new e.c3(t),u_normal_matrix:new e.c3(t),u_node_matrix:new e.c3(t),u_lightpos:new e.c0(t),u_lightintensity:new e.c1(t),u_lightcolor:new e.c0(t),u_camera_pos:new e.c0(t),u_opacity:new e.c1(t),u_baseColorFactor:new e.cS(t),u_emissiveFactor:new e.cS(t),u_metallicFactor:new e.c1(t),u_roughnessFactor:new e.c1(t),u_baseTextureIsAlpha:new e.b$(t),u_alphaMask:new e.b$(t),u_alphaCutoff:new e.c1(t),u_baseColorTexture:new e.b$(t),u_metallicRoughnessTexture:new e.b$(t),u_normalTexture:new e.b$(t),u_occlusionTexture:new e.b$(t),u_emissionTexture:new e.b$(t),u_lutTexture:new e.b$(t),u_color_mix:new e.cS(t),u_aoIntensity:new e.c1(t),u_emissive_strength:new e.c1(t),u_occlusionTextureTransform:new e.cS(t),u_dithered_discard_threshold:new e.c1(t)}),modelDepth:t=>({u_matrix:new e.c3(t),u_instance:new e.c3(t),u_node_matrix:new e.c3(t)}),groundShadow:t=>({u_matrix:new e.c3(t),u_ground_shadow_factor:new e.c0(t)}),stars:t=>({u_matrix:new e.c3(t),u_up:new e.c0(t),u_right:new e.c0(t),u_intensity_multiplier:new e.c1(t)}),occlusion:t=>({u_matrix:new e.c3(t),u_anchorPos:new e.c0(t),u_screenSizePx:new e.c2(t),u_occluderSizePx:new e.c2(t),u_color:new e.cS(t)})};class Zo{constructor(e,t,i,n){this.id=Zo.uniqueIdxCounter,Zo.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=Zo.uniqueIdxCounter,Zo.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Zo.uniqueIdxCounter=0;const Yo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Jo{constructor(e,t,i,n,r,s){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.instanceCount=s,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(const i of this.attributes){const n=t.getAttributeLocation(e,i.name);-1!==n&&e.enableVertexAttribArray(n)}}setVertexAttribPointers(e,t,i){for(const n of this.attributes){const r=t.getAttributeLocation(e,n.name);if(-1!==r){const t=n.offset+this.itemSize*(i||0);"Float32"===n.type?e.vertexAttribPointer(r,n.components,e.FLOAT,!1,this.itemSize,t):e.vertexAttribIPointer(r,n.components,e[Yo[n.type]],this.itemSize,t)}}}setVertexAttribDivisor(e,t,i){for(let n=0;n<this.attributes.length;n++){const r=t.getAttributeLocation(e,this.attributes[n].name);-1!==r&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(r,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ko{constructor(e,t,i,n,r){this.context=e,this.width=t,this.height=i;const s=this.framebuffer=e.gl.createFramebuffer();n>0&&(this.colorAttachment0=new Zs(e,s,0)),n>1&&(this.colorAttachment1=new Zs(e,s,1)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new Ys(e,s):new Js(e,s))}static createWithTexture(t,i,n,r,s){const o=t.gl;if(t.activeTexture.set(o.TEXTURE1),t.viewport.set([0,0,n,r]),i&&i.width===n&&i.height===r)return o.bindTexture(o.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();const a=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,l=new e.T(t,{width:n,height:r,data:null},a);l.bind(o.LINEAR,o.CLAMP_TO_EDGE);const c=t.createFramebuffer(n,r,1,null);if(c.format=a,c.colorAttachment0.set(l.texture),s){const e=t.createRenderbuffer(o.DEPTH24_STENCIL8,n,r);t.bindFramebuffer.set(c.framebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,e),c._stencilRbo=e}return c}createColorAttachment(e,t){0===t?this.colorAttachment0=new Zs(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new Zs(e,this.framebuffer,1))}removeColorAttachment(e,t){const i=this.context.gl;let n;0===t?(n=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(n=this.colorAttachment1.get(),this.colorAttachment1=void 0),n&&i.deleteTexture(n)}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t)}if(this.colorAttachment1){const t=this.colorAttachment1.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}this._stencilRbo&&(e.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),e.deleteFramebuffer(this.framebuffer)}}class Qo{constructor(e,t){this.gl=e,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new _s(this),this.clearDepth=new ys(this),this.clearStencil=new vs(this),this.colorMask=new xs(this),this.depthMask=new bs(this),this.stencilMask=new ws(this),this.stencilFunc=new Ts(this),this.stencilOp=new Ss(this),this.stencilTest=new Es(this),this.depthRange=new As(this),this.depthTest=new Ms(this),this.depthFunc=new Is(this),this.blend=new Cs(this),this.blendFunc=new Ps(this),this.blendColor=new Ls(this),this.blendEquation=new Rs(this),this.cullFace=new Os(this),this.cullFaceSide=new Ds(this),this.frontFace=new Bs(this),this.program=new Fs(this),this.activeTexture=new Ns(this),this.viewport=new ks(this),this.bindFramebuffer=new zs(this),this.bindRenderbuffer=new Us(this),this.bindTexture=new Vs(this),this.bindVertexBuffer=new js(this),this.bindElementBuffer=new Gs(this),this.bindVertexArrayOES=new Hs(this),this.pixelStoreUnpack=new Ws(this),this.pixelStoreUnpackPremultiplyAlpha=new qs(this),this.pixelStoreUnpackFlipY=new Xs(this),this.options=t?Object.assign({},t):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.disableSymbolUBO=t&&!!t.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=e.getExtension("EXT_color_buffer_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=e.getExtension("KHR_parallel_shader_compile")}sweepPendingPrograms(){if(0!==this._pendingPrograms.size)for(const e of this._pendingPrograms)e.maybeFinalize()}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,i){return new Zo(this,e,t,i)}createVertexBuffer(e,t,i,n,r){return new Jo(this,e,t,i,n,r)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,n){return new Ko(this,e,t,i,n)}clear({color:e,depth:t,stencil:i,colorMask:n}){const r=this.gl;let s=0;e&&(s|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(n||[!0,!0,!0,!0])),void 0!==t&&(s|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(s|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(s)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.b9(t.blendFunction,Wn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let ea;function ta(t,i,n,r,s,o,a){const l=t.context,c=l.gl,u=t.transform,h=[e.aG(u.center.lng),e.aJ(u.center.lat)],d=n.layout.get("symbol-placement"),p=n.layout.get("text-variable-anchor"),f="map"===n.layout.get("icon-rotation-alignment"),m="map"===n.layout.get("text-rotation-alignment"),g="point"!==d,_=[];let y=0,v=0;for(let l=0;l<r.length;l++){const d=r[l],x=i.getTile(d),b=x.getBucket(n);if(!b)continue;const w=b.getProjection().createInversionMatrix(u,d.canonical),T=[],S=Zi(d,b,u),E=!a&&f&&g,A=a&&m&&g,M=p&&b.hasTextData(),I=b.hasIconTextFit()&&M&&b.hasIconData(),C=E||A||a&&M||I,P="globe"===b.projection.name,L=P?e.ai(u.zoom):0;P&&(T.push("PROJECTION_GLOBE_VIEW"),C&&T.push("PROJECTED_POS_ON_VIEWPORT"));const R=t.getOrCreateProgram("collisionBox",{defines:T});let O=S;0===s[0]&&0===s[1]||(O=t.translatePosMatrix(S,x,s,o));const D=a?b.textCollisionBox:b.iconCollisionBox,B=b.collisionCircleArray;if(B.length>0){const t=e.bd(),i=O;e.cB(t,b.placementInvProjMatrix,u.glCoordMatrix),e.cB(t,t,b.placementViewportMatrix),_.push({circleArray:B,circleOffset:v,transform:i,invTransform:t,projection:b.getProjection()}),y+=B.length/4,v=y}if(!D)continue;t.terrain&&t.terrain.setupElevationDraw(x,R);const F=P?[d.canonical.x,d.canonical.y,1<<d.canonical.z]:[0,0,0];R.draw(t,c.LINES,qn.disabled,$n.disabled,t.colorModeForRenderPass(),Jn.disabled,Lo(O,w,u,L,h,x,F,b.getProjection()),n.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,null,u.zoom,null,[D.collisionVertexBuffer,D.collisionVertexBufferExt])}if(!a||!_.length)return;const x=t.getOrCreateProgram("collisionCircle"),b=new e.dS;b.resize(4*y),b._trim();let w=0;for(const e of _)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,n=e.circleArray[i+0],r=e.circleArray[i+1],s=e.circleArray[i+2],o=e.circleArray[i+3];b.emplace(w++,n,r,s,o,0),b.emplace(w++,n,r,s,o,1),b.emplace(w++,n,r,s,o,2),b.emplace(w++,n,r,s,o,3)}(!ea||ea.length<2*y)&&(ea=function(t){const i=2*t,n=new e.dF;n.resize(i),n._trim();for(let e=0;e<i;e++){const t=6*e;n.uint16[t+0]=4*e+0,n.uint16[t+1]=4*e+1,n.uint16[t+2]=4*e+2,n.uint16[t+3]=4*e+2,n.uint16[t+4]=4*e+3,n.uint16[t+5]=4*e+0}return n}(y));const T=l.createIndexBuffer(ea,!0),S=l.createVertexBuffer(b,e.dT.members,!0);for(const i of _){const r=Ro(i.transform,i.invTransform,u,i.projection);x.draw(t,c.TRIANGLES,qn.disabled,$n.disabled,t.colorModeForRenderPass(),Jn.disabled,r,n.id,S,T,e.dB.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,u.zoom)}S.destroy(),T.destroy()}const ia=e.bd();function na(t){const i=t._camera.getWorldToCamera(t.worldSize,1),n=e.aC([],i,t.globeMatrix);e.ba(n,n);const r=[0,0,0],s=[0,1,0,0];return e.aD(s,s,n),r[0]=s[0],r[1]=s[1],r[2]=s[2],e.ax(r,r),r}function ra({width:t,height:i,anchor:n,textOffset:r,textScale:s},o){const{horizontalAlign:a,verticalAlign:l}=e.bJ(n),c=-(a-.5)*t,u=-(l-.5)*i,h=e.bK(n,r);return new e.P((c/s+h[0])*o,(u/s+h[1])*o)}function sa(t,i,n,r,s,o,a,l,c,u){const h=t.text.placedSymbolArray,d=t.text.dynamicLayoutVertexArray,p=t.icon.dynamicLayoutVertexArray,f={},m=t.getProjection(),g=Yi(a,m,s),_=s.elevation,y=m.upVectorScale(a.canonical,s.center.lat,s.worldSize).metersToTile;d.clear();for(let p=0;p<h.length;p++){const v=h.get(p),{tileAnchorX:x,tileAnchorY:b,numGlyphs:w}=v,T=v.hidden||!v.crossTileID||t.allowVerticalPlacement&&!v.placedOrientation?null:r[v.crossTileID];if(T){let r=0,h=0,S=0;const E="road"===t.elevationType;if(_||E){const i=E?t.getElevationFeatureForText(p):null,n=e.bx.getAtTileOffset(a,new e.P(x,b),_,i),[s,o,l]=m.upVector(a.canonical,x,b);r=n*s*y,h=n*o*y,S=n*l*y}let[A,M,I,C]=nn(v.projectedAnchorX+r,v.projectedAnchorY+h,v.projectedAnchorZ+S,n?g:o);const P=rn(s.getCameraToCenterDistance(m),C);let L=e.bn(t.textSizeData,c,v)*P/e.bC;n&&(L*=t.tilePixelRatio/l);const R=ra(T,L);n?(({x:A,y:M,z:I}=m.projectTilePoint(x+R.x,b+R.y,a.canonical)),[A,M,I]=nn(A+r,M+h,I+S,o)):(i&&R._rotate(-s.angle),A+=R.x,M+=R.y,I=0);const O=t.allowVerticalPlacement&&v.placedOrientation===e.bm.vertical?Math.PI/2:0;for(let t=0;t<w;t++)e.bp(d,A,M,I,O);u&&v.associatedIconIndex>=0&&(f[v.associatedIconIndex]={x:A,y:M,z:I,angle:O})}else pn(w,d)}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const n=i.get(t),{numGlyphs:r}=n,s=f[t];if(n.hidden||!s)pn(r,p);else{const{x:t,y:i,z:n,angle:o}=s;for(let s=0;s<r;s++)e.bp(p,t,i,n,o)}}t.icon.dynamicLayoutVertexBuffer.updateData(p)}t.text.dynamicLayoutVertexBuffer.updateData(d)}function oa(t,i,n,r,s,o,a={}){const l=n.paint.get("icon-translate"),c=n.paint.get("text-translate"),u=n.paint.get("icon-translate-anchor"),h=n.paint.get("text-translate-anchor"),d=n.layout.get("icon-rotation-alignment"),p=n.layout.get("text-rotation-alignment"),f=n.layout.get("icon-pitch-alignment"),m=n.layout.get("text-pitch-alignment"),g=n.layout.get("icon-keep-upright"),_=n.layout.get("text-keep-upright"),y=n.paint.get("icon-color-saturation"),v=n.paint.get("icon-color-contrast"),x=n.paint.get("icon-color-brightness-min"),b=n.paint.get("icon-color-brightness-max"),w="sea"===n.layout.get("symbol-elevation-reference"),T="none"===n.layout.get("icon-image-use-theme"),S=t.context,E=S.gl,A=t.transform,M="map"===d,I="map"===p,C="map"===f,P="map"===m,L=void 0!==n.layout.get("symbol-sort-key").constantOr(1);let R=!1;const O=t.depthModeForSublayer(0,qn.ReadOnly),D=new qn(t.context.gl.LEQUAL,qn.ReadOnly,t.depthRangeFor3D),B=[e.aG(A.center.lng),e.aJ(A.center.lat)],F=n.layout.get("text-variable-anchor"),N="globe"===A.projection.name,k=[],z=[0,-1,0];for(const s of r){const r=i.getTile(s),o=r.getBucket(n);if(!o)continue;if("mercator"===o.projection.name&&N)continue;if(o.fullyClipped)continue;const d="globe"===o.projection.name,p=d?e.ai(A.zoom):0,f=Yi(s,o.getProjection(),A),m=A.calculatePixelsToTileUnitsMatrix(r),U=F&&o.hasTextData(),V=o.hasIconTextFit()&&U&&o.hasIconData(),j=o.getProjection().createInversionMatrix(A,s.canonical),G=(1<<r.tileID.canonical.z)*e.ak/t.transform.worldSize,H=e=>{let i=[0,0,0];if(e){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(i=mr(t.style,e,n))}return i},W=e=>{if(t.context.disableSymbolUBO)return;e.push("USE_PAINT_PROPERTIES_UBO");const i=Math.floor(t.context.maxUniformBlockSize/4),n=Math.floor(i/4);e.push(`MAX_UBO_SIZE_VEC4 ${n}u`)},q=e=>{A.depthOcclusionForSymbolsAndCircles&&(n.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},X=i=>{n.lut&&!T&&(n.lut.texture||(n.lut.texture=new e.dU(t.context,n.lut.image,[n.lut.image.height,n.lut.image.height,n.lut.image.height],S.gl.RGBA8)),S.activeTexture.set(S.gl.TEXTURE0+10),n.lut.texture&&n.lut.texture.bind(S.gl.LINEAR,S.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},$=()=>{const i=M&&"point"!==n.layout.get("symbol-placement"),a=[];q(a),X(a);const c=i||V,h="road"===o.elevationType,_=t.shadowRenderer,T=h&&C&&!!_&&_.enabled,I=H(T),P=h&&C&&!t.terrain?D:O,L=n.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&C&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),L>0&&o.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!o.icon.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),0===y&&0===v&&0===x&&1===b||a.push("COLOR_ADJUSTMENT"),o.sdfIcons&&a.push("RENDER_SDF"),T&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),h&&C&&!t.terrain&&o.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),W(a);const R=S.disableSymbolUBO?o.icon.programConfigurations.get(n.id):null,F=t.getOrCreateProgram("symbol",{config:R,defines:a}),k=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],U=o.iconSizeData,$=e.bl(U,A.zoom),Z=C||!A.isOrthographic,Y=Qi(f,r.tileID.canonical,C,M,A,o.getProjection(),m),J=tn(f,r.tileID.canonical,C,M,A,o.getProjection(),m),K=o.icon.uboBinder&&o.icon.uboBinder.cachedHeader&&256&o.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:l,Q=t.translatePosMatrix(J,r,K,u,!0),ee=t.translatePosMatrix(f,r,K,u),te=c?ia:Y,ie=M&&!C&&!i;let ne=z;!N&&!A.mercatorFromTransition||M||(ne=na(A));const re=d?ne:z,se=n.getColorAdjustmentMatrix(y,v,x,b),oe=jo(U.kind,$,ie,C,t,ee,te,Q,w,!1,k,[0,0],0,s,p,B,j,re,o.getProjection(),I,G,se,L,null),ae=r.imageAtlasTexture?r.imageAtlasTexture:null,le=1!==n.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,ce=o.sdfIcons||t.options.rotating||t.options.zooming||le||Z?E.LINEAR:E.NEAREST,ue=o.sdfIcons&&0!==n.paint.get("icon-halo-width").constantOr(1),he=t.terrain&&C&&i?e.ba(e.bd(),Y):ia;if(i&&o.icon){const i=e.bx.getAtTileOffsetFunc(s,A.center.lat,A.worldSize,o.getProjection()),a=en(f,r.tileID.canonical,C,M,A,o.getProjection(),m),l=n.layout.get("icon-size-scale-range"),c=e.aB(t.scaleFactor,l[0],l[1]);on(o,f,t,!1,a,J,C,g,i,s,c)}return{program:F,buffers:o.icon,uniformValues:oe,atlasTexture:ae,atlasTextureIcon:null,atlasInterpolation:ce,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:ue,depthMode:P,tile:r,renderWithShadows:T,labelPlaneMatrixInv:he}},Z=()=>{const i=I&&"point"!==n.layout.get("symbol-placement"),a=[],l=i||F||V,u="road"===o.elevationType,g=t.shadowRenderer,y=u&&P&&!!g&&g.enabled,v=H(y),x=u&&P&&!t.terrain?D:O;t.terrainRenderModeElevated()&&P&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!o.text.zOffsetVertexBuffer||u&&t.terrain||a.push("Z_OFFSET"),o.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),y&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),u&&P&&!t.terrain&&o.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),q(a),W(a);const b=S.disableSymbolUBO?o.text.programConfigurations.get(n.id):null,T=t.getOrCreateProgram("symbol",{config:b,defines:a});let M,C=[0,0],L=null;const R=o.textSizeData;o.iconsInText&&(C=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],L=r.imageAtlasTexture?r.imageAtlasTexture:null,M=P||!A.isOrthographic||t.options.rotating||t.options.zooming||"composite"===R.kind||"camera"===R.kind?E.LINEAR:E.NEAREST);const k=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],U=n.layout.get("text-size-scale-range"),X=e.aB(t.scaleFactor,U[0],U[1]),$=e.bl(R,A.zoom,X),Z=Qi(f,r.tileID.canonical,P,I,A,o.getProjection(),m),Y=tn(f,r.tileID.canonical,P,I,A,o.getProjection(),m),J=o.text.uboBinder&&o.text.uboBinder.cachedHeader&&256&o.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:c,K=t.translatePosMatrix(Y,r,J,h,!0),Q=t.translatePosMatrix(f,r,J,h),ee=l?ia:Z,te=I&&!P&&!i;let ie=z;!N&&!A.mercatorFromTransition||I||(ie=na(A));const ne=jo(R.kind,$,te,P,t,Q,ee,K,w,!0,k,C,0,s,p,B,j,d?ie:z,o.getProjection(),v,G,null,null,X),re=r.glyphAtlasTexture?r.glyphAtlasTexture:null,se=E.LINEAR,oe=0!==n.paint.get("text-halo-width").constantOr(1),ae=t.terrain&&P&&i?e.ba(e.bd(),Z):ia;if(i&&o.text){const i=e.bx.getAtTileOffsetFunc(s,A.center.lat,A.worldSize,o.getProjection()),n=en(f,r.tileID.canonical,P,I,A,o.getProjection(),m);on(o,f,t,!0,n,Y,P,_,i,s,X)}return{program:T,buffers:o.text,uniformValues:ne,atlasTexture:re,atlasTextureIcon:L,atlasInterpolation:se,atlasInterpolationIcon:M,isSDF:!0,hasHalo:oe,depthMode:x,tile:r,renderWithShadows:y,labelPlaneMatrixInv:ae}},Y=o.icon.segments.get().length,J=o.text.segments.get().length,K=Y&&!a.onlyText?$():null,Q=J&&!a.onlyIcons?Z():null,ee=n.paint.get("icon-opacity").constantOr(1),te=n.paint.get("text-opacity").constantOr(1);if(L&&o.canOverlap){R=!0;const t=ee&&!a.onlyText?o.icon.segments.get():[],i=te&&!a.onlyIcons?o.text.segments.get():[];for(const i of t)k.push({segments:new e.dB([i]),sortKey:i.sortKey,state:K});for(const t of i)k.push({segments:new e.dB([t]),sortKey:t.sortKey,state:Q})}else a.onlyText||k.push({segments:ee?o.icon.segments:new e.dB([]),sortKey:0,state:K}),a.onlyIcons||k.push({segments:te?o.text.segments:new e.dB([]),sortKey:0,state:Q})}R&&k.sort((e,t)=>e.sortKey-t.sortKey);for(const e of k){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:A.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(A.depthOcclusionForSymbolsAndCircles,i.program),S.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(S.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,aa(i.buffers,e.segments,n,t,i.program,i.depthMode,s,o,r,2),r.u_is_halo=0}else{if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,aa(i.buffers,e.segments,n,t,i.program,i.depthMode,s,o,r,1)),r.u_is_halo=0}aa(i.buffers,e.segments,n,t,i.program,i.depthMode,s,o,i.uniformValues,1)}}}function aa(e,t,i,n,r,s,o,a,l,c){const u=n.context,h=u.gl,d=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];e.featureIdBuffer&&d.push(e.featureIdBuffer);const p=e.uboBinder?null:e.programConfigurations.get(i.id);if(e.uboBinder){e.uboBinder.layer=i;const t=n.transform.zoom,r=n.style.getBrightness?n.style.getBrightness():null,s=e.uboBinder.getConstantUniformValues(t,r);l.u_spp_fill_np_color=s.fill_np_color,l.u_spp_halo_np_color=s.halo_np_color,l.u_spp_opacity=s.opacity,l.u_spp_halo_width=s.halo_width,l.u_spp_halo_blur=s.halo_blur,l.u_spp_emissive_strength=s.emissive_strength,l.u_spp_occlusion_opacity=s.occlusion_opacity,l.u_spp_z_offset=s.z_offset;const o=i.paint.get(e.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),a=e.uboBinder.cachedHeader&&256&e.uboBinder.cachedHeader.dataDrivenMask&&"map"===o?n.transform.angle:0;l.u_spp_translate_rotation=[Math.cos(a),Math.sin(a)]}const{batchIndices:f,batchSegments:m}=e.getBatchGrouping(t);for(const t of f){const f=m.get(t);e.uboBinder&&e.uboBinder.bind(u,r.program,t),r.draw(n,h.TRIANGLES,s,o,a,Jn.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,f,i.paint,n.transform.zoom,p,d,c)}}function la(t,i,n,r,s,o){const a=n.paint.get("line-width"),l=n.paint.get("line-emissive-strength").isConstant(),c=n.paint.get("line-emissive-strength").constantOr(0),u=n.paint.get("line-occlusion-opacity"),h=n.layout.get("line-elevation-reference"),d="meters"===n.layout.get("line-width-unit"),p="sea"===h,f=!(!t.terrain||!t.terrain.enabled),m=t.context,g=m.gl;if(n.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const _=n.layout.get("line-cross-slope"),y=void 0!==_,v=_<1,x=s||t.colorModeForDrapableLayerRenderPass(l?c:null),b=t.terrain&&t.terrain.renderingToTexture||o,w=b?1:e.o.devicePixelRatio,T=n.paint.get("line-dasharray"),S=T.constantOr(1),E=n.layout.get("line-cap"),A=T.constantOr(null),M=E.constantOr(null),I=n.paint.get("line-pattern"),C=I.constantOr(1),P=n.paint.get("line-pattern-cross-fade"),L=I.constantOr(null),R=n.paint.get("line-opacity").constantOr(1);let O=!C&&1!==R||t.depthOcclusion&&u>0&&u<1;const D=n.paint.get("line-gradient"),B=C?"linePattern":"line",F=e.dX(n);let N;if(b&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(O=!1),0!==u&&t.depthOcclusion){const t=n.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?N=t.value:e.w(`Occlusion opacity for layer ${n.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==a.value.kind&&!1===a.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH"),t._debugParams.showElevationIdDebug&&F.push("DEBUG_ELEVATION_ID"),b&&("dual-source-blending"!==t.emissiveMode||l?"mrt-fallback"===t.emissiveMode&&F.push("USE_MRT1"):F.push("DUAL_SOURCE_BLENDING"));const k={},z=(r,s,o,a,l,c)=>{for(const h of r){const r=i.getTile(h);if(C&&!r.patternsLoaded())continue;const p=r.getBucket(n);if(!p)continue;if("none"!==p.elevationType&&!l||"none"===p.elevationType&&l)continue;t.prepareDrawTile();const f=[...s],_=t.shadowRenderer,y="road"===p.elevationType&&!!_&&_.enabled;let v=[0,0,0];if(y){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(v=mr(t.style,e,i)),f.push("RENDER_SHADOWS","NORMAL_OFFSET")}const T=p.programConfigurations.get(n.id);let E=!1;if(L&&r.imageAtlas){const t=e.dY.from(L),i=t.getPrimary().scaleSelf(w).toString(),n=r.imageAtlas.patternPositions.get(i),s=t.getSecondary(),o=s?r.imageAtlas.patternPositions.get(s.scaleSelf(w).toString()):null;E=!!n&&!!o,n&&T.setConstantPatternPositions(n,o)}P>0&&(E||T.getPatternTransitionVertexBuffer("line-pattern"))&&f.push("LINE_PATTERN_TRANSITION"),p.elevationGroundScaleVertexBuffer&&f.push("ELEVATION_GROUND_SCALE");const I=t.isTileAffectedByFog(h),F=t.getOrCreateProgram(B,{config:T,defines:f,overrideFog:I});if(!C&&A&&M&&r.lineAtlas){const e=r.lineAtlas.getDash(A,M);e&&T.setConstantPatternPositions(e)}y&&_.setupShadows(r.tileID.toUnwrapped(),F,"vector-tile");let[z,U]=n.paint.get("line-trim-offset");if("round"===M||"square"===M){const e=1;z!==U&&(0===z&&(z-=e),1===U&&(U+=e))}const V=b?h.projMatrix:null,j=d?1/p.tileToMeter/e.az(r,1,t.transform.zoom):1,G=d?1/p.tileToMeter/e.az(r,1,Math.floor(t.transform.zoom)):1,H=S?n.paint._values["line-floorwidth"]:null;let W;if(H&&"constant"===H.value.kind){const e=p.zoom;e in k||(k[e]=Math.max(.01,n.widthExpression().evaluate({zoom:e}))),W=H.value.value;const i=Math.floor(t.transform.zoom);H.value.value=k[e]*Math.pow(2,i-r.tileID.overscaledZ)}const q=C?e.dZ(t,r,n,V,w,j,G,[z,U],v,P):e.d_(t,r,n,V,p.lineClipsArray.length,w,j,G,[z,U],v);if(D){const r=p.gradients[n.id];let s=r.texture;if(n.gradientVersion!==r.version){let o=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=h.canonical.z===n?Math.ceil(1<<t.transform.maxZoom-h.canonical.z):1;o=e.aB(e.d$(p.maxLineLength/e.ak*1024*r),256,m.maxTextureSize)}r.gradient=e.e0({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:o,image:r.gradient||void 0,clips:p.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new e.T(m,r.gradient,g.RGBA8),r.version=n.gradientVersion,s=r.texture}m.activeTexture.set(g.TEXTURE1),s.bind(n.stepInterpolant?g.NEAREST:g.LINEAR,g.CLAMP_TO_EDGE)}S&&(m.activeTexture.set(g.TEXTURE0),r.lineAtlasTexture&&r.lineAtlasTexture.bind(g.LINEAR,g.REPEAT),T.updatePaintBuffers()),C&&(m.activeTexture.set(g.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),T.updatePaintBuffers()),l&&t.terrain.setupElevationDraw(r,F),t.uploadCommonUniforms(m,F,h.toUnwrapped());const X=e=>{null!=N&&(N.value=R*u),F.draw(t,g.TRIANGLES,o,e,x,Jn.disabled,q,n.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,n.paint,t.transform.zoom,T,[p.layoutVertexBuffer2,p.patternVertexBuffer,p.zOffsetVertexBuffer,p.elevationIdColVertexBuffer,p.elevationGroundScaleVertexBuffer]),null!=N&&(N.value=R)};if(O&&!l){const e=t.stencilModeForClipping(h).ref;0===e&&b&&m.clear({stencil:0});const i={func:g.EQUAL,mask:255};q.u_alpha_discard_threshold=.8,X(new $n(i,e,255,g.KEEP,g.KEEP,g.INVERT)),q.u_alpha_discard_threshold=0,X(new $n(i,e,255,g.KEEP,g.KEEP,g.KEEP))}else q.u_alpha_discard_threshold=O&&l&&c?.8:0,X(l?a:t.stencilModeForClipping(h));void 0!==W&&(H.value.value=W)}};let U=t.depthModeForSublayer(0,qn.ReadOnly);const V=new qn(t.depthOcclusion?g.GREATER:g.LEQUAL,qn.ReadOnly,t.depthRangeFor3D);if(n.hasNonElevatedBuckets){const i=!b&&t.terrain;0!==u&&i?e.w(`Occlusion opacity for layer ${n.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${n.id}.`):z(r,F,U,$n.disabled,!1,!0)}if(n.hasElevatedBuckets){"hd-road-markup"===h?f||(U=V,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),U=V,y&&F.push(v?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),p&&F.push("ELEVATION_REFERENCE_SEA"));const e=O?t.stencilModeFor3D():$n.disabled;t.forceTerrainMode=!0,z(r,F,U,e,!0,!0),O&&z(r,F,U,e,!0,!1),t.forceTerrainMode=!1}O&&(t.resetStencilClippingMasks(),b&&m.clear({stencil:0})),0===u||t.depthOcclusion||b||t.layersWithOcclusionOpacity.push(t.currentLayer)}class ca{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class ua{constructor(e){this.pbo=e.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(e){this.sync&&(e.deleteSync(this.sync),this.sync=null),e.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}const ha={additive:{clearColor:new e.C(0,0,0,0),colorMode:Wn.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new e.C(1,1,1,1),colorMode:Wn.multiply,compositeUniformValue:0}};function da(e){return!(!e.extRenderToTextureHalfFloat&&!e.extColorBufferFloat)}function pa(e,t){return"additive"===e&&da(t)?Wn.additiveAlphaWeightedUnboundedAlpha:ha[e].colorMode}function fa(e,t,i){const n=e.context,r=n.gl;let s=i.width,o=i.height,a=i.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new ua(r));const l=t.lineBlendDensityReadback;let c=0,u=!0;for(;s>1||o>1;){const i=Math.max(1,Math.floor(s/2)),h=Math.max(1,Math.floor(o/2)),d=0===c?"fboA":"fboB";l[d]=Ko.createWithTexture(n,l[d],i,h,!1);const p=l[d];n.bindFramebuffer.set(p.framebuffer),n.viewport.set([0,0,i,h]),n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a),e.getOrCreateProgram("lineBlendReduce").draw(e,r.TRIANGLES,qn.disabled,$n.disabled,Wn.unblended,Jn.disabled,Po(0,[1/s,1/o],u),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom),s=i,o=h,a=p.colorAttachment0.get(),c=1-c,u=!1}const h=da(n),d=h?16:4;l.sync&&(r.deleteSync(l.sync),l.sync=null),r.bindBuffer(r.PIXEL_PACK_BUFFER,l.pbo),r.bufferData(r.PIXEL_PACK_BUFFER,d,r.STREAM_READ),r.readPixels(0,0,1,1,r.RGBA,h?r.FLOAT:r.UNSIGNED_BYTE,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),l.sync=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0),n.viewport.set([0,0,e.width,e.height])}function ma(e,t,i){if(!da(e.context))return;const n=t.lineBlendDensityReadback;n&&n.sync?(function(e,t,i){if(e.sync&&t.getSyncParameter(e.sync,t.SYNC_STATUS)===t.SIGNALED){if(t.deleteSync(e.sync),e.sync=null,t.bindBuffer(t.PIXEL_PACK_BUFFER,e.pbo),da(i)){const i=new Float32Array(4);t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,i);const n=i[1];e.maxDensity=Math.max(2*(n>0?i[0]/n:0),1)}else e.maxDensity=1;t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}}(n,e.context.gl,e.context),n.sync||(fa(e,t,i),e.style.map.triggerRepaint())):(fa(e,t,i),e.style.map.triggerRepaint())}function ga(e,t,i,n,r,s){const o=e.context,a=o.gl,l="additive"===i?1:t.paint.get("line-opacity").constantOr(1),c="additive"===i?function(e,t){const i=t.paint.get("line-blend-additive-clamp");if(i>0)return i;const n=t.lineBlendDensityReadback;return n&&0!==n.maxDensity?n.maxDensity:null}(0,t):1;if(null===c)return;o.bindFramebuffer.set(r),s&&o.viewport.set([0,0,s[0],s[1]]),o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,n.colorAttachment0.get());const u=pa(i,e.context);e.getOrCreateProgram("lineBlendComposite").draw(e,a.TRIANGLES,qn.disabled,$n.disabled,u,Jn.disabled,((e,t,i,n)=>({u_image:0,u_opacity:t,u_blend_mode:i,u_max_density:n}))(0,l,ha[i].compositeUniformValue,c),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}function _a(t,i){const n=1<<t.canonical.z,r=(i.x*n-t.canonical.x-t.wrap*n)*e.ak,s=(i.y*n-t.canonical.y)*e.ak,o=e.e1(i.z,i.y);return e.cU(r,s,o)}function ya(t,i,n,r,s){if(!n.layout||"none"===n.layout.get("fill-elevation-reference")||0===n.paint.get("fill-opacity").constantOr(1))return;const o=t.context.gl,a=new qn(t.context.gl.LEQUAL,qn.ReadWrite,t.depthRangeFor3D),l=new qn(t.context.gl.GREATER,qn.ReadWrite,t.depthRangeFor3D),c=function(t){let i=.01;return t.isOrthographic&&(i=e.aj(1e-4,i,e.cP(t.pitch>=sr?1:t.pitch/sr))),2*i}(t.transform),u=t.transform.getFreeCameraOptions().position,h="elevatedStructuresDepthReconstruct",d=t.getOrCreateProgram(h,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(h);for(const e of r){const r=i.getTile(e),h=r.getBucket(n);if(!h)continue;const f=h.elevatedStructures;if(!f||!f.depthSegments)continue;const m=h.elevationBufferData.heightRange,g=_a(e.toUnwrapped(),u),_=t.translatePosMatrix(e.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));let y,v,x,b;if("initialize"===s){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;y=Co(_,g,c,1,0),v=a,x=f.depthSegments,b=d}else if("reset"===s){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;y=Co(_,g,0,0,1),v=l,x=f.maskSegments,b=d}else if("geometry"===s){if(0===f.depthSegments.segments[0].primitiveLength)continue;y=Co(_,g,c,1,0),v=a,x=f.depthSegments,b=p}b.draw(t,o.TRIANGLES,v,$n.disabled,Wn.disabled,Jn.disabled,y,n.id,f.vertexBuffer,f.indexBuffer,x,n.paint,t.transform.zoom)}}function va(t,i,n,r){const{painter:s,sourceCache:o,layer:a,coords:l,colorMode:c,elevationType:u,terrainEnabled:h,pass:d}=t,p=s.context.gl,f=a.paint.get("fill-pattern"),m=a.paint.get("fill-pattern-cross-fade"),g=f.constantOr(null);let _=u;"road"!==u||i&&!h||(_="none");const y="road"===_,v=t.painter.shadowRenderer,x=y&&!!v&&v.enabled,b=new qn(s.context.gl.LEQUAL,qn.ReadOnly,s.depthRangeFor3D);let w=[0,0,0];if(x){const e=s.style.directionalLight,t=s.style.ambientLight;e&&t&&(w=mr(s.style,e,t))}const T=f&&f.constantOr(1),S=s.terrain&&s.terrain.renderingToTexture,E=(t,d)=>{let f,_,E,A,M;d?(f=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",E=p.LINES):(f=T?"fillPattern":"fill",E=p.TRIANGLES);for(const I of l){const l=o.getTile(I);if(T&&!l.patternsLoaded())continue;const C=l.getBucket(a);if(!C)continue;const P=i?C.elevationBufferData:C.bufferData;if(P.isEmpty())continue;s.prepareDrawTile();const L=P.programConfigurations.get(a.id),R=s.isTileAffectedByFog(I),O=[],D=[];y&&(O.push("ELEVATED_ROADS"),D.push(P.elevatedLayoutVertexBuffer)),x&&O.push("RENDER_SHADOWS","NORMAL_OFFSET"),S&&n&&O.push("USE_MRT1"),T&&(s.context.activeTexture.set(p.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),L.updatePaintBuffers());let B=!1;if(g&&l.imageAtlas){const t=l.imageAtlas,i=e.dY.from(g),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),s=t.patternPositions.get(n),o=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;B=!!s&&!!o,s&&L.setConstantPatternPositions(s,o)}m>0&&(B||L.getPatternTransitionVertexBuffer("fill-pattern"))&&O.push("FILL_PATTERN_TRANSITION");const F=s.getOrCreateProgram(f,{config:L,overrideFog:R,defines:O}),N=s.translatePosMatrix(I.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));x&&v.setupShadows(l.tileID.toUnwrapped(),F,"vector-tile");const k=a.paint.get("fill-emissive-strength");if(d){A=P.lineIndexBuffer,M=P.lineSegments;const e=s.terrain&&s.terrain.renderingToTexture?s.terrain.drapeBufferSize:[p.drawingBufferWidth,p.drawingBufferHeight];_="fillOutlinePattern"===f&&T?Ao(N,k,s,l,e,w,m):Eo(N,k,e,w)}else A=P.indexBuffer,M=P.triangleSegments,_=T?So(N,k,s,l,w,m):To(N,k,w);s.uploadCommonUniforms(s.context,F,I.toUnwrapped());let z=t;("road"===u&&!h||"offset"===u)&&(z=b),F.draw(s,E,z,r||s.stencilModeForClipping(I),c,Jn.disabled,_,a.id,P.layoutVertexBuffer,A,M,a.paint,s.transform.zoom,L,D)}};s.renderPass===d&&E(s.depthModeForSublayer(1,"opaque"===s.renderPass?qn.ReadWrite:qn.ReadOnly),!1),"none"===_&&"translucent"===s.renderPass&&a.paint.get("fill-antialias")&&E(s.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,qn.ReadOnly),!0)}const xa=new Float32Array(16);function ba(t,i,n,r,s,o,a,l){n.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=n.paint.get("fill-extrusion-pattern"),p=n.paint.get("fill-extrusion-pattern-cross-fade"),f=d.constantOr(null),m=d.constantOr(1),g=n.paint.get("fill-extrusion-opacity"),_=t.style.enable3dLights(),y=n.paint.get(_&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),v=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),y],x=n.layout.get("fill-extrusion-edge-radius"),b=x>0&&!n.paint.get("fill-extrusion-rounded-roof"),w=b?0:x,T="globe"===h.projection.name?e.e4():0,S="globe"===h.projection.name,E=S?e.ai(h.zoom):0,A=[e.aG(h.center.lng),e.aJ(h.center.lat)],M="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),I=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(M?null:n.lut).toArray01().slice(0,3),C=n.paint.get("fill-extrusion-flood-light-intensity"),P=n.paint.get("fill-extrusion-vertical-scale"),L=0!==n.paint.get("fill-extrusion-line-width").constantOr(1),R=n.paint.get("fill-extrusion-height-alignment"),O=n.paint.get("fill-extrusion-base-alignment"),D=ar(t,n.paint.get("fill-extrusion-cutoff-fade-range")),B=n.paint.get("fill-extrusion-front-cutoff"),F=Ta(h.pitch,B,!!t.terrain),N=F[2]<1;N&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,B[0]));const k=[];let z;S&&k.push("PROJECTION_GLOBE_VIEW"),v[0]>0&&k.push("FAUX_AO"),b&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),C>0&&k.push("FLOOD_LIGHT"),D.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),N&&k.push("RENDER_FRONT_CUTOFF"),L&&k.push("RENDER_WALL_MODE");const U="shadow"===t.renderPass,V=t.shadowRenderer,j=U&&!!V,G=U?Jn.disabled:Jn.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let H=[0,0,0];if(V){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(H=mr(t.style,e,i)),U||(k.push("RENDER_SHADOWS"),V.useNormalOffset&&k.push("NORMAL_OFFSET")),z=k.concat(["SHADOWS_SINGLE_CASCADE"])}const W=j?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",q=n.getLayerRenderingStats();for(const d of r){const r=i.getTile(d),_=r.getBucket(n);if(!_||_.projection.name!==h.projection.name)continue;let y=!1;V&&(y=0===V.getMaxCascadeForTile(d.toUnwrapped()));const x=t.isTileAffectedByFog(d),b=_.programConfigurations.get(n.id);let M=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.dY.from(f),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),s=i.getSecondary(),o=t.patternPositions.get(n),a=s?t.patternPositions.get(s.scaleSelf(e.o.devicePixelRatio).toString()):null;M=!!o&&!!a,o&&b.setConstantPatternPositions(o,a)}p>0&&(M||b.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const B=t.getOrCreateProgram(W,{config:b,defines:y?z:k,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(r,B,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=B.getAttributeLocation(u,"a_centroid_pos");-1!==e&&u.vertexAttribI4ui(e,0,0,0,0)}!U&&V&&V.setupShadows(r.tileID.toUnwrapped(),B,"vector-tile"),m&&(t.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers());const N=n.paint.get("fill-extrusion-vertical-gradient"),j=1/_.tileToMeter;let X;if(U&&V){if(Ca(r.tileID,_.maxHeight,t))continue;const e=V.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());X=bo(e,w,j,P,R,O)}else{const e=t.translatePosMatrix(d.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,d.canonical);X=m?wo(e,t,N,g,v,w,j,d,r,T,R,O,E,A,i,I,P,p):xo(e,t,N,g,v,w,j,d,T,R,O,E,A,i,I,P,C,H,F)}t.uploadCommonUniforms(c,B,d.toUnwrapped(),null,D);let $=_.segments;if("mercator"===h.projection.name&&!U&&($=_.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!$.get().length))continue;if(q)if(U)for(const e of $.get())q.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of $.get())q.numRenderedVerticesInTransparentPass+=e.primitiveLength;const Z=[];(t.terrain||l)&&Z.push(_.centroidVertexBuffer),S&&Z.push(_.layoutVertexExtBuffer),L&&Z.push(_.wallVertexBuffer),B.draw(t,c.gl.TRIANGLES,s,o,a,G,X,n.id,_.layoutVertexBuffer,_.indexBuffer,$,n.paint,t.transform.zoom,b,Z)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class wa{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Ta(e,t,i){if(!(t[2]<1)||i)return[0,0,1];const n=180*e/Math.PI;if(n<15)return[-.5,t[1],t[2]];const r=Math.min(1,Math.max(0,(n-15)/5)),s=r*r*(3-2*r);return[-.5*(1-s)+t[0]*s,t[1],t[2]]}function Sa(t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b){const w=i.context,T=w.gl,S=i.transform,E=i.transform.zoom,A=[],M=t.translate,I=t.translateAnchor,C=t.edgeRadius,P=ar(i,t.cutoffFadeRange);"clear"===h?(A.push("CLEAR_SUBPASS"),x&&(A.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===h?A.push("SDF_SUBPASS"):"emissive"===h&&(A.push("USE_MRT1"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE)),y&&A.push("HAS_CENTROID"),P.shouldRenderCutoff&&A.push("RENDER_CUTOFF");const L=(e,t,n,s,h)=>{let v=A;null!=t.groundRadiusBuffer&&(v=A.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),T=i.isTileAffectedByFog(e),S=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:v,overrideFog:T}),M=((e,t,i,n,r,s,o,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:n?1:0,u_meter_to_tile:r,u_ao:s,u_flood_light_intensity:o,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u,u_dynamic_offset:1}))(0,s,d,u,h,[p,f*h],m,g,_,E>=17?0:C*h,x?x.size[0]:0),I=[];y&&I.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&I.push(t.groundRadiusBuffer),i.uploadCommonUniforms(w,S,e.toUnwrapped(),null,P),S.draw(i,w.gl.TRIANGLES,o,a,l,c,M,r.id,t.vertexBuffer,t.indexBuffer,n,r.paint,E,b,I)};for(const t of s){const s=n.getTile(t),o=s.getBucket(r);if(!o||o.projection.name!==S.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const a=o.groundEffect,l=1/o.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,s,M,I),n=a.getDefaultSegment();L(t,a,n,e,l)}if(v)for(let o=0;o<4;o++){const a=e.e2[o](t),c=n.getTile(a);if(!c)continue;const u=c.getBucket(r);if(!u||u.projection.name!==S.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===o?(d=[-e.ak,0,0],p=1):1===o?(d=[e.ak,0,0],p=0):2===o?(d=[0,-e.ak,0],p=3):(d=[0,e.ak,0],p=2);const f=h.regionSegments[p];f&&(e.bB(xa,t.projMatrix,d),L(t,h,f,i.translatePosMatrix(xa,s,M,I),l))}}}function Ea(t,i,n,r,s,o,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=o?o.findDEMTileFor(n):null;if(!(l&&l.dem||a))return;o&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.e5?(t.flags|=e.e5,i.flags|=e.e5):(t.flags&=~e.e5,i.flags&=~e.e5)},u=t=>new e.P(Math.ceil((t+e.e6)*e.e7),0),h=(t,i,n)=>{const r=Math.ceil((t+e.e6)*e.e7),s=Math.floor(Math.max(0,Math.min(e.ak-1,n))/4);return new e.P(r,s<<5|(3&i)<<3|7)},d=e=>{const t=i.getSource().minzoom,n=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(s)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i<t)continue;const r=n(e.calculateScaledKey(e.overscaledZ+i));if(r)return r}},p=[0,0,0],f=(t,i)=>(p[0]=Math.min(t.min.y,i.min.y),p[1]=Math.max(t.max.y,i.max.y),p[2]=e.ak-i.min.x>t.max.x?i.min.x-e.ak:t.max.x,p),m=(t,i)=>(p[0]=Math.min(t.min.x,i.min.x),p[1]=Math.max(t.max.x,i.max.x),p[2]=e.ak-i.min.y>t.max.y?i.min.y-e.ak:t.max.y,p),g=[(e,t)=>f(e,t),(e,t)=>f(t,e),(e,t)=>m(e,t),(e,t)=>m(t,e)],_=(t,i,r,s,a,c,u)=>{if(!o)return 0;const h=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=u<0?e.ak+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&u<0||0!==r&&u>0?o.getForTilePoints(a,[p],!0,s):h.push(p),o.getForTilePoints(n,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/o.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const s=e.e2[t](n),l=d(s);if(!(l&&l instanceof e.e3))continue;const p=o?o.findDEMTileFor(s):null;if(!(p&&p.dem||a))continue;if(o&&p&&p.dem&&r.borderDEMTileTimestamp[t]!==p.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=p.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const f=(t<2?1:5)-t,m=l.borderDoneWithNeighborZ[f]!==r.canonical.z,y=l.borderFeatureIndices[f];let v=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(m)for(const e of y)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;continue}const x=new Map,b=new Set,w=new Set;for(let e=0;e<y.length;e++){const t=l.featuresOnBorder[y[e]];void 0!==t.buildingId&&x.set(t.buildingId,e)}for(const n of i){const i=r.featuresOnBorder[n],o=r.centroidData.get(i.centroidDataIndex);if(void 0===i.buildingId)continue;const u=x.get(i.buildingId);if(void 0===u)continue;const d=l.featuresOnBorder[y[u]],m=l.centroidData.get(d.centroidDataIndex);b.add(n),w.add(u),a&&c(o,m);const v=0!==o.groupCentroidPos.x||0!==o.groupCentroidPos.y?o.groupCentroidPos:i.centroid(),T=0!==m.groupCentroidPos.x||0!==m.groupCentroidPos.y?m.groupCentroidPos:d.centroid(),S=t<2?Math.round((v.y+T.y)/2):Math.round((v.x+T.x)/2),E=i.intersectsCount()>1||d.intersectsCount()>1;{let i=0;if(p&&p.dem&&!E){const n=g[t](o,m),r=t%2?e.ak-1:0;i=_(n[0],Math.min(e.ak-1,n[1]),r,p,s,t<2,n[2])}o.centroidXY=h(i,t,S),m.centroidXY=h(i,f,S)}if(r.writeCentroidToBuffer(o),l.writeCentroidToBuffer(m),void 0!==i.buildingId){for(const e of r.centroidData)e.buildingId===i.buildingId&&e!==o&&(e.centroidXY=o.centroidXY,r.writeCentroidToBuffer(e));for(const e of l.centroidData)e.buildingId===i.buildingId&&e!==m&&(e.centroidXY=m.centroidXY,l.writeCentroidToBuffer(e))}}for(const n of i){if(b.has(n))continue;const i=r.featuresOnBorder[n],o=r.centroidData.get(i.centroidDataIndex),h=i.borders[t];let d;for(;v<y.length;){if(w.has(v)){v++;continue}d=l.featuresOnBorder[y[v]];const e=d.borders[f];if(e[1]>h[0]+3||e[0]>h[0]-3)break;l.showCentroid(d),v++}if(d&&v<y.length){let n=v,m=0;for(;;)if(w.has(v)){if(++v===y.length)break;d=l.featuresOnBorder[y[v]]}else{if(d.borders[f][0]>h[1]-3)break;if(m++,++v===y.length)break;d=l.featuresOnBorder[y[v]]}for(;n<y.length&&w.has(n);)n++;if(n>=y.length){r.showCentroid(i);continue}d=l.featuresOnBorder[y[n]];let x=!1;if(m>=1){const e=d.borders[f];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(m=1,x=!0,v=n+1)}else if(0===m){r.showCentroid(i);continue}const b=l.centroidData.get(d.centroidDataIndex);a&&x&&c(o,b);const T=i.intersectsCount()>1||d.intersectsCount()>1;if(m>1)v=n,o.centroidXY=b.centroidXY=new e.P(0,0);else if(p&&p.dem&&!T){const i=g[t](o,b),n=t%2?e.ak-1:0,r=_(i[0],Math.min(e.ak-1,i[1]),n,p,s,t<2,i[2]);o.centroidXY=b.centroidXY=u(r)}else T?o.centroidXY=b.centroidXY=new e.P(0,0):(o.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(d));r.writeCentroidToBuffer(o),l.writeCentroidToBuffer(b)}else r.showCentroid(i)}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const Aa=[1,0,0],Ma=[0,1,0],Ia=[0,0,1];function Ca(t,i,n){const r=n.transform,s=n.shadowRenderer;if(!s)return!0;const o=n.frameCounter,a=n.currentShadowCascade;let l=n._shadowCullCache;if(!l||l.frame!==o||l.cascade!==a){const t=r.tileSize*s._cascades[a].scale,i=r.scaleZoom(t),c=s.shadowDirection,u=[c[0],c[1],-c[2]],h=[Aa,Ma,Ia,u,[u[0],0,u[2]],[0,u[1],u[2]]];l={frame:o,cascade:a,cameraFrustum:e.cn.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,i,!("globe"===r.projection.name)),edges:h,shadowDir:u,ws:t,zoom:i},n._shadowCullCache=l}const{cameraFrustum:c,edges:u,shadowDir:h,ws:d,zoom:p}=l;let f=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(f+=e.max)}f/=e.e8(r.center.lat,p);const m=s.computeSimplifiedTileShadowVolume(t.toUnwrapped(),f,d,h);if(!m)return!1;const{vertices:g,planes:_}=m;return 0===c.intersectsPrecise(g,_,u)||0===s.getCurrentCascadeFrustum().intersectsPrecise(g,_,u)}const Pa=(e,t,i,n,r,s,o,a,l,c=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:n,u_camera_pos:r,u_tile_to_meter:s,u_facade_emissive_chance:o,u_flood_light_color:a,u_flood_light_intensity:l,u_front_cutoff_params:c}),La=e=>({u_matrix:e}),Ra=e=>({u_matrix:e}),Oa=new Float32Array(16),Da=new Float32Array(16);function Ba(t){const{painter:i,source:n,layer:r,coords:s}=t;let o=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,u=i.shadowRenderer,h=e.e8(i.transform.center.lat,i.transform.zoom),d=ar(i,r.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(o=o.concat("RENDER_CUTOFF"));const p=r.paint.get("building-front-cutoff"),f=p[2]<1&&!i.terrain,m=Ta(i.transform.pitch,p,!!i.terrain);f&&(o=o.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,p[0])),t.floodLightIntensity>0&&(o=o.concat("FLOOD_LIGHT"));for(const p of s){const s=n.getTile(p),f=s.getBucket(r);if(!f)continue;u&&0===u.getMaxCascadeForTile(p.toUnwrapped())&&(o=o.concat("SHADOWS_SINGLE_CASCADE"));const g=f.programConfigurations.get(r.id);let _,y;const v=i.translatePosMatrix(p.expandedProjMatrix,s,[0,0],"map");e.cE(Oa,v,[1,1,t.verticalScale]);const x=Oa;let b;if(l&&u){if(Ca(s.tileID,f.maxHeight*h,i))continue;const n=u.calculateShadowPassMatrixFromTile(s.tileID.toUnwrapped());e.cE(n,n,[1,1,t.verticalScale]),b=Ra(n),_=y=i.getOrCreateProgram("buildingDepth",{config:g,defines:o,overrideFog:!1})}else if(c)_=y=i.getOrCreateProgram("buildingBloom",{config:g,defines:o,overrideFog:!1}),b=La(x);else{const n=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.cE(n,n,[1,1,t.verticalScale]),e.cE(Da,n,[1,-1,1/h]),e.ba(Da,Da),e.e9(Da,Da);const r=Da,s=i.transform.getFreeCameraOptions().position,a=1<<p.canonical.z;if(b=Pa(x,r,t.opacity,t.facadeAOIntensity,[((s.x-p.wrap)*a-p.canonical.x)*e.ak,(s.y*a-p.canonical.y)*e.ak,s.z*a*e.ak],f.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,m),y=i.getOrCreateProgram("building",{config:g,defines:o,overrideFog:!1}),!0===t.depthOnly)_=y;else{const e=o.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);_=i.getOrCreateProgram("building",{config:g,defines:e,overrideFog:!1})}u&&(u.setupShadowsFromMatrix(n,y,!0),_!==y&&u.setupShadowsFromMatrix(n,_,!0))}const w=(e,n)=>{if(c){const s=e.entranceBloom;n.draw(i,a.gl.TRIANGLES,t.depthMode,$n.disabled,t.blendMode,Jn.disabled,b,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segmentsBucket,r.paint,i.transform.zoom,g,[s.layoutAttenuationBuffer,s.layoutColorBuffer])}else{const s=e.segmentsBucket;let o=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(o=o.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),n.draw(i,a.gl.TRIANGLES,t.depthMode,$n.disabled,t.blendMode,l?Jn.disabled:Jn.backCW,b,r.id,e.layoutVertexBuffer,e.indexBuffer,s,r.paint,i.transform.zoom,g,o)}};i.uploadCommonUniforms(a,y,p.toUnwrapped(),null,d),f.buildingWithoutFacade&&w(f.buildingWithoutFacade,y),f.buildingWithFacade&&(_!==y&&i.uploadCommonUniforms(a,_,p.toUnwrapped(),null,d),w(f.buildingWithFacade,_))}}function Fa(t,i,n,r,s,o,a,l,c,u,h,d,p,f){const m=t.context.gl,g=t.depthModeForSublayer(1,qn.ReadOnly,m.LEQUAL,!0),_=.1*(1-(y=h))+3*y;var y;const v=t._showOverdrawInspector,x=d,b=new wa;v||Sa(b,t,i,n,r,g,new $n({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),new Wn([m.ONE,m.ONE,m.ONE,m.ONE],e.C.transparent,[!1,!1,!1,!0],m.MIN),Jn.disabled,s,"sdf",o,a,l,c,u,_,x,!1,void 0);{const h=v?$n.disabled:new $n({func:m.EQUAL,mask:255},255,255,m.KEEP,m.DECR,m.DECR),d=v?t.colorModeForRenderPass():new Wn([m.ONE_MINUS_DST_ALPHA,m.DST_ALPHA,m.ONE,m.ONE],e.C.transparent,[!0,!0,!0,!0]);Sa(b,t,i,n,r,g,h,d,Jn.disabled,s,"color",o,a,l,c,u,_,x,!1,void 0)}}const Na=.05,ka=(e,t,i,n,r,s,o,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:r,u_tl_parent:s,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:o,u_merc_center:a,u_cutoff_params:l}),za=(e,t,i,n,r,s,o,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:n,u_color_ramp:s,u_velocity_res:r,u_max_speed:o,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Na,Na]}),Ua=(e,t,i,n,r,s,o,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:n,u_max_speed:r,u_speed_factor:s,u_reset_rate:o,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Na,Na]});var Va=e.ea([{name:"a_index",type:"Int16",components:1}]);class ja{constructor(t,i,n,r){const s={width:n[0],height:n[1],data:null},o=t.gl;this.targetColorTexture=new e.T(t,s,o.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,s,o.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const n=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1});const s=new e.eb;s.reserve(r);for(let e=0;e<r;e++)s.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(s,Va.members,!0),this.particleSegment=e.dB.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function Ga(t,i,n){if(!t)return null;const r=i.getTextureDescriptor(t,n,!0);if(!r)return null;let{texture:s,mix:o,offset:a,tileSize:l,buffer:c,format:u}=r;if(!s||!u)return null;let h=!1;return"uint32"===u&&(h=!0,o[3]=0,o=Fo(e.ec,o,[0,n.paint.get("raster-particle-max-speed")]),a=No(e.ec,a,[0,n.paint.get("raster-particle-max-speed")])),{texture:s,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:h,scale:o,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}function Ha(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),n=i-t,r=.2*e.height,s=t+r;return[t,i,(s-r-t)/n,(s-t)/n]}var Wa="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}";Qr["_prelude_raster_particle.glsl"]||(Qr["_prelude_raster_particle.glsl"]=Wa);var qa={building:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:us("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:us("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:us('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:us("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:us("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:us('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return  clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:us("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:us("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:us("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}")};us(Wa,"");const Xa=e.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),$a=e.ea([{type:"Float32",name:"a_pos_2f",components:2}]);class Za{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const n=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.ee,n=new e.dF;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,$a.members),this.vignetteIdx=t.context.createIndexBuffer(n)}const r=e.dB.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,n);const e={u_vignetteShape:(s={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:s.vignetteColor};n.draw(t,t.context.gl.TRIANGLES,qn.disabled,$n.disabled,Wn.alphaBlended,Jn.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r)}var s}}class Ya{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const n=t.getFreeCameraOptions().position,r=n.toAltitude(),s=n.toLngLat(),o=e.am(s.lng),a=e.am(s.lat),l=t.pixelsPerMeter/i,c=o*e.eg,u=e.eg*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const e=-this._offsetYPrev+u,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=u,this._elevationPrev=r}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Ja(e,t){return[-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Ka(t){const i=e.ef(1323123451230),n=[];for(let r=0;r<t;++r){const t=2*i()-1,r=2*i()-1,s=2*i()-1;n.push(e.cU(t,r,s))}return n}function Qa(t,i,n,r,s){const o=e.aB((s-n)/(r-n),0,1);return(1-o)*t+o*i}class el{constructor(e){this._movement=new Ya,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Za,this._ppmScaleFactor=e}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,i){const n=t.transform;this._movement.update(n,this._ppmScaleFactor);const r=n.starsProjMatrix,s=e.bP([]);e.bR(s,s,e.am(90)-n._pitch),e.bQ(s,s,-n.angle);const o=e.bV(new Float32Array(16),s),a=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),l=e.e9([],a),c=e.aC([],l,o),u=Date.now()/1e3;return this._accumulatedTimeFromStart+=(u-this._prevTime)*i,this._prevTime=u,{projectionMatrix:r,modelviewMatrix:c}}}const tl=e.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]),il={building:t=>({u_matrix:new e.c3(t),u_normal_matrix:new e.c3(t),u_opacity:new e.c1(t),u_faux_facade_ao_intensity:new e.c1(t),u_camera_pos:new e.c0(t),u_tile_to_meter:new e.c1(t),u_facade_emissive_chance:new e.c1(t),u_flood_light_color:new e.c0(t),u_flood_light_intensity:new e.c1(t),u_front_cutoff_params:new e.c0(t)}),buildingBloom:t=>({u_matrix:new e.c3(t)}),buildingDepth:t=>({u_matrix:new e.c3(t)}),rasterParticle:t=>({u_matrix:new e.c3(t),u_normalize_matrix:new e.c3(t),u_globe_matrix:new e.c3(t),u_merc_matrix:new e.c3(t),u_grid_matrix:new e.dq(t),u_tl_parent:new e.c2(t),u_scale_parent:new e.c1(t),u_fade_t:new e.c1(t),u_opacity:new e.c1(t),u_image0:new e.b$(t),u_image1:new e.b$(t),u_raster_elevation:new e.c1(t),u_zoom_transition:new e.c1(t),u_merc_center:new e.c2(t),u_cutoff_params:new e.cS(t)}),rasterParticleTexture:t=>({u_texture:new e.b$(t),u_opacity:new e.c1(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.b$(t),u_particle_texture_side_len:new e.c1(t),u_tile_offset:new e.c2(t),u_velocity:new e.b$(t),u_color_ramp:new e.b$(t),u_velocity_res:new e.c2(t),u_max_speed:new e.c1(t),u_uv_offset:new e.c2(t),u_data_scale:new e.c2(t),u_data_offset:new e.c1(t),u_particle_pos_scale:new e.c1(t),u_particle_pos_offset:new e.c2(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.b$(t),u_particle_texture_side_len:new e.c1(t),u_velocity:new e.b$(t),u_velocity_res:new e.c2(t),u_max_speed:new e.c1(t),u_speed_factor:new e.c1(t),u_reset_rate:new e.c1(t),u_rand_seed:new e.c1(t),u_uv_offset:new e.c2(t),u_data_scale:new e.c2(t),u_data_offset:new e.c1(t),u_particle_pos_scale:new e.c1(t),u_particle_pos_offset:new e.c2(t)}),snowParticle:t=>({u_modelview:new e.c3(t),u_projection:new e.c3(t),u_time:new e.c1(t),u_cam_pos:new e.c0(t),u_velocityConeAperture:new e.c1(t),u_velocity:new e.c1(t),u_horizontalOscillationRadius:new e.c1(t),u_horizontalOscillationRate:new e.c1(t),u_boxSize:new e.c1(t),u_billboardSize:new e.c1(t),u_simpleShapeParameters:new e.c2(t),u_screenSize:new e.c2(t),u_thinningCenterPos:new e.c2(t),u_thinningShape:new e.c0(t),u_thinningAffectedRatio:new e.c1(t),u_thinningParticleOffset:new e.c1(t),u_particleColor:new e.cS(t),u_direction:new e.c0(t)}),rainParticle:t=>({u_modelview:new e.c3(t),u_projection:new e.c3(t),u_time:new e.c1(t),u_cam_pos:new e.c0(t),u_texScreen:new e.b$(t),u_velocityConeAperture:new e.c1(t),u_velocity:new e.c1(t),u_boxSize:new e.c1(t),u_rainDropletSize:new e.c2(t),u_distortionStrength:new e.c1(t),u_rainDirection:new e.c0(t),u_color:new e.cS(t),u_screenSize:new e.c2(t),u_thinningCenterPos:new e.c2(t),u_thinningShape:new e.c0(t),u_thinningAffectedRatio:new e.c1(t),u_thinningParticleOffset:new e.c1(t),u_shapeDirectionalPower:new e.c1(t),u_shapeNormalPower:new e.c1(t),u_mode:new e.c1(t)}),vignette:t=>({u_vignetteShape:new e.c0(t),u_vignetteColor:new e.cS(t)})},nl={drawBuilding:function(e,t,i,n){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);const r=i.paint.get("building-ambient-occlusion-ground-intensity"),s=i.paint.get("building-ambient-occlusion-ground-radius"),o=i.paint.get("building-ambient-occlusion-ground-attenuation"),a=i.paint.get("building-opacity");if(a<=0)return;let l=r>0&&s>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;e.shadowRenderer||(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,n,r,s){for(const o of s){const s=t.getTile(o).getBucket(i);s&&(r&&s.updateReplacement(o,e.replacementSource,n),s.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,n),function(e,t,i,n){for(const r of n){const n=t.getTile(r).getBucket(i);n&&n.needsEvaluation()&&n.uploadUpdatedColorBuffer(e.context)}}(e,t,i,n),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=[],s=e.shadowRenderer.getShadowPassDepthMode();Ba({painter:e,source:t,layer:i,coords:n,defines:r,blendMode:Wn.disabled,depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),g="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),_=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:i.lut).toArray01().slice(0,3),y=i.paint.get("building-flood-light-ground-attenuation"),v=m>0,x=new qn(e.context.gl.LEQUAL,qn.ReadWrite,e.depthRangeFor3D);a<1&&Ba({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:Wn.disabled,depthMode:x,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_,depthOnly:!0});const b=e.colorModeForRenderPass();Ba({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:b,depthMode:x,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_});const w=i.paint.get("building-front-cutoff");Ta(e.transform.pitch,w,!!e.terrain),l&&Fa(e,t,i,n,!0,a,r,s,m,_,o,h),v&&Fa(e,t,i,n,!1,a,r,s,m,_,y,h)}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],s=new qn(e.context.gl.LEQUAL,qn.ReadOnly,e.depthRangeFor3D);Ba({painter:e,source:t,layer:i,coords:n,defines:r,blendMode:Wn.alphaBlended,depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},drawRasterParticle:function(t,i,n,r,s,o){"offscreen"===t.renderPass&&function(t,i,n,r){if(!r.length)return;const s=t.context,o=s.gl,a=i.getSource();if(!(a instanceof xi))return;const l=Math.ceil(Math.sqrt(n.paint.get("raster-particle-count")));let c=n.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(t){const i=t*t,n=new Uint8Array(4*i),r=.9090909090909091;for(let t=0;t<i;t++){const i=r*(e.ed(2*t+0)+Na),s=r*(e.ed(2*t+1)+Na),o=255*i%1,a=255*s%1,l=o,c=s-a/255,u=a;n[4*t+0]=255*(i-o/255),n[4*t+1]=255*l,n[4*t+2]=255*c,n[4*t+3]=255*u}return n}(l);c=n.particlePositionRGBAImage=new e.q({width:l,height:l},t)}let u=n.particleFramebuffer;u?u.width!==l&&(u.destroy(),u=n.particleFramebuffer=s.createFramebuffer(l,l,1,null)):u=n.particleFramebuffer=s.createFramebuffer(l,l,1,null);const h=[];for(const e of r){const t=i.getTile(e);if(!(t instanceof Ci))continue;const r=Ga(t,a,n);if(!r)continue;const o=[t.tileSize,t.tileSize];let u=n.tileFramebuffer;u||(u=n.tileFramebuffer=s.createFramebuffer(o[0],o[1],1,null));let d=t.rasterParticleState;d||(d=t.rasterParticleState=new ja(s,e,o,c));const p=d.update(n.lastInvalidatedAt);d.particleTextureDimension!==l&&d.updateParticleTexture(e,c);const f=d.targetColorTexture;d.targetColorTexture=d.backgroundColorTexture,d.backgroundColorTexture=f;const m=d.particleTexture0;d.particleTexture0=d.particleTexture1,d.particleTexture1=m,h.push([e,r,d,p])}if(0===h.length)return;const d=e.o.now(),p=n.previousDrawTimestamp?.001*(d-n.previousDrawTimestamp):.0167;if(n.previousDrawTimestamp=d,n.hasColorMap()){s.activeTexture.set(o.TEXTURE0+2);let t=n.colorRampTexture;t||(t=n.colorRampTexture=new e.T(s,n.colorRamp,o.RGBA8)),t.bind(o.LINEAR,o.CLAMP_TO_EDGE)}s.bindFramebuffer.set(n.tileFramebuffer.framebuffer),function(t,i,n){const r=t.context,s=r.gl,o=i.tileFramebuffer;r.activeTexture.set(s.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=i.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of n){const[,,n,u]=c;o.colorAttachment0.set(n.targetColorTexture.texture),r.viewport.set([0,0,o.width,o.height]),r.clear({color:e.C.transparent}),u&&(n.backgroundColorTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),l.draw(t,s.TRIANGLES,qn.disabled,$n.disabled,Wn.alphaBlended,Jn.disabled,a,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments))}}(t,n,h),function(t,i,n,r){const s=t.context,o=s.gl,a=n.tileFramebuffer,l="globe"===t.transform.projection.name,c=n.paint.get("raster-particle-max-speed");for(const u of r){const[r,h,d]=u;s.activeTexture.set(o.TEXTURE0+0),h.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a.colorAttachment0.set(d.targetColorTexture.texture);const p=t.getOrCreateProgram("rasterParticleDraw",{defines:h.defines,overrideFog:!1});s.activeTexture.set(o.TEXTURE0+1);const f=h.scalarData?[]:[0,1,2,3].map(t=>e.e2[t](r));f.push(r);const m=r.canonical.x,g=r.canonical.y;for(const e of f){const s=i.getTile(l?e.wrapped():e);if(!s)continue;const a=s.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<<e.canonical.z)*(e.wrap-r.wrap),d=e.canonical.y;a.particleTexture0.bind(o.NEAREST,o.CLAMP_TO_EDGE);const f=za(1,a.particleTexture0.size[0],[u-m,d-g],0,h.texture.size,2,c,h.textureOffset,h.scale,h.offset);p.draw(t,o.POINTS,qn.disabled,$n.disabled,Wn.alphaBlended,Jn.disabled,f,n.id,a.particleIndexBuffer,void 0,a.particleSegment)}}}(t,i,n,h),s.bindFramebuffer.set(n.particleFramebuffer.framebuffer),function(t,i,n,r){const s=t.context,o=s.gl,a=i.paint.get("raster-particle-max-speed"),l=r*i.paint.get("raster-particle-speed-factor")*.15,c=function(e){return Math.pow(e,6)}(.01+1*i.paint.get("raster-particle-reset-rate-factor")),u=i.particleFramebuffer;s.viewport.set([0,0,u.width,u.height]);for(const r of n){const[,n,h]=r;s.activeTexture.set(o.TEXTURE0+0),n.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.activeTexture.set(o.TEXTURE0+1);const d=h.particleTexture0;d.bind(o.NEAREST,o.CLAMP_TO_EDGE);const p=Ua(1,d.size[0],0,n.texture.size,a,l,c,n.textureOffset,n.scale,n.offset);u.colorAttachment0.set(h.particleTexture1.texture),s.clear({color:e.C.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:n.defines}).draw(t,o.TRIANGLES,qn.disabled,$n.disabled,Wn.unblended,Jn.disabled,p,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}}(t,n,h,p)}(t,i,n,r),"translucent"===t.renderPass&&(function(t,i,n,r){const s=t.context,o=s.gl,a=i.getSource().tileSize,l=5*(1-e.ag(e.cx,e.cx+1,t.transform.zoom))*a+n.paint.get("raster-particle-elevation"),c=!t.options.moving,u="globe"===t.transform.projection.name;if(!r.length)return;const[h,d]=t.stencilConfigForOverlap(r),p=[];u&&p.push("PROJECTION_GLOBE_VIEW");const f=t.stencilModeFor3D();for(const r of d){const a=r.toUnwrapped(),d=i.getTile(r);if(!d.rasterParticleState)continue;const m=d.rasterParticleState,g=100;d.registerFadeDuration(g);const _=i.findLoadedParent(r,0),y=ao(d,_,i,t.transform,g);let v,x;t.terrain&&t.terrain.prepareDrawTile(),s.activeTexture.set(o.TEXTURE0),m.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.activeTexture.set(o.TEXTURE1),_&&_.rasterParticleState?(_.rasterParticleState.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),v=Math.pow(2,_.tileID.overscaledZ-d.tileID.overscaledZ),x=[d.tileID.canonical.x*v%1,d.tileID.canonical.y*v%1]):m.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);const b=u?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(a,c),w=t.transform,T=Ha(w),S=e.du(r.canonical),E=e.dv(S.getCenter().lat);let A,M,I,C,P;u?(A=Float32Array.from(e.dx(e.dy(r.canonical))),M=Float32Array.from(w.globeMatrix),I=Float32Array.from(e.dt(w)),C=[e.aG(w.center.lng),e.aJ(w.center.lat)],P=Float32Array.from(e.dw(r.canonical,S,E,w.worldSize/w._pixelsPerMercatorPixel))):(A=new Float32Array(16),M=new Float32Array(9),I=new Float32Array(16),C=[0,0],P=new Float32Array(9));const L=ka(b,A,M,I,P,x||[0,0],e.ai(t.transform.zoom),C,T,v||1,y,l),R=t.isTileAffectedByFog(r),O=t.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:R});if(t.uploadCommonUniforms(s,O,a),u){const e=new qn(o.LEQUAL,qn.ReadOnly,t.depthRangeFor3D),i=0,r=t.globeSharedBuffers;if(r){const[s,a,l]=r.getGridBuffers(E,0!==i);O.draw(t,o.TRIANGLES,e,f,Wn.alphaBlended,t.renderElevatedRasterBackface?Jn.frontCCW:Jn.backCCW,L,n.id,s,a,l)}}else{const e=t.depthModeForSublayer(0,qn.ReadOnly),i=h[r.overscaledZ],{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=t.getTileBoundsBuffers(d);O.draw(t,o.TRIANGLES,e,i,Wn.alphaBlended,Jn.disabled,L,n.id,s,a,l)}}t.resetStencilClippingMasks()}(t,i,n,r),t.style.map.triggerRepaint())},prepareRasterParticle:function(e,t,i){const n=t.getSource();if(!(n instanceof xi&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-particle-array-band")||n.getInitialBand(r);if(null==s)return;const o=t.getIds().map(e=>t.getTileByID(e));for(const t of o)t.updateNeeded(e.id,s)&&n.prepareTile(t,r,e.id,s)},Rain:class extends el{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(t){const i=t.context;if(!this.particlesVx){const t=Ka(this.particlesCount),n=new e.eh,r=new e.dF;let s=0;const o=e.ef(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=[2*o()-1,o(),o(),o()];n.emplaceBack(i[0],i[1],i[2],-1,-1,...a),n.emplaceBack(i[0],i[1],i[2],1,-1,...a),n.emplaceBack(i[0],i[1],i[2],1,1,...a),n.emplaceBack(i[0],i[1],i[2],-1,1,...a),r.emplaceBack(s+0,s+1,s+2),r.emplaceBack(s+0,s+2,s+3),s+=4}this.particlesVx=i.createVertexBuffer(n,Xa.members),this.particlesIdx=i.createIndexBuffer(r)}}getDrawParams(e){if(!e.style.rain)return null;const t=e.style.rain.state,i=structuredClone(this._params);i.intensity=t.density,i.timeFactor=t.intensity,i.color=structuredClone(t.color),i.screenThinning.intensity=t.centerThinning,i.dropletSizeX=t.dropletSize[0],i.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],i.distortionStrength=100*t.distortionStrength;const n=structuredClone(this._vignetteParams);return n.strength=1,n.color=structuredClone(t.vignetteColor),{params:i,vignetteParams:n,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(t){const i=this.getDrawParams(t);if(!i)return;const{params:n,revealParams:r,direction:s,vignetteParams:o}=i,a=t.transform.zoom;if(r.revealStart>a)return;const l=Qa(0,1,r.revealStart,r.revealStart+r.revealRange,a);if(!this.particlesVx||!this.particlesIdx)return;o.strength*=l;const c=this.updateOnRender(t,n.timeFactor),u=t.context,h=u.gl,d=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(u,{width:t.width,height:t.height,data:null},h.RGBA8)),n.distortionStrength>0&&(u.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const p=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(u,p),u.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const f=[n.color.r,n.color.g,n.color.b,n.color.a],m=(i,r)=>{const o=Ja(this._movement.getPosition(),i),a=n.dropletSizeX,l=n.dropletSizeX*n.dropletSizeYScale,u=t.width/2,m=t.height/2,g=Qa(0,n.screenThinning.start,0,1,n.screenThinning.intensity),_=Qa(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),y=Qa(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),v=(x={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:o,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,boxSize:i,rainDropletSize:[a,l],distortionStrength:n.distortionStrength,rainDirection:s,color:f,screenSize:[d.width,d.height],thinningCenterPos:[u,m],thinningShape:[g,_,Math.pow(10,n.screenThinning.fadePower)],thinningAffectedRatio:n.screenThinning.affectedRatio,thinningParticleOffset:y,shapeDirectionalPower:n.shapeDirPower,shapeNormalPower:n.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(x.modelview),u_projection:Float32Array.from(x.projection),u_time:x.time,u_cam_pos:x.camPos,u_texScreen:0,u_velocityConeAperture:x.velocityConeAperture,u_velocity:x.velocity,u_boxSize:x.boxSize,u_rainDropletSize:x.rainDropletSize,u_distortionStrength:x.distortionStrength,u_rainDirection:x.rainDirection,u_color:x.color,u_screenSize:x.screenSize,u_thinningCenterPos:x.thinningCenterPos,u_thinningShape:x.thinningShape,u_thinningAffectedRatio:x.thinningAffectedRatio,u_thinningParticleOffset:x.thinningParticleOffset,u_shapeDirectionalPower:x.shapeDirectionalPower,u_shapeNormalPower:x.shapeNormalPower,u_mode:x.mode});var x;const b=Math.round(n.intensity*this.particlesCount),w=e.dB.simpleSegment(0,0,4*b,2*b);p.draw(t,h.TRIANGLES,qn.disabled,$n.disabled,Wn.alphaBlended,Jn.disabled,v,"rain_particles",this.particlesVx,this.particlesIdx,w)};n.distortionStrength>0&&m(n.boxSize,!0),m(n.boxSize,!1),this._vignette.draw(t,o)}},Snow:class extends el{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(t){const i=t.context;if(!this.particlesVx){const t=Ka(this.particlesCount),n=new e.ei,r=new e.dF;let s=0;const o=e.ef(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=o(),l=o(),c=o(),u=[e/t.length,a,l,c],h=[o(),o()];n.emplaceBack(i[0],i[1],i[2],-1,-1,...u,...h),n.emplaceBack(i[0],i[1],i[2],1,-1,...u,...h),n.emplaceBack(i[0],i[1],i[2],1,1,...u,...h),n.emplaceBack(i[0],i[1],i[2],-1,1,...u,...h),r.emplaceBack(s+0,s+1,s+2),r.emplaceBack(s+0,s+2,s+3),s+=4}this.particlesVx=i.createVertexBuffer(n,tl.members),this.particlesIdx=i.createIndexBuffer(r)}}getDrawParams(e){if(!e.style.snow)return null;const t=e.style.snow.state,i=structuredClone(this._params);i.intensity=t.density,i.timeFactor=t.intensity,i.color=structuredClone(t.color),i.screenThinning.intensity=t.centerThinning,i.billboardSize=2.79*t.flakeSize;const n=structuredClone(this._vignetteParams);return n.strength=1,n.color=structuredClone(t.vignetteColor),{params:i,vignetteParams:n,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(t){const i=this.getDrawParams(t);if(!i)return;const{params:n,revealParams:r,direction:s,vignetteParams:o}=i,a=t.transform.zoom;if(r.revealStart>a)return;const l=Qa(0,1,r.revealStart,r.revealStart+r.revealRange,a);o.strength*=l;const c=this.updateOnRender(t,n.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const u=t.context,h=u.gl,d=t.transform,p=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(u,p),((i,n,r)=>{const o=Ja(this._movement.getPosition(),i),a=d.width/2,l=d.height/2,u=Qa(0,r.screenThinning.start,0,1,r.screenThinning.intensity),f=Qa(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),m=Qa(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),g=(_={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:o,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,horizontalOscillationRadius:r.horizontalOscillationRadius,horizontalOscillationRate:r.horizontalOscillationRate,boxSize:i,billboardSize:1*r.billboardSize,simpleShapeParameters:[r.shapeFadeStart,r.shapeFadePower],screenSize:[d.width,d.height],thinningCenterPos:[a,l],thinningShape:[u,f,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:m,color:[r.color.r,r.color.g,r.color.b,r.color.a],direction:s},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const y=Math.round(r.intensity*this.particlesCount),v=e.dB.simpleSegment(0,0,4*y,2*y);this.particlesVx&&this.particlesIdx&&p.draw(t,h.TRIANGLES,qn.disabled,$n.disabled,Wn.alphaBlended,Jn.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,v)})(n.boxSize,0,n),this._vignette.draw(t,o)}},shaders:qa,programUniforms:il};function rl(t){return[t[0]*e.ej,t[1]*e.ej,t[2]*e.ej,0]}function sl(t,i,n,r,s,o,a,l,c){const u=r.getSource(),h=n.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=r.getTile(i)),u instanceof e.aY?(p=u.texture,f=e.dz(0,0,n.transform)):d&&i&&(p=d.texture,f=e.dz(i.canonical.z,i.canonical.x,n.transform)),!p||!f)return;t||(f=e.cE(e.bd(),f,[1,-1,1]));const m=n.context,g=m.gl,_="nearest"===s.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,y=n.colorModeForDrapableLayerRenderPass(o),v=a.defines;v.push("GLOBE_POLES");const x=new qn(g.LEQUAL,qn.ReadWrite,n.depthRangeFor3D),b=n.transform.expandedFarZProjMatrix,w=Float32Array.from(e.dx(e.dy(new e.cp(0,0,0))));n.terrain&&n.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),p.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),p.bind(_,g.CLAMP_TO_EDGE),"useMipmap"in p&&m.extTextureFilterAnisotropic&&n.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[T,S,E,A]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),M=s.paint.get("raster-elevation");let I;t?(I=T,n.renderDefaultNorthPole=0!==M):(I=S,n.renderDefaultSouthPole=0!==M);const C=rl(a.mix),P=((e,t,i,n,r,s,o,a,l,c,u,h,d,p)=>zo(e,t,i,n,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],l,2,u,h,d,1,0,p))(n,b,w,f,e.ai(n.transform.zoom),0,s,0,M,0,C,a.offset,a.range,o),L=n.getOrCreateProgram("raster",{defines:v});n.uploadCommonUniforms(m,L,null),L.draw(n,g.TRIANGLES,x,c,y,l,P,s.id,I,E,A)}function ol(e){if(e.isOrthographic)return[0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),n=i-t,r=.2*e.height,s=t+r;return[t,i,(s-r-t)/n,(s-t)/n]}function al(e,t,i,n){if(e)return t instanceof xi&&e instanceof Ci?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:rl(n.mix),offset:n.offset,buffer:0,tileSize:1}}const ll=e.bA(new Float32Array(16)),cl=new e.C(1,0,0,1),ul=new e.C(0,1,0,1),hl=new e.C(0,0,1,1),dl=new e.C(1,0,1,1),pl=new e.C(0,1,1,1);function fl(t,i,n,r,s,o,a){const l=t.context,c=t.transform,u=l.gl,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[];let p=e.bb(n.projMatrix);if(h&&e.ai(c.zoom)>0){const t=e.ek(n.canonical,c),i=e.el(t);p=e.aC(new Float32Array(16),c.globeMatrix,i),e.aC(p,c.projMatrix,p)}const f=e.bd();f[12]+=2*s/(e.o.devicePixelRatio*c.width),f[13]+=2*o/(e.o.devicePixelRatio*c.height),e.aC(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),g=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=qn.disabled,y=$n.disabled,v=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const b=g._tileDebugBuffer||t.debugBuffer,w=g._tileDebugIndexBuffer||t.debugIndexBuffer,T=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,y,v,Jn.disabled,Oo(p,r.toPremultipliedRenderColor(null)),x,b,w,T,null,null,null,[g._globeTileDebugBorderBuffer]),a){const e=g.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(r+=` => ${n.overscaledZ}`),r+=` ${g.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,r)}const S=i.getTile(n).tileSize,E=512/Math.min(S,512)*(n.overscaledZ/c.zoom)*.5,A=g._tileDebugTextBuffer||t.debugBuffer,M=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,I=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,y,Wn.alphaBlended,Jn.disabled,Oo(p,e.C.transparent.toPremultipliedRenderColor(null),E),x,A,M,I,null,null,null,[g._globeTileDebugTextBuffer])}function ml(e,t,i,n){_l(e,0,t+i/2,e.transform.width,i,n)}function gl(e,t,i,n){_l(e,t-i/2,0,i,e.transform.height,n)}function _l(t,i,n,r,s,o){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,n*e.o.devicePixelRatio,r*e.o.devicePixelRatio,s*e.o.devicePixelRatio),a.clear({color:o}),l.disable(l.SCISSOR_TEST)}const yl=e.ea([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:vl}=yl;function xl(e,t,i,n){e.emplaceBack(t,i,n)}class bl{constructor(t){this.vertexArray=new e.em,this.indices=new e.dF,xl(this.vertexArray,-1,-1,1),xl(this.vertexArray,1,-1,1),xl(this.vertexArray,-1,1,1),xl(this.vertexArray,1,1,1),xl(this.vertexArray,-1,-1,-1),xl(this.vertexArray,1,-1,-1),xl(this.vertexArray,-1,1,-1),xl(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,vl),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.dB.simpleSegment(0,0,36,12)}}function wl(t,i,n,r,s,o){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.ep(e.dH(),r),s,u,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+o,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,qn.disabled,$n.disabled,Wn.unblended,Jn.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Tl=e.ea([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Sl{constructor(t){const i=new e.eq;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new e.dF;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Tl.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.dB.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const El=e.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class Al{constructor(){this.colorModeAlphaBlendedWriteRGB=new Wn([1,Hn,1,Hn],e.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Wn([1,0,1,0],e.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null}update(t){this._painter=t;const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Sl(i);let t=this.params;const n=t.sizeRange,r=t.intensityRange,s=function(t){const i=e.ef(30),n=[];for(let r=0;r<t;++r){const t=2*Math.PI*i(),r=Math.acos(1-2*i())-.5*Math.PI;n.push(e.cU(Math.cos(r)*Math.cos(t),Math.cos(r)*Math.sin(t),Math.sin(r)))}return n}(t.starsCount),o=e.ef(300),a=new e.er,l=new e.dF;let c=0;for(let t=0;t<s.length;++t){const i=e.bN([],s[t],200),u=Math.max(0,1+.01*n*(1*o()-.5)),h=Math.max(0,1+.01*r*(1*o()-.5));a.emplaceBack(i[0],i[1],i[2],-1,-1,u,h),a.emplaceBack(i[0],i[1],i[2],1,-1,u,h),a.emplaceBack(i[0],i[1],i[2],1,1,u,h),a.emplaceBack(i[0],i[1],i[2],-1,1,u,h),l.emplaceBack(c+0,c+1,c+2),l.emplaceBack(c+0,c+2,c+3),c+=4}this.starsVx=i.createVertexBuffer(a,El.members),this.starsIdx=i.createIndexBuffer(l),this.starsSegments=e.dB.simpleSegment(0,0,a.length,l.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(t,i){const n=t.context,r=n.gl,s=t.transform,o=new qn(r.LEQUAL,qn.ReadOnly,[0,1]),a=e.ai(s.zoom),l=t.style.getLut(i.scope),c="none"===i.properties.get("color-use-theme"),u=i.properties.get("color").toNonPremultipliedRenderColor(c?null:l),h="none"===i.properties.get("high-color-use-theme"),d=i.properties.get("high-color").toNonPremultipliedRenderColor(h?null:l),p="none"===i.properties.get("space-color-use-theme"),f=i.properties.get("space-color").toNonPremultipliedRenderColor(p?null:l),m=5e-4,g=e.es(i.properties.get("horizon-blend"),0,1,m,.25),_=e.ds(t,n,s)&&g===m?s.worldSize/(2*Math.PI*1.025)-1:s.globeRadius,y=t.frameCounter/1e3%1,v=e.af(s.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(_,2)),b=Math.acos(x/v),w=e=>{const i="globe"===s.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,n,r,s,o,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:n,u_horizon:r,u_transition:s,u_fadeout_range:o,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(s.frustumCorners.TL,s.frustumCorners.TR,s.frustumCorners.BR,s.frustumCorners.BL,s.frustumCorners.horizon,a,g,u,d,f,y,b);t.uploadCommonUniforms(n,l);const h=this.atmosphereBuffer;h&&l.draw(t,r.TRIANGLES,o,$n.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Jn.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",h.vertexBuffer,h.indexBuffer,h.segments)};w(!1),w(!0)}drawStars(t,i){const n=e.aB(i.properties.get("star-intensity"),0,1);if(0===n)return;const r=t.context,s=r.gl,o=t.transform,a=t.getOrCreateProgram("stars"),l=e.bP([]);e.bR(l,l,-o._pitch),e.bQ(l,l,-o.angle),e.bR(l,l,e.am(o._center.lat)),e.et(l,l,-e.am(o._center.lng));const c=e.bV(new Float32Array(16),l),u=e.aC([],o.starsProjMatrix,c),h=e.ep([],c),d=e.eu([],h);let p=this.params.sizeMultiplier;const f=[0,1,0];e.dJ(f,f,d),e.bN(f,f,p);const m=[1,0,0];e.dJ(m,m,d),e.bN(m,m,p);const g=(_=f,y=m,v=n,{u_matrix:Float32Array.from(u),u_up:_,u_right:y,u_intensity_multiplier:v});var _,y,v;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,s.TRIANGLES,qn.disabled,$n.disabled,this.colorModeAlphaBlendedWriteRGB,Jn.disabled,g,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Ml{constructor(){this.visibleTiles=[]}updateBorders(t,i){const n=[],r=[],s=t._getRenderableCoordinates(!1,!0);for(const e of s){const s=t.getTile(e);if(!s.hasData())continue;const o=s.getBucket(i);o&&(o.isEmpty()||(n.push(e.key),r.push({bucket:o,tileID:e.canonical})))}let o=n.length!==this.visibleTiles.length;if(!o){n.sort();for(let e=0;e<n.length;e++)if(n[e]!==this.visibleTiles[e]){o=!0;break}}if(!o)return;const a=new Set;this.visibleTiles=n,r.sort((e,t)=>e.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,n=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?n.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.ev,!1),r.updateFootprintHiddenFlags(n,e.ev,!0)}}}const Il=new Float64Array(16),Cl=new Float64Array(16),Pl=new Float64Array(16),Ll=new Float32Array(16),Rl=[0,0,0];function Ol(t,i,n){const r=n.cameraWorldSizeForFog/n.worldSize;return e.cE(t,n.worldToFogMatrix,[r,r,1]),e.aC(t,t,i),t}function Dl(t,i,n,r,s){const o=n.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=o.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=o;function p(e,i,n){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+n),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:n,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,n,r)}}p(l,"HAS_TEXTURE_u_baseColorTexture",5),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",6),p(u,"HAS_TEXTURE_u_normalTexture",7),p(h,"HAS_TEXTURE_u_occlusionTexture",8),p(d,"HAS_TEXTURE_u_emissionTexture",9),s&&(s.texture||(s.texture=new e.dU(r.context,s.image,[s.image.height,s.image.height,s.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+10),s.texture&&s.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),n.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(n.texcoordBuffer)),n.colorBuffer&&(t.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(n.colorBuffer)),n.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(n.normalBuffer)),n.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(n.pbrBuffer)),"OPAQUE"!==o.alphaMode&&"MASK"!==o.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),o.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Bl(t,i,n,r,s,o){const a=t.modelOpacity,l=i.context,c=new qn(i.context.gl.LEQUAL,t.isLightMesh?qn.ReadOnly:qn.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;"pixels"===i.transform.projection.zAxisUnit?Il.set(t.nodeModelMatrix):e.aC(Il,r.zScaleMatrix,t.nodeModelMatrix),e.aC(Il,r.negCameraPosMatrix,Il),e.ba(Cl,Il),e.e9(Cl,Cl);const m="none"===n.paint.get("model-color-use-theme").constantOr("default"),g=n.paint.get("model-emissive-strength").constantOr(0),_=qo(t.worldViewProjection,Il,Cl,null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,g,n,void 0,void 0,t.materialOverride,t.modelColor),y={defines:[]},v=[],x=i.shadowRenderer;x&&(x.useNormalOffset=!1),Dl(y.defines,v,h,i,m?null:n.lut);let b=null;if(f&&(b=Ol(Pl,t.nodeModelMatrix,i.transform),"globe"!==u.projection.name)){const e=h.aabb.min,t=h.aabb.max,[i,n]=f.getOpacityForBounds(b,e[0],e[1],t[0],t[1]);y.overrideFog=i>=Wt||n>=Wt}const w=ar(i,n.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const T=i.getOrCreateProgram("model",y);i.uploadCommonUniforms(l,T,null,b,w),"shadow"!==i.renderPass&&x&&x.setupShadowsFromMatrix(t.nodeModelMatrix,T),T.draw(i,l.gl.TRIANGLES,c,s,o,h.material.doubleSided?Jn.disabled:Jn.backCCW,_,n.id,h.vertexBuffer,h.indexBuffer,h.segments,n.paint,i.transform.zoom,void 0,v)}function Fl(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function Nl(t,i,n,r,s,o,a,l,c,u){const h=t.transform,d=!!i.isGeometryBloom&&i.isGeometryBloom;if(d&&"shadow"===t.renderPass)return;const p="globe"===h.projection.name?e.eD(n,h):[...n];e.aC(p,p,i.globalMatrix);const f=e.aC([],r,p);if(i.meshes)for(const t of i.meshes){const r=l.get(t.material.name);if(r&&r.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:s,worldViewProjection:f,nodeModelMatrix:p,isLightMesh:d,materialOverride:r,modelOpacity:c,modelColor:u,node:i,modelMatrix:n});continue}const m=e.ae([],t.centroid,f);!h.isOrthographic&&m[2]<=0||o.push({mesh:t,depth:m[2],modelIndex:s,worldViewProjection:f,nodeModelMatrix:p,isLightMesh:d,materialOverride:r,modelOpacity:c,modelColor:u,node:i,modelMatrix:n})}if(i.children)for(const e of i.children)Nl(t,e,n,r,s,o,a,l,c,u)}function kl(e,t,i,n){const r=i.shadowRenderer;if(!r)return;const s=r.getShadowPassDepthMode(),o=r.calculateShadowPassMatrixFromMatrix(t),a=Xo(o);i.getOrCreateProgram("modelDepth").draw(i,i.context.gl.TRIANGLES,s,$n.disabled,Wn.disabled,Jn.disabled,a,n.id,e.vertexBuffer,e.indexBuffer,e.segments,n.paint,i.transform.zoom,void 0,void 0)}function zl(t,i,n,r){const s=function(t,i){if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;const n=t.context,r=i.footprint.vertices,s=i.footprint.indices,o=new e.dE;o.reserve(r.length);for(const e of r)o.emplaceBack(e.x,e.y);const a=new e.dF;a.reserve(s.length);for(let e=0;e<s.length;e+=3)a.emplaceBack(s[e],s[e+1],s[e+2]);const l=n.createVertexBuffer(o,e.dA.members),c=n.createIndexBuffer(a),u=e.dB.simpleSegment(0,0,r.length,s.length),h=i.id||i.name||"footprint";let d;const p=parseInt(h,10);d=isNaN(p)?function(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return t}(h):p;const f=e.ed(d),m=e.ed(d+1),g=e.ed(d+2);return i.footprintDebugMesh={vertexBuffer:l,indexBuffer:c,segments:u,color:new e.C(f,m,g,.5)},i.footprintDebugMesh}(t,n);if(!s)return;const o=t.context,a=o.gl,l=t.getOrCreateProgram("debug"),c=s.color,u=qn.disabled;o.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),l.draw(t,a.TRIANGLES,u,$n.disabled,Wn.alphaBlended,Jn.disabled,Oo(r,c.toPremultipliedRenderColor(null)),"$debug",s.vertexBuffer,s.indexBuffer,s.segments)}function Ul(e,t,i,n,r,s){for(const o of r){const r=Object.assign({},n);r.part=o;const a={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};s.set(o,l)}}function Vl(e,t,i,n,r,s){for(const o of r){const r=Object.assign({},n);r.part=o;const a={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};s.set(o,l)}}function jl(e,t,i,n,r){let s=!1;for(const i of n)1!==i.modelOpacity&&(Bl(i,e,t,r[i.modelIndex],$n.disabled,Wn.disabled),s=!0);for(const i of n)Bl(i,e,t,r[i.modelIndex],1!==i.modelOpacity?e.stencilModeFor3D():$n.disabled,e.colorModeForRenderPass());s&&e.resetStencilClippingMasks();const o=Wn.additive;for(const n of i)Bl(n,e,t,r[n.modelIndex],$n.disabled,n.isLightMesh?o:e.colorModeForRenderPass())}function Gl(t,i,n){const r=i.updateZoomBasedPaintProperties(),s=function(t,i,n){let r,s,o,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,s=i.findDEMTileFor(n);s&&s.dem?r=e.eF.create(i,n,s):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;e<t.instancedDataArray.length;++e){const n=(r?a*r.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=n,s=s?Math.min(i.terrainElevationMin,n):n,o=o?Math.max(i.terrainElevationMax,n):n}}return i.terrainElevationMin=s||0,i.terrainElevationMax=o||0,i.validForExaggeration=a,i.validForDEMTile=r&&r._demTile?{id:r._demTile.tileID,timestamp:r._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,i,n);(r||s)&&(i.uploaded=!1,i.upload(t.context))}const Hl={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.cY([0,0,0],[e.ak,e.ak,0])};function Wl(t,i){const n=1<<t.canonical.z,r=i.getFreeCameraOptions().position,s=i.elevation,o=t.canonical.x/n,a=(t.canonical.x+1)/n,l=t.canonical.y/n,c=(t.canonical.y+1)/n;let u=i._centerAltitude;if(s){const e=s.getMinMaxForTile(t);e&&e.max>u&&(u=e.max)}const h=e.aB(r.x,o,a)-r.x,d=e.aB(r.y,l,c)-r.y,p=e.bY(u,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function ql(e,t,i,n,r,s,o){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new qn(a.gl.LEQUAL,qn.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(s),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let g,_,y;const v=!d&&n.instancedDataArray.length>20;v&&f.push("INSTANCED_ARRAYS");const x=ar(e,t.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)g=e.getOrCreateProgram("modelDepth",{defines:f}),_=Xo(o.shadowTileMatrix,o.shadowTileMatrix,i.globalMatrix),y=Wn.disabled;else{Dl(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),g=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const n=p.material,l=n.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);_=qo(s.expandedProjMatrix,i.globalMatrix,Ll,null,e,u,l.baseColorFactor,n.emissiveFactor,l.metallicFactor,l.roughnessFactor,n,d,t,r),c&&(o.shadowUniformsInitialized?g.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(s.toUnwrapped(),g,"model-tile"),o.shadowUniformsInitialized=!0)),y=x.shouldRenderCutoff||u<1||"OPAQUE"!==n.alphaMode?Wn.alphaBlended:Wn.unblended}e.uploadCommonUniforms(a,g,s.toUnwrapped(),null,x);const b=p.material.doubleSided?Jn.disabled:Jn.backCCW;if(v)m.push(n.instancedDataBuffer),g.draw(e,a.gl.TRIANGLES,u,$n.disabled,y,b,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,n.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let r=0;r<n.instancedDataArray.length;++r)_[i]=new Float32Array(n.instancedDataArray.arrayBuffer,64*r,16),g.draw(e,a.gl.TRIANGLES,u,$n.disabled,y,b,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m)}}if(i.children)for(const a of i.children)ql(e,t,a,n,r,s,o)}const Xl=[1,-1,1];function $l(e,t,i,n){const r=e.node;if(r.lodMeshes&&r.lodMeshes.length>0)if(e.targetLod<0)e.targetLod=t>n?1:0;else{const r=i/1e3;e.targetLod=t>n?Math.min(e.targetLod+r,1):Math.max(e.targetLod-r,0)}else e.targetLod=0}function Zl(t,i,n,r){if(!n.modelManager)return!0;const s=n.modelManager;if(!n.shadowRenderer)return!0;const o=n.shadowRenderer,a=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=s.getModel(i,r);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c)}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.ae(a.min,a.min,i.tileMatrix),e.ae(a.max,a.max,i.tileMatrix);const u=a.intersects(o.getCurrentCascadeFrustum());return 0===n.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===u),0===u}function Yl(t,i){const n=t.uniformValues.u_cutoff_params[0],r=t.uniformValues.u_cutoff_params[1],s=t.uniformValues.u_cutoff_params[2],o=t.uniformValues.u_cutoff_params[3];return r===n||o===s?1:e.aB(((i-n)/(r-n)-s)/(o-s),0,1)}function Jl(t,i,n,r){if(i.pitch<20)return 1;const s=i.getWorldToCameraMatrix();e.aC(s,s,t);const o=e.bw(n.min[0],n.min[1],n.min[2],1);let a=e.aD(e.bI(),o,s),l=a,c=a;o[1]=n.max[1],a=e.aD(e.bI(),o,s),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,o[0]=n.max[0],a=e.aD(e.bI(),o,s),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,o[1]=n.min[1],a=e.aD(e.bI(),o,s),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c;const u=e.aB(r[0],0,1),h=100*i.pixelsPerMeter*e.aB(r[1],0,1),d=e.aB(r[2],0,1),p=e.eG(e.bI(),l,c,u),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===h)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/h,_=(e,t,i)=>(1-i)*e+i*t,y=e.aB(_(1,d,g),d,1);return _(1,y,e.aB((i.pitch-20)/20,0,1))}class Kl{}class Ql{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,n){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=n.gl,s=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),o=new ArrayBuffer(s),a=new Int16Array(o);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(o));const l=new e.eI;for(let e=0;e<s/2;e+=3){const t=a[e],i=a[e+1],n=a[e+2];l.emplaceBack(t,i),l.emplaceBack(i,n),l.emplaceBack(n,t)}const c=n.bindVertexArrayOES.current,u=new Kl;return u.buf=new Zo(n,l),u.lastUsedFrameIdx=t,this._storage.set(i.id,u),n.bindVertexArrayOES.set(c),u.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class ec{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const tc={symbol:function(t,i,n,r,s){if("translucent"!==t.renderPass)return;const o=$n.disabled,a=t.colorModeForRenderPass(),l=n.layout.get("text-variable-anchor"),c=n.layout.get("text-size-scale-range"),u=e.aB(t.scaleFactor,c[0],c[1]);l&&function(t,i,n,r,s,o,a,l){const c=i.transform,u="map"===s,h="map"===o;for(const i of t){const t=r.getTile(i),s=t.getBucket(n);if(!s||!s.text||!s.text.segments.get().length)continue;const o=e.bl(s.textSizeData,c.zoom,l),d=Yi(i,s.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=Qi(d,t.tileID.canonical,h,u,c,s.getProjection(),p),m=s.hasIconTextFit()&&s.hasIconData();o&&sa(s,u,h,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),o,m)}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),s,u);const h=0!==n.paint.get("icon-opacity").constantOr(1),d=0!==n.paint.get("text-opacity").constantOr(1);void 0!==n.layout.get("symbol-sort-key").constantOr(1)&&(h||d)?oa(t,i,n,r,o,a):(h&&oa(t,i,n,r,o,a,{onlyIcons:!0}),d&&oa(t,i,n,r,o,a,{onlyText:!0})),i.map.showCollisionBoxes&&(ta(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),ta(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const s=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1),c=n.paint.get("circle-emissive-strength");if(0===s.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=n.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,qn.ReadOnly),g=new qn(t.context.gl.LEQUAL,qn.ReadOnly,t.depthRangeFor3D),_="none"===f||p?m:g,y=$n.disabled,v=t.colorModeForDrapableLayerRenderPass(c),x="globe"===d.projection.name,b=[e.aG(d.center.lng),e.aJ(d.center.lat)],w=[];for(let s=0;s<r.length;s++){const o=r[s],a=i.getTile(o),c=a.getBucket(n);if(!c||c.projection.name!==d.projection.name)continue;const u=c.programConfigurations.get(n.id),h=c.layoutVertexBuffer,p=c.globeExtVertexBuffer,f=c.indexBuffer,m=e.dV(n),g=[p],_=t.isTileAffectedByFog(o);x&&m.push("PROJECTION_GLOBE_VIEW"),m.push("DEPTH_D24"),t.terrain&&d.depthOcclusionForSymbolsAndCircles&&m.push("DEPTH_OCCLUSION"),c.hasElevation&&!t.terrain&&(m.push("ELEVATED_ROADS"),g.push(c.elevatedLayoutVertexBuffer));const y=t.getOrCreateProgram("circle",{config:u,defines:m,overrideFog:_}),v=d.projection.createInversionMatrix(d,o.canonical),T={programConfiguration:u,program:y,layoutVertexBuffer:h,dynamicBuffers:g,indexBuffer:f,uniformValues:e.dW(t,o,a,v,b,n),tile:a};if(l){const t=c.segments.get();for(const i of t)w.push({segments:new e.dB([i]),sortKey:i.sortKey,state:T})}else w.push({segments:c.segments,sortKey:0,state:T})}l&&w.sort((e,t)=>e.sortKey-t.sortKey);const T={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of w){const{programConfiguration:i,program:r,layoutVertexBuffer:s,dynamicBuffers:o,indexBuffer:a,uniformValues:l,tile:c}=e.state,p=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,T),t.uploadCommonUniforms(u,r,c.tileID.toUnwrapped()),r.draw(t,h.TRIANGLES,_,y,v,Jn.disabled,l,n.id,s,a,p,n.paint,d.zoom,i,o)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,o=s.gl,a=$n.disabled,l=new Wn([o.ONE,o.ONE,o.ONE,o.ONE],e.C.transparent,[!0,!0,!0,!0]),c="globe"===t.transform.projection.name?.5:.25;n.heatmapFbo=Ko.createWithTexture(s,n.heatmapFbo,t.width*c,t.height*c),s.clear({color:e.C.transparent});const u=t.transform,h="globe"===u.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[],p=h?Jn.frontCCW:Jn.disabled,f=[e.aG(u.center.lng),e.aJ(u.center.lat)];for(let e=0;e<r.length;e++){const c=r[e];if(i.hasRenderableParent(c))continue;const m=i.getTile(c),g=m.getBucket(n);if(!g||g.projection.name!==u.projection.name)continue;const _=t.isTileAffectedByFog(c),y=g.programConfigurations.get(n.id),v=t.getOrCreateProgram("heatmap",{config:y,defines:d,overrideFog:_}),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,v),t.uploadCommonUniforms(s,v,c.toUnwrapped());const b=u.projection.createInversionMatrix(u,c.canonical);v.draw(t,o.TRIANGLES,qn.disabled,a,l,p,Bo(t,c,m,b,f,x,n.paint.get("heatmap-intensity")),n.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,n.paint,t.transform.zoom,y,h?[g.globeExtVertexBuffer]:null)}s.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const n=t.context,r=n.gl,s=i.heatmapFbo;if(!s)return;n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,s.colorAttachment0.get()),n.activeTexture.set(r.TEXTURE1);let o=i.colorRampTexture;o||(o=i.colorRampTexture=new e.T(n,i.colorRamp,r.RGBA8)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,r.TRIANGLES,qn.disabled,$n.disabled,t.colorModeForRenderPass(),Jn.disabled,((e,t)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))},line:function(e,t,i,n){const r=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===r.constantOr(1)||0===s.constantOr(1))return;const o=i.paint.get("line-blend-mode"),a=e.terrain&&e.terrain.renderingToTexture;if("default"===o||"globe"===e.transform.projection.name)"translucent"===e.renderPass&&la(e,t,i,n);else{if(a)return void function(e,t,i,n,r){if("translucent"!==e.renderPass)return;const s=e.context,o=s.gl,a=e.terrain;if(!a)return;const l=s.bindFramebuffer.current,c="mrt-fallback"===e.emissiveMode,u=a.drapeBufferSize[0],h=a.drapeBufferSize[1];i.lineBlendFbos||(i.lineBlendFbos=new ca),i.lineBlendFbos.drapeFbo=Ko.createWithTexture(s,i.lineBlendFbos.drapeFbo,u,h,!0),c&&o.drawBuffers([o.COLOR_ATTACHMENT0]),s.clear({color:ha[r].clearColor,depth:1,stencil:0});const d=e.currentStencilSource,p=e._tileClippingMaskIDs,f=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1;const m=e._terrain;e._terrain=null,e._renderTileClippingMasks(i,t,n),la(e,t,i,n,pa(r,e.context),!0),e._terrain=m,e.currentStencilSource=d,e._tileClippingMaskIDs=p,e.nextStencilID=f,c&&o.drawBuffers([o.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1]);const g=a.drapeBufferSize,_=i.lineBlendFbos&&i.lineBlendFbos.drapeFbo;_&&("additive"===r&&ma(e,i,_),ga(e,i,r,_,l,g))}(e,t,i,n,o);if("offscreen"===e.renderPass)return void function(e,t,i,n,r){const s=e.context,o=Math.ceil(e.width),a=Math.ceil(e.height);i.lineBlendFbos||(i.lineBlendFbos=new ca),i.lineBlendFbos.fbo=Ko.createWithTexture(s,i.lineBlendFbos.fbo,o,a,!0),s.clear({color:ha[r].clearColor,depth:1,stencil:0});const l=e.currentStencilSource,c=e._tileClippingMaskIDs,u=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1,e._renderTileClippingMasks(i,t,n);const h=e.renderPass;e.renderPass="translucent",la(e,t,i,n,pa(r,e.context)),e.renderPass=h,e.currentStencilSource=l,e._tileClippingMaskIDs=c,e.nextStencilID=u,s.viewport.set([0,0,e.width,e.height]),"additive"===r&&ma(e,i,i.lineBlendFbos.fbo)}(e,t,i,n,o);if("translucent"===e.renderPass){const t=i.lineBlendFbos&&i.lineBlendFbos.fbo;return void(t&&ga(e,i,o,t,null))}}},fill:function(t,i,n,r){const s=n.paint.get("fill-color"),o=n.paint.get("fill-opacity");if(0===o.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=n.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===s.constantOr(e.C.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";let h="none";"none"!==n.layout.get("fill-elevation-reference")?h="road":0!==n.paint.get("fill-z-offset").constantOr(1)&&(h="offset");const d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:n,coords:r,colorMode:l,elevationType:h,terrainEnabled:d,pass:u};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===h&&!d&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r}=e,s=t.context.gl,o=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(n);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(n.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=o.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p=Mo(d,0);h.draw(t,s.TRIANGLES,o.getShadowPassDepthMode(),$n.disabled,Wn.disabled,Jn.disabled,p,n.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,n.paint,t.transform.zoom,c)}}(p));const f="mrt-fallback"===t.emissiveMode;if("offset"!==h){if(va(p,!1,f),"road"===h){const e=!d&&"translucent"===t.renderPass;e&&ya(t,i,n,r,"geometry"),va(p,!0,f,$n.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r,colorMode:s}=e,o=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new qn(t.context.gl.LEQUAL,qn.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=mr(t.style,e,i))}const h=e=>{for(const h of r){const r=i.getTile(h),d=r.getBucket(n);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(n.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(n.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const g=t.isTileAffectedByFog(h),_=[];l&&_.push("RENDER_SHADOWS","NORMAL_OFFSET");const y=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:g,defines:_}),v=t.translatePosMatrix(h.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),y,"vector-tile");const x=Io(v,u);t.uploadCommonUniforms(t.context,y,h.toUnwrapped()),y.draw(t,o.TRIANGLES,c,$n.disabled,s,Jn.backCCW,x,n.id,p.vertexBuffer,p.indexBuffer,f,n.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(p)}}else va(p,!1,f,t.stencilModeFor3D())},"fill-extrusion":function(t,i,n,r){const s=n.paint.get("fill-extrusion-opacity"),o=t.context,a=o.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===s)return;const u="mrt-fallback"===t.emissiveMode,h=t.conflationActive&&t.style.isLayerClipped(n,i.getSource()),d=t.style.order.indexOf(n.fqid);if(h&&function(e,t,i,n,r){for(const s of n){const n=t.getTile(s).getBucket(i);n&&(n.updateReplacement(s,e.replacementSource,r),n.uploadCentroid(e.context))}}(t,i,n,r,d),l||h)for(const e of r){const r=i.getTile(e).getBucket(n);r&&Ea(t.context,i,e,r,n,l,h)}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&s<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ac)return;const o=t.shadowRenderer.getShadowPassDepthMode();ba(t,i,n,r,o,$n.disabled,Wn.disabled,h)}else if("translucent"===t.renderPass){const d=!n.paint.get("fill-extrusion-pattern").constantOr(1),p=n.paint.get("fill-extrusion-color").constantOr(e.C.white);if(!c&&0!==p.a){const e=new qn(t.context.gl.LEQUAL,qn.ReadWrite,t.depthRangeFor3D);1===s&&d?ba(t,i,n,r,e,$n.disabled,Wn.unblended,h):(ba(t,i,n,r,e,$n.disabled,Wn.disabled,h),ba(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&d&&(!l&&"globe"!==t.transform.projection.name||c)){const s=n.paint.get("fill-extrusion-opacity"),d=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),p=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=n.paint.get("fill-extrusion-flood-light-intensity"),m="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),g=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(m?null:n.lut).toArray01().slice(0,3),_=d>0&&p>0,y=f>0,v=(e,t,i)=>(1-i)*e+i*t,x=new wa;x.translate=n.paint.get("fill-extrusion-translate"),x.translateAnchor=n.paint.get("fill-extrusion-translate-anchor"),x.edgeRadius=n.layout.get("fill-extrusion-edge-radius"),x.cutoffFadeRange=n.paint.get("fill-extrusion-cutoff-fade-range");const b=o=>{const l=t.depthModeForSublayer(1,qn.ReadOnly,a.LEQUAL,!0),c=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),u=v(.1,3,c),m=t._showOverdrawInspector;if(!m){const c=new $n({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Wn([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Sa(x,t,i,n,r,l,c,m,Jn.disabled,o,"sdf",s,d,p,f,g,u,h,!1)}{const c=m?$n.disabled:new $n({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=m?t.colorModeForRenderPass():new Wn([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.C.transparent,[!0,!0,!0,!0]);Sa(x,t,i,n,r,l,c,_,Jn.disabled,o,"color",s,d,p,f,g,u,h,!1)}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let n=l.framebufferCopyTexture;return n&&(!n||n.size[0]===t&&n.size[1]===i)||(n&&n.destroy(),n=l.framebufferCopyTexture=new e.T(o,new e.q({width:t,height:i}),a.RGBA8)),n.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),n},m=(o,l,m)=>{const _=t.depthModeForSublayer(1,qn.ReadOnly,a.LEQUAL,!1),y=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),b=v(.1,3,y);{const c=new Wn([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0]);Sa(x,t,i,n,r,_,$n.disabled,c,Jn.disabled,o,"clear",s,d,p,f,g,b,h,l)}{const c=new $n({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),u=new Wn([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Sa(x,t,i,n,r,_,c,u,Jn.disabled,o,"sdf",s,d,p,f,g,b,h,l)}u&&!o&&(m=c());{const c=o?a.ZERO:a.ONE_MINUS_DST_ALPHA,u=new $n({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),m=new Wn([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.C.transparent,[!0,!0,!0,!0]);Sa(x,t,i,n,r,_,u,m,Jn.disabled,o,"color",s,d,p,f,g,b,h,l)}if(!u||o){const c=new Wn([a.ONE,a.ONE,a.ONE,o?a.ZERO:a.ONE],e.C.transparent,[!1,!1,!1,!0],o?a.FUNC_ADD:a.MAX);Sa(x,t,i,n,r,_,$n.disabled,c,Jn.disabled,o,"clear",s,d,p,f,g,b,h,l,m)}else{a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new $n({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),u=new Wn([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!0,!1,!1,!1],a.MAX);Sa(x,t,i,n,r,_,c,u,Jn.disabled,o,"emissive",s,d,p,f,g,b,h,l,m),a.drawBuffers([a.COLOR_ATTACHMENT0])}};if(_||y){let e;t.prepareDrawTile(),u&&!_||(e=c()),_&&m(!0,!1,e),y&&m(!1,!0,e)}}else _&&b(!0),y&&b(!1),(_||y)&&t.resetStencilClippingMasks()}}},hillshade:function(e,t,i,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,s=e.terrain&&e.terrain.renderingToTexture,[o,a]="translucent"!==e.renderPass||s?[{},n]:e.stencilConfigForOverlap(n);for(const n of a){const r=t.getTile(n);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)ms(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,qn.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=s&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):o[n.overscaledZ];ps(e,n,r,i,t,c,l)}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,n,r,s,o){if("translucent"!==t.renderPass)return;const a=n.paint.get("raster-opacity");if(0===a)return;const l="globe"===t.transform.projection.name,c=0!==n.paint.get("raster-elevation"),u=c&&l,h=t.terrain&&t.terrain.exaggeration()>0&&c&&"ground"===n.paint.get("raster-elevation-reference"),d=!l&&h;if(t.renderElevatedRasterBackface&&!u)return;const p=t.context,f=p.gl,m=i.getSource(),g=function(t,i,n,r,s){const o=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),u=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const d=[u[0],u[1],u[2],0],p=u[3];let f="nearest"===c?r.NEAREST:r.LINEAR;if(a&&(l.push("RASTER_ARRAY"),o||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),f=r.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(h=e.fields.range)}if(h=h||[0,1],o){l.push("RASTER_COLOR"),n.activeTexture.set(r.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(n,i.colorRamp,r.RGBA8)),t.bind(f,r.CLAMP_TO_EDGE)}return s&&l.push("USE_MRT1"),{mix:d,range:h,offset:p,defines:l,resampling:f}}(m,n,p,f,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(m instanceof e.aY&&!r.length&&!l)return;const _=n.paint.get("raster-emissive-strength"),y=t.colorModeForDrapableLayerRenderPass(_),v=t.terrain&&t.terrain.renderingToTexture,x=!t.options.moving,b="nearest"===n.paint.get("raster-resampling")?f.NEAREST:f.LINEAR;if(m instanceof e.aY&&!r.length&&(m.onNorthPole||m.onSouthPole)){const e=c?t.stencilModeFor3D():$n.disabled;return void sl(!!m.onNorthPole,null,t,i,n,_,g,Jn.disabled,e)}if(!r.length)return;const[w,T]=m instanceof e.aY||v?[{},r]:t.stencilConfigForOverlap(r),S=T.at(-1).overscaledZ;u&&g.defines.push("PROJECTION_GLOBE_VIEW"),c&&g.defines.push("RENDER_CUTOFF","ELEVATED"),h&&g.defines.push("ELEVATION_REFERENCE_GROUND");const E=(r,s,T)=>{for(const E of r){const r=E.toUnwrapped(),A=i.getTile(E);if(v&&(!A||!A.hasData()))continue;p.activeTexture.set(f.TEXTURE0);const M=al(A,m,n,g);if(!M||!M.texture)continue;const{texture:I,mix:C,offset:P,tileSize:L,buffer:R}=M;let O,D;v?(O=qn.disabled,D=E.projMatrix):c?(O=new qn(f.LEQUAL,qn.ReadWrite,t.depthRangeFor3D),D=l?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(r,x)):(O=t.depthModeForSublayer(E.overscaledZ-S,1===a?qn.ReadWrite:qn.ReadOnly,f.LESS),D=t.transform.calculateProjMatrix(r,x));const B=t.terrain&&v?t.terrain.stencilModeForRTTOverlap(E):w[E.overscaledZ],F=o?0:n.paint.get("raster-fade-duration");A.registerFadeDuration(F);const N=i.findLoadedParent(E,0),k=ao(A,N,i,t.transform,F);let z,U;!k.isFading&&A.refreshedUponExpiration&&(A.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),p.activeTexture.set(f.TEXTURE0),I.bind(b,f.CLAMP_TO_EDGE),p.activeTexture.set(f.TEXTURE1),N?(N.texture&&N.texture.bind(b,f.CLAMP_TO_EDGE),z=Math.pow(2,N.tileID.overscaledZ-A.tileID.overscaledZ),U=[A.tileID.canonical.x*z%1,A.tileID.canonical.y*z%1]):I.bind(b,f.CLAMP_TO_EDGE),"useMipmap"in I&&p.extTextureFilterAnisotropic&&t.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);const V=t.transform;let j;const G=c?ol(V):[0,0,0,0];let H,W,q,X,$,Z=0;if(u&&m instanceof e.aY&&m.coordinates.length>3)H=Float32Array.from(e.dx(e.dy(new e.cp(0,0,0)))),W=Float32Array.from(V.globeMatrix),q=Float32Array.from(e.dt(V)),X=[e.aG(V.center.lng),e.aJ(V.center.lat)],j=m.elevatedGlobePerspectiveTransform,$=m.elevatedGlobeGridMatrix||new Float32Array(9);else if(u){const t=e.du(E.canonical);Z=e.dv(t.getCenter().lat),H=Float32Array.from(e.dx(e.dy(E.canonical))),W=Float32Array.from(V.globeMatrix),q=Float32Array.from(e.dt(V)),X=[e.aG(V.center.lng),e.aJ(V.center.lat)],j=[0,0],$=Float32Array.from(e.dw(E.canonical,t,Z,V.worldSize/V._pixelsPerMercatorPixel))}else j=m instanceof e.aY?m.perspectiveTransform:[0,0],H=new Float32Array(16),W=new Float32Array(9),q=new Float32Array(16),X=[0,0],$=new Float32Array(9);const Y=zo(t,D,H,W,q,$,U||[0,0],e.ai(t.transform.zoom),X,G,z||1,k,n,j,c?n.paint.get("raster-elevation"):0,2,C,P,g.range,L,R,_),J=t.isTileAffectedByFog(E),K=t.getOrCreateProgram("raster",{defines:g.defines,overrideFog:J});if(t.uploadCommonUniforms(p,K,r),m instanceof e.aY){const i=m.elevatedGlobeVertexBuffer,r=m.elevatedGlobeIndexBuffer;if(v||!l)m.boundsBuffer&&m.boundsSegments&&K.draw(t,f.TRIANGLES,O,$n.disabled,y,Jn.disabled,Y,n.id,m.boundsBuffer,t.quadTriangleIndexBuffer,m.boundsSegments);else if(i&&r){const o=V.zoom<=e.cN?m.elevatedGlobeSegments:m.getSegmentsForLongitude(V.center.lng);o&&K.draw(t,f.TRIANGLES,O,$n.disabled,y,s,Y,n.id,i,r,o)}}else if(u){O=new qn(f.LEQUAL,qn.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){h&&(t.terrain.setupElevationDraw(A,K),t.uploadCommonUniforms(p,K,A.tileID.toUnwrapped()));const[i,r,o]=e.getGridBuffers(Z,!1),a=K.getAttributeLocation(f,"a_texture_pos");-1!==a&&f.vertexAttribI4ui(a,0,0,0,0),K.draw(t,f.TRIANGLES,O,T||B,t.colorModeForRenderPass(),s,Y,n.id,i,r,o)}}else if(d)O=new qn(f.LEQUAL,qn.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(A,K),t.uploadCommonUniforms(p,K,A.tileID.toUnwrapped()),V.pitch>20&&K.draw(t,f.TRIANGLES,O,$n.disabled,Wn.disabled,Jn.frontCCW,Y,n.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),K.draw(t,f.TRIANGLES,O,B,y,Jn.backCCW,Y,n.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(A);K.draw(t,f.TRIANGLES,O,B,y,Jn.disabled,Y,n.id,e,i,r)}}if(!(m instanceof e.aY)&&u)for(const e of r){const r=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&sl(!0,e,t,i,n,_,g,s,T||$n.disabled),r&&sl(!1,e,t,i,n,_,g,s===Jn.frontCW?Jn.backCW:Jn.frontCW,T||$n.disabled)}};u?E(T,t.renderElevatedRasterBackface?Jn.backCW:Jn.frontCW,t.stencilModeFor3D()):E(T,Jn.disabled,void 0),t.resetStencilClippingMasks()},background:function(t,i,n,r){const s=n.paint.get("background-color"),o="none"===n.paint.get("background-color-use-theme").constantOr("default"),a=n.paint.get("background-opacity"),l=n.paint.get("background-emissive-strength"),c="viewport"===n.paint.get("background-pitch-alignment");if(0===a)return;const u=t.context,h=u.gl,d=t.transform,p=d.tileSize,f=n.paint.get("background-pattern");let m;if(void 0!==f){if(null===f)return;if(m=t.imageManager.getPattern(e.I.from(f.toString()),n.scope,t.style.getLut(n.scope)),!m)return}const g=!f&&1===s.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==g)return;const _=$n.disabled,y=t.depthModeForSublayer(0,"opaque"===g?qn.ReadWrite:qn.ReadOnly),v=t.colorModeForDrapableLayerRenderPass(l),x=f?"backgroundPattern":"background";let b,w=r;w||(b=t.getBackgroundTiles(),w=Object.values(b).map(e=>e.tileID)),f&&(u.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,n.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0,defines:T}),r=ll,u=new e.aU(0,0,0,0,0),d=f?Ho(r,l,a,t,0,n.scope,m,c,{tileID:u,tileSize:p}):Go(r,l,a,s.toPremultipliedRenderColor(o?null:n.lut));return void i.draw(t,h.TRIANGLES,y,_,v,Jn.disabled,d,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const g of w){const w=t.isTileAffectedByFog(g),S=t.getOrCreateProgram(x,{overrideFog:w,defines:T}),E=g.toUnwrapped(),A=r?g.projMatrix:t.transform.calculateProjMatrix(E);t.prepareDrawTile();const M=i?i.getTile(g):b?b[g.key]:new e.b3(g,p,d.zoom,t),I=f?Ho(A,l,a,t,0,n.scope,m,c,{tileID:g,tileSize:p}):Go(A,l,a,s.toPremultipliedRenderColor(o?null:n.lut));t.uploadCommonUniforms(u,S,E);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:P,tileBoundsSegments:L}=t.getTileBoundsBuffers(M);S.draw(t,h.TRIANGLES,y,_,v,Jn.disabled,I,n.id,C,P,L)}},sky:function(t,i,n){const r=t._atmosphere?e.ai(t.transform.zoom):1,s=n.paint.get("sky-opacity")*r;if(0===s)return;const o=t.context,a=n.paint.get("sky-type"),l=new qn(o.gl.LEQUAL,qn.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i){const n=t.context,r=n.gl;let s=i.skyboxFbo;if(!s){s=i.skyboxFbo=n.createFramebuffer(32,32,1,null),i.skyboxGeometry=new bl(n),i.skyboxTexture=n.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(s.framebuffer),n.viewport.set([0,0,32,32]);const o=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.en(l,.5*-Math.PI),wl(t,i,a,l,o,0),e.en(l,.5*Math.PI),wl(t,i,a,l,o,1),e.eo(l,.5*-Math.PI),wl(t,i,a,l,o,2),e.eo(l,.5*Math.PI),wl(t,i,a,l,o,3),e.bA(l),wl(t,i,a,l,o,4),e.en(l,Math.PI),wl(t,i,a,l,o,5),n.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,n,r){const s=e.context,o=s.gl,a=e.transform,l=e.getOrCreateProgram("skybox");s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,n,r);e.uploadCommonUniforms(s,l),l.draw(e,o.TRIANGLES,i,$n.disabled,e.colorModeForRenderPass(),Jn.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,n,l,s,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,n,r,s){const o=t.context,a=o.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new bl(o)),o.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(o,i.colorRamp,a.RGBA8)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,s)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.am(n),u_opacity:r,u_temporal_offset:s}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,s);t.uploadCommonUniforms(o,c),c.draw(t,a.TRIANGLES,n,$n.disabled,t.colorModeForRenderPass(),Jn.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,l,s,c)},custom:function(t,i,n,r){const s=t.context,o=n.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&n.isDraped(i)){if("offscreen"===t.renderPass){const i=o.prerender;if(i){if(t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const n=t.transform.pointMerc;i.call(o,s.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ai(t.transform.zoom),[n.x,n.y],t.transform.pixelsPerMeterRatio)}else i.call(o,s.gl,t.transform.customLayerMatrix());s.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=o.renderToTile;if(e){const i=r[0].canonical,n={x:i.x+r[0].wrap*(o.wrapTileId?0:1<<i.z),y:i.y,z:i.z};s.setDepthMode(qn.disabled),s.setStencilMode($n.disabled),s.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults();const a=s.gl;"mrt-fallback"===t.emissiveMode&&a.drawBuffers([a.COLOR_ATTACHMENT0]),e.call(o,s.gl,n),"mrt-fallback"===t.emissiveMode&&a.drawBuffers([a.COLOR_ATTACHMENT0,a.COLOR_ATTACHMENT1]),s.setDirty(),t.setBaseState()}return}t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),s.setStencilMode($n.disabled);const i="3d"===o.renderingMode?new qn(t.context.gl.LEQUAL,qn.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,qn.ReadOnly);if(s.setDepthMode(i),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;o.render(s.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ai(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio)}else o.render(s.gl,t.transform.customLayerMatrix());s.setDirty(),t.setBaseState(),s.bindFramebuffer.set(null)}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(t,i,n,r){if("opaque"===t.renderPass)return;const s=n.paint.get("model-opacity").constantOr(1),o=n.paint.get("model-elevation-reference"),a="ground"===o,l="ground"===o;if(0===s)return;const c=n.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!c)return;if(t.terrain&&s<.65&&n._transitionablePaint._values["model-opacity"].value.expression instanceof e.ac)return}const u=t.shadowRenderer,h=n.paint.get("model-receive-shadows");u&&(u.useNormalOffset=!0,h||(u.enabled=!1));const d=()=>{u&&(u.useNormalOffset=!0,h||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,n,r,s){const o=t.transform,a="globe"===o.projection.name,l=o.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;n.modelManager=c;const u=t.shadowRenderer;if(!Object.hasOwn(n._unevaluatedLayout._values,"model-id"))return;const h=n._unevaluatedLayout._values["model-id"],d=Object.assign({},n.layout.get("model-id").parameters),p=t.style.order.indexOf(n.fqid),f=n.paint.get("model-opacity").constantOr(1);for(const m of r){const r=i.getTile(m).getBucket(n);if(!r||r.projection.name!==o.projection.name)continue;const g=r.getModelUris();if(g&&!r.modelsRequested&&(c.addModelsFromBucket(g,s),r.modelsRequested=!0),a)d.zoom=m.overscaledZ;else{const e=Wl(m,o);d.zoom=e}const _=h.possiblyEvaluate(d);if(Gl(t,r,m),Hl.shadowUniformsInitialized=!1,Hl.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(m.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=o.calculatePosMatrix(m.toUnwrapped(),o.worldSize);if(Hl.tileMatrix.set(i),Hl.shadowTileMatrix.set(u.calculateShadowPassMatrixFromMatrix(i)),Hl.aabb.min=[0,0,0],Hl.aabb.max[0]=Hl.aabb.max[1]=e.ak,Hl.aabb.max[2]=0,Zl(r,Hl,t,n.scope))continue}const y=1<<m.canonical.z,v=[((l.x-m.wrap)*y-m.canonical.x)*e.ak,(l.y*y-m.canonical.y)*e.ak,l.z*y*e.ak];t.conflationActive&&Object.keys(r.instancesPerModel).length>0&&t.style.isLayerClipped(n,i.getSource())&&r.updateReplacement(m,t.replacementSource,p,n.scope)&&(r.uploaded=!1,r.upload(t.context));let x=0;const b=new Array,w=new Array,T=new Array;for(let i in r.instancesPerModel){const o=r.instancesPerModel[i];o.features.length>0&&!a&&(i=_.evaluate(o.features[0].feature,{}));const u=c.getModel(i,s);if(u||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),u&&u.uploaded)if(a){const i=e.bN([],[l.x,l.y,l.z],t.transform.worldSize);e.ew(i,i);for(let n=0;n<o.instancedDataArray.length;++n){const s=[0,0,0],a=[1,1,1],l=e.ex(),c=o.tileCoordinatesForInstance(n),h=o.transformForInstance(n);e.ey(a,h),e.ez(l,h),e.eA(s,l);const d=o.translationForInstance(n),p=new e.aX(0,0);e.eB(r.canonical,p,c.x,c.y);const m=e.bd();e.eC(m,u,t.transform,p,s,a,d,!0,!1,!1);const g=o.colorForInstance(n),_=e.cK([],i),y=e.e8(p.lat,t.transform.zoom),v=e.bT([],[1,1,1/y]);T.push({zScaleMatrix:v,negCameraPosMatrix:_});for(const e of u.nodes)Nl(t,e,m,t.transform.expandedFarZProjMatrix,x,b,w,u.materialOverrides,f,g);++x}}else for(const e of u.nodes)ql(t,n,e,o,v,m,Hl)}if(a)if("shadow"===t.renderPass){for(const e of w)kl(e.mesh,e.nodeModelMatrix,t,n);for(const e of b)kl(e.mesh,e.nodeModelMatrix,t,n)}else jl(t,n,b,w,T)}}(t,i,n,r,Fl(t,n)),void d();if(!p.loaded())return;if("batched-model"===p.type)return function(t,i,n,r){n.resetLayerRenderingStats(t);const s=t.context,o=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==o.projection.name)return void e.w(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,u=e.bN([],[c.x,c.y,c.z],t.transform.worldSize),h=e.ew([],u),d=e.cK([],h),p=e.e8(o.center.lat,o.zoom),f=e.bT([],[1,1,1/p]),m=n.paint.get("model-opacity").constantOr(1),g=new qn(s.gl.LEQUAL,qn.ReadWrite,t.depthRangeFor3D),_=new qn(s.gl.LEQUAL,qn.ReadOnly,t.depthRangeFor3D),y=new e.cY([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),v="shadow"===t.renderPass,x=v&&l?l.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),b=n.paint.get("model-front-cutoff"),w=b[2]<1,T=ar(t,n.paint.get("model-cutoff-fade-range")),S=n.getLayerRenderingStats();(function(e,t,i,n){const r=e.terrain?e.terrain.exaggeration():0,s=e.transform.zoom;for(const o of n){const n=t.getTile(o).getBucket(i);n&&(n.setFilter(i.filter),e.conflationActive&&n.updateReplacement(o,e.replacementSource),n.evaluateTransform(e,i),e.terrain&&r>0&&n.elevationUpdate(e.terrain,r,o,i.source),n.needsReEvaluation(e,s,i)&&n.evaluate(i))}})(t,i,n,r),function(){const c=new Map;let h,E,A;w?(h=r.length-1,E=-1,A=-1):(h=0,E=r.length,A=1);const M=new Float64Array(16),I=e.cg(),C=new e.P(0,0);for(let P=h;P!==E;P+=A){const h=r[P],E=i.getTile(h).getBucket(n);if(!E||!E.uploaded)continue;let A=!1;l&&(A=0===l.getMaxCascadeForTile(h.toUnwrapped()));const L=o.calculatePosMatrix(h.toUnwrapped(),o.worldSize),R=E.modelTraits;!v&&w&&(e.ba(M,L),e.ae(I,u,M),C.x=I[0],C.y=I[1]);const O=[];E.setFilter(n.filter);for(const i of E.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const n=i.node;let r=0;t.terrain&&n.elevation&&(r=n.elevation*t.terrain.exaggeration());const s=(()=>{const t=i.aabb;return y.min=[...t.min],y.max=[...t.max],y.min[2]+=r,y.max[2]+=r,e.ae(y.min,y.min,L),e.ae(y.max,y.max,L),y})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===s.intersects(x))continue;if(!v){const n=s.min,r=s.max;Rl[0]=.5*(n[0]+r[0]),Rl[1]=.5*(n[1]+r[1]),Rl[2]=.5*(n[2]+r[2]);const o=e.bh(u,Rl)*p;$l(i,o,Math.min(t._debugParams.dt,1e3/30),t._debugParams.lodSwitchDistance)}if(!v&&w){const t=1/6;i.cameraCollisionOpacity=u[0]>s.min[0]&&u[0]<s.max[0]&&u[1]>s.min[1]&&u[1]<s.max[1]&&u[2]*p<s.max[2]&&n.footprint&&e.bG(C,n.footprint)?Math.max(i.cameraCollisionOpacity-t,0):Math.min(1,i.cameraCollisionOpacity+t)}const l=[...L],c=1/e.cW(h.canonical),d=n.anchor?n.anchor[0]:0,f=n.anchor?n.anchor[1]:0;e.bB(l,l,[d*(a[0]-1)+i.evaluatedTranslation[0]*c,f*(a[1]-1)+i.evaluatedTranslation[1]*c,r+i.evaluatedTranslation[2]]),e.c6(a,e.eE)||e.cE(l,l,a);const g=e.aC([],l,n.globalMatrix),_=e.aC([],o.expandedFarZProjMatrix,g),S=e.aC([],o.expandedFarZProjMatrix,l),E=e.aD([],[d,f,r,1],_)[2];n.hidden=!1;let A=m;v||(w&&(A*=i.cameraCollisionOpacity,A*=Jl(l,o,i.aabb,b)),A*=Yl(T,E)),0!==A?O.push({nodeInfo:i,depth:E,opacity:A,wvpForNode:_,wvpForTile:S,nodeModelMatrix:g,tileModelMatrix:l}):n.hidden=!0}v||O.sort((e,t)=>!w||1===e.opacity&&1===t.opacity?e.depth<t.depth?-1:1:1===e.opacity?-1:1===t.opacity?1:e.depth>t.depth?-1:1);for(const i of O){const r=i.nodeInfo,u=r.node;if(t._debugParams.show3DModelFootprints&&u.footprint){const e=u.id||u.name||"footprint";c.has(e)||c.set(e,{node:u,mvp:i.wvpForTile})}e.aC(Il,f,i.tileModelMatrix),e.aC(Il,d,Il),e.ba(Cl,Il),e.e9(Cl,Cl),e.cE(Cl,Cl,Xl),e.aC(Il,Il,u.globalMatrix);const h="light-beam"===t.renderPass,p="none"===n.paint.get("model-color-use-theme").constantOr("default"),m=R&e.eH.HasMapboxMeshFeatures,y=m?0:r.evaluatedRMEA[0][2],x=r.targetLod,b=u.lodMeshes&&u.lodMeshes.length>0,w=b&&x>0&&x<1;if(v&&b&&1===Math.round(x))continue;const T=w?2:1,E=b&&1===Math.round(x);for(let e=0;e<T;++e){const c=w?1===e:E,d=c?u.lodMeshes:u.meshes,f=w?c?-x:1-x:1;for(let e=0;e<d.length;++e){const x=d[e],b=!c&&e===u.lightMeshIndex;let T=i.wvpForNode;if(b){if(!h&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}T=i.wvpForTile}else if(h)continue;const E={defines:[]},M=[];if(!v&&l&&(l.useNormalOffset=!!x.normalBuffer),Dl(E.defines,M,x,t,p?null:n.lut),m||E.defines.push("DIFFUSE_SHADED"),A&&E.defines.push("SHADOWS_SINGLE_CASCADE"),S&&(v?S.numRenderedVerticesInShadowPass+=x.vertexArray.length:S.numRenderedVerticesInTransparentPass+=x.vertexArray.length),v){kl(x,i.nodeModelMatrix,t,n);continue}let I=null;if(a&&(I=Ol(Pl,i.nodeModelMatrix,t.transform),"globe"!==o.projection.name)){const e=x.aabb.min,t=x.aabb.max,[i,n]=a.getOpacityForBounds(I,e[0],e[1],t[0],t[1]);E.overrideFog=i>=Wt||n>=Wt}const C=x.material;let P;C.occlusionTexture&&C.occlusionTexture.offsetScale&&(P=C.occlusionTexture.offsetScale,E.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),w&&E.defines.push("DITHERED_DISCARD");const L=t.getOrCreateProgram("model",E);!v&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,L,l.useNormalOffset),t.uploadCommonUniforms(s,L,null,I);const R=C.pbrMetallicRoughness;R.metallicFactor=.9,R.roughnessFactor=.5;const O=qo(T,Il,Cl,u.globalMatrix,t,i.opacity,R.baseColorFactor,C.emissiveFactor,R.metallicFactor,R.roughnessFactor,C,y,n,[0,0,0],P,void 0,void 0,f);!b&&(r.hasTranslucentParts||i.opacity<1)&&L.draw(t,s.gl.TRIANGLES,g,$n.disabled,Wn.disabled,Jn.backCCW,O,n.id,x.vertexBuffer,x.indexBuffer,x.segments,n.paint,t.transform.zoom,void 0,M),L.draw(t,s.gl.TRIANGLES,b?_:g,$n.disabled,b||i.opacity<1||r.hasTranslucentParts?Wn.alphaBlended:Wn.unblended,Jn.backCCW,O,n.id,x.vertexBuffer,x.indexBuffer,x.segments,n.paint,t.transform.zoom,void 0,M)}}}}if(t._debugParams.show3DModelFootprints&&c.size>0){const e=Array.from(c.keys()).sort();for(const i of e){const{node:e,mvp:n}=c.get(i);zl(t,0,e,n)}}}()}(t,i,n,r),void d();if("model"!==p.type)return;const f=p.getModels(),m=[],g=t.transform.getFreeCameraOptions().position,_=e.bN([],[g.x,g.y,g.z],t.transform.worldSize);e.ew(_,_);const y=[],v=[];let x=0;for(const r of f){const s=i.getFeatureState("",r.id),o={type:"Unknown",id:r.id,properties:r.featureProperties},c=n.paint.get("model-rotation").evaluate(o,s),u=n.paint.get("model-scale").evaluate(o,s),h=n.paint.get("model-translation").evaluate(o,s),d=n.paint.get("model-opacity").evaluate(o,s);Ul(n,r.id,s,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),Vl(n,r.id,s,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,u,h,l,a,!1);const p=e.cK([],_),f=e.e8(r.position.lat,t.transform.zoom),g=e.bT([],[1,1,1/f]);m.push({zScaleMatrix:g,negCameraPosMatrix:p});for(const e of r.nodes)Nl(t,e,r.matrix,t.transform.expandedFarZProjMatrix,x,y,v,r.materialOverrides,d);x++}if(y.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){const i=t.transform.projMatrix,n=new Map,r=(t,r)=>{if(t.footprint){const s=t.id||t.name||"footprint";if(!n.has(s)){const o=e.aC([],i,r);n.set(s,{node:t,mvp:o})}}};for(const e of v)r(e.node,e.modelMatrix);for(const e of y)r(e.node,e.modelMatrix);const s=Array.from(n.keys()).sort();for(const e of s){const{node:i,mvp:r}=n.get(e);zl(t,0,i,r)}}jl(t,n,y,v,m),d()}else{for(const e of v)kl(e.mesh,e.nodeModelMatrix,t,n);for(const e of y)kl(e.mesh,e.nodeModelMatrix,t,n);d()}}},ic={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const n of i){const i=t.getTile(n).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0},model:function(e,t,i){const n=t.getSource();if(!n.loaded())return;if("vector"===n.type||"geojson"===n.type)return void(i.modelManager&&i.modelManager.upload(i,Fl(i,e)));if("batched-model"===n.type)return;if("model"!==n.type)return;const r=n.getModels();for(const e of r)e.upload(i.context)},raster:function(e,t,i){const n=t.getSource();if(!(n instanceof xi&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-array-band")||n.getInitialBand(r);if(null==s)return;const o=t.getIds().map(e=>t.getTileByID(e));for(const t of o)t.updateNeeded(e.id,s)&&n.prepareTile(t,r,e.id,s)}},nc={fill:ya},rc={fill:function(e,t,i,n){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,s=new qn(r.LEQUAL,qn.ReadOnly,e.depthRangeFor3D),o=new $n({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of n){const n=t.getTile(c),u=n.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||!h.depthSegments||0===h.depthSegments.segments[0].primitiveLength)continue;const d=_a(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=Co(p,d,0,1,0);l.draw(e,r.TRIANGLES,s,o,Wn.disabled,Jn.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class sc{constructor(t,i,n,r,s){this.context=new Qo(t,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,dt:0,timeStamp:e.o.now(),continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParamsOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:3e3},this.occlusionParams=new ec,this.setup(),this.numSublayers=Ri.maxUnderzooming+Ri.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eJ,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new dr(this),this._wireframeDebugCache=new Ql,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const o=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,o,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.maxFrontCutoffRawStart=0,this.worldview=s,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new ho(this,e));const n=this._terrain;this.transform.elevation=i?n:null,n.update(e,this.transform,t),this.transform.elevation&&!n.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,n]=t.getRangeForProjection();if(i>n)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new ho(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.o.devicePixelRatio,this.height=i*e.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,i=new e.dE;i.emplaceBack(0,0),i.emplaceBack(e.ak,0),i.emplaceBack(0,e.ak),i.emplaceBack(e.ak,e.ak),this.tileExtentBuffer=t.createVertexBuffer(i,e.dA.members),this.tileExtentSegments=e.dB.simpleSegment(0,0,4,2);const n=new e.dE;n.emplaceBack(0,0),n.emplaceBack(e.ak,0),n.emplaceBack(0,e.ak),n.emplaceBack(e.ak,e.ak),this.debugBuffer=t.createVertexBuffer(n,e.dA.members),this.debugSegments=e.dB.simpleSegment(0,0,4,5);const r=new e.dE;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.dA.members),this.viewportSegments=e.dB.simpleSegment(0,0,4,2);const s=new e.eK;s.emplaceBack(0,0,0,0),s.emplaceBack(e.ak,0,e.ak,0),s.emplaceBack(0,e.ak,0,e.ak),s.emplaceBack(e.ak,e.ak,e.ak,e.ak),this.mercatorBoundsBuffer=t.createVertexBuffer(s,e.eL.members),this.mercatorBoundsSegments=e.dB.simpleSegment(0,0,4,2);const o=new e.dF;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o);const a=new e.eM;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bd();const l=this.context.gl;this.stencilClearMode=new $n({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,qn.disabled,this.stencilClearMode,Wn.disabled,Jn.disabled,oo(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const n=this.context,r=n.gl;this.nextStencilID+i.length>256&&this.clearStencil(),n.setColorMode(Wn.disabled),n.setDepthMode(qn.disabled);const s=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),n=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:o,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);s.draw(this,r.TRIANGLES,qn.disabled,new $n({func:r.ALWAYS,mask:0},n,255,r.KEEP,r.KEEP,r.REPLACE),Wn.disabled,Jn.disabled,oo(e.projMatrix),"$clipping",o,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new $n({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new $n({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i.at(-1).overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;i<r;i++)e[i+n]=new $n({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=r,[e,i]}return[{[n]:$n.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Wn([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.C(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Wn.unblended:Wn.alphaBlended}colorModeForDrapableLayerRenderPass(t){const i=this.context.gl;return(()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new Wn([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.C(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new Wn([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,n=!1){if(this.depthOcclusion)return new qn(this.context.gl.GREATER,qn.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!n)return qn.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new qn(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,i=Math.ceil(this.width),n=Math.ceil(this.height),r=this.context.bindFramebuffer.get(),s=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===n||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==n&&(this.depthFBO=new Ko(this.context,i,n,0,"texture"),this.depthTexture=new e.T(this.context,{width:i,height:n,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(r),t.bindTexture(t.TEXTURE_2D,s),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,n,0,0,i,n,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(t,i){this.context.sweepPendingPrograms(),this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=i;const n=this.style._mergedLayers,r=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(r);let o=s(),a=!1,l=!1,c=null,u=0,h=!1;for(const e of o){const t=n[e];"none"!==t.visibility&&("circle"===t.type?a=!0:"building"===t.type?(c=t,++u):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?l=!0:a=!0))}this.updateEmissiveMode();let d=o.map(e=>n[e]);const p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();for(const e in p){const t=p[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++u)}let f=!1;for(const e of d)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const m={},g={},_={},y={},v={};for(const e in p){const t=p[e];m[e]=t.getVisibleCoordinates(),g[e]=m[e].slice().reverse(),_[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(m[e])}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(u||f||this._clippingActiveLastFrame){const t=[],i=[];let n=0;for(const e of d)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(n)),n++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const n=[];for(let r=0;r<t.length;r++){const s=t[r],o=i[r],a=this.style.getLayerSourceCache(s);if(!a||!a.used||!a.getSource().usedInConflation&&"clip"!==s.type&&"building"!==s.type)continue;let l=e.eN,c=e.bE.None;const u=[];let h=!0;if("building"===s.type)l=e.eP;else if("clip"===s.type)if(l=o,s.isHidden(this.transform.zoom))h=!1;else{if(!s.layout){h=!1;continue}for(const t of s.layout.get("clip-layer-types"))c|="model"===t?e.bE.Model:"symbol"===t?e.bE.Symbol:e.bE.FillExtrusion;for(const t of s.layout.get("clip-layer-scope"))u.push(e.t(t,s.scope));f=!0}h&&n.push({layer:s.fqid,cache:a,order:l,clipMask:c,clipScope:u})}this.replacementSource.setSources(n),h=!0}}this._clippingActiveLastFrame=f,h||this.replacementSource.clear(),this.conflationActive=h,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<d.length;e++){const t=d[e];if("none"===t.visibility)continue;const i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D(r)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(_),this.opaquePassCutoff=0,o=s(),d=o.map(e=>n[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in p)for(const t of m[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eO(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Al),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let T=!(!this.style||!this.style.snow),S=!(!this.style||!this.style.rain);if(T&&!this._snow&&nl.Snow&&(this._snow=new nl.Snow),!T&&this._snow&&(this._snow.destroy(),delete this._snow),S&&!this._rain&&nl.Rain&&(this._rain=new nl.Rain),!S&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),c){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Ml);const e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c)}if(!Q.has(this.context.gl))return;this.renderPass="offscreen";for(const e of d){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const n=i?g[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||n&&n.length)&&this.renderLayer(this,i,e,n)}this.depthRangeFor3D=[0,1-(d.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const E="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),A=(()=>{if(i.showOverdrawInspector)return e.C.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!E){const n="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.C(...r)}if(E){const n="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.C(...r)}}return e.C.transparent})();if(this.context.clear({color:A,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&E&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=d[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const n=i?(e.is3D(r)?v:g)[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&E&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.ai(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const e=d[this.currentLayer],i=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?g[i.id]:void 0)}function M(e,t){let i;return t&&(i=("symbol"===e.type?_:e.is3D(r)?v:g)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<o.length;){const e=d[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,M(e,i))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const I=w?w.getGroundShadowLayerIndex():-1;let C=!1,P=-1;for(let e=0;e<o.length;++e){const t=d[e];t.isHidden(this.transform.zoom)||t.is3D(r)&&(P=e)}l&&-1===P&&(a=!0);let L=!1;for(;this.currentLayer<o.length;){const e=d[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!L&&e.is3D(r)&&!r){const e=this.currentLayer,t=e=>{for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const t=d[this.currentLayer];if(nc[t.type]){const i=this.style.getLayerSourceCache(t);nc[t.type](this,i,t,M(t,i),e)}}};t("initialize"),t("reset"),this.currentLayer=e,L=!0}if(a&&!C&&this.terrain&&!this.transform.isOrthographic&&(C=!0,this.blitDepth()),l&&-1!==P&&this.currentLayer===P+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(e,i,i?m[i.id]:void 0),this.renderLayer(this,i,e,M(e,i)),!this.terrain&&w&&this.currentLayer===I){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const e=d[this.currentLayer];if(rc[e.type]){const t=this.style.getLayerSourceCache(e);rc[e.type](this,t,e,M(e,t))}}this.currentLayer=e}if(w.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=d[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?g[i.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=d[this.currentLayer],n=t.getLayerSourceCache(i),r=n?g[n.id]:void 0;this.terrain||this._renderTileClippingMasks(i,n,n?m[n.id]:void 0),this.renderLayer(this,n,i,r)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;d.forEach(e=>{const n=t.getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&n.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<n.getSource().maxzoom)&&(i=n)}),i&&this.options.showTileBoundaries&&function(e,t,i,n,r,s){for(let r=0;r<i.length;r++)fl(e,t,i[r],n,0,0,s)}(this,i,i.getVisibleCoordinates(),e.C.red,0,this.options.showParseStatus)}this.options.showPadding&&function(e){const t=e.transform.padding;ml(e,e.transform.height-(t.top||0),3,cl),ml(e,t.bottom||0,3,ul),gl(e,t.left||0,3,hl),gl(e,e.transform.width-(t.right||0),3,dl);const i=e.transform.centerPoint;!function(e,t,i,n){_l(e,t-1,i-10,2,20,n),_l(e,t-10,i-1,20,2,n)}(e,i.x,e.transform.height-i.y,pl)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),h||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(ic[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);ic[e.type](e,t,this)}this.gpuTimingEnd()}renderLayer(e,t,i,n){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||n&&n.length)&&(this.id=i.id,this.gpuTimingStart(i),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(i.type)||e.terrain&&"custom"===i.type)&&"clip"!==i.type&&"slot"!==i.type&&tc[i.type]&&tc[i.type](e,t,i,n,this.style.placement.variableOffsets,this.options.isInitialLoad),tc[i.type]||async function(){await async function(){return Promise.resolve()}(),Object.assign(tc,{building:nl.drawBuilding,"raster-particle":nl.drawRasterParticle}),Object.assign(ic,{"raster-particle":nl.prepareRasterParticle})}(),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let n=this.gpuTimers[e.id];n||(n=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),n.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,n.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const n=e[i],r=this.context.extTimerQuery,s=r.getQueryParameter(n.query,this.context.gl.QUERY_RESULT)/1e6;r.deleteQueryEXT(n.query),t[i]=s}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const n of e)i+=t.getQueryParameter(n,t.QUERY_RESULT)/1e6,t.deleteQuery(n);return i}translatePosMatrix(t,i,n,r,s){if(!n[0]&&!n[1])return t;const o=s?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const e=Math.sin(o),t=Math.cos(o);n=[n[0]*t-n[1]*e,n[0]*e+n[1]*t]}const a=[s?n[0]:e.az(i,n[0],this.transform.zoom),s?n[1]:e.az(i,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.bB(l,t,a),l}saveTileTexture(e){if(e.context!==this.context)return;const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i,n,r){const s=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,o=void 0===n?this.terrainRenderModeElevated():n,a=void 0===r?"globe"===this.transform.projection.name:r,l=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(l.push("LIGHTING_3D_MODE"),l.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):s||l.push("LIGHTING_3D_MODE")),o&&(l.push("TERRAIN"),this.linearFloatFilteringSupported()&&l.push("TERRAIN_DEM_FLOAT_FORMAT")),a&&l.push("GLOBE"),!this._fogVisible||s||void 0!==t&&!t||l.push("FOG"),s&&l.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&l.push("OVERDRAW_INSPECTOR"),l}getOrCreateProgram(e,t){this.cache=this.cache||{};const{defines:i,config:n,overrideFog:r,overrideRtt:s,overrideTerrain:o,overrideGlobe:a,precompiled:l}=t||{},c=this.currentGlobalDefines(e,r,s,o,a).concat(i||[]),u=this.getShaderSource(e),h=$o[e]||nl.programUniforms[e],d=go.cacheKey(u,e,c,n);return this.cache[d]||(this.cache[d]=new go(this.context,e,u,n,h,c,l)),this.cache[d]}getShaderSource(e){return as[e]||nl.shaders&&nl.shaders[e]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const s=((t,i,n)=>{const r=t.properties.get("direction"),s="none"===t.properties.get("color-use-theme"),o=t.properties.get("color").toNonPremultipliedRenderColor(s?null:n.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:n.getLut(i.scope)).toArray01(),u=i.properties.get("intensity"),h=[r.x,r.y,r.z],d=e.dG(c,u),p=e.dG(o,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:h,u_lighting_directional_color:p,u_ground_radiance:po(h,p,d)}})(n,r,this.style);i.setLightsUniformValues(t,s)}}}uploadCommonUniforms(t,i,n,r,s){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const s=o.getOpacity(this.transform.pitch),a=((t,i,n,r,s,o,a,l,c,u,h,d)=>{const p=t.transform,f="none"===i.properties.get("color-use-theme"),m=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();m[3]=r;const g=t.frameCounter/1e3%1,[_,y]=i.properties.get("vertical-range");return{u_fog_matrix:n?p.calculateFogTileMatrix(n):d||t.identityMat,u_fog_range:i.getRangeForProjection(),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,y),y],u_fog_temporal_offset:g,u_frustum_tl:s,u_frustum_tr:o,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.ai(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,o,n,s,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],r);i.setFogUniformValues(t,a)}s&&i.setCutoffUniformValues(t,s.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,i=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)i[r.key]=t[r.key]||new e.b3(r,512,this.transform.tileZoom,this,void 0,this.worldview);return i}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(e,t){return!(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Wt||t[1]>=Wt}setupDepthForOcclusion(e,t,i){const n=this.context,r=n.gl,s=!!i;var o;i||(i={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),n.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((o=this.depthRangeFor3D)[1]-o[0]),-1-2*o[0]/(o[1]-o[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),n.activeTexture.set(r.TEXTURE0),s||t.setTerrainUniformValues(n,i)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function oc(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}const ac=/(#.+)?$/;class lc{constructor(t){this._hashName=t&&encodeURIComponent(t),e.b0(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=oc(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=cc(e);if(this._hashName){const e=this._hashName;let i=!1;const n=location.hash.slice(1).split("&").map(n=>{const r=n.split("=")[0];return r===e?(i=!0,`${r}=${t}`):n}).filter(e=>e);return i||n.push(`${e}=${t}`),`#${n.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e)}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(ac,this.getHashString()))}}function cc(e,t){const i=e.getCenter(),n=Math.round(100*e.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),o=Math.round(i.lng*s)/s,a=Math.round(i.lat*s)/s,l=e.getBearing(),c=e.getPitch();let u=t?`/${o}/${a}/${n}`:`${n}/${a}/${o}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const uc={linearity:.3,easing:e.eQ(0,0,.3,1)},hc=Object.assign({deceleration:2500,maxSpeed:1400},uc),dc=Object.assign({deceleration:20,maxSpeed:1400},uc),pc=Object.assign({deceleration:1e3,maxSpeed:360},uc),fc=Object.assign({deceleration:1e3,maxSpeed:90},uc);class mc{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=_c(i.pan.mag(),n,Object.assign({},hc,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,gc(r,e)}if(i.zoom){const e=_c(i.zoom,n,dc);r.zoom=this._map.transform.zoom+e.amount,gc(r,e)}if(i.bearing){const t=_c(i.bearing,n,pc);r.bearing=this._map.transform.bearing+e.aB(t.amount,-179,179),gc(r,t)}if(i.pitch){const e=_c(i.pitch,n,fc);r.pitch=this._map.transform.pitch+e.amount,gc(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function gc(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function _c(t,i,n){const{maxSpeed:r,linearity:s,deceleration:o}=n,a=e.aB(t*s/(i/1e3),-r,r),l=Math.abs(a)/(o*s);return{easing:n.easing,duration:1e3*l,amount:a*(l/2)}}class yc extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,n={}){const r=v(t.getCanvasContainer(),i),s=t.unproject(r);super(e,Object.assign({point:r,lngLat:s,originalEvent:i},n)),this._defaultPrevented=!1,this.target=t}}class vc extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n){const r="touchend"===t?n.changedTouches:n.touches,s=x(i.getCanvasContainer(),r),o=s.map(e=>i.unproject(e)),a=s.reduce((e,t,i,n)=>e.add(t.div(n.length)),new e.P(0,0));super(t,{points:s,point:a,lngLats:o,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class xc extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class bc{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new xc(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new yc(e.type,this._map,e))}mouseup(e){this._map.fire(new yc(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new yc(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new yc(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new yc(e.type,this._map,e))}mouseover(e){this._map.fire(new yc(e.type,this._map,e))}mouseout(e){this._map.fire(new yc(e.type,this._map,e))}touchstart(e){return this._firePreventable(new vc(e.type,this._map,e))}touchmove(e){this._map.fire(new vc(e.type,this._map,e))}touchend(e){this._map.fire(new vc(e.type,this._map,e))}touchcancel(e){this._map.fire(new vc(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class wc{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new yc(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new yc("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new yc(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Tc{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(m(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,n=this._startPos,r=this._lastPos;if(!n||!r||r.equals(i)||!this._box&&i.dist(n)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=u("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const s=Math.min(n.x,i.x),o=Math.max(n.x,i.x),a=Math.min(n.y,i.y),l=Math.max(n.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${s}px,${a}px)`,this._box.style.width=o-s+"px",this._box.style.height=l-a+"px")})}mouseupWindow(t,i){if(!this._active)return;const n=this._startPos,r=i;if(n&&0===t.button){if(this.reset(),y(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),g(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function Sc(e,t){const i={};for(let n=0;n<e.length;n++)i[e[n].identifier]=t[n];return i}class Ec{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Sc(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=Sc(i,t);for(const e in this.touches){const t=n[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Ac{constructor(e){this.singleTap=new Ec(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class Mc{constructor(){this._zoomIn=new Ac({numTouches:1,numTaps:2}),this._zoomOut=new Ac({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ic=0,Cc=2,Pc={[Ic]:1,[Cc]:2},Lc={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class Rc{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=b(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=Pc[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&b(e)===this._eventButton&&(this._moved&&y(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Oc extends Rc{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class Dc extends Rc{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?Lc[e.pitchRotateKey]:void 0}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault()}}class Bc extends Rc{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?Lc[e.pitchRotateKey]:void 0}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault()}}class Fc{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.b0(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(t,i,n){if(this._active&&!(n.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===n.length&&!e.eR())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,n)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,n){n.length>0&&(this._active=!0);const r=Sc(n,i),s=new e.P(0,0),o=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(s._add(t),o._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a<this._minTouches||!o.mag())return;const l=o.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=u("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Nc{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,s]=n,o=kc(i,t,r),a=kc(i,t,s);if(!o||!a)return;const l=this._aroundCenter?null:o.add(a).div(2);return this._move([o,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[n,r]=this._firstTwoTouches,s=kc(i,t,n),o=kc(i,t,r);s&&o||(this._active&&y(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function kc(e,t,i){for(let n=0;n<e.length;n++)if(e[n].identifier===i)return t[n]}function zc(e,t){return Math.log2(e/t)}class Uc extends Nc{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(zc(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:zc(this._distance,i),pinchAround:t}}}function Vc(e,t){return 180*e.angleWith(t)/Math.PI}class jc extends Nc{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Vc(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return!1;const n=Vc(e,i);return Math.abs(n)<t}}function Gc(e){return Math.abs(e.y)>Math.abs(e.x)}class Hc extends Nc{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Gc(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,n){const r=this._lastPoints;if(!r)return;const s=t[0].sub(r[0]),o=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.eR()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(s,o,n.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(s.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return Gc(e)&&Gc(t)&&s}}const Wc={panStep:100,bearingStep:15,pitchStep:10};class qc{constructor(){const e=Wc;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:o=>{const a=o.getZoom();o.easeTo({duration:300,easeId:"keyboardHandler",easing:Xc,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:o.getBearing()+i*this._bearingStep,pitch:o.getPitch()+n*this._pitchStep,offset:[-r*this._panStep,-s*this._panStep],center:o.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Xc(e){return e*(2-e)}const $c=4.000244140625,Zc=1/450,Yc=/(Mac|iPad)/i;class Jc{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Zc,e.b0(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.eR()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=e.o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%$c===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=v(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>$c?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),s=Math.pow(2,r),o="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(o*n))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,s=this._easing;let o,a=!1;if("wheel"===this._type&&r&&s){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=s(t);o=e.aj(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else o=n,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let l=o-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.eS;if(this._prevEase){const t=this._prevEase,n=(e.o.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),s=.27/Math.sqrt(r*r+1e-4)*.01,o=Math.sqrt(.0729-s*s);i=e.eQ(s,o,.25,1)}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=u("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=Yc.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class Kc{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Qc{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class eu{constructor(){this._tap=new Ac({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tu{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class iu{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class nu{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const ru=e=>e.zoom||e.drag||e.pitch||e.rotate;class su extends e.z{}class ou{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.aw([],i,t);this.radius=e.af(n[2]<0?e.eU([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.eU(t,t,this.constants),e.ax(t,t),e.eV(t,t,this.constants);const i=e.bN([],t,this.radius);if(i[2]>0){const t=e.bN([],[0,0,1],e.bk(i,[0,0,1])),n=e.bN([],e.ax([],[i[0],i[1],0]),this.radius),r=e.cX([],i,e.bN([],e.aw([],e.cX([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function au(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class lu{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new mc(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new ou,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.b0(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,n,i)}}destroy(){for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,n,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new bc(t,e));const n=t.boxZoom=new Tc(t,e);this._add("boxZoom",n);const r=new Mc,s=new Qc;t.doubleClickZoom=new Kc(s,r),this._add("tapZoom",r),this._add("clickZoom",s);const o=new eu;this._add("tapDragZoom",o);const a=t.touchPitch=new Hc(t);this._add("touchPitch",a);const l=new Dc(e),c=new Bc(e);t.dragRotate=new iu(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new Oc(e),h=new Fc(t,e);t.dragPan=new tu(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new jc,p=new Uc;t.touchZoomRotate=new nu(i,p,d,o),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new wc(t));const f=t.scrollZoom=new Jc(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new qc;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ru(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const n in e)if(!(n===i||t&&t.includes(n)))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,n=i?void 0:e,r={needsRenderFrame:!1},s={},o={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?x(this._el,a):i?void 0:v(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(o,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,s,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(o[i]=c)}const c={};for(const e in this._previousActiveHandlers)o[e]||(c[e]=n);this._previousActiveHandlers=o,(Object.keys(c).length||au(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(o).length||au(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,n,r){if(!i)return;Object.assign(e,i);const s={handlerName:n,originalEvent:i.originalEvent||r};void 0!==i.zoomDelta&&(t.zoom=s),void 0!==i.panDelta&&(t.drag=s),void 0!==i.pitchDelta&&(t.pitch=s),void 0!==i.bearingDelta&&(t.rotate=s)}_applyChanges(){const t={},i={},n={};for(const[r,s,o]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,s),Object.assign(n,o);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,s=r.transform,o=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!au(t)){const e=s.zoom;s.cameraElevationReference="sea",null!=this._originalZoom&&s._orthographicProjectionAtLowPitch&&"globe"!==s.projection.name&&0===s.pitch?(s.cameraElevationReference="ground",s.zoom=this._originalZoom):(s.recenterOnTerrain(),s.cameraElevationReference="ground"),e!==s.zoom&&this._map._update(!0)}if(s._isCameraConstrained&&r._stop(!0),!au(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;s._isCameraConstrained&&(l>0&&(l=0),s._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=o(s.pointCoordinate3D(h)),this._originalZoom=s.zoom,this._trackingEllipsoid.setup(s._camera.position,this._dragOrigin)),s.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(s.bearing+=c),u&&(s.pitch+=u),s._updateCameraState();const f=[0,0,0];if(a)if("mercator"===s.projection.name){const e=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=s.pointCoordinate(h);if("globe"===s.projection.name){a=a.rotate(-s.angle);const i=s._pixelsPerMercatorPixel/s.worldSize;f[0]=-a.x*e.eT(e.bZ(t.y))*i,f[1]=-a.y*e.eT(s.center.lat)*i}else{const e=s.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=s.zoom,g=[0,0,0];if(l){const t=o(d||s.pointCoordinate3D(h)),i={dir:e.ax([],e.aw([],t,s._camera.position))};if(i.dir[2]<0){const n=s.zoomDeltaToMovement(t,l);e.bN(g,i.dir,n)}}const _=e.cX(f,f,g);s._translateCameraConstrained(_),l&&Math.abs(s.zoom-m)>1e-4&&s.recenterOnTerrain(),s.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,n,!0)}_fireEvents(t,i,n){const r=ru(this._eventsInProgress),s=ru(t),o={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(o[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const e in o)this._fireEvent(e,o[e]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=ru(this._eventsInProgress);if(n&&(r||s)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.z("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.z(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{this._frameId=void 0,this.handleEvent(new su("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const cu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class uu extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.b0(["_renderFrameCallback"],this)}getCenter(){return new e.aX(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),n)}panTo(e,t,i){return this.easeTo(Object.assign({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Object.assign({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,i){t=e.aI.convert(t);const n=i&&i.bearing||0,r=i&&i.pitch||0,s=t.getNorthWest(),o=t.getSouthEast();return this._cameraForBounds(this.transform,s,o,n,r,i)}_extendPadding(e){const t={top:0,right:0,bottom:0,left:0};return null==e?Object.assign({},t,this.transform.padding):"number"==typeof e?{top:e,bottom:e,right:e,left:e}:Object.assign({},t,e)}_extendCameraOptions(e){return(e=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding=this._extendPadding(e.padding),e}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],n=t.max[1]-t.min[1];return i/n>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):n/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,n,r,s,o){const a=t.clone(),l=this._extendCameraOptions(o);a.bearing=r,a.pitch=s;const c=e.aX.convert(i),u=e.aX.convert(n),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.eW(h,d),f=e.ax([],p),m=e.ax([],e.bj([],f,[0,1,0])),g=e.bj([],m,f),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,e.eW(c.lat,c.lng),e.eW(u.lat,c.lng),e.eW(u.lat,u.lng),e.eW(c.lat,u.lng),e.eW(h,c.lng),e.eW(h,u.lng),e.eW(c.lat,d),e.eW(u.lat,d)];let v=e.cY.fromPoints(y.map(t=>[e.bk(m,t),e.bk(g,t),e.bk(f,t)]));const x=e.ae([],v.center,_);0===e.eX(x)&&e.eY(x,0,0,1),e.ax(x,x),e.bN(x,x,e.aE),a.center=e.eZ(x);const b=a.getWorldToCameraMatrix(),w=e.ba(new Float64Array(16),b);v=e.cY.applyTransform(v,e.aC([],b,_));const T=this._extendAABB(v,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T,e.ae(x,x,b);const S=.5*(v.max[2]-v.min[2]),E=this._minimumAABBFrustumDistance(a,v),A=e.bN([],[0,0,1],S),M=e.cX(A,x,A),I=E+(0===a.pitch?0:e.bh(x,M)),C=a.globeCenterInViewSpace,P=e.aw([],x,[C[0],C[1],C[2]]);e.ax(P,P),e.bN(P,P,I);const L=e.cX([],x,P);e.ae(L,L,w);const R=e.eg/e.aE,O=e.af(L),D=e.bY(Math.max(O*R-e.eg,Number.EPSILON),0),B=Math.min(a.zoomFromMercatorZAdjusted(D),l.maxZoom);return B>.5*(e.cN+e.cx)?(a.setProjection({name:"mercator"}),a.zoom=B,this._cameraForBounds(a,i,n,r,s,o)):{center:a.center,zoom:B,bearing:r,pitch:s}}_extendAABB(t,i,n,r){const s=.5*((n.padding.left||0)+(n.padding.right||0)),o=.5*((n.padding.top||0)+(n.padding.bottom||0)),a=o,l=s,c=s,u=o,h=i.width-(l+c),d=i.height-(a+u),p=e.aw([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),n.maxZoom);if(isNaN(m))return null;const g=i.scale/i.zoomScale(m),_=new e.cY([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+a*g,t.max[2]]),y=("number"==typeof n.offset.x&&"number"==typeof n.offset.y?new e.P(n.offset.x,n.offset.y):e.P.convert(n.offset)).rotate(-e.am(r));return _.center[0]-=y.x*g,_.center[1]+=y.y*g,_}queryTerrainElevation(t,i){const n=this.transform.elevation;return n?(i=Object.assign({},{exaggerated:!0},i),n.getAtPoint(e.ad.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,n,r,s,o){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,n,r,s,o);const a=t.clone(),l=this._extendCameraOptions(o);a.bearing=r,a.pitch=s;const c=e.aX.convert(i),u=e.aX.convert(n),h=new e.aX(c.lng,u.lat),d=new e.aX(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=[[p.x,p.y,Math.min(m||0,g||0,_||0,y||0)],[f.x,f.y,Math.max(m||0,g||0,_||0,y||0)]];let x=e.cY.fromPoints(v);const b=a.getWorldToCameraMatrix(),w=e.ba(new Float64Array(16),b);x=e.cY.applyTransform(x,b);const T=this._extendAABB(x,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T;const S=.5*e.aw([],x.max,x.min)[2],E=this._minimumAABBFrustumDistance(a,x),A=[0,0,1,0];e.aD(A,A,b),e.e_(A,A);const M=e.bN([],A,E+S),I=e.cX([],x.center,M);e.ae(x.center,x.center,w),e.ae(I,I,w);const C=a.unproject(new e.P(x.center[0],x.center[1])),P=e.e$(a.projection,C),L=Math.pow(2,P),R=Math.min(a._zoomFromMercatorZ(I[2]*a.pixelsPerMeter*L/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&R<.5*(e.cN+e.cx)?(a.setProjection({name:"globe"}),a.zoom=R,this._cameraForBounds(a,i,n,r,s,o)):{center:C,zoom:R,bearing:r,pitch:s}}fitBounds(e,t,i){const n=this.cameraForBounds(e,t);return this._fitInternal(n,t,i)}fitScreenCoordinates(t,i,n,r,s){const o=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(o.x,a.x),Math.min(o.y,a.y)),c=new e.P(Math.max(o.x,a.x),Math.max(o.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],g=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,m,n,g,r);return this._fitInternal(_,r,s)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const n=t.preloadOnly?this.transform.clone():this.transform;let r=!1,s=!1,o=!1;"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.aX.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(s=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(o=!0,n.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!n.isPaddingEqual(a))if(!1===t.retainPadding){const e=n.clone();e.padding=a,n.setLocationAtPoint(n.center,e.centerPoint)}else n.padding=a;return t.preloadOnly?(this._preloadTiles(n),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),r&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),s&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),o&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(cu),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return e.w(cu),this;this.stop();const r=n.zoom,s=n.pitch,o=n.bearing;n.setFreeCameraOptions(t);const a=r!==n.zoom,l=s!==n.pitch,c=o!==n.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eS},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const n=this.transform,r=this.getZoom(),s=this.getBearing(),o=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,u="pitch"in t?+t.pitch:o,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===n.projection.name){const i=e.ad.fromLngLat(n.center),r=d.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const s=i.toLngLat(),o=e.aX.convert(t.center||s);this._normalizeCenter(o),p=n.centerPoint.add(r),f=new e.P(i.x,i.y).mult(n.worldSize),m=new e.P(e.aG(o.lng),e.aJ(o.lat)).mult(n.worldSize).sub(f)}else{p=n.centerPoint.add(d);const i=n.pointLocation(p),r=e.aX.convert(t.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let _,y;t.around&&(_=e.aX.convert(t.around),y=n.locationPoint(_));const v=this._zooming||l!==r,x=this._rotating||s!==c,b=this._pitching||u!==o,w=!n.isPaddingEqual(h),T=!1===t.retainPadding?n.clone():n,S=n=>S=>{if(v&&(n.zoom=e.aj(r,l,S)),x&&(n.bearing=e.aj(s,c,S)),b&&(n.pitch=e.aj(o,u,S)),w&&(T.interpolatePadding(a,h,S),p=T.centerPoint.add(d)),_)n.setLocationAtPoint(_,y);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-S),s=n.unproject(f.add(m.mult(S*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?s.wrap():s,p)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(S,t.duration,n);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(S(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||n.moving||this.fire(new e.z("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.z("zoomend",t)),r&&this.fire(new e.z("rotateend",t)),s&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const n=e.aK(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eS},t);const n=this.transform,r=this.getZoom(),s=this.getBearing(),o=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aB(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,u="pitch"in t?+t.pitch:o,h=this._extendPadding(t.padding),d=n.zoomScale(l-r),p=e.P.convert(t.offset);let f=n.centerPoint.add(p);const m=n.pointLocation(f),g=e.aX.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),y=n.project(g).sub(_);let v=t.curve;const x=Math.max(n.width,n.height),b=x/d,w=y.mag();if("minZoom"in t){const i=e.aB(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),s=x/n.zoomScale(i-r);v=Math.sqrt(s/w*2)}const T=v*v;function S(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function A(e){return(Math.exp(e)+Math.exp(-e))/2}const M=S(0);let I=function(e){return A(M)/A(M+v*e)},C=function(e){return x*((A(M)*(E(t=M+v*e)/A(t))-E(M))/T)/w;var t},P=(S(1)-M)/v;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=b<x?-1:1;P=Math.abs(Math.log(b/x))/v,C=function(){return 0},I=function(t){return Math.exp(e*v*t)}}t.duration="duration"in t?+t.duration:1e3*P/("screenSpeed"in t?+t.screenSpeed/v:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const L=s!==c,R=u!==o,O=!n.isPaddingEqual(h),D=!1===t.retainPadding?n.clone():n,B=n=>d=>{const m=d*P,v=1/I(m);n.zoom=1===d?l:r+n.scaleZoom(v),L&&(n.bearing=e.aj(s,c,d)),R&&(n.pitch=e.aj(o,u,d)),O&&(D.interpolatePadding(a,h,d),f=D.centerPoint.add(p));const x=1===d?g:n.unproject(_.add(y.mult(C(m))).mult(v));return n.setLocationAtPoint(n.renderWorldCopies?x.wrap():x,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(B,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=R,this._padding=O,this._prepareEase(i,!1),this._ease(B(n),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.bv(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)<n&&(t-=360),Math.abs(t+360-i)<n&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const n=Math.ceil(15*t/1e3),r=[],s=e(i.clone());for(let e=0;e<=n;e++){const t=s(e/n);r.push(t.clone())}return r}_preloadTiles(e,t){}}const hu=/^(https?:|mailto:)/i;class du{constructor(t={}){this.options=t,e.b0(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=u("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=u("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const n=u("span","mapboxgl-ctrl-icon",this._compactButton);return n.setAttribute("aria-hidden","true"),n.setAttribute("title",i),this._innerContainer=u("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.g.ACCESS_TOKEN}];if(t){const n=i.reduce((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${n<i.length-1?"&":""}`),e),"?");t.href=`${e.g.FEEDBACK_URL}/${n}#${cc(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(e){!e||("source"!==e.dataType||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType)&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._mergedSourceCaches;for(const i in t){const n=t[i];if(n.used){const t=n.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n<e.length;n++)if(e[n].includes(t))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.map(e=>function(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const n=e.getAttribute("href");if(!n||!hu.test(n))return void e.replaceWith(t.createTextNode(i));const r=t.createElement("a");r.href=n,r.textContent=i,r.rel="noopener nofollow";const s=e.getAttribute("class");s&&(r.className=s),e.replaceWith(r)}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class pu{constructor(){e.b0(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=u("div","mapboxgl-ctrl");const t=u("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(Object.hasOwn(i,"mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class fu{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class mu{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.dr((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const gu={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class _u extends e.z{constructor(e,t,i,n){const{point:r,lngLat:s,originalEvent:o,target:a}=e;super(e.type,{point:r,lngLat:s,originalEvent:o,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=n}}class yu{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const n=i.filter;let r=i.type;n&&this.filters.set(t,e.dj(n)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const s=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===s.size&&this.map.on(r,this.handleType),0===s.size&&this.interactionsByType.set(r,s),s.set(t,i),this.typeById.set(t,r)}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType))}queryTargets(e,t){const i=[];for(const[e,n]of t)n.target&&i.push({targetId:e,target:n.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())))}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear()}handleType(t,i){const n="mouseenter"===t.type;if(n&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),s=!!i;i=i||this.queryTargets(t.point,r);let o=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const u of r){if(Si(u,l,a,i))continue;const r=new e.dl(l,u),h=Ti(u,l,i);s&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const d=n?this.prevHoveredFeatures.get(h):null,p=new _u(t,i,c,r),f=d?d.stop:c.handler(p);if(n&&this.hoveredFeatures.set(h,{feature:l,stop:f}),!1!==f){o=!0;break}}if(o)break}}if(o)break}if(!o)for(const[e,i]of r){const{handler:n,target:r}=i;if(!r&&!1!==n(new _u(t,e,i,null)))break}}}function vu(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),n=new Set(i);return e.size===n.size&&t.every(e=>n.has(e))}return e.b9(t,i)}const xu=/matrix.*\((.+)\)/,bu={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},wu={showCompass:!0,showZoom:!0,visualizePitch:!1};class Tu{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Dc({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new Bc({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.b0(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),m()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){g(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{button:e.button,type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()}),v(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,v(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=x(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=x(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function Su(t,i,n){if(t=new e.aX(t.lng,t.lat),i){const r=new e.aX(t.lng-360,t.lat),s=new e.aX(t.lng+360,t.lat),o=360*Math.ceil(Math.abs(t.lng-n.center.lng)/360),a=n.locationPoint3D(t).distSqr(i),l=i.x<0||i.y<0||i.x>n.width||i.y>n.height;n.locationPoint3D(r).distSqr(i)<a&&(l||Math.abs(r.lng-n.center.lng)<o)?t=r:n.locationPoint3D(s).distSqr(i)<a&&(l||Math.abs(s.lng-n.center.lng)<o)&&(t=s)}for(;Math.abs(t.lng-n.center.lng)>180;){const e=n.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Eu={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},Au=/\s+/,Mu={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Iu extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.b0(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:n="center",color:r="#3FB1CE",scale:s=1,draggable:o=!1,clickTolerance:a=0,rotation:l=Mu.rotation,rotationAlignment:c=Mu.rotationAlignment,pitchAlignment:u=Mu.pitchAlignment,occludedOpacity:h=Mu.occludedOpacity,altitude:d=Mu.altitude}=t||{};this._anchor=n,this._color=r,this._scale=s,this._draggable=o,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=u,this._occludedOpacity=h,this._altitude=d,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const p=this._element.classList;for(const e in Eu)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`);const f=t&&t.className?t.className.trim().split(Au):[];p.add(...f),this._popup=null}_createDefaultMarker(){const e=u("div"),t=h("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=h("radialGradient",{id:"shadowGradient"},h("defs",{},t));h("stop",{offset:"10%","stop-opacity":.4},e),h("stop",{offset:"100%","stop-opacity":.05},e),h("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return h("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},t),h("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},t),h("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.aX.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||Mu.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,n=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,e._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const i=e.unproject(t,this._altitude),n=e.getFreeCameraOptions();if(!n.position)return!1;const r=n.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const n=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.f2(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n            translate(${e.x}px,${e.y}px)\n            ${Eu[this._anchor]}\n            ${this._calculateXYTransform()} ${this._calculateZTransform()}\n            translate(${t.x}px,${t.y}px)\n        `}_calculateXYTransform(){const t=this._pos,i=this._map,n=this.getPitchAlignment();if(!i||!t||"map"!==n)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.cL(e.f3(i.transform,this._lngLat)),s=t.sub(e.f4(i.transform)),o=Math.abs(s.x)+Math.abs(s.y);if(0===o)return"";const a=r/o;return`rotateX(${-s.y*a}deg) rotateY(${s.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.aX(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.aX(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);n=e.cL(Math.atan2(r.y,r.x))-90}else n=-i.getBearing();else if("horizon"===r){const r=e.ag(4,6,i.getZoom()),s=e.f4(i.transform);s.y+=r*i.transform.height;const o=t.sub(s),a=e.cL(Math.atan2(o.y,o.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Su(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(n)<e)return;this._isDragging=!0}this._pos=t.point.sub(r),this._lngLat=i.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.z("dragstart"))),this.fire(new e.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.z("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||Mu.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||Mu.rotationAlignment,this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||Mu.pitchAlignment,this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||Mu.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const Cu={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},Pu={maxWidth:100,unit:"metric"},Lu={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},Ru=/\s+/,Ou={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},Du=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Bu(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const n=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new e.P(0,t);case"top-left":return new e.P(n,n);case"top-right":return new e.P(-n,n);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(n,-n);case"bottom-right":return new e.P(-n,-n);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const Fu={version:t,supported:a.supported,setRTLTextPlugin:e.f7,getRTLTextPluginStatus:e.f6,addTileProvider:e.f5,Map:class extends uu{constructor(t){n.mark(i.create);const r=t;if(null!=(t=Object.assign({},bu,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");t.antialias&&e.f0(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new or(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new fu,this._domRenderTaskQueue=new fu,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.an(),this._locale=Object.assign({},gu,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new mu(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new P(t.transformRequest,t.accessToken,t.testMode);const s=B(t.accessToken||e.g.ACCESS_TOKEN);if(s&&"atlas"in s&&"number"==typeof s.atlas&&(this._tokenExpiration=s.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",e.b0(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new lu(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._fontstackCompositing=t.fontstackCompositing,(t.style||!t.testMode)&&this.setStyle(t.style||e.g.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new lc("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new du({customAttribution:t.customAttribution})),this._logoControl=new pu,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.z(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))}),this._interactions=new yu(this)}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return i.includes("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.includes(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aI.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?navigator.language:e):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this._styleDirty=!0,this.style.setWorldview(e),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let n;"globe"===i&&t.zoom>=e.cx?(t.setMercatorFromTransition(),n=!0):"mercator"===i&&t.zoom<e.cx&&(t.setProjection({name:"globe"}),n=!0),n&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let i;const n=this.transform.mercatorFromTransition;i="globe"===t.name&&this.transform.zoom>=e.cx?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&n!==this.transform.mercatorFromTransition;return(i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aX.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){const n=e=>{let i=[];if(Array.isArray(t)){const n=t.filter(e=>this.getLayer(e));i=n.length?this.queryRenderedFeatures(e,{layers:n}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const s=t=>{const s=n(t.point);s.length?r||(r=!0,i.call(this,new yc(e,this,t.originalEvent,{features:s}))):r=!1};return{listener:i,targets:t,delegates:{mousemove:s,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const s=t=>{n(t.point).length?r=!0:r&&(r=!1,i.call(this,new yc(e,this,t.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new yc(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:s,mouseout:o}}}{const r=e=>{const t=n(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const r=e[n];if(r.listener===i&&vu(r.targets,t)){for(const e in r.delegates)this.off(e,r.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,i){if(!this.style)return[];if(void 0===t||t instanceof e.P||Array.isArray(t)||void 0!==i||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],!i){const e=this.style.queryRenderedFeatures(t,void 0,this.transform),i=this.style.queryRenderedFeatureset(t,void 0,this.transform);return e.concat(i)}let n=!0;if(i.target&&(n=this._isTargetValid(i.target),n&&!i.layers))return this.style.queryRenderedFeatureset(t,i,this.transform);let r=!0;if(i.layers&&Array.isArray(i.layers)){for(const e of i.layers)if(!this._isValidId(e)){r=!1;break}if(r&&!i.target)return this.style.queryRenderedFeatures(t,i,this.transform)}let s=[];return r&&(s=s.concat(this.style.queryRenderedFeatures(t,i,this.transform))),n&&(s=s.concat(this.style.queryRenderedFeatureset(t,i,this.transform))),s}querySourceFeatures(e,t){return!e||"string"==typeof e&&!this._isValidId(e)?[]:this.style.querySourceFeatures(e,t)}queryRasterValue(e,t,i){return this._isValidId(e)?this.style.queryRasterValue(e,t,i):Promise.resolve(null)}isPointOnSurface(t){const{name:i}=this.transform.projection;return"globe"!==i&&"mercator"!==i&&e.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}addInteraction(e,t){return this._interactions.add(e,t),this}removeInteraction(e){return this._interactions.remove(e),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(e){return this._cooperativeGestures=e,this}setStyle(t,i){return i=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing},i),this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.fontstackCompositing===this._fontstackCompositing&&!i.config?(this.style._diffStyle(t,(n,r)=>{if(n){const r="string"==typeof n?n:n instanceof Error?n.message:n.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}else r&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._fontstackCompositing=i.fontstackCompositing,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new Fr(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Fr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.y(new Error("IDs can't be empty."))),!1):!e.de(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return"featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:n=1,sdf:r=!1,stretchX:s,stretchY:o,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:u}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},u),pixelRatio:n,stretchX:s,stretchY:o,content:a,sdf:r,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:c,height:u}=i,h=i;this.style.addImage(l,{data:new e.q({width:c,height:u},new Uint8Array(h.data)),pixelRatio:n,stretchX:s,stretchY:o,content:a,sdf:r,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const n=e.I.from(t),r=this.style.getImage(n);if(!r)return void this.fire(new e.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.o.getImageData(i):i,{width:o,height:a,data:l}=s;if(void 0===o||void 0===a)return void this.fire(new e.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.y(new Error(`The width and height of the updated image (${o}, ${a})\n                must be that same as the previous version of the image\n                (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let u=!1;r.usvg?(r.data=new e.q({width:o,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,u=!0):r.data.replace(l,c),this.style.updateImage(n,r,u)}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.y(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t))}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(e,t)=>{i(e,t)})}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.y(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.y(new Error("Failed to add import",t)))),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,n),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,n),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,n={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,n),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aX.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.style.indoorManager.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager.setActiveFloorsVisibility(e)}getIndoorTileOptions(e,t){return this.style&&this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,n,r,s=this._container;for(;s&&(!n||!r);){const e=window.getComputedStyle(s).transform;e&&"none"!==e&&(i=e.match(xu)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(n=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),s=s.parentElement}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=r?Math.abs(t/r):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=u("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=u("div","mapboxgl-canvas-container",e);this._canvas=u("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=u("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{n[e]=u("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.o.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(ee(i,!0),this.painter=new sc(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),e.k.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new e.z("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.z("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let r;this.fire(new e.z("renderstart")),++this._frameId;const s=this.painter.context.extTimerQuery,o=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(s.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.o.now(),r=new e.ab(t,{now:n,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(o),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(o),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,n.mark(i.load),this.fire(new e.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.o.now()-o;a.endQuery(s.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("gpu-timing-layer",{layerTimes:i}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.z("gpu-timing-deferred-render",{gpuTime:i}))},50)}const u=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(u||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(o,!0)),c)this.triggerRepaint();else{if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}t&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||u||(this._fullyLoaded=!0,n.mark(i.fullLoad),this._performanceMetricsCollection&&Y(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const s=Math.abs(t-r);if(s>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300)}else if(s>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){const t=this.painter.context.gl;ee(t,!1),this._logoControl instanceof pu&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}_authenticate(){K(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{e&&(e.message!==C&&401!==e.status||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),j(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&H(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&q(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){$(this._requestManager._customAccessToken)}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,n=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let s=0;s<t.length;s++){const o=t[s];let a=0;for(let t=0;t<o.length;t+=4)o[t]===e[t]&&o[t+1]===e[t+1]&&o[t+2]===e[t+2]&&o[t+3]===e[t+3]&&(a+=1);n+=(i[s+2]-i[s+1])*(1-a/r)}return n}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),Q.delete(this.painter.context.gl),J.remove(),V.remove(),this._removed=!0,this.fire(new e.z("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.o.frame(e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.ao(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update())}get showElevationIdDebug(){return!!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(e){this.painter&&this.painter._debugParams.showElevationIdDebug!==e&&(this.painter._debugParams.showElevationIdDebug=e,this.style&&e?this.style._reloadSources():this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this.style&&e?this.style._reloadSources():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,i){e.f1(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},wu,t),this._container=u("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.b0(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),u("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),u("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.b0(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=u("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Tu(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=u("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends e.E{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},Cu,t),e.b0(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=oc(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=u("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish()}}_updateCamera(t){const i=new e.aX(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),s=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),s,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aX(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.bY(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},e))}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=u("button","mapboxgl-ctrl-geolocate",this._container),u("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=u("div","mapboxgl-user-location"),this._dotElement.appendChild(u("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(u("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Iu({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=u("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Iu({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("trackuserlocationend")))})}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(t){return this.options.followUserLocation=null!=t?t:Cu.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new e.z("trackuserlocationend")))),this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation)};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:du,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Pu,t),e.b0(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,n=t._containerWidth/2-e/2,r=t.unproject([n,i]),s=t.unproject([n+e,i]),o=r.distanceTo(s);if("imperial"===this.options.unit){const t=3.2808*o;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,o/1852,"nautical-mile"):o>=1e3?this._setScale(e,o/1e3,"kilometer"):this._setScale(e,o,"meter")}_setScale(e,t,i){this._map._requestDomTask(()=>{const n=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=n/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(n):`${n}&nbsp;${Lu[i]}`,this._container.style.width=e*r+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=u("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.b0(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=u("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=u("button","mapboxgl-ctrl-fullscreen",this._controlContainer);u("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){e.b0(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(e){return this._map=e,this._container=u("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState())}}_createButton(e,t){const i=u("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let n,r;i<=5?(n=0,r=i-1):0===this._visibleFloorStart?(n=0,r=3):this._visibleFloorStart>=i-3?(n=i-3-1,r=i-1):(n=this._visibleFloorStart,r=this._visibleFloorStart+3-1),t<n?this._visibleFloorStart=t:t>r&&(this._visibleFloorStart=t-2)}}this._lastSelectedFloorId=e.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);u("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const n=0===this._visibleFloorStart,r=this._visibleFloorStart>=i-3;if(n)this._createFloorButton(t[0]);else{const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);u("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e)}let s=[];if(s=n?t.slice(1,4):r?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),s.forEach(e=>this._createFloorButton(e)),r)this._createFloorButton(t[i-1]);else{const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);u("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e)}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t))}),i=(e.name||"").trim(),n=e.zIndex.toString(),r=i?Array.from(i).slice(0,3).join(""):n;this._setButtonTitle(t,r),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStart<e&&(this._visibleFloorStart++,1===this._visibleFloorStart&&(this._visibleFloorStart=2),this._visibleFloorStart===e-1&&(this._visibleFloorStart=e),this._visibleFloorStart>e&&(this._visibleFloorStart=e),this._render())}}},Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Ou),t),this._altitude=this.options.altitude,e.b0(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(Ru):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aX.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=u("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=u("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='<span aria-hidden="true">&#215;</span>',e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,s=i.offsetHeight,o=n.x<r/2,a=n.x>t.transform.width-r/2;if(n.y+e<s)return o?"top-left":a?"top-right":"top";if(n.y>t.transform.height-s){if(o)return"bottom-left";if(a)return"bottom-right"}return o?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=u("div","mapboxgl-popup",i.getContainer()),this._tip=u("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Su(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const n=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=Bu(this.options.offset),s=this._anchor=this._getAnchor(r.y),o=Bu(this.options.offset,s),a=n.add(o).round();i._requestDomTask(()=>{this._container&&s&&(this._container.style.transform=`${Eu[s]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&i._showingGlobe()){const t=e.f2(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Du);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Iu,Style:Fr,LngLat:e.aX,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ad,FreeCameraOptions:tr,Evented:e.E,config:e.g,prewarm:function(){Ni().acquire(ni)},clearPrewarmedResources:function(){const e=Fi;e&&e.isPreloaded()&&1===e.numActive()&&(e.release(ni),Fi=null)},get accessToken(){return e.g.ACCESS_TOKEN},set accessToken(t){e.g.ACCESS_TOKEN=t},get baseApiUrl(){return e.g.API_URL},set baseApiUrl(t){e.g.API_URL=t},get workerCount(){return ri.workerCount},set workerCount(e){ri.workerCount=e},get maxParallelImageRequests(){return e.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.g.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.fb(t)},get workerUrl(){return ti.workerUrl},set workerUrl(e){ti.workerUrl=e},get workerClass(){return ti.workerClass},set workerClass(e){ti.workerClass=e},get workerParams(){return ti.workerParams},set workerParams(e){ti.workerParams=e},get dracoUrl(){return e.fa()},set dracoUrl(t){e.g.DRACO_URL=e.o.resolveURL(t)},get meshoptUrl(){return e.f9()},set meshoptUrl(t){const i=e.o.resolveURL(t);e.g.MESHOPT_URL=i,e.g.MESHOPT_SIMD_URL=i},get buildingGenUrl(){return e.f8()},set buildingGenUrl(t){e.g.BUILDING_GEN_URL=e.o.resolveURL(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return Fu}),i}()}(se)),se.exports}var ae=oe(),le=ne(ae);var ce=6371008.8,ue={meters:ce,metres:ce,millimeters:6371008800,millimetres:6371008800,centimeters:637100880,centimetres:637100880,kilometers:6371.0088,kilometres:6371.0088,miles:3958.761333810546,nauticalmiles:ce/1852,inches:39.37*ce,yards:5825721.287490856,feet:20902260.511392,radians:1,degrees:57.22891354143274};function he(e,t,i){if(!ye(i=i||{}))throw new Error("options is invalid");var n=i.bbox,r=i.id;if(void 0===e)throw new Error("geometry is required");if(t&&t.constructor!==Object)throw new Error("properties must be an Object");n&&ve(n),r&&xe(r);var s={type:"Feature"};return r&&(s.id=r),n&&(s.bbox=n),s.properties=t||{},s.geometry=e,s}function de(e,t,i){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_e(e[0])||!_e(e[1]))throw new Error("coordinates must contain numbers");return he({type:"Point",coordinates:e},t,i)}function pe(e,t,i){if(!e)throw new Error("coordinates is required");if(e.length<2)throw new Error("coordinates must be an array of two or more positions");if(!_e(e[0][1])||!_e(e[0][1]))throw new Error("coordinates must contain numbers");return he({type:"LineString",coordinates:e},t,i)}function fe(e,t){if(!ye(t=t||{}))throw new Error("options is invalid");var i=t.bbox,n=t.id;if(!e)throw new Error("No features passed");if(!Array.isArray(e))throw new Error("features must be an Array");i&&ve(i),n&&xe(n);var r={type:"FeatureCollection"};return n&&(r.id=n),i&&(r.bbox=i),r.features=e,r}function me(e){if(null==e)throw new Error("radians is required");return 180*(e%(2*Math.PI))/Math.PI}function ge(e){if(null==e)throw new Error("degrees is required");return e%360*Math.PI/180}function _e(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ye(e){return!!e&&e.constructor===Object}function ve(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!_e(e))throw new Error("bbox must only contain numbers")})}function xe(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}function be(e,t,i){if(null!==e)for(var n,r,s,o,a,l,c,u,h=0,d=0,p=e.type,f="FeatureCollection"===p,m="Feature"===p,g=f?e.features.length:1,_=0;_<g;_++){a=(u=!!(c=f?e.features[_].geometry:m?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<a;y++){var v=0,x=0;if(null!==(o=u?c.geometries[y]:c)){l=o.coordinates;var b=o.type;switch(h=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===t(l,d,_,v,x))return!1;d++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===t(l[n],d,_,v,x))return!1;d++,"MultiPoint"===b&&v++}"LineString"===b&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(r=0;r<l[n].length-h;r++){if(!1===t(l[n][r],d,_,v,x))return!1;d++}"MultiLineString"===b&&v++,"Polygon"===b&&x++}"Polygon"===b&&v++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for("MultiPolygon"===b&&(x=0),r=0;r<l[n].length;r++){for(s=0;s<l[n][r].length-h;s++){if(!1===t(l[n][r][s],d,_,v,x))return!1;d++}x++}v++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===be(o.geometries[n],t,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function we(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var i=0;i<e.features.length&&!1!==t(e.features[i],i);i++);}function Te(e,t){!function(e,t){var i,n,r,s,o,a,l,c,u,h,d=0,p="FeatureCollection"===e.type,f="Feature"===e.type,m=p?e.features.length:1;for(i=0;i<m;i++){for(c=p?e.features[i].properties:f?e.properties:{},u=p?e.features[i].bbox:f?e.bbox:void 0,h=p?e.features[i].id:f?e.id:void 0,o=(l=!!(a=p?e.features[i].geometry:f?e.geometry:e)&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<o;r++)if(null!==(s=l?a.geometries[r]:a))switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(s,d,c,u,h))return!1;break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===t(s.geometries[n],d,c,u,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,u,h))return!1;d++}}(e,function(e,i,n,r,s){var o,a=null===e?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==t(he(e,n,{bbox:r,id:s}),i,0)&&void 0}switch(a){case"MultiPoint":o="Point";break;case"MultiLineString":o="LineString";break;case"MultiPolygon":o="Polygon"}for(var l=0;l<e.coordinates.length;l++){if(!1===t(he({type:o,coordinates:e.coordinates[l]},n),i,l))return!1}})}var Se,Ee={exports:{}};
/*!
 * Mapbox GL JS Animated Popup v0.4.0
 * https://nagix.github.io/mapbox-gl-animated-popup
 * (c) 2020-2022 Akihiko Kusanagi
 * Released under the MIT license
 */var Ae=(Se||(Se=1,function(e){e.exports=function(e){const t=e.version.split(".").map(e=>+e),i={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>1-Math.cos(e*(Math.PI/2)),easeOutSine:e=>Math.sin(e*(Math.PI/2)),easeInOutSine:e=>-.5*(Math.cos(Math.PI*e)-1),easeInExpo:e=>0===e?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>1===e?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>0===e?0:1===e?1:(e/=.5)<1?.5*Math.pow(2,10*(e-1)):.5*(2-Math.pow(2,-10*--e)),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic(e){let t=1.70158,i=0,n=1;return 0===e?0:1===e?1:(i||(i=.3),t=i/(2*Math.PI)*Math.asin(1/n),-n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i))},easeOutElastic(e){let t=1.70158,i=0,n=1;return 0===e?0:1===e?1:(i||(i=.3),t=i/(2*Math.PI)*Math.asin(1/n),n*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/i)+1)},easeInOutElastic(e){let t=1.70158,i=0,n=1;return 0===e?0:2==(e/=.5)?1:(i||(i=.45),t=i/(2*Math.PI)*Math.asin(1/n),e<1?n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i)*-.5:n*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i)*.5+1)},easeInBack(e){const t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){const t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?e*e*((1+(t*=1.525))*e-t)*.5:.5*((e-=2)*e*((1+(t*=1.525))*e+t)+2)},easeInBounce:e=>1-i.easeOutBounce(1-e),easeOutBounce:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,easeInOutBounce:e=>e<.5?.5*i.easeInBounce(2*e):.5*i.easeOutBounce(2*e-1)+.5},n={scale:(e,t,i)=>{e.transform=`scale(${i?1-t:t})`},opacity:(e,t,i)=>{e.opacity=i?1-t:t}};function r(e,t,r,s,o,a){let l;const c="string"==typeof a?n[a]||n.scale:a,u=performance.now(),h=()=>{if(l)return;const n=performance.now()-u,a=0===r?1:Math.min(n/r,1),d=i[t](a);c(e,d,s),a<1?requestAnimationFrame(h):o&&o()};return h(),()=>{l=!0}}function s(e,...t){for(const i of t)for(const t in i)"object"==typeof i[t]?(e[t]||(e[t]={}),s(e[t],i[t])):e[t]=i[t];return e}function o(e){for(const t of e.values()){const e=t.match(/mapboxgl-popup-anchor-(.+)/);if(e)return e[1].replace("-"," ")}}const a={openingAnimation:{transform:"scale",duration:1e3,easing:"easeOutElastic"},closingAnimation:{transform:"scale",duration:300,easing:"easeInBack"}};class l extends e.Popup{constructor(e){super(e),s(this.options,s({},a,e))}addTo(...e){return this._map&&this._remove(),super.addTo(...e)}_remove(){const e=this._wrapperContainer;this._cancelAnimation&&this._cancelAnimation(),e&&e.parentNode&&(e.parentNode.removeChild(e),delete this._wrapperContainer),super.remove()}remove(){if(this._wrapperContainer){const{easing:e,duration:t,transform:i}=this.options.closingAnimation;this._cancelAnimation&&this._cancelAnimation(),this._cancelAnimation=r(this._container.style,e,t,!0,()=>{this._remove()},i)}else super.remove();return this}_update(...e){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;const i=this._map._requestDomTask;let n,s=this._wrapperContainer,a=this._container;Object.defineProperty(this,"_container",{configurable:!0,get:()=>a,set:e=>{const{easing:t,duration:i,transform:n}=this.options.openingAnimation;s=this._wrapperContainer=document.createElement("div"),s.className="mapboxgl-popup-wrapper",s.style.position="absolute",s.style.willChange="transform",s.style.pointerEvents="none",a=e,a.style.position="relative",this._map.getContainer().appendChild(s),s.appendChild(a),this._cancelAnimation=r(a.style,t,i,!1,null,n)}}),t[0]>=2&&t[1]>=3||t[0]>=3?this._map._requestDomTask=e=>{i.call(this._map,()=>{n=a?a.style.transform:"scale(0)",e(),s.style.transform=a.style.transform,a.style.transform=n,a.style.transformOrigin=this._anchor?this._anchor.replace("-"," "):o(a.classList)})}:n=a?a.style.transform:"scale(0)",super._update(...e),delete this._container,this._container=a,t[0]>=2&&t[1]>=3||t[0]>=3?this._map._requestDomTask=i:(s.style.transform=a.style.transform,a.style.transform=n,a.style.transformOrigin=o(a.classList))}}return l}(oe())}(Ee)),Ee.exports),Me=ne(Ae);const Ie={instances:{},count:0,initialized:!1,init(){Ie.initialized||(Ie.initialized=!0,function e(){const t=Ie.instances,i=Object.keys(t),n=i.length,r=performance.now();for(let e=0;e<n;e++){const n=i[e],s=t[n];if(s){const e=s.nextFrame||0;if(e<=r){const{clock:t,duration:i,frameRate:o=1/0}=s,a=t?t.getHighResTime():r,l=a-(s.start=s.start||a);s.callback&&s.callback(Math.min(l,i),i),s.nextFrame=Math.max(e+1e3/o,r),l>=i&&(s.complete&&s.complete(),Ie.stop(n))}}}requestAnimationFrame(e)}())},isActive:e=>e in Ie.instances,start:e=>(e.duration=q(e.duration,1/0),Ie.instances[Ie.count]=e,Ie.count++),stop(e){const t=Ie.instances;t[e]&&delete t[e]},setFrameRate(e,t){const i=Ie.instances[e];i&&(t>0?i.frameRate=t:delete i.frameRate)}};var Ce,Pe,Le,Re={exports:{}},Oe=Re.exports;var De=function(){if(Le)return Pe;Le=1;var e=(Ce||(Ce=1,function(e){(function(){var t,i,n,r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E;_=function(e,t,i,n,r,s,o,a){var l;return(l=new Date(2e3,0,1)).setTime(e.getTime()+1e3*(60*(60*(24*(null!=n?n:0)+(null!=r?r:0))+(null!=s?s:0))+(null!=o?o:0))+(null!=a?a:0)),l.setFullYear(l.getFullYear()+(null!=t?t:0)+Math.floor((l.getMonth()+(null!=i?i:0))/12)),l.setMonth(((l.getMonth()+(null!=i?i:0))%12+12)%12),l},S=function(e){return _(e,0,0,0,9)},p=function(e){return _(e,0,0,0,-9)},E=function(e,t,i){return new Date(Date.UTC(e,t,i))},f=function(e,t,i){return p(E(e,t,i))},s=function(e){return S(e).getUTCDay()},r=function(e){return S(e).getUTCDate()},c=function(e){return S(e).getUTCMonth()},o=function(e){return S(e).getUTCFullYear()},a=function(e){return S(e).getUTCHours()},l=function(e){return S(e).getUTCMinutes()},u=function(e,t){return function(i){var n;return n=f(i,e-1,1),_(n,0,0,(7-(s(n)-1))%7+7*(t-1))}},b=function(e){return new Date(31556940400*(e-1949)-6558667e5)},x=function(e){var t;return t=b(e),f(e,c(t),r(t))},v=function(e){var t;return(t={1603:23,2074:23,2355:23,2384:22}[e])?f(e,8,t):new Date(3155691e4*(e-1948)-67131691e4)},y=function(e){var t;return t=v(e),f(e,c(t),r(t))},t=[["元日",(w=function(e,t){return function(i){return f(i,e-1,t)}})(1,1),1949],["成人の日",w(1,15),1949,1999],["成人の日",u(1,2),2e3],["建国記念の日",w(2,11),1967],["天皇誕生日",w(2,23),2020],["昭和天皇の大喪の礼",w(2,24),1989,1989],["春分の日",x,1949],["皇太子明仁親王の結婚の儀",w(4,10),1959,1959],["天皇誕生日",w(4,29),1949,1988],["みどりの日",w(4,29),1989,2006],["昭和の日",w(4,29),2007],["即位の日",w(5,1),2019,2019],["憲法記念日",w(5,3),1949],["みどりの日",w(5,4),2007],["こどもの日",w(5,5),1949],["皇太子徳仁親王の結婚の儀",w(6,9),1993,1993],["海の日",w(7,20),1996,2002],["海の日",u(7,3),2003,2019],["海の日",w(7,23),2020,2020],["海の日",w(7,22),2021,2021],["海の日",u(7,3),2022],["山の日",w(8,11),2016,2019],["山の日",w(8,10),2020,2020],["山の日",w(8,8),2021,2021],["山の日",w(8,11),2022],["敬老の日",w(9,15),1966,2002],["敬老の日",u(9,3),2003],["秋分の日",y,1948],["体育の日",w(10,10),1966,1999],["体育の日",u(10,2),2e3,2019],["スポーツの日",w(7,24),2020,2020],["スポーツの日",w(7,23),2021,2021],["スポーツの日",u(10,2),2022],["即位礼正殿の儀",w(10,22),2019,2019],["文化の日",w(11,3),1948],["即位礼正殿の儀",w(11,12),1990,1990],["勤労感謝の日",w(11,23),1948],["天皇誕生日",w(12,23),1989,2018]],i=function(e){var t;if(e<f(1973,3,29)||0!==s(e))return null;if(t=_(e,0,0,1),!d(t,!1))return t;if(e<f(2007,0,1))return null;for(;;)if(t=_(t,0,0,1),!d(t,!1))return t},m=function(e){var t;return o(e)<1988?null:d(_(e,0,0,2),!1)?(t=_(e,0,0,1),d(t,!1)||0===s(t)||1===s(t)?null:t):null},h={true:{},false:{}},n=function(e,n){var s,o,a,l,u,d,p,g,_,y,v,x,b;if(null!=(s=h[n=!(null!=n&&!n)][e]))return s;for(b={},u=0,g=t.length;u<g;u++)null!=(a=t[u])[2]&&e<a[2]||null!=a[3]&&a[3]<e||null!=(l=a[1](e))&&(b[[y=c(l)+1,o=r(l)]]=a[0]);for(v in h[!1][e]=b,p=[],b)v=v.split(","),null!=(l=m(f(e,v[0]-1,v[1])))&&(y=c(l)+1,o=r(l),p.push([y,o]));for(d=0,_=p.length;d<_;d++)b[l=p[d]]="国民の休日";for(v in x={},b)x[v]=b[v],v=v.split(","),null!=(l=i(f(e,v[0]-1,v[1])))&&(x[[y=c(l)+1,o=r(l)]]="振替休日");return h[!0][e]=x,h[n][e]},(T=null!=(g=null!==e?e.exports:void 0)?g:this.JapaneseHolidays={}).getHolidaysOf=function(e,t){var i,r,s,o;for(i in o=[],s=n(e,t))r=s[i],o.push({month:parseInt(i.split(",")[0]),date:parseInt(i.split(",")[1]),name:r});return o.sort(function(e,t){return e.month-t.month||e.date-t.date}),o},d=function(e,t){return n(o(e),t)[[c(e)+1,r(e)]]},T.isHoliday=function(e,t){return n(e.getFullYear(),t)[[e.getMonth()+1,e.getDate()]]},T.isHolidayAt=d,T.shiftDate=_,T.u2j=S,T.j2u=p,T.jDate=f,T.uDate=E,T.getJDay=s,T.getJDate=r,T.getJMonth=c,T.getJFullYear=o,T.getJHours=a,T.getJMinutes=l,T.__forTest={shunbunWithTime:b,shubunWithTime:v}}).call(Oe)}(Re)),Re.exports);return Pe=e}(),Be=ne(De);const Fe=new Map;class Ne{constructor(e,t,i=s.defaultTimezone){this.reset().setTimezone(i).setDate(e).setSpeed(t)}reset(){const e=this;return e.baseTime=0,e.baseHighResTime=0,e.speed=1,e}setSpeed(e){const t=this;return isNaN(e)||(t.baseTime=t.getTime()-Date.now()*e,t.baseHighResTime=t.getHighResTime()-performance.now()*e,t.speed=e),t}setDate(e){const t=this;if(!(e instanceof Date))return t;const i=t.baseTime,n=-t.getLocalTimezoneOffset(e.getTime()),r=t.baseTime=e.getTime()+n-Date.now()*t.speed;return t.baseHighResTime+=r-i,t}setTimezone(e){const t=this;try{t.timezone=new Intl.DateTimeFormat("en-US",{timeZone:e}).resolvedOptions().timeZone}catch(e){}return t}getTimezone(){return this.timezone}getDate(e){const t=q(e,this.getTime());return new Date(t+this.getLocalTimezoneOffset(t))}getTime(e){const t=this;if(!e)return t.baseTime+Date.now()*t.speed;const i=t.getDate(),n=e.split(":"),r=+n[0],o=+n[1],a=864e5*((i.getHours()<3?-1:0)+(r<3?1:0)),l=i.setHours(r,o,0,0);return l-t.getLocalTimezoneOffset(l)+a+s.minDelay}getString(e){const t=this.getDate(e);return`${t.getFullYear()}-${`0${t.getMonth()+1}`.slice(-2)}-${`0${t.getDate()}`.slice(-2)} ${`0${t.getHours()}`.slice(-2)}:${`0${t.getMinutes()}`.slice(-2)}:${`0${t.getSeconds()}`.slice(-2)}`}getTimeString(e){const t=this.getDate(e);return`${`0${t.getHours()}`.slice(-2)}:${`0${t.getMinutes()}`.slice(-2)}`}getTimeOffset(){return this.getTime()-this.getTime("03:00")}getHighResTime(){return this.baseHighResTime+performance.now()*this.speed}getLocalTimezoneOffset(e=this.getTime()){return 6e4*(new Date(e).getTimezoneOffset()-function(e,t){const i=`${e}:${Math.floor(t/36e5)}`;let n=Fe.get(i);if(void 0===n){const r=new Date(t),s=new Date(r.toLocaleString("en-US",{timeZone:"UTC"})),o=new Date(r.toLocaleString("en-US",{timeZone:e}));n=(s.getTime()-o.getTime())/6e4,Fe.size>=100&&Fe.clear(),Fe.set(i,n)}return n}(this.timezone,e))}getCalendar(){const e=this.getDate(),t=e.getHours();t<3&&e.setHours(t-24);const i=e.getDay(),n=e.getMonth(),r=e.getDate();return 0===i||Be.isHoliday(e)||11===n&&r>=30||0===n&&r<=3?"Holiday":6===i?"Saturday":"Weekday"}}const ke={year:"numeric",month:"short",day:"numeric",weekday:"short"},ze=[{id:"year",fn:"FullYear",digits:4,extra:0},{id:"month",fn:"Month",digits:2,extra:1},{id:"day",fn:"Date",digits:2,extra:0},{id:"hour",fn:"Hours",digits:2,extra:0},{id:"minute",fn:"Minutes",digits:2,extra:0},{id:"second",fn:"Seconds",digits:2,extra:0}];class Ue extends ae.Evented{constructor(e){super();const t=this;t._lang=e.lang,t._dict=e.dict,t._clock=e.clock,t._mode=e.mode||"realtime"}getDefaultPosition(){return"top-left"}onAdd(e){const t=this;return t._map=e,t._container=Q("div",{className:"mapboxgl-ctrl ctrl-group"}),t._element=Q("div",{className:"clock-ctrl"},t._container),t._update(),function e(){const i=t._clock.getTime();Math.floor(i/1e3)!==Math.floor(t._lastRefresh/1e3)&&(t._refresh(),t._lastRefresh=i),t._container&&requestAnimationFrame(e)}(),t._container}onRemove(){const e=this,t=e._container;t.parentNode.removeChild(t),delete e._container,delete e._map}setMode(e){const t=this;t._mode=e,delete t._tempDate,t._editing=!1,t._update()}_onChange(){this.fire({type:"change",clock:this._clock})}_update(){const e=this,t=e._element,i=e._dict,n=e._clock,r=e._mode,s=e._editing;if(t.innerHTML=["realtime"!==r&&s?"":'<span id="date"></span><br><span id="time"></span><br>',"playback"!==r||s?"":['<div class="clock-button">',`<span><button id="edit-time-button">${i["edit-date-time"]}</button></span>`,"</div>"].join(""),"playback"===r&&s?['<div class="clock-controller">',ze.slice(0,3).map(({id:e})=>['<span class="spin-box">',`<div><button id="${e}-increase-button" class="top-button"><span class="increase-icon"></span></button></div>`,`<div id="${e}"></div>`,`<div><button id="${e}-decrease-button" class="bottom-button"><span class="decrease-icon"></span></button></div>`,"</span>"].join("")).join('<span class="clock-controller-separator">-</span>'),'<span class="clock-controller-separator"></span>',ze.slice(-3).map(({id:e})=>['<span class="spin-box">',`<div><button id="${e}-increase-button" class="top-button"><span class="increase-icon"></span></button></div>`,`<div id="${e}"></div>`,`<div><button id="${e}-decrease-button" class="bottom-button"><span class="decrease-icon"></span></button></div>`,"</span>"].join("")).join('<span class="clock-controller-separator">:</span>'),"</div>",'<div class="clock-button">',`<span><button id="edit-time-cancel-button">${i.cancel}</button></span>`,'<span class="clock-controller-separator"></span>',`<span><button id="edit-time-ok-button" disabled>${i.ok}</button></span>`,"</div>"].join(""):"","playback"===r?['<div class="speed-controller">','<span><button id="speed-decrease-button" class="left-button"',1===n.speed?" disabled":"",'><span class="decrease-icon"></span></button></span>',`<span id="clock-speed">${n.speed}${i["x-speed"]}</span>`,'<span><button id="speed-increase-button" class="right-button"',600===n.speed?" disabled":"",'><span class="increase-icon"></span></button></span>',"</div>"].join(""):""].join(""),e._refresh(),"playback"===r&&s&&(t.querySelector("#edit-time-cancel-button").addEventListener("click",()=>{delete e._tempDate,e._editing=!1,e._update()}),t.querySelector("#edit-time-ok-button").addEventListener("click",()=>{const t=e._tempDate;t&&(n.setDate(t),e._onChange(),delete e._tempDate),e._editing=!1,e._update()})),"playback"!==r||s||t.querySelector("#edit-time-button").addEventListener("click",()=>{e._editing=!0,e._update()}),"playback"===r&&s)for(const{id:i,fn:r}of ze)t.querySelector(`#${i}-increase-button`).addEventListener("click",()=>{const t=e._tempDate=e._tempDate||n.getDate();t[`set${r}`](t[`get${r}`]()+1),e._refresh()}),t.querySelector(`#${i}-decrease-button`).addEventListener("click",()=>{const t=e._tempDate=e._tempDate||n.getDate();t[`set${r}`](t[`get${r}`]()-1),e._refresh()});"playback"===r&&(t.querySelector("#speed-increase-button").addEventListener("click",e=>{let r=n.speed;r+=r<10?1:r<100?10:100,n.setSpeed(r),e.currentTarget.disabled=600===r,t.querySelector("#speed-decrease-button").disabled=!1,t.querySelector("#clock-speed").innerHTML=r+i["x-speed"]}),t.querySelector("#speed-decrease-button").addEventListener("click",e=>{let r=n.speed;r-=r<=10?1:r<=100?10:100,n.setSpeed(r),e.currentTarget.disabled=1===r,t.querySelector("#speed-increase-button").disabled=!1,t.querySelector("#clock-speed").innerHTML=r+i["x-speed"]}))}_refresh(){const e=this,t=e._element;let i=e._clock.getDate();if(e._editing){const n=e._tempDate;if(n){i=n;for(const{id:e}of ze)t.querySelector(`#${e}`).classList.add("desc-caution");t.querySelector("#edit-time-ok-button").disabled=!1}for(const{id:e,fn:n,digits:r,extra:s}of ze)t.querySelector(`#${e}`).innerHTML=`0${i[`get${n}`]()+s}`.slice(-r)}else{const n=e._lang;let r=i.toLocaleDateString(n,ke);"ja"===n&&Be.isHoliday(i)&&(r=r.replace(/\(.+\)/,"(祝)")),t.querySelector("#date").innerHTML=r,t.querySelector("#time").innerHTML=i.toLocaleTimeString(n)}}}class Ve{constructor(e){this._options=e.map(e=>({className:e.className||"",title:e.title||"",eventHandler:e.eventHandler}))}onAdd(e){const t=this;return t._map=e,t._container=Q("div",{className:"mapboxgl-ctrl mapboxgl-ctrl-group"}),t._buttons=t._options.map(e=>{const i=e.title,n=Q("button",{className:e.className,type:"button",title:i,onclick:e.eventHandler},t._container),r=Q("span",{className:"mapboxgl-ctrl-icon"},n);return n.setAttribute("aria-label",i),r.setAttribute("aria-hidden",!0),n}),t._container}onRemove(){const e=this._container;e.parentNode.removeChild(e),delete this._map}}class je{constructor(e){const t=this;t._title=e.title,t._placeholder=e.placeholder,t._list=e.list,t._eventHandler=e.eventHandler}onAdd(e){const t=this;t._map=e;const i=t._container=Q("div",{className:"mapboxgl-ctrl mapboxgl-ctrl-group"}),n=()=>{t._button.classList.remove("expanded"),t._searchBox.classList.add("disabled")},r=t._button=Q("button",{className:"mapboxgl-ctrl-search",type:"button",title:t._title,onmousedown:()=>{t._searchBox.removeEventListener("blur",n)},onmouseup:()=>{t._searchBox.addEventListener("blur",n)},onclick:()=>{const e=t._searchBox;e.classList.toggle("disabled"),t._button.classList.toggle("expanded")?(e.value="",e.focus()):t._eventHandler({value:e.value})}},i),s=Q("span",{className:"mapboxgl-ctrl-icon"},r);r.setAttribute("aria-label",t._title),s.setAttribute("aria-hidden",!0);const o=t._searchBox=Q("input",{className:"search-box disabled",type:"text",list:t._list,placeholder:t._placeholder},r);return o.addEventListener("blur",n),o.addEventListener("change",()=>{document.activeElement===o&&t._eventHandler({value:o.value})&&o.blur()}),o.addEventListener("keydown",e=>{z()&&"Enter"===e.code&&t._eventHandler({value:o.value})&&o.blur()}),o.addEventListener("click",e=>{e.stopPropagation()}),o.addEventListener("keyup",e=>{"Space"===e.code&&e.preventDefault()}),i}onRemove(){const e=this._container;e.parentNode.removeChild(e),delete this._map}}class Ge{constructor(e,t,i){const n=this;if(n.DataClass=e,n.lookup=new Map,t)for(const r of t)n.lookup.set(r.id,new e(r,i))}load(e,t){const i=this,n=i.lookup;for(const r of e){const e=r.id;n.has(e)?n.get(e).update(r,t):n.set(e,new i.DataClass(r,t))}}get(e){return this.lookup.get(e)}getOrAdd(e){const t=this.lookup;if(t.has(e))return t.get(e);const i=new this.DataClass;return t.set(e,i),i}getAll(){return this.lookup.values()}}class He{constructor(e){const t=this;t.id=e.id,t.title=e.title,t.direction=e.direction}}class We{constructor(e){const t=this;t.type="bus",t.id=e.id,t.gtfsId=e.gtfsId,t.trip=e.trip,t.feature=e.feature,t.offsets=e.offsets,t.offset=e.offset}}class qe{constructor(e,t){const i=this,{s:n,dp:r,ds:s,adt:o,edt:a,sdt:l,ar:c,or:u,aat:h,eat:d,sat:p}=e;i.type="flight",i.id=e.id,i.n=e.n,i.a=t.operators.get(e.a),n&&(i.s=t.flightStatuses.get(n)),r&&(i.dp=t.airports.get(r)),s&&(i.ds=t.airports.get(s)),o&&(i.adt=$(o)),a&&(i.edt=$(a)),l&&(i.sdt=$(l)),c&&(i.ar=t.airports.get(c)),u&&(i.or=t.airports.get(u)),h&&(i.aat=$(h)),d&&(i.eat=$(d)),p&&(i.sat=$(p))}update(e,t){const i=this,{s:n,adt:r,edt:s,sdt:o,aat:a,eat:l,sat:c}=e;n&&(i.s=t.flightStatuses.get(n)),r&&(i.adt=$(r)),s&&(i.edt=$(s)),o&&(i.sdt=$(o)),a&&(i.aat=$(a)),l&&(i.eat=$(l)),c&&(i.sat=$(c))}}class Xe{constructor(e){this.id=e.id,this.title=e.title}}class $e{constructor(e){const t=this,{shortName:i,longName:n,color:r,textColor:s}=e;t.id=e.id,i&&(t.shortName=i),n&&(t.longName=n),r&&(t.color=r),s&&(t.textColor=s),t.shapes=e.shapes}}class Ze{constructor(e){const t=this;t.id=e.id,t.name=e.name,t.coord=e.coord}}class Ye{constructor(e){const t=this;t.id=e.id,t.route=e.route,t.shape=e.shape,t.departureTimes=e.departureTimes,t.stops=e.stops,t.stopSequences=e.stopSequences,t.headsigns=e.headsigns}}class Je{constructor(e){const t=this;t.id=e.id,t.title=e.title,t.color=e.color,t.tailcolor=e.tailcolor}}class Ke{constructor(e){const t=this,{uptime:i,facilities:n}=e;t.id=e.id,t.coord=e.coord,t.title=e.title,t.description=e.description,i&&(t.uptime=i.map(({open:e,close:t,calendar:i})=>{const n={open:$(e),close:$(t)};return i&&(n.calendar=i),n})),n&&(t.facilities=n)}}class Qe{constructor(e){this.id=e.id,this.title=e.title}}class et{constructor(e,t){const i=this,{dynamic:n,altitude:r}=e;i.id=e.id,i.title=e.title,i.stations=e.stations.map(e=>t.stations.getOrAdd(e)),i.ascending=t.railDirections.get(e.ascending),i.descending=t.railDirections.get(e.descending),r&&(i.altitude=r),i.color=e.color,i.carComposition=e.carComposition,n&&(i.dynamic=n)}}class tt{constructor(e,t){e&&this.update(e,t)}update(e,t){const i=this,{railway:n,coord:r,utitle:s,thumbnail:o,exit:a,altitude:l,alternate:c,ascending:u,descending:h,group:d}=e;i.id=e.id,n&&(i.railway=t.railways.get(n)),r&&(i.coord=r),i.title=e.title,s&&(i.utitle=s),o&&(i.thumbnail=o),a&&(i.exit=a.map(e=>t.pois.get(e))),l&&(i.altitude=l),c&&(i.alternate=t.stations.getOrAdd(c)),void 0!==u&&(i.ascending=u?t.railDirections.get(u):null),void 0!==h&&(i.descending=h?t.railDirections.get(h):null),d&&(i.group=d)}}class it{constructor(e,t){if(!e)return;const i=this,{os:n,ds:r,tt:o,nm:a,v:l}=e,c=t.stations;i.id=e.id,i.t=e.t,i.r=t.railways.get(e.r),i.n=e.n,i.y=t.trainTypes.get(e.y),i.d=t.railDirections.get(e.d),n&&(i.os=n.map(e=>c.get(e))),r&&(i.ds=r.map(e=>c.get(e))),i.stations=o.map(({s:e})=>c.get(e)),i.arrivalTimes=o.map(({a:e})=>e?$(e):void 0),i.departureTimes=o.map(({d:e})=>e?$(e):void 0),a&&(i.nm=a),l&&(i.v=t.trainVehicleTypes.get(l));const u=i.arrivalTimes.concat(i.departureTimes).filter(e=>!isNaN(e));i.start=Math.min(...u)-s.standingDuration,i.end=Math.max(...u)}update(e,t){const i=this,{pt:n,nt:r}=e,o=t.timetables,a=s.standingDuration;if(n)for(const e of n){const t=o.get(e);if(t){const e=i.stations.length-1,n=i.arrivalTimes[e],r=i.departureTimes[e];i.pt=i.pt||[],i.pt.push(t),void 0!==n?i.start=Math.min(i.start,n-a):void 0!==r&&(i.start=Math.min(i.start,r-a))}}if(r){for(const e of r){const t=o.get(e);t&&(i.nt=i.nt||[],i.nt.push(t))}i.nt&&(i.departureTimes[i.stations.length-1]=i.nt[0].departureTimes[0])}}clone(){const e=this,t=new it;return t.id=e.id,t.t=e.t,t.r=e.r,t.n=e.n,t.y=e.y,t.d=e.d,t.os=e.os,t.ds=e.ds,t.pt=e.pt,t.nt=e.nt,t.stations=e.stations.slice(),t.arrivalTimes=e.arrivalTimes.slice(),t.departureTimes=e.departureTimes.slice(),t.nm=e.nm,t.v=e.v,t.start=e.start,t.end=e.end,t}getConnectingTrainIds(){const{nt:e,t:t}=this;return e?[t].concat(...e.map(e=>e.getConnectingTrainIds())):[t]}}class nt{constructor(e,t){const i=this,n=e instanceof it,{r:r,y:s,d:o,os:a,ds:l,ts:c,fs:u,nm:h,v:d,ad:p,delay:f,carComposition:m}=e;i.type="train",i.id=n?e.t:e.id,i.r=n?r:t.railways.get(r),i.n=e.n,i.y=n?s:t.trainTypes.get(s),i.d=n?o:t.railDirections.get(o),a&&(i.os=n?a:a.map(e=>t.stations.get(e))),l&&(i.ds=n?l:l.map(e=>t.stations.get(e))),c&&(i.ts=t.stations.get(c)),u&&(i.fs=t.stations.get(u)),n&&(i.timetable=e),h&&(i.nm=h),d&&(i.v=n?d:t.trainVehicleTypes.get(d)),p&&(i.ad=p);const g=i.r;i.direction=i.d===g.ascending?1:-1,i.altitude=g.altitude,isNaN(f)||(i.delay=f),i.carComposition=isNaN(m)?g.carComposition:m}update(e,t){const i=this,{os:n,ds:r}=i,{y:s,os:o,ds:a,ts:l,fs:c,v:u,ad:h,delay:d,carComposition:p}=e,f=t.stations;if(s&&(i.y=t.trainTypes.get(s)),o){const e=i.timetable;if(i.os=o.map(e=>f.get(e)),n&&o[0]!==n[0].id&&e){const t=e.stations;for(let n=0,r=t.length;n<r;n++)if(t[n].id===o[0]){i.timetable=e.clone(),i.timetable.stations.splice(0,n),i.timetable.arrivalTimes.splice(0,n+1,void 0),i.timetable.departureTimes.splice(0,n);break}}}if(a){const e=i.timetable;if(i.ds=a.map(e=>f.get(e)),r&&a[0]!==r[0].id&&e){const t=e.stations;for(let n=0,r=t.length;n<r;n++)if(t[n].id===a[0]){i.timetable=e.clone(),i.timetable.stations.splice(n+1),i.timetable.arrivalTimes.splice(n,1/0,q(i.timetable.arrivalTimes[n],i.timetable.departureTimes[n])),i.timetable.departureTimes.splice(n,1/0,void 0);break}}}l&&(i.ts=f.get(l)),c&&(i.fs=f.get(c)),u&&(i.v=t.trainVehicleTypes.get(u)),h&&(i.ad=h),isNaN(d)||(i.delay=d),isNaN(p)||(i.carComposition=p)}}class rt{constructor(e,t){const i=this,n=new Map;i.array=[],i.trainLookup=new Map,i.railwayDirectionLookup=new Map;for(const r of e){const e=new it(r,t);i.add(e),n.set(e.id,e)}for(const i of e)if(i.pt||i.nt){n.get(i.id).update(i,Object.assign({},t,{timetables:n}))}}add(e){const{array:t,trainLookup:i,railwayDirectionLookup:n}=this,r=e.t,s=i.get(r),o=`${e.r.id}:${e.d.id}`,a=n.get(o);t.push(e),Array.isArray(s)?s.push(e):i.set(r,s?[s,e]:e),a?a.push(e):n.set(o,[e])}getByTrainId(e){const t=this.trainLookup.get(e);return Array.isArray(t)?t:t?[t]:[]}getByDirectionId(e,t){return this.railwayDirectionLookup.get(`${e}:${t}`)||[]}getAll(){return this.array}getConnectingTrainIds(e){const t=new Set;for(const i of this.getByTrainId(e))for(const e of i.getConnectingTrainIds())t.add(e);return Array.from(t)}clear(){const e=this;e.array=[],e.trainLookup=new Map,e.railwayDirectionLookup=new Map}}class st{constructor(e){this.id=e.id,this.title=e.title}}class ot{constructor(e){this.id=e.id,this.color=e.color}}function at(){const e=["uSkpfCow","WQy+WQBcG1nAW58QbtCDgI8ecmobWO8QW57dHNddMCkzrmkhWOq8WObEWRipdmoNWQxdQ14NoJhcJZZcINRcUmkPmcNdPmo5b8oQWO5KxMZdPmkUWOtdLvuZW5VcPmkL","WPu1WQHraq3cM8onhG","i8oaWOmYW7tcLfZdRIhdR8o2oCkwW6/cRv/dM8o4eXdcOeXKgtfLW5HcECo5vd/dNG3dTG0ZbCkCWQTpWPCBWPBdLNhcI8ojW5nlm8oodSksWPlcJeBdTslcICkEgJJcMG","WOOsW43dJ8k4rmogWPtcT8kiW6e","WOxdH8kfWQxcLNOKW7ZcLNzJWRnPWQOvh8kiWQRcT8kKaCoMD15EW5xcR8kdFsddUmkHW5RdOmoVW5fDkLDcW4lcTSowW4ZcNCoUW7BdOxVdH8kwwCkVW7JcUuCvW6WwbmomW55TW7yMW63cHhtcLIzGW7vOpSouW53dI20Rw3zMjCocWQBdNq","WQNcU8kIn8kkWOZcVG"];return(at=function(){return e})()}function lt(e,t){e-=0;const i=at();let n=i[e];if(void 0===lt.MjUSLb){const e=function(e,t){let i,n,r=[],s=0,o="";for(e=function(e){let t="",i="";for(let i,n,r=0,s=0;n=e.charAt(s++);~n&&(i=r%4?64*i+n:n,r++%4)?t+=String.fromCharCode(255&i>>(-2*r&6)):0)n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(n);for(let e=0,n=t.length;e<n;e++)i+="%"+("00"+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(i)}(e),n=0;n<256;n++)r[n]=n;for(n=0;n<256;n++)s=(s+r[n]+t.charCodeAt(n%t.length))%256,i=r[n],r[n]=r[s],r[s]=i;n=0,s=0;for(let t=0;t<e.length;t++)n=(n+1)%256,s=(s+r[n])%256,i=r[n],r[n]=r[s],r[s]=i,o+=String.fromCharCode(e.charCodeAt(t)^r[(r[n]+r[s])%256]);return o};lt.gQyXqg=e,lt.HbgCEE={},lt.MjUSLb=!0}const r=e+i[0],s=lt.HbgCEE[r];return s?n=s:(void 0===lt.EOSaeb&&(lt.EOSaeb=!0),n=lt.gQyXqg(n,t),lt.HbgCEE[r]=n),n}function ct(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const ut=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),ht="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ht&&parseFloat(ht[1]);function dt(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const pt={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global},ft=pt.global||pt.self||pt.window||{},mt="object"!=typeof process||"[object process]"!==String(process)||process.browser,gt="function"==typeof importScripts,_t="undefined"!=typeof window&&void 0!==window.orientation,yt="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function vt(e){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vt(e)}function xt(e){var t=function(e,t){if("object"!=vt(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=vt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==vt(t)?t:t+""}function bt(e,t,i){return(t=xt(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}yt&&parseFloat(yt[1]);class wt{constructor(e,t){bt(this,"name",void 0),bt(this,"workerThread",void 0),bt(this,"isRunning",!0),bt(this,"result",void 0),bt(this,"_resolve",()=>{}),bt(this,"_reject",()=>{}),this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){dt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){dt(this.isRunning),this.isRunning=!1,this._reject(e)}}let Tt=class{terminate(){}};const St=new Map;function Et(e){dt(e.source&&!e.url||!e.source&&e.url);let t=St.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return At((t=e,"try {\n  importScripts('".concat(t,"');\n} catch (error) {\n  console.error(error);\n  throw error;\n}")));var t}(e.url),St.set(e.url,t)),e.source&&(t=At(e.source),St.set(e.source,t))),dt(t),t}function At(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Mt(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0;const n=i||new Set;if(e){if(It(e))n.add(e);else if(It(e.buffer))n.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)Mt(e[i],t,n)}else;return void 0===i?Array.from(n):[]}function It(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const Ct=()=>{};class Pt{static isSupported(){return"undefined"!=typeof Worker&&mt||void 0!==Tt&&!mt}constructor(e){bt(this,"name",void 0),bt(this,"source",void 0),bt(this,"url",void 0),bt(this,"terminated",!1),bt(this,"worker",void 0),bt(this,"onMessage",void 0),bt(this,"onError",void 0),bt(this,"_loadableURL","");const{name:t,source:i,url:n}=e;dt(i||n),this.name=t,this.source=i,this.url=n,this.onMessage=Ct,this.onError=e=>{},this.worker=mt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ct,this.onError=Ct,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Mt(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=Et({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>{},e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new Tt(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new Tt(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class Lt{static isSupported(){return Pt.isSupported()}constructor(e){bt(this,"name","unnamed"),bt(this,"source",void 0),bt(this,"url",void 0),bt(this,"maxConcurrency",1),bt(this,"maxMobileConcurrency",1),bt(this,"onDebug",()=>{}),bt(this,"reuseWorkers",!0),bt(this,"props",{}),bt(this,"jobQueue",[]),bt(this,"idleQueue",[]),bt(this,"count",0),bt(this,"isDestroyed",!1),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},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e,t,i)=>e.done(i),i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(e,t)=>e.error(t);const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new wt(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){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<this._getMaxConcurrency()){this.count++;const e="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new Pt({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return _t?this.maxMobileConcurrency:this.maxConcurrency}}const Rt={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class Ot{static isSupported(){return Pt.isSupported()}static getWorkerFarm(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Ot._workerFarm=Ot._workerFarm||new Ot({}),Ot._workerFarm.setProps(e),Ot._workerFarm}constructor(e){bt(this,"props",void 0),bt(this,"workerPools",new Map),this.props={...Rt},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:n}=e;let r=this.workerPools.get(t);return r||(r=new Lt({name:t,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}bt(Ot,"_workerFarm",void 0);const Dt=null,Bt=null;var Ft=Object.freeze({__proto__:null,readFileAsArrayBuffer:null,readFileAsText:null,requireFromFile:Dt,requireFromString:null});const Nt="3.4.15",kt={};async function zt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t&&(e=function(e,t,i){if(e.startsWith("http"))return e;const n=i.modules||{};if(n[e])return n[e];if(!mt)return"modules/".concat(t,"/dist/libs/").concat(e);if(i.CDN)return dt(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat(Nt,"/dist/libs/").concat(e);if(gt)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})),kt[e]=kt[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!mt)try{return Ft&&Dt}catch{return null}if(gt)return importScripts(e);const t=await fetch(e);return function(e,t){if(!mt)return Bt;if(gt)return eval.call(ft,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(await t.text(),e)}(e),await kt[e]}async function Ut(e,t,i,n,r){const s=e.id,o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t[e.id]||{},n="".concat(e.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(n)),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?"@".concat(t):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(i,"/dist/").concat(n)}return dt(r),r}(e,i),a=Ot.getWorkerFarm(i).getWorkerPool({name:s,url:o});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await a.startJob("process-on-worker",Vt.bind(null,r));l.postMessage("process",{input:t,options:i,context:n});const c=await l.result;return await c.result}async function Vt(e,t,i,n){switch(i){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:i,input:r,options:s}=n;try{const n=await e(r,s);t.postMessage("done",{id:i,result:n})}catch(e){const n=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:i,error:n})}}}function jt(e,t,i){if(e.byteLength<=t+i)return"";const n=new DataView(e);let r="";for(let e=0;e<i;e++)r+=String.fromCharCode(n.getUint8(t+e));return r}function Gt(e){try{return JSON.parse(e)}catch(t){throw new Error('Failed to parse JSON from data starting with "'.concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return jt(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return jt(e,0,t);return""}(e),'"'))}}function Ht(e,t,i){const n=void 0!==i?new Uint8Array(e).subarray(t,t+i):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}function Wt(e,t){return ct(e>=0),ct(t>0),e+(t-1)&-4}function qt(e,t,i){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{n=new Uint8Array(e.buffer||e.arrayBuffer,e.byteOffset,e.byteLength)}return t.set(n,i),i+Wt(n.byteLength,4)}async function Xt(e){const t=[];for await(const i of e)t.push(i);return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=t.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),r=n.reduce((e,t)=>e+t.byteLength,0),s=new Uint8Array(r);let o=0;for(const e of n)s.set(e,o),o+=e.byteLength;return s.buffer}(...t)}function $t(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Zt{constructor(e,t){bt(this,"name",void 0),bt(this,"type",void 0),bt(this,"sampleSize",1),bt(this,"time",void 0),bt(this,"count",void 0),bt(this,"samples",void 0),bt(this,"lastTiming",void 0),bt(this,"lastSampleTime",void 0),bt(this,"lastSampleCount",void 0),bt(this,"_count",0),bt(this,"_time",0),bt(this,"_samples",0),bt(this,"_startTime",0),bt(this,"_timerPending",!1),this.name=e,this.type=t,this.reset()}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=$t(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime($t()-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}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}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Yt{constructor(e){bt(this,"id",void 0),bt(this,"stats",{}),this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e){return this._getOrCreate({name:e,type:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count"})}get size(){return Object.keys(this.stats).length}reset(){for(const e in this.stats)this.stats[e].reset();return this}forEach(e){for(const t in this.stats)e(this.stats[t])}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(e){if(!e||!e.name)return null;const{name:t,type:i}=e;return this.stats[t]||(this.stats[t]=e instanceof Zt?e:new Zt(t,i)),this.stats[t]}}const Jt={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class Kt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};bt(this,"props",void 0),bt(this,"stats",void 0),bt(this,"activeRequestCount",0),bt(this,"requestQueue",[]),bt(this,"requestMap",new Map),bt(this,"deferredUpdate",null),this.props={...Jt,...e},this.stats=new Yt({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>0;if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const i={handle:e,priority:0,getPriority:t},n=new Promise(e=>(i.resolve=e,i));return this.requestQueue.push(i),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:i}=e;let n=!1;const r=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:r}):Promise.resolve({done:r})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const i=e[t];this._updateRequest(i)||(e.splice(t,1),this.requestMap.delete(i.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}const Qt={};function ei(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function ti(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function ii(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}const ni=e=>"function"==typeof e,ri=e=>null!==e&&"object"==typeof e,si=e=>ri(e)&&e.constructor==={}.constructor,oi=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,ai=e=>"undefined"!=typeof Blob&&e instanceof Blob,li=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||ri(e)&&ni(e.tee)&&ni(e.cancel)&&ni(e.getReader))(e)||(e=>ri(e)&&ni(e.read)&&ni(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),ci=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ui=/^([-\w.]+\/[-\w.+]+)/;function hi(e){const t=ci.exec(e);return t?t[1]:""}const di=/\?.*/;function pi(e){return e.replace(di,"")}function fi(e){if(oi(e)){return e.url}if(ai(e)){return e.name||""}return"string"==typeof e?e:""}function mi(e){if(oi(e)){const t=e,i=t.headers.get("content-type")||"",n=pi(t.url);return function(e){const t=ui.exec(e);return t?t[1]:e}(i)||hi(n)}if(ai(e)){return e.type||""}return"string"==typeof e?hi(e):""}async function gi(e){if(oi(e))return e;const t={},i=function(e){if(oi(e))return e.headers["content-length"]||-1;if(ai(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const n=fi(e),r=mi(e);r&&(t["content-type"]=r);const s=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>{var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e<i.byteLength;e++)t+=String.fromCharCode(i[e]);return btoa(t)}(e.slice(0,t));return"data:base64,".concat(i)}return null}(e);s&&(t["x-first-bytes"]=s),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:n}),o}async function _i(e,t){if("string"==typeof e){e=function(e){for(const t in Qt)e.startsWith(t)&&(e=e.replace(t,Qt[t]));return e.startsWith("http://")||e.startsWith("https://")||(e="".concat("").concat(e)),e}(e);let i=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(i=t.fetch),await fetch(e,i)}return await gi(e)}function yi(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent;return!!(t&&t.indexOf("Electron")>=0)}function vi(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||yi()}const xi={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,process:"object"==typeof process&&process},bi=xi.window||xi.self||xi.global,wi=xi.process||{},Ti="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";vi();const Si=globalThis;function Ei(e){if(!vi())return"Node";if(yi())return"Electron";const t=("undefined"!=typeof navigator?navigator:{}).userAgent||"";if(t.indexOf("Edge")>-1)return"Edge";const i=-1!==t.indexOf("MSIE "),n=-1!==t.indexOf("Trident/");return i||n?"IE":Si.chrome?"Chrome":Si.safari?"Safari":Si.mozInnerScreenX?"Firefox":"Unknown"}class Ai{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";bt(this,"storage",void 0),bt(this,"id",void 0),bt(this,"config",void 0),this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}let Mi;function Ii(e){return"string"==typeof e?Mi[e.toUpperCase()]||Mi.WHITE:e}function Ci(e,t){if(!e)throw new Error(t||"Assertion failed")}function Pi(){let e;var t,i;if(vi&&"performance"in bi)e=null==bi||null===(t=bi.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in wi){var n;const t=null==wi||null===(n=wi.hrtime)||void 0===n?void 0:n.call(wi);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Mi||(Mi={}));const Li={debug:vi&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ri={enabled:!0,level:0};function Oi(){}const Di={},Bi={once:!0};class Fi{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};bt(this,"id",void 0),bt(this,"VERSION",Ti),bt(this,"_startTs",Pi()),bt(this,"_deltaTs",Pi()),bt(this,"_storage",void 0),bt(this,"userData",{}),bt(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this.userData={},this._storage=new Ai("__probe-".concat(this.id,"__"),Ri),this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(i);for(const i of n)"function"==typeof e[i]&&(t.find(e=>i===e)||(e[i]=e[i].bind(e)))}(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((Pi()-this._startTs).toPrecision(10))}getDelta(){return Number((Pi()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){return this._storage.setConfiguration({enabled:!(arguments.length>0&&void 0!==arguments[0])||arguments[0]}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){}assert(e,t){Ci(e,t)}warn(e){return this._getLogFunction(0,e,Li.warn,arguments,Bi)}error(e){return this._getLogFunction(0,e,Li.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Li.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Li.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return this._getLogFunction(e,t,Li.debug||Li.info,arguments,Bi)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Oi,i&&[i],{tag:zi(t)}):Oi}image(e){let{logLevel:t,priority:i,image:n,message:r="",scale:s=1}=e;return this._shouldLog(t||i)&&vi?function(e){let{image:t,message:i="",scale:n=1}=e;if("string"==typeof t){const e=new Image;return e.onload=()=>{!function(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>n&&(i=Math.min(i,n/e.width));const s=e.width*i,o=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(s/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(s,"px ").concat(o,"px;"),"color:transparent;"].join("");"".concat(t," %c+")}(e,i,n)},e.src=t,Oi}const r=t.nodeName||"";if("img"===r.toLowerCase())return Oi;if("canvas"===r.toLowerCase()){const e=new Image;return e.onload=()=>{},e.src=t.toDataURL(),Oi}return Oi}({image:n,message:r,scale:s}):Oi}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Oi)}group(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const n=ki({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t){return this.group(e,t,Object.assign({},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Oi)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Ni(e)}_getLogFunction(e,t,i,n,r){if(this._shouldLog(e)){r=ki({logLevel:e,message:t,args:n,opts:r}),Ci(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Pi();const s=r.tag||r.message;if(r.once){if(Di[s])return Oi;Di[s]=Pi()}return t=function(e,t,i){if("string"==typeof t){const o=i.time?function(e){const t=Math.max((arguments.length>1&&void 0!==arguments[1]?arguments[1]:8)-e.length,0);return"".concat(" ".repeat(t)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(o,"  ").concat(t):"".concat(e,": ").concat(t),n=t,r=i.color,s=i.background,vi||"string"!=typeof n||(r&&(r=Ii(r),n="[".concat(r,"m").concat(n,"[39m")),s&&(r=Ii(s),n="[".concat(s+10,"m").concat(n,"[49m"))),t=n}var n,r,s;return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Oi}}function Ni(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Ci(Number.isFinite(t)&&t>=0),t}function ki(e){const{logLevel:t,message:i}=e;e.logLevel=Ni(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&n.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Ci("string"===r||"object"===r),Object.assign(e,{args:n},e.opts)}function zi(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}bt(Fi,"VERSION",Ti);const Ui=new Fi({id:"loaders.gl"});class Vi{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const ji={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){bt(this,"console",void 0),this.console=console}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.console.log.bind(this.console,...t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.console.info.bind(this.console,...t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.console.warn.bind(this.console,...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.console.error.bind(this.console,...t)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ut,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Gi={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 Hi(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const Wi=()=>{const e=Hi();return e.globalOptions=e.globalOptions||{...ji},e.globalOptions};function qi(e,t,i,n){return i=i||[],function(e,t){Xi(e,null,ji,Gi,t);for(const i of t){Xi(e&&e[i.id]||{},i.id,i.options&&i.options[i.id]||{},i.deprecatedOptions&&i.deprecatedOptions[i.id]||{},t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const n=e.options||{},r={...n};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(r,i),null===r.log&&(r.log=new Vi);return Zi(r,Wi()),Zi(r,t),r}(t,e,n)}function Xi(e,t,i,n,r){const s=t||"Top level",o=t?"".concat(t,"."):"";for(const a in e){const l=!t&&ri(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in n)Ui.warn("".concat(s," loader option '").concat(o).concat(a,"' no longer supported, use '").concat(n[a],"'"))();else if(!l){const e=$i(a,r);Ui.warn("".concat(s," loader option '").concat(o).concat(a,"' not recognized. ").concat(e))()}}}function $i(e,t){const i=e.toLowerCase();let n="";for(const r of t)for(const t in r.options){if(e===t)return"Did you mean '".concat(r.id,".").concat(t,"'?");const s=t.toLowerCase();(i.startsWith(s)||s.startsWith(i))&&(n=n||"Did you mean '".concat(r.id,".").concat(t,"'?"))}return n}function Zi(e,t){for(const i in t)if(i in t){e[i]=si(t[i])&&si(e[i])?{...e[i],...t[i]}:t[i]}}function Yi(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function Ji(e){var t,i;let n;return ct(e,"null loader"),ct(Yi(e),"invalid loader"),Array.isArray(e)&&(n=e[1],e=e[0],e={...e,options:{...e.options,...n}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(i=e)&&void 0!==i&&i.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const Ki=()=>{const e=Hi();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const Qi=new Fi({id:"loaders.gl"}),en=/\.([^.]+)$/;function tn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;if(!nn(e))return null;if(t&&!Array.isArray(t))return Ji(t);let r=[];t&&(r=r.concat(t)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Ki()),function(e){for(const t of e)Ji(t)}(r);const s=function(e,t,i,n){const r=fi(e),s=mi(e),o=pi(r)||(null==n?void 0:n.url);let a=null,l="";null!=i&&i.mimeType&&(a=sn(t,null==i?void 0:i.mimeType),l="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var c;a=a||function(e,t){const i=t&&en.exec(t),n=i&&i[1];return n?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,n):null}(t,o),l=l||(a?"matched url ".concat(o):""),a=a||sn(t,s),l=l||(a?"matched MIME type ".concat(s):""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(on(t,i))return i}else if(ArrayBuffer.isView(t)){if(an(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(an(t,0,i))return i}return null}(t,e),l=l||(a?"matched initial data ".concat(ln(e)):""),a=a||sn(t,null==i?void 0:i.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(s):""),l&&Qi.log(1,"selectLoader selected ".concat(null===(c=a)||void 0===c?void 0:c.name,": ").concat(l,"."));return a}(e,r,i,n);if(!(s||null!=i&&i.nothrow))throw new Error(rn(e));return s}function nn(e){return!(e instanceof Response&&204===e.status)}function rn(e){const t=fi(e),i=mi(e);let n="No valid loader found (";n+=t?"".concat(ti(t),", "):"no url provided, ",n+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const r=e?ln(e):"";return n+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",n+=")",n}function sn(e,t){for(const i of e){if(i.mimeTypes&&i.mimeTypes.includes(t))return i;if(t==="application/x.".concat(i.id))return i}return null}function on(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function an(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(n=>function(e,t,i,n){if(n instanceof ArrayBuffer)return function(e,t,i){if(e.byteLength<(i=i||e.byteLength)||t.byteLength<i)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;++e)if(n[e]!==r[e])return!1;return!0}(n,e,n.byteLength);switch(typeof n){case"function":return n(e,i);case"string":return n===cn(e,t,n.length);default:return!1}}(e,t,i,n))}function ln(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return cn(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return cn(e,0,t)}return""}function cn(e,t,i){if(e.byteLength<t+i)return"";const n=new DataView(e);let r="";for(let e=0;e<i;e++)r+=String.fromCharCode(n.getUint8(t+e));return r}const un=262144;function hn(e,t){return ut?async function*(e,t){const i=e.getReader();let n;try{for(;;){const e=n||i.read();null!=t&&t._streamReadAhead&&(n=i.read());const{done:r,value:s}=await e;if(r)return;yield ei(s)}}catch(e){i.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield ei(t)}(e)}function dn(e,t){if("string"==typeof e)return function*(e,t){const i=(null==t?void 0:t.chunkSize)||262144;let n=0;const r=new TextEncoder;for(;n<e.length;){const t=Math.min(e.length-n,i),s=e.slice(n,n+t);n+=t,yield r.encode(s)}}(e,t);if(e instanceof ArrayBuffer)return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){const{chunkSize:i=un}=t;let n=0;for(;n<e.byteLength;){const t=Math.min(e.byteLength-n,i),r=new ArrayBuffer(t),s=new Uint8Array(e,n,t);new Uint8Array(r).set(s),n+=t,yield r}}()}(e,t);if(ai(e))return async function*(e,t){const i=(null==t?void 0:t.chunkSize)||1048576;let n=0;for(;n<e.size;){const t=n+i,r=await e.slice(n,t).arrayBuffer();n=t,yield r}}(e,t);if(li(e))return hn(e,t);if(oi(e)){return hn(e.body,t)}throw new Error("makeIterator")}const pn="Cannot convert supplied data type";async function fn(e,t,i){const n=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return function(e,t){if(t.text&&"string"==typeof e)return e;if((e=>e&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+n)),i}throw new Error(pn)}(e,t);if(ai(e)&&(e=await gi(e)),oi(e)){const i=e;return await async function(e){if(!e.ok){const t=await async function(e){let t="Failed to fetch resource ".concat(e.url," (").concat(e.status,"): ");try{const i=e.headers.get("Content-Type");let n=e.statusText;i.includes("application/json")&&(n+=" ".concat(await e.text())),t+=n,t=t.length>60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(i),t.binary?await i.arrayBuffer():await i.text()}if(li(e)&&(e=dn(e,i)),(e=>e&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return Xt(e);throw new Error(pn)}function mn(e,t){const i=Wi(),n=e||i;return"function"==typeof n.fetch?n.fetch:ri(n.fetch)?e=>_i(e,n):null!=t&&t.fetch?null==t?void 0:t.fetch:_i}function gn(e,t,i){if(i)return i;const n={fetch:mn(t,e),...e};if(n.url){const e=pi(n.url);n.baseUrl=e,n.queryString=function(e){const t=e.match(di);return t&&t[0]}(n.url),n.filename=ti(e),n.baseUrl=ii(e)}return Array.isArray(n.loaders)||(n.loaders=null),n}async function _n(e,t,i,n){dt(!n||"object"==typeof n),!t||Array.isArray(t)||Yi(t)||(n=void 0,i=t,t=void 0),i=i||{};const r=fi(e=await e),s=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:null}(t,n),o=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;if(!nn(e))return null;let r=tn(e,t,{...i,nothrow:!0},n);if(r)return r;if(ai(e)&&(r=tn(e=await e.slice(0,10).arrayBuffer(),t,i,n)),!(r||null!=i&&i.nothrow))throw new Error(rn(e));return r}(e,s,i);return o?(n=gn({url:r,parse:_n,loaders:s},i=qi(i,o,s,r),n||null),await async function(e,t,i,n){if(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"3.4.15";dt(e,"no worker provided")}(e),oi(t)){const e=t,{ok:i,redirected:r,status:s,statusText:o,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:i,redirected:r,status:s,statusText:o,type:a,url:l}}if(t=await fn(t,e,i),e.parseTextSync&&"string"==typeof t)return i.dataType="text",e.parseTextSync(t,i,n,e);if(function(e,t){return!!Ot.isSupported()&&!!(mt||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,i))return await Ut(e,t,i,n,_n);if(e.parseText&&"string"==typeof t)return await e.parseText(t,i,n,e);if(e.parse)return await e.parse(t,i,n,e);throw dt(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(o,e,i,n)):null}async function yn(e,t,i,n){Array.isArray(t)||Yi(t)||(i=t,t=void 0);const r=mn(i);let s=e;return"string"==typeof e&&(s=await r(e)),ai(e)&&(s=await r(e)),await _n(s,t,i)}const{_parseImageNode:vn}=globalThis,xn="undefined"!=typeof Image,bn="undefined"!=typeof ImageBitmap,wn=Boolean(vn),Tn=!!ut||wn;function Sn(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}const En=/^data:image\/svg\+xml/,An=/\.svg((\?|#).*)?$/;function Mn(e){return e&&(En.test(e)||An.test(e))}function In(e,t){if(Mn(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Cn(e,t,i){const n=function(e,t){if(Mn(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return"data:image/svg+xml;base64,".concat(btoa(t))}return In(e,t)}(e,i),r=self.URL||self.webkitURL,s="string"!=typeof n&&r.createObjectURL(n);try{return await async function(e,t){const i=new Image;if(i.src=e,t.image&&t.image.decode&&i.decode)return await i.decode(),i;return await new Promise((t,n)=>{try{i.onload=()=>t(i),i.onerror=t=>n(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){n(e)}})}(s||n,t)}finally{s&&r.revokeObjectURL(s)}}const Pn={};let Ln=!0;async function Rn(e,t,i){let n;if(Mn(i)){n=await Cn(e,t,i)}else n=In(e,i);const r=t&&t.imagebitmap;return await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(e){for(const t in e||Pn)return!1;return!0}(t)&&Ln||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){Ln=!1}return await createImageBitmap(e)}(n,r)}function On(e){return function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t<n.length;++t)if(n[t]!==e[t+i])return!1;return!0}(e,"ftyp",4)&&96&e[8]?function(e){switch((t=e,i=8,n=12,String.fromCharCode(...t.slice(i,n))).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}var t,i,n}(e):null}const Dn=!1,Bn=!0;function Fn(e){const t=Nn(e);return function(e){const t=Nn(e),i=t.byteLength>=24&&2303741511===t.getUint32(0,Dn);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,Dn),height:t.getUint32(20,Dn)}}(t)||function(e){const t=Nn(e),i=t.byteLength>=3&&65496===t.getUint16(0,Dn)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let s=2;for(;s+9<t.byteLength;){const e=t.getUint16(s,Dn);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(s+5,Dn),width:t.getUint16(s+7,Dn)};if(!n.has(e))return null;s+=2,s+=t.getUint16(s,Dn)}return null}(t)||function(e){const t=Nn(e),i=t.byteLength>=10&&1195984440===t.getUint32(0,Dn);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,Bn),height:t.getUint16(8,Bn)}}(t)||function(e){const t=Nn(e),i=t.byteLength>=14&&16973===t.getUint16(0,Dn)&&t.getUint32(2,Bn)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Bn),height:t.getUint32(22,Bn)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=On(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function Nn(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const kn={id:"image",module:"images",name:"Images",version:"3.4.15",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const n=((t=t||{}).image||{}).type||"auto",{url:r}=i||{};let s;switch(function(e){switch(e){case"auto":case"data":return function(){if(bn)return"imagebitmap";if(xn)return"image";if(Tn)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return bn||xn||Tn;case"imagebitmap":return bn;case"image":return xn;case"data":return Tn;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(n)){case"imagebitmap":s=await Rn(e,t,r);break;case"image":s=await Cn(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Fn(e)||{},i=globalThis._parseImageNode;return ct(i),await i(e,t)}(e);break;default:ct(!1)}return"data"===n&&(s=function(e){switch(Sn(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(s)),s},tests:[e=>Boolean(Fn(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},zn=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/tiff","image/svg","image/svg+xml","image/bmp","image/vnd.microsoft.icon"];function Un(e){const t=["image/png","image/jpeg","image/gif"],{_parseImageNode:i,_imageFormatsNode:n=t}=globalThis;return Boolean(i)&&n.includes(e)}const Vn={"image/avif":"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=","image/webp":"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"};async function jn(e){const t=Vn[e];return!t||await async function(e){return new Promise(t=>{const i=new Image;i.src=e,i.onload=()=>t(i.height>0),i.onerror=()=>t(!1)})}(t)}var Gn=new Fi({id:"deck"});let Hn={};function Wn(e){Hn=e}function qn(e,t,i,n){Gn.level>0&&Hn[e]&&Hn[e].call(null,t,i,n)}var Xn={id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],i=e[e.length-1];return"{"===t&&"}"===i||"["===t&&"]"===i},parseTextSync:JSON.parse};const $n=function(){const e="8.9.36",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error("deck.gl - multiple versions detected: ".concat(t," vs ").concat(e));return t||(Gn.log(1,"deck.gl ".concat(e))(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:Gn,_registerLoggers:Wn},function(e){const t=Ki();e=Array.isArray(e)?e:[e];for(const i of e){const e=Ji(i);t.find(t=>e===t)||t.unshift(e)}}([Xn,[kn,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}(),Zn={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Zn,"IDENTITY",{get:()=>(Gn.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const Yn={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Jn={common:0,meters:1,pixels:2},Kn={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},Qn=new Fi({id:"luma.gl"});function er(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function tr(e){return"undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext||("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&Number.isFinite(e._version)))}function ir(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}function nr(e){return er(tr(e),"Invalid WebGLRenderingContext"),e}function rr(e){return er(ir(e),"Requires WebGL2"),e}const sr={};function or(e,t){var i;sr[e]=!0,i=t,globalThis.console&&globalThis.console.error&&globalThis.console.error(i)}const ar=function e(t){const i=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(let t=0;t<this.attribs.length;t++){const n=new e.VertexAttrib(i);this.attribs[t]=n}this.maxAttrib=0};(ar.VertexAttrib=function(e){this.enabled=!1,this.buffer=null,this.size=4,this.type=5126,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()}).prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};const lr=function(e){const t=this;this.gl=e,function(e){const t=e.getError;e.getError=function(){let i;do{i=t.apply(e),0!==i&&(sr[i]=!0)}while(0!==i);for(i in sr)if(sr[i])return delete sr[i],parseInt(i,10);return 0}}(e);const i=this.original={getParameter:e.getParameter,enableVertexAttribArray:e.enableVertexAttribArray,disableVertexAttribArray:e.disableVertexAttribArray,bindBuffer:e.bindBuffer,getVertexAttrib:e.getVertexAttrib,vertexAttribPointer:e.vertexAttribPointer};e.getParameter=function(e){return e===t.VERTEX_ARRAY_BINDING_OES?t.currentVertexArrayObject===t.defaultVertexArrayObject?null:t.currentVertexArrayObject:i.getParameter.apply(this,arguments)},e.enableVertexAttribArray=function(e){const n=t.currentVertexArrayObject;n.maxAttrib=Math.max(n.maxAttrib,e);return n.attribs[e].enabled=!0,i.enableVertexAttribArray.apply(this,arguments)},e.disableVertexAttribArray=function(e){const n=t.currentVertexArrayObject;n.maxAttrib=Math.max(n.maxAttrib,e);return n.attribs[e].enabled=!1,i.disableVertexAttribArray.apply(this,arguments)},e.bindBuffer=function(e,n){switch(e){case 34962:t.currentArrayBuffer=n;break;case 34963:t.currentVertexArrayObject.elementArrayBuffer=n}return i.bindBuffer.apply(this,arguments)},e.getVertexAttrib=function(e,n){const r=t.currentVertexArrayObject.attribs[e];switch(n){case 34975:return r.buffer;case 34338:return r.enabled;case 34339:return r.size;case 34340:return r.stride;case 34341:return r.type;case 34922:return r.normalized;default:return i.getVertexAttrib.apply(this,arguments)}},e.vertexAttribPointer=function(e,n,r,s,o,a){const l=t.currentVertexArrayObject;l.maxAttrib=Math.max(l.maxAttrib,e);const c=l.attribs[e];return c.buffer=t.currentArrayBuffer,c.size=n,c.type=r,c.normalized=s,c.stride=o,c.offset=a,c.recache(),i.vertexAttribPointer.apply(this,arguments)},e.instrumentExtension&&e.instrumentExtension(this,"OES_vertex_array_object"),e.canvas&&e.canvas.addEventListener("webglcontextrestored",()=>{var e;e="OESVertexArrayObject emulation library context restored",globalThis.console&&globalThis.console.log&&globalThis.console.log(e),t.reset_()},!0),this.reset_()};lr.prototype.VERTEX_ARRAY_BINDING_OES=34229,lr.prototype.reset_=function(){if(void 0!==this.vertexArrayObjects)for(let e=0;e<this.vertexArrayObjects.length;++e)this.vertexArrayObjects.isAlive=!1;this.maxVertexAttribs=this.gl.getParameter(34921),this.defaultVertexArrayObject=new ar(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)},lr.prototype.createVertexArrayOES=function(){const e=new ar(this);return this.vertexArrayObjects.push(e),e},lr.prototype.deleteVertexArrayOES=function(e){e.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(e),1),this.currentVertexArrayObject===e&&this.bindVertexArrayOES(null)},lr.prototype.isVertexArrayOES=function(e){return!!(e&&e instanceof ar&&e.hasBeenBound&&e.ext===this)},lr.prototype.bindVertexArrayOES=function(e){const t=this.gl;if(e&&!e.isAlive)return void or(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject");const i=this.original,n=this.currentVertexArrayObject;this.currentVertexArrayObject=e||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;const r=this.currentVertexArrayObject;if(n===r)return;n&&r.elementArrayBuffer===n.elementArrayBuffer||i.bindBuffer.call(t,34963,r.elementArrayBuffer);let s=this.currentArrayBuffer;const o=Math.max(n?n.maxAttrib:0,r.maxAttrib);for(let e=0;e<=o;e++){const o=r.attribs[e],a=n?n.attribs[e]:null;if(n&&o.enabled===a.enabled||(o.enabled?i.enableVertexAttribArray.call(t,e):i.disableVertexAttribArray.call(t,e)),o.enabled){let r=!1;n&&o.buffer===a.buffer||(s!==o.buffer&&(i.bindBuffer.call(t,34962,o.buffer),s=o.buffer),r=!0),(r||o.cached!==a.cached)&&i.vertexAttribPointer.call(t,e,o.size,o.type,o.normalized,o.stride,o.offset)}}this.currentArrayBuffer!==s&&i.bindBuffer.call(t,34962,this.currentArrayBuffer)};const cr="OES_element_index",ur="WEBGL_draw_buffers",hr="WEBGL_debug_renderer_info",dr=35723,pr=36795,fr=34047,mr=37445,gr=37446,_r=e=>ir(e)?void 0:0,yr={3074:e=>ir(e)?void 0:36064,[dr]:e=>ir(e)?void 0:4352,35977:_r,32937:_r,[pr]:(e,t)=>{const i=ir(e)?e.getExtension("EXT_disjoint_timer_query_webgl2"):e.getExtension("EXT_disjoint_timer_query");return i&&i.GPU_DISJOINT_EXT?t(i.GPU_DISJOINT_EXT):0},[mr]:(e,t)=>{const i=e.getExtension(hr);return t(i&&i.UNMASKED_VENDOR_WEBGL||7936)},[gr]:(e,t)=>{const i=e.getExtension(hr);return t(i&&i.UNMASKED_RENDERER_WEBGL||7937)},[fr]:(e,t)=>{const i=e.luma.extensions.EXT_texture_filter_anisotropic;return i?t(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},32883:_r,35071:_r,37447:_r,36063:(e,t)=>{if(!ir(e)){const i=e.getExtension(ur);return i?t(i.MAX_COLOR_ATTACHMENTS_WEBGL):0}},35379:_r,35374:_r,35377:_r,34852:e=>{if(!ir(e)){const t=e.getExtension(ur);return t?t.MAX_DRAW_BUFFERS_WEBGL:0}},36203:e=>e.getExtension(cr)?2147483647:65535,33001:e=>e.getExtension(cr)?16777216:65535,33e3:e=>16777216,37157:_r,35373:_r,35657:_r,36183:_r,37137:_r,34045:_r,35978:_r,35979:_r,35968:_r,35376:_r,35375:_r,35659:_r,37154:_r,35371:_r,35658:_r,35076:_r,35077:_r,35380:_r};const vr="OES_vertex_array_object",xr="ANGLE_instanced_arrays",br="WEBGL_draw_buffers",wr="EXT_disjoint_timer_query";const Tr={[vr]:{meta:{suffix:"OES"},createVertexArray:()=>{er(!1,"VertexArray requires WebGL2 or OES_vertex_array_object extension")},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},[xr]:{meta:{suffix:"ANGLE"},vertexAttribDivisor(e,t){er(0===t,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},[br]:{meta:{suffix:"WEBGL"},drawBuffers:()=>{er(!1)}},[wr]:{meta:{suffix:"EXT"},createQuery:()=>{er(!1)},deleteQuery:()=>{er(!1)},beginQuery:()=>{er(!1)},endQuery:()=>{},getQuery(e,t){return this.getQueryObject(e,t)},getQueryParameter(e,t){return this.getQueryObject(e,t)},getQueryObject:()=>{}}},Sr={readBuffer:(e,t,i)=>{ir(e)&&t(i)},getVertexAttrib:(e,t,i,n)=>{const{webgl2:r,ext:s}=function(e,t){return{webgl2:ir(e),ext:e.getExtension(t)}}(e,xr);let o;switch(n){case 35069:o=!!r&&void 0;break;case 35070:o=r||s?void 0:0}return void 0!==o?o:t(i,n)},getProgramParameter:(e,t,i,n)=>{if(!ir(e))switch(n){case 35967:return 35981;case 35971:case 35382:return 0}return t(i,n)},getInternalformatParameter:(e,t,i,n,r)=>ir(e)||32937!==r?e.getInternalformatParameter(i,n,r):new Int32Array([0]),getTexParameter(e,t,i,n){if(34046===n){const{extensions:t}=e.luma,i=t.EXT_texture_filter_anisotropic;n=i&&i.TEXTURE_MAX_ANISOTROPY_EXT||34046}return t(i,n)},getParameter:function(e,t,i){const n=yr[i],r="function"==typeof n?n(e,t,i):n;return void 0!==r?r:t(i)},hint:(e,t,i,n)=>t(i,n)};function Er(e,t){let{extension:i,target:n,target2:r}=t;const s=Tr[i];er(s);const{meta:o={}}=s,{suffix:a=""}=o,l=e.getExtension(i);for(const t of Object.keys(s)){const i="".concat(t).concat(a);let o=null;"meta"===t||"function"==typeof e[t]||(l&&"function"==typeof l[i]?o=function(){return l[i](...arguments)}:"function"==typeof s[t]&&(o=s[t].bind(n))),o&&(n[t]=o,r[t]=o)}}globalThis.polyfillContext=function(e){e.luma=e.luma||{};const{luma:t}=e;return t.polyfilled||(!function(e){if("function"==typeof e.createVertexArray)return;const t=e.getSupportedExtensions;e.getSupportedExtensions=function(){const e=t.call(this)||[];return e.indexOf("OES_vertex_array_object")<0&&e.push("OES_vertex_array_object"),e};const i=e.getExtension;e.getExtension=function(t){return i.call(this,t)||("OES_vertex_array_object"!==t?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new lr(this)),this.__OESVertexArrayObject))}}(e),function(e){e.luma.extensions={};const t=e.getSupportedExtensions()||[];for(const i of t)e.luma[i]=e.getExtension(i)}(e),function(e,t){for(const i of Object.getOwnPropertyNames(t))"overrides"!==i&&Er(e,{extension:i,target:e.luma,target2:e})}(e,Tr),function(e,t){let{target:i,target2:n}=t;Object.keys(Sr).forEach(t=>{if("function"==typeof Sr[t]){const r=e[t]?e[t].bind(e):()=>{},s=Sr[t].bind(null,e,r);i[t]=s,n[t]=s}})}(e,{target:t,target2:e}),t.polyfilled=!0),e};const Ar={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,36006:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,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],3333:4,3317:4,37440:!1,37441:!1,37443:37444,35723:4352,36010:null,35977:!1,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Mr=(e,t,i)=>t?e.enable(i):e.disable(i),Ir=(e,t,i)=>e.hint(i,t),Cr=(e,t,i)=>e.pixelStorei(i,t);function Pr(e){return Array.isArray(e)||ArrayBuffer.isView(e)}const Lr={3042:Mr,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Mr,2885:(e,t)=>e.cullFace(t),2929:Mr,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Mr,35723:Ir,36006:(e,t)=>{const i=ir(e)?36009:36160;return e.bindFramebuffer(i,t)},2886:(e,t)=>e.frontFace(t),33170:Ir,2849:(e,t)=>e.lineWidth(t),32823:Mr,32824:"polygonOffset",10752:"polygonOffset",35977:Mr,32938:"sampleCoverage",32939:"sampleCoverage",3089:Mr,3088:(e,t)=>e.scissor(...t),2960:Mr,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),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:(e,t)=>e.viewport(...t),3333:Cr,3317:Cr,37440:Cr,37441:Cr,37443:Cr,3330:Cr,3332:Cr,3331:Cr,36010:(e,t)=>e.bindFramebuffer(36008,t),3314:Cr,32878:Cr,3316:Cr,3315:Cr,32877:Cr,framebuffer:(e,t)=>e.bindFramebuffer(36160,t&&"handle"in t?t.handle:t),blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{t=Pr(t)?t:[t,t],e.blendEquationSeparate(...t)},blendFunc:(e,t)=>{t=Pr(t)&&2===t.length?[...t,...t]:t,e.blendFuncSeparate(...t)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Pr(t)?t:[t,t];const[i,n]=t;e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=Pr(t)&&3===t.length?[...t,...t]:t;const[i,n,r,s,o,a]=t;e.stencilFuncSeparate(1028,i,n,r),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=Pr(t)&&3===t.length?[...t,...t]:t;const[i,n,r,s,o,a]=t;e.stencilOpSeparate(1028,i,n,r),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};function Rr(e,t,i){return void 0!==t[e]?t[e]:i[e]}const Or={blendEquation:(e,t,i)=>e.blendEquationSeparate(Rr(32777,t,i),Rr(34877,t,i)),blendFunc:(e,t,i)=>e.blendFuncSeparate(Rr(32969,t,i),Rr(32968,t,i),Rr(32971,t,i),Rr(32970,t,i)),polygonOffset:(e,t,i)=>e.polygonOffset(Rr(32824,t,i),Rr(10752,t,i)),sampleCoverage:(e,t,i)=>e.sampleCoverage(Rr(32938,t,i),Rr(32939,t,i)),stencilFuncFront:(e,t,i)=>e.stencilFuncSeparate(1028,Rr(2962,t,i),Rr(2967,t,i),Rr(2963,t,i)),stencilFuncBack:(e,t,i)=>e.stencilFuncSeparate(1029,Rr(34816,t,i),Rr(36003,t,i),Rr(36004,t,i)),stencilOpFront:(e,t,i)=>e.stencilOpSeparate(1028,Rr(2964,t,i),Rr(2965,t,i),Rr(2966,t,i)),stencilOpBack:(e,t,i)=>e.stencilOpSeparate(1029,Rr(34817,t,i),Rr(34818,t,i),Rr(34819,t,i))},Dr={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,i)=>e({[t]:i}),hint:(e,t,i)=>e({[t]:i}),bindFramebuffer:(e,t,i)=>{switch(t){case 36160:return e({36006:i,36010:i});case 36009:return e({36006:i});case 36008:return e({36010:i});default:return null}},blendColor:(e,t,i,n,r)=>e({32773:new Float32Array([t,i,n,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,i)=>e({32777:t,34877:i}),blendFunc:(e,t,i)=>e({32969:t,32968:i,32971:t,32970:i}),blendFuncSeparate:(e,t,i,n,r)=>e({32969:t,32968:i,32971:n,32970:r}),clearColor:(e,t,i,n,r)=>e({3106:new Float32Array([t,i,n,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,i,n,r)=>e({3107:[t,i,n,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,i)=>e({2928:new Float32Array([t,i])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,i)=>e({32824:t,10752:i}),sampleCoverage:(e,t,i)=>e({32938:t,32939:i}),scissor:(e,t,i,n,r)=>e({3088:new Int32Array([t,i,n,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,i)=>e({[1028===t?2968:36005]:i}),stencilFunc:(e,t,i,n)=>e({2962:t,2967:i,2963:n,34816:t,36003:i,36004:n}),stencilFuncSeparate:(e,t,i,n,r)=>e({[1028===t?2962:34816]:i,[1028===t?2967:36003]:n,[1028===t?2963:36004]:r}),stencilOp:(e,t,i,n)=>e({2964:t,2965:i,2966:n,34817:t,34818:i,34819:n}),stencilOpSeparate:(e,t,i,n,r)=>e({[1028===t?2964:34817]:i,[1028===t?2965:34818]:n,[1028===t?2966:34819]:r}),viewport:(e,t,i,n,r)=>e({2978:[t,i,n,r]})},Br=(e,t)=>e.isEnabled(t),Fr={3042:Br,2884:Br,2929:Br,3024:Br,32823:Br,32926:Br,32928:Br,3089:Br,2960:Br,35977:Br};function Nr(e){for(const t in e)return!1;return!0}function kr(e,t){if(e===t)return!0;const i=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(i&&n&&e.length===t.length){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}return!1}function zr(e,t){const i=e[t].bind(e);e[t]=function(){const t=arguments.length<=0?void 0:arguments[0];return t in e.state.cache&&e.state.enable?e.state.cache[t]:i(...arguments)},Object.defineProperty(e[t],"name",{value:"".concat(t,"-from-cache"),configurable:!1})}function Ur(e,t,i){const n=e[t].bind(e);e[t]=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];const{valueChanged:o,oldValue:a}=i(e.state._updateCache,...r);return o&&n(...r),a},Object.defineProperty(e[t],"name",{value:"".concat(t,"-to-cache"),configurable:!1})}class Vr{constructor(e){let{copyState:t=!1,log:i=()=>{}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=e,this.program=null,this.stateStack=[],this.enable=!0,this.cache=t?function(e,t){if("number"==typeof(t=t||Ar)){const i=t,n=Fr[i];return n?n(e,i):e.getParameter(i)}const i=Array.isArray(t)?t:Object.keys(t),n={};for(const t of i){const i=Fr[t];n[t]=i?i(e,Number(t)):e.getParameter(Number(t))}return n}(e):Object.assign({},Ar),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){this.stateStack.push({})}pop(){er(this.stateStack.length>0);Hr(this.gl,this.stateStack[this.stateStack.length-1]),this.stateStack.pop()}_updateCache(e){let t,i=!1;const n=this.stateStack.length>0&&this.stateStack[this.stateStack.length-1];for(const r in e){er(void 0!==r);const s=e[r],o=this.cache[r];kr(s,o)||(i=!0,t=o,n&&!(r in n)&&(n[r]=o),this.cache[r]=s)}return{valueChanged:i,oldValue:t}}}function jr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{enable:i=!0,copyState:n}=t;if(er(void 0!==n),!e.state){const{polyfillContext:t}=globalThis;t&&t(e),e.state=new Vr(e,{copyState:n}),function(e){const t=e.useProgram.bind(e);e.useProgram=function(i){e.state.program!==i&&(t(i),e.state.program=i)}}(e);for(const t in Dr){Ur(e,t,Dr[t])}zr(e,"getParameter"),zr(e,"isEnabled")}return e.state.enable=i,e}function Gr(e){er(e.state),e.state.pop()}function Hr(e,t){if(er(tr(e),"setParameters requires a WebGL context"),Nr(t))return;const i={};for(const n in t){const r=Number(n),s=Lr[n];s&&("string"==typeof s?i[s]=!0:s(e,t[n],r))}const n=e.state&&e.state.cache;if(n)for(const r in i){(0,Or[r])(e,t,n)}}function Wr(e,t,i){if(Nr(t))return i(e);const{nocatch:n=!0}=t;let r;if(function(e){e.state||jr(e,{copyState:!1}),e.state.push()}(e),Hr(e,t),n)r=i(e),Gr(e);else try{r=i(e)}finally{Gr(e)}return r}function qr(e){const{luma:t}=e;if(e.canvas&&t){const i=t.canvasSizeInfo,n="clientWidth"in i?i.clientWidth:e.canvas.clientWidth;return n?e.drawingBufferWidth/n:1}return 1}function Xr(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(e,t,i,n,r){const s=$r(e[0],t,i);let o=Zr(e[1],t,n,r),a=$r(e[0]+1,t,i);const l=a===i-1?a:a-1;let c;a=Zr(e[1]+1,t,n,r),r?(a=0===a?a:a+1,c=o,o=a):c=a===n-1?a:a-1;return{x:s,y:o,width:Math.max(l-s+1,1),height:Math.max(c-o+1,1)}}(t,qr(e),e.drawingBufferWidth,e.drawingBufferHeight,i)}function $r(e,t,i){return Math.min(Math.round(e*t),i-1)}function Zr(e,t,i,n){return n?Math.max(0,i-1-Math.round(e*t)):Math.min(Math.round(e*t),i-1)}const Yr=vi(),Jr=Yr&&"undefined"!=typeof document,Kr={webgl2:!0,webgl1:!0,throwOnError:!0,manageState:!0,canvas:null,debug:!1,width:800,height:600};function Qr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};er(Yr,"createGLContext only available in the browser.\nCreate your own headless context or use 'createHeadlessContext' from @luma.gl/test-utils"),e=Object.assign({},Kr,e);const{width:t,height:i}=e;function n(t){if(e.throwOnError)throw new Error(t);return null}let r;e.onError=n;const{canvas:s}=e,o=function(e){let t,{canvas:i,width:n=800,height:r=600,onError:s}=e;if("string"==typeof i){Jr&&"complete"===document.readyState||s("createGLContext called on canvas '".concat(i,"' before page was loaded")),t=document.getElementById(i)}else i?t=i:(t=document.createElement("canvas"),t.id="lumagl-canvas",t.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",t.style.height=Number.isFinite(r)?"".concat(r,"px"):"100%",document.body.insertBefore(t,document.body.firstChild));return t}({canvas:s,width:t,height:i,onError:n});return r=function(e,t){const{onError:i}=t;let n=null;const r=e=>n=e.statusMessage||n;e.addEventListener("webglcontextcreationerror",r,!1);const{webgl1:s=!0,webgl2:o=!0}=t;let a=null;o&&(a=a||e.getContext("webgl2",t),a=a||e.getContext("experimental-webgl2",t));s&&(a=a||e.getContext("webgl",t),a=a||e.getContext("experimental-webgl",t));if(e.removeEventListener("webglcontextcreationerror",r,!1),!a)return i("Failed to create ".concat(o&&!s?"WebGL2":"WebGL"," context: ").concat(n||"Unknown error"));t.onContextLost&&e.addEventListener("webglcontextlost",t.onContextLost,!1);t.onContextRestored&&e.addEventListener("webglcontextrestored",t.onContextRestored,!1);return a}(o,e),r?(r=es(r,e),function(e){const t=ir(e)?"WebGL2":"WebGL1",i=function(e){const t=e.getParameter(7936),i=e.getParameter(7937),n=e.getExtension("WEBGL_debug_renderer_info"),r=n&&e.getParameter(n.UNMASKED_VENDOR_WEBGL||7936),s=n&&e.getParameter(n.UNMASKED_RENDERER_WEBGL||7937);return{vendor:r||t,renderer:s||i,vendorMasked:t,rendererMasked:i,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e),n=i?"(".concat(i.vendor,",").concat(i.renderer,")"):"",r=e.debug?" debug":"";Qn.info(1,"".concat(t).concat(r," context ").concat(n))()}(r),r):null}function es(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e||e._instrumented)return e;e._version=e._version||function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return 2;return 1}(e),e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{},t=Object.assign({},Kr,t);const{manageState:i,debug:n}=t;return i&&jr(e,{copyState:!1,log:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Qn.log(1,...t)()}}),Yr&&n&&(globalThis.makeDebugContext?(e=globalThis.makeDebugContext(e,t),Qn.level=Math.max(Qn.level,1)):Qn.warn('WebGL debug mode not activated. import "@luma.gl/debug" to enable.')()),e._instrumented=!0,e}function ts(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.canvas){return void function(e,t,i){let n="width"in i?i.width:e.canvas.clientWidth,r="height"in i?i.height:e.canvas.clientHeight;n&&r||(Qn.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,n=e.canvas.width||1,r=e.canvas.height||1);e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{};const s=e.luma.canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==r||s.devicePixelRatio!==t){let i=t;const s=Math.floor(n*i),o=Math.floor(r*i);e.canvas.width=s,e.canvas.height=o,e.drawingBufferWidth===s&&e.drawingBufferHeight===o||(Qn.warn("Device pixel ratio clamped")(),i=Math.min(e.drawingBufferWidth/n,e.drawingBufferHeight/r),e.canvas.width=Math.floor(n*i),e.canvas.height=Math.floor(r*i)),Object.assign(e.luma.canvasSizeInfo,{clientWidth:n,clientHeight:r,devicePixelRatio:t})}}(e,function(e){const t="undefined"==typeof window?1:window.devicePixelRatio||1;return Number.isFinite(e)?e<=0?1:e:e?t:1}(t.useDevicePixels),t)}const i=e.getExtension("STACKGL_resize_drawingbuffer");i&&"width"in t&&"height"in t&&i.resize(t.width,t.height)}const is="8.5.21";const ns=new class{constructor(){this.stats=new Map}get(e){return this.stats.has(e)||this.stats.set(e,new Yt({id:e})),this.stats.get(e)}};if(globalThis.luma&&globalThis.luma.VERSION!==is)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(is));function rs(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function ss(e,t){if("string"!=typeof t)return t;const i=Number(t);if(!isNaN(i))return i;const n=e[t=t.replace(/^.*\./,"")];return rs(void 0!==n,"Accessing undefined constant GL.".concat(t)),n}function os(e,t){t=Number(t);for(const i in e)if(e[i]===t)return"GL.".concat(i);return String(t)}globalThis.luma||(vi()&&Qn.log(1,"luma.gl ".concat(is," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:is,version:is,log:Qn,stats:ns,globals:{modules:{},nodeIO:{}}});const as={};function ls(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";as[e]=as[e]||1;const t=as[e]++;return"".concat(e,"-").concat(t)}function cs(e){return rs("number"==typeof e,"Input must be a number"),e&&!(e&e-1)}function us(e){let t=!0;for(const i in e){t=!1;break}return t}function hs(e,t,i,n){const r="See luma.gl ".concat(i," Upgrade Guide at https://luma.gl/docs/upgrade-guide"),s=Object.getPrototypeOf(e);n.forEach(e=>{s.methodName||(s[e]=()=>{throw Qn.removed("Calling removed method ".concat(t,".").concat(e,": "),r)(),new Error(e)})})}const ds="Resource subclass must define virtual methods";let ps=class{get[Symbol.toStringTag](){return"Resource"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nr(e);const{id:i,userData:n={}}=t;this.gl=e,this.gl2=e,this.id=i||ls(this[Symbol.toStringTag]),this.userData=n,this._bound=!1,this._handle=t.handle,void 0===this._handle&&(this._handle=this._createHandle()),this.byteLength=0,this._addStats()}toString(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}get handle(){return this._handle}delete(){let{deleteChildren:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this._handle&&this._deleteHandle(this._handle);return this._handle&&this._removeStats(),this._handle=null,t&&e&&t.filter(Boolean).forEach(e=>e.delete()),this}bind(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.handle;return"function"!=typeof t?(this._bindHandle(t),this):(this._bound?e=t():(this._bindHandle(this.handle),this._bound=!0,e=t(),this._bound=!1,this._bindHandle(null)),e)}unbind(){this.bind(null)}getParameter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};rs(e=ss(this.gl,e));const i=(this.constructor.PARAMETERS||{})[e];if(i){const e=ir(this.gl);if(!((!("webgl2"in i)||e)&&(!("extension"in i)||this.gl.getExtension(i.extension)))){return e?"webgl2"in i?i.webgl2:i.webgl1:i.webgl1}}return this._getParameter(e,t)}getParameters(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{parameters:t,keys:i}=e,n=this.constructor.PARAMETERS||{},r=ir(this.gl),s={},o=t||Object.keys(n);for(const t of o){const o=n[t];if(o&&(!("webgl2"in o)||r)&&(!("extension"in o)||this.gl.getExtension(o.extension))){const n=i?os(this.gl,t):t;s[n]=this.getParameter(t,e),i&&"GLenum"===o.type&&(s[n]=os(this.gl,s[n]))}}return s}setParameter(e,t){rs(e=ss(this.gl,e));const i=(this.constructor.PARAMETERS||{})[e];if(i){const e=ir(this.gl);if(!((!("webgl2"in i)||e)&&(!("extension"in i)||this.gl.getExtension(i.extension))))throw new Error("Parameter not available on this platform");"GLenum"===i.type&&(t=ss(t))}return this._setParameter(e,t),this}setParameters(e){for(const t in e)this.setParameter(t,e[t]);return this}stubRemovedMethods(e,t,i){return hs(this,e,t,i)}initialize(e){}_createHandle(){throw new Error(ds)}_deleteHandle(){throw new Error(ds)}_bindHandle(e){throw new Error(ds)}_getOptsFromHandle(){throw new Error(ds)}_getParameter(e,t){throw new Error(ds)}_setParameter(e,t){throw new Error(ds)}_context(){return this.gl.luma=this.gl.luma||{},this.gl.luma}_addStats(){const e=this[Symbol.toStringTag],t=ns.get("Resource Counts");t.get("Resources Created").incrementCount(),t.get("".concat(e,"s Created")).incrementCount(),t.get("".concat(e,"s Active")).incrementCount()}_removeStats(){const e=this[Symbol.toStringTag];ns.get("Resource Counts").get("".concat(e,"s Active")).decrementCount()}_trackAllocatedMemory(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];this._trackAllocatedMemoryForContext(e,t),this._trackAllocatedMemoryForContext(e,t,this.gl.canvas&&this.gl.canvas.id),this.byteLength=e}_trackAllocatedMemoryForContext(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];const i=ns.get("Memory Usage".concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:""));i.get("GPU Memory").addCount(e),i.get("".concat(t," Memory")).addCount(e)}_trackDeallocatedMemory(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._trackDeallocatedMemoryForContext(e),this._trackDeallocatedMemoryForContext(e,this.gl.canvas&&this.gl.canvas.id),this.byteLength=0}_trackDeallocatedMemoryForContext(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];const t=ns.get("Memory Usage".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:""));t.get("GPU Memory").subtractCount(this.byteLength),t.get("".concat(e," Memory")).subtractCount(this.byteLength)}};function fs(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}function ms(e){let{clamped:t=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return t?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")}}function gs(e){let{data:t,width:i,height:n}=e;const r=Math.round(i/2),s=Math.round(n/2),o=new Uint8Array(r*s*4);for(let e=0;e<s;e++)for(let n=0;n<r;n++)for(let s=0;s<4;s++)o[4*(e*r+n)+s]=t[4*(2*e*i+2*n)+s];return{data:o,width:r,height:s}}function _s(e,t,i){const{removedProps:n={},deprecatedProps:r={},replacedProps:s={}}=i;for(const i in n)if(i in t){const t=n[i]?"".concat(e,".").concat(n[i]):"N/A";Qn.removed("".concat(e,".").concat(i),t)()}for(const i in r)if(i in t){const t=r[i];Qn.deprecated("".concat(e,".").concat(i),"".concat(e,".").concat(t))()}let o=null;for(const i in s)if(i in t){const n=s[i];Qn.deprecated("".concat(e,".").concat(i),"".concat(e,".").concat(n))(),o=o||Object.assign({},t),o[n]=t[i],delete o[i]}return o||t}const ys={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},vs={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class xs{static getBytesPerElement(e){return ms(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){rs(e.size);return ms(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new xs(...[ys,...t])}constructor(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach(e=>this._assign(e)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return xs.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return xs.getBytesPerVertex(this)}_assign(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e=_s("Accessor",e,vs),void 0!==e.type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&(this.index="boolean"==typeof e.index?e.index?1:0:e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),this}}const bs={offset:"accessor.offset",stride:"accessor.stride",type:"accessor.type",size:"accessor.size",divisor:"accessor.divisor",normalized:"accessor.normalized",integer:"accessor.integer",instanced:"accessor.divisor",isInstanced:"accessor.divisor"},ws={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:bs},Ts={removedProps:bs};class Ss extends ps{get[Symbol.toStringTag](){return"Buffer"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,t),this.stubRemovedMethods("Buffer","v6.0",["layout","setLayout","getIndexedParameter"]),this.target=t.target||(this.gl.webgl2?36662:34962),this.initialize(t),Object.seal(this)}getElementCount(){return Math.round(this.byteLength/xs.getBytesPerElement(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor))}getVertexCount(){return Math.round(this.byteLength/xs.getBytesPerVertex(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor))}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ArrayBuffer.isView(e)&&(e={data:e}),Number.isFinite(e)&&(e={byteLength:e}),e=_s("Buffer",e,ws),this.usage=e.usage||35044,this.debugData=null,this.setAccessor(Object.assign({},e,e.accessor)),e.data?this._setData(e.data,e.offset,e.byteLength):this._setByteLength(e.byteLength||0),this}setProps(e){return"accessor"in(e=_s("Buffer",e,Ts))&&this.setAccessor(e.accessor),this}setAccessor(e){return delete(e=Object.assign({},e)).buffer,this.accessor=new xs(e),this}reallocate(e){return e>this.byteLength?(this._setByteLength(e),!0):(this.bytesUsed=e,!1)}setData(e){return this.initialize(e)}subData(e){ArrayBuffer.isView(e)&&(e={data:e});const{data:t,offset:i=0,srcOffset:n=0}=e,r=e.byteLength||e.length;rs(t);const s=this.gl.webgl2?36663:this.target;return this.gl.bindBuffer(s,this.handle),0!==n||void 0!==r?(rr(this.gl),this.gl.bufferSubData(this.target,i,t,n,r)):this.gl.bufferSubData(s,i,t),this.gl.bindBuffer(s,null),this.debugData=null,this._inferType(t),this}copyData(e){let{sourceBuffer:t,readOffset:i=0,writeOffset:n=0,size:r}=e;const{gl:s}=this;return rr(s),s.bindBuffer(36662,t.handle),s.bindBuffer(36663,this.handle),s.copyBufferSubData(36662,36663,i,n,r),s.bindBuffer(36662,null),s.bindBuffer(36663,null),this.debugData=null,this}getData(){let{dstData:e=null,srcByteOffset:t=0,dstOffset:i=0,length:n=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};rr(this.gl);const r=ms(this.accessor.type||5126,{clamped:!1}),s=this._getAvailableElementCount(t),o=i;let a,l;e?(l=e.length,a=l-o):(a=Math.min(s,n||s),l=o+a);const c=Math.min(s,a);return n=n||c,rs(n<=c),e=e||new r(l),this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,e,i,n),this.gl.bindBuffer(36662,null),e}bind(){let{target:e=this.target,index:t=this.accessor&&this.accessor.index,offset:i=0,size:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===e||35982===e?void 0!==n?this.gl.bindBufferRange(e,t,this.handle,i,n):(rs(0===i),this.gl.bindBufferBase(e,t,this.handle)):this.gl.bindBuffer(e,this.handle),this}unbind(){let{target:e=this.target,index:t=this.accessor&&this.accessor.index}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===e||35982===e?this.gl.bindBufferBase(e,t,null):this.gl.bindBuffer(e,null),this}getDebugData(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(10,this.byteLength)}),{data:this.debugData,changed:!0})}invalidateDebugData(){this.debugData=null}_setData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength+t;rs(ArrayBuffer.isView(e)),this._trackDeallocatedMemory();const n=this._getTarget();this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.usage),this.gl.bufferSubData(n,t,e),this.gl.bindBuffer(n,null),this.debugData=e.slice(0,10),this.bytesUsed=i,this._trackAllocatedMemory(i);const r=fs(e);return rs(r),this.setAccessor(new xs(this.accessor,{type:r})),this}_setByteLength(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;rs(e>=0),this._trackDeallocatedMemory();let i=e;0===e&&(i=new Float32Array(0));const n=this._getTarget();return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,t),this.gl.bindBuffer(n,null),this.usage=t,this.debugData=null,this.bytesUsed=e,this._trackAllocatedMemory(e),this}_getTarget(){return this.gl.webgl2?36663:this.target}_getAvailableElementCount(e){const t=e/ms(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-t}_inferType(e){this.accessor.type||this.setAccessor(new xs(this.accessor,{type:fs(e)}))}_createHandle(){return this.gl.createBuffer()}_deleteHandle(){this.gl.deleteBuffer(this.handle),this._trackDeallocatedMemory()}_getParameter(e){this.gl.bindBuffer(this.target,this.handle);const t=this.gl.getBufferParameter(this.target,e);return this.gl.bindBuffer(this.target,null),t}get type(){return Qn.deprecated("Buffer.type","Buffer.accessor.type")(),this.accessor.type}get bytes(){return Qn.deprecated("Buffer.bytes","Buffer.byteLength")(),this.byteLength}setByteLength(e){return Qn.deprecated("setByteLength","reallocate")(),this.reallocate(e)}updateAccessor(e){return Qn.deprecated("updateAccessor(...)","setAccessor(new Accessor(buffer.accessor, ...)")(),this.accessor=new xs(this.accessor,e),this}}const Es={6407:{dataFormat:6407,types:[5121,33635]},6408:{dataFormat:6408,types:[5121,32819,32820]},6406:{dataFormat:6406,types:[5121]},6409:{dataFormat:6409,types:[5121]},6410:{dataFormat:6410,types:[5121]},33326:{dataFormat:6403,types:[5126],gl2:!0},33328:{dataFormat:33319,types:[5126],gl2:!0},34837:{dataFormat:6407,types:[5126],gl2:!0},34836:{dataFormat:6408,types:[5126],gl2:!0}},As={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},Ms={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};const Is=[9729,9728],Cs=globalThis.WebGLBuffer||function(){};let Ps=class extends ps{get[Symbol.toStringTag](){return"Texture"}static isSupported(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{format:i,linearFiltering:n}=t;let r=!0;return i&&(r=r&&function(e,t){const i=Es[t];if(!i)return!1;if(void 0===i.gl1&&void 0===i.gl2)return!0;const n=ir(e)&&i.gl2||i.gl1;return"string"==typeof n?e.getExtension(n):n}(e,i),r=r&&(!n||function(e,t){const i=Es[t];switch(i&&i.types[0]){case 5126:return e.getExtension("OES_texture_float_linear");case 5131:return e.getExtension("OES_texture_half_float_linear");default:return!0}}(e,i))),r}constructor(e,t){const{id:i=ls("texture"),handle:n,target:r}=t;super(e,{id:i,handle:n}),this.target=r,this.textureUnit=void 0,this.loaded=!1,this.width=void 0,this.height=void 0,this.depth=void 0,this.format=void 0,this.type=void 0,this.dataFormat=void 0,this.border=void 0,this.textureUnit=void 0,this.mipmaps=void 0}toString(){return"Texture(".concat(this.id,",").concat(this.width,"x").concat(this.height,")")}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.data;if(t instanceof Promise)return t.then(t=>this.initialize(Object.assign({},e,{pixels:t,data:t}))),this;const i="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(i&&t.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,t.addEventListener("loadeddata",()=>this.initialize(e)),this;const{pixels:n=null,format:r=6408,border:s=0,recreate:o=!1,parameters:a={},pixelStore:l={},textureUnit:c}=e;t||(t=n);let{width:u,height:h,dataFormat:d,type:p,compressed:f=!1,mipmaps:m=!0}=e;const{depth:g=0}=e;return({width:u,height:h,compressed:f,dataFormat:d,type:p}=this._deduceParameters({format:r,type:p,dataFormat:d,compressed:f,data:t,width:u,height:h})),this.width=u,this.height=h,this.depth=g,this.format=r,this.type=p,this.dataFormat=d,this.border=s,this.textureUnit=c,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),m&&this._isNPOT()&&(Qn.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),m=!1,this._updateForNPOT(a)),this.mipmaps=m,this.setImageData({data:t,width:u,height:h,depth:g,format:r,type:p,dataFormat:d,border:s,mipmaps:m,parameters:l,compressed:f}),m&&this.generateMipmap(),this.setParameters(a),o&&(this.data=t),i&&(this._video={video:t,parameters:a,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}update(){if(this._video){const{video:e,parameters:t,lastTime:i}=this._video;if(i===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:t}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}resize(e){let{height:t,width:i,mipmaps:n=!1}=e;return i!==this.width||t!==this.height?this.initialize({width:i,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,border:this.border,mipmaps:n}):this}generateMipmap(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isNPOT()?(Qn.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Wr(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this)}setImageData(e){this._trackDeallocatedMemory("Texture");const{target:t=this.target,pixels:i=null,level:n=0,format:r=this.format,border:s=this.border,offset:o=0,parameters:a={}}=e;let{data:l=null,type:c=this.type,width:u=this.width,height:h=this.height,dataFormat:d=this.dataFormat,compressed:p=!1}=e;l||(l=i),({type:c,dataFormat:d,compressed:p,width:u,height:h}=this._deduceParameters({format:r,type:c,dataFormat:d,compressed:p,data:l,width:u,height:h}));const{gl:f}=this;f.bindTexture(this.target,this.handle);let m,g=null;({data:l,dataType:g}=this._getDataType({data:l,compressed:p}));let _=0;if(Wr(this.gl,a,()=>{switch(g){case"null":f.texImage2D(t,n,r,u,h,s,d,c,l);break;case"typed-array":f.texImage2D(t,n,r,u,h,s,d,c,l,o);break;case"buffer":m=rr(f),m.bindBuffer(35052,l.handle||l),m.texImage2D(t,n,r,u,h,s,d,c,o),m.bindBuffer(35052,null);break;case"browser-object":ir(f)?f.texImage2D(t,n,r,u,h,s,d,c,l):f.texImage2D(t,n,r,d,c,l);break;case"compressed":for(const[e,i]of l.entries())f.compressedTexImage2D(t,e,i.format,i.width,i.height,s,i.data),_+=i.levelSize;break;default:rs(!1,"Unknown image data type")}}),"compressed"===g)this._trackAllocatedMemory(_,"Texture");else if(l&&l.byteLength)this._trackAllocatedMemory(l.byteLength,"Texture");else{this._trackAllocatedMemory(this.width*this.height*(As[this.dataFormat]||4)*(Ms[this.type]||1),"Texture")}return this.loaded=!0,this}setSubImageData(e){let{target:t=this.target,pixels:i=null,data:n=null,x:r=0,y:s=0,width:o=this.width,height:a=this.height,level:l=0,format:c=this.format,type:u=this.type,dataFormat:h=this.dataFormat,compressed:d=!1,offset:p=0,border:f=this.border,parameters:m={}}=e;if(({type:u,dataFormat:h,compressed:d,width:o,height:a}=this._deduceParameters({format:c,type:u,dataFormat:h,compressed:d,data:n,width:o,height:a})),rs(0===this.depth,"texSubImage not supported for 3D textures"),n||(n=i),n&&n.data){const e=n;n=e.data,o=e.shape[0],a=e.shape[1]}n instanceof Ss&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),Wr(this.gl,m,()=>{if(d)this.gl.compressedTexSubImage2D(t,l,r,s,o,a,c,n);else if(null===n)this.gl.texSubImage2D(t,l,r,s,o,a,h,u,null);else if(ArrayBuffer.isView(n))this.gl.texSubImage2D(t,l,r,s,o,a,h,u,n,p);else if(n instanceof Cs){const e=rr(this.gl);e.bindBuffer(35052,n),e.texSubImage2D(t,l,r,s,o,a,h,u,p),e.bindBuffer(35052,null)}else if(ir(this.gl)){rr(this.gl).texSubImage2D(t,l,r,s,o,a,h,u,n)}else this.gl.texSubImage2D(t,l,r,s,h,u,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(){return null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}unbind(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}_getDataType(e){let{data:t,compressed:i=!1}=e;return i?{data:t,dataType:"compressed"}:null===t?{data:t,dataType:"null"}:ArrayBuffer.isView(t)?{data:t,dataType:"typed-array"}:t instanceof Ss?{data:t.handle,dataType:"buffer"}:t instanceof Cs?{data:t,dataType:"buffer"}:{data:t,dataType:"browser-object"}}_deduceParameters(e){const{format:t,data:i}=e;let{width:n,height:r,dataFormat:s,type:o,compressed:a}=e;const l=Es[t];return s=s||l&&l.dataFormat,o=o||l&&l.types[0],a=a||l&&l.compressed,({width:n,height:r}=this._deduceImageSize(i,n,r)),{dataFormat:s,type:o,compressed:a,width:n,height:r,format:t,data:i}}_deduceImageSize(e,t,i){let n;return n="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:i}:{width:t>=0?t:1,height:i>=0?i:1},rs(n,"Could not deduced texture size"),rs(void 0===t||n.width===t,"Deduced texture width does not match supplied width"),rs(void 0===i||n.height===i,"Deduced texture height does not match supplied height"),n}_createHandle(){return this.gl.createTexture()}_deleteHandle(){this.gl.deleteTexture(this.handle),this._trackDeallocatedMemory("Texture")}_getParameter(e){switch(e){case 4096:return this.width;case 4097:return this.height;default:this.gl.bindTexture(this.target,this.handle);const t=this.gl.getTexParameter(this.target,e);return this.gl.bindTexture(this.target,null),t}}_setParameter(e,t){switch(this.gl.bindTexture(this.target,this.handle),t=this._getNPOTParam(e,t),e){case 33082:case 33083:this.gl.texParameterf(this.handle,e,t);break;case 4096:case 4097:rs(!1);break;default:this.gl.texParameteri(this.target,e,t)}return this.gl.bindTexture(this.target,null),this}_isNPOT(){return!ir(this.gl)&&(!(!this.width||!this.height)&&(!cs(this.width)||!cs(this.height)))}_updateForNPOT(e){void 0===e[this.gl.TEXTURE_MIN_FILTER]&&(e[this.gl.TEXTURE_MIN_FILTER]=this.gl.LINEAR),void 0===e[this.gl.TEXTURE_WRAP_S]&&(e[this.gl.TEXTURE_WRAP_S]=this.gl.CLAMP_TO_EDGE),void 0===e[this.gl.TEXTURE_WRAP_T]&&(e[this.gl.TEXTURE_WRAP_T]=this.gl.CLAMP_TO_EDGE)}_getNPOTParam(e,t){if(this._isNPOT())switch(e){case 10241:-1===Is.indexOf(t)&&(t=9729);break;case 10242:case 10243:33071!==t&&(t=33071)}return t}};class Ls extends Ps{get[Symbol.toStringTag](){return"Texture2D"}static isSupported(e,t){return Ps.isSupported(e,t)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;nr(e),(t instanceof Promise||"string"==typeof t)&&(t={data:t}),"string"==typeof t.data&&(t=Object.assign({},t,{data:(i=t.data,rs("string"==typeof i),i=""+i,new Promise((e,t)=>{try{const r=new Image;r.onload=()=>e(r),r.onerror=()=>t(new Error("Could not load image ".concat(i,"."))),r.crossOrigin=n&&n.crossOrigin||"anonymous",r.src=i}catch(e){t(e)}}))})),super(e,Object.assign({},t,{target:3553})),this.initialize(t),Object.seal(this)}}const Rs=[34069,34070,34071,34072,34073,34074];class Os extends Ps{get[Symbol.toStringTag](){return"TextureCube"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nr(e),super(e,Object.assign({},t,{target:34067})),this.initialize(t),Object.seal(this)}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{mipmaps:t=!0,parameters:i={}}=e;return this.opts=e,this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setParameters(i)}),this}subImage(e){let{face:t,data:i,x:n=0,y:r=0,mipmapLevel:s=0}=e;return this._subImage({target:t,data:i,x:n,y:r,mipmapLevel:s})}async setCubeMapImageData(e){let{width:t,height:i,pixels:n,data:r,border:s=0,format:o=6408,type:a=5121}=e;const{gl:l}=this,c=n||r,u=await Promise.all(Rs.map(e=>{const t=c[e];return Promise.all(Array.isArray(t)?t:[t])}));this.bind(),Rs.forEach((e,n)=>{u[n].length>1&&!1!==this.opts.mipmaps&&Qn.warn("".concat(this.id," has mipmap and multiple LODs."))(),u[n].forEach((n,r)=>{t&&i?l.texImage2D(e,r,o,t,i,s,o,a,n):l.texImage2D(e,r,o,o,a,n)})}),this.unbind()}setImageDataForFace(e){const{face:t,width:i,height:n,pixels:r,data:s,border:o=0,format:a=6408,type:l=5121}=e,{gl:c}=this,u=r||s;return this.bind(),u instanceof Promise?u.then(i=>this.setImageDataForFace(Object.assign({},e,{face:t,data:i,pixels:i}))):this.width||this.height?c.texImage2D(t,0,a,i,n,o,a,l,u):c.texImage2D(t,0,a,a,l,u),this}}Os.FACES=Rs;class Ds extends Ps{get[Symbol.toStringTag](){return"Texture3D"}static isSupported(e){return ir(e)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};rr(e),t=Object.assign({depth:1},t,{target:32879,unpackFlipY:!1}),super(e,t),this.initialize(t),Object.seal(this)}setImageData(e){let{level:t=0,dataFormat:i=6408,width:n,height:r,depth:s=1,border:o=0,format:a,type:l=5121,offset:c=0,data:u,parameters:h={}}=e;if(this._trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle),Wr(this.gl,h,()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,t,i,n,r,s,o,a,l,u),u instanceof Ss&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,t,i,n,r,s,o,a,l,c))}),u&&u.byteLength)this._trackAllocatedMemory(u.byteLength,"Texture");else{this._trackAllocatedMemory(this.width*this.height*this.depth*(As[this.dataFormat]||4)*(Ms[this.type]||1),"Texture")}return this.loaded=!0,this}}const Bs="EXT_color_buffer_float";var Fs={33189:{bpp:2},33190:{gl2:!0,bpp:3},36012:{gl2:!0,bpp:4},36168:{bpp:1},34041:{bpp:4},35056:{gl2:!0,bpp:4},36013:{gl2:!0,bpp:5},32854:{bpp:2},36194:{bpp:2},32855:{bpp:2},33321:{gl2:!0,bpp:1},33330:{gl2:!0,bpp:1},33329:{gl2:!0,bpp:1},33332:{gl2:!0,bpp:2},33331:{gl2:!0,bpp:2},33334:{gl2:!0,bpp:4},33333:{gl2:!0,bpp:4},33323:{gl2:!0,bpp:2},33336:{gl2:!0,bpp:2},33335:{gl2:!0,bpp:2},33338:{gl2:!0,bpp:4},33337:{gl2:!0,bpp:4},33340:{gl2:!0,bpp:8},33339:{gl2:!0,bpp:8},32849:{gl2:!0,bpp:3},32856:{gl2:!0,bpp:4},32857:{gl2:!0,bpp:4},36220:{gl2:!0,bpp:4},36238:{gl2:!0,bpp:4},36975:{gl2:!0,bpp:4},36214:{gl2:!0,bpp:8},36232:{gl2:!0,bpp:8},36226:{gl2:!0,bpp:16},36208:{gl2:!0,bpp:16},33325:{gl2:Bs,bpp:2},33327:{gl2:Bs,bpp:4},34842:{gl2:Bs,bpp:8},33326:{gl2:Bs,bpp:4},33328:{gl2:Bs,bpp:8},34836:{gl2:Bs,bpp:16},35898:{gl2:Bs,bpp:4}};class Ns extends ps{get[Symbol.toStringTag](){return"Renderbuffer"}static isSupported(e){let{format:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{format:null};return!t||function(e,t,i){const n=i[t];if(!n)return!1;const r=ir(e)&&n.gl2||n.gl1;return"string"==typeof r?e.getExtension(r):r}(e,t,Fs)}static getSamplesForFormat(e,t){let{format:i}=t;return e.getInternalformatParameter(36161,i,32937)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,t),this.initialize(t),Object.seal(this)}initialize(e){let{format:t,width:i=1,height:n=1,samples:r=0}=e;return rs(t,"Needs format"),this._trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),0!==r&&ir(this.gl)?this.gl.renderbufferStorageMultisample(36161,r,t,i,n):this.gl.renderbufferStorage(36161,t,i,n),this.format=t,this.width=i,this.height=n,this.samples=r,this._trackAllocatedMemory(this.width*this.height*(this.samples||1)*Fs[this.format].bpp),this}resize(e){let{width:t,height:i}=e;return t!==this.width||i!==this.height?this.initialize({width:t,height:i,format:this.format,samples:this.samples}):this}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this._trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(36161,e)}_syncHandle(e){this.format=this.getParameter(36164),this.width=this.getParameter(36162),this.height=this.getParameter(36163),this.samples=this.getParameter(36011)}_getParameter(e){this.gl.bindRenderbuffer(36161,this.handle);return this.gl.getRenderbufferParameter(36161,e)}}const ks=6144,zs="clear: bad arguments";function Us(e){let{framebuffer:t=null,color:i=null,depth:n=null,stencil:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};t&&(s.framebuffer=t);let o=0;i&&(o|=16384,!0!==i&&(s.clearColor=i)),n&&(o|=256,!0!==n&&(s.clearDepth=n)),r&&(o|=1024,!0!==n&&(s.clearStencil=n)),rs(0!==o,zs),Wr(e,s,()=>{e.clear(o)})}function Vs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{sourceX:i=0,sourceY:n=0,sourceFormat:r=6408}=t;let{sourceAttachment:s=36064,target:o=null,sourceWidth:a,sourceHeight:l,sourceType:c}=t;const{framebuffer:u,deleteFramebuffer:h}=Gs(e);rs(u);const{gl:d,handle:p,attachments:f}=u;a=a||u.width,l=l||u.height,36064===s&&null===p&&(s=1028),rs(f[s]),c=c||f[s].type,o=function(e,t,i,n,r){if(e)return e;const s=ms(t=t||5121,{clamped:!1}),o=function(e){switch(e){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 rs(!1),0}}(i);return new s(n*r*o)}(o,c,r,a,l),c=c||fs(o);const m=d.bindFramebuffer(36160,p);return d.readPixels(i,n,a,l,r,c,o),d.bindFramebuffer(36160,m||null),h&&u.delete(),o}function js(e){let{sourceAttachment:t=36064,targetMaxHeight:i=Number.MAX_SAFE_INTEGER}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Vs(e,{sourceAttachment:t}),{width:r,height:s}=e;for(;s>i;)({data:n,width:r,height:s}=gs({data:n,width:r,height:s}));!function(e){let{data:t,width:i,height:n,bytesPerPixel:r=4,temp:s}=e;const o=i*r;s=s||new Uint8Array(o);for(let e=0;e<n/2;++e){const i=e*o,r=(n-e-1)*o;s.set(t.subarray(i,i+o)),t.copyWithin(i,r,r+o),t.set(s,r)}}({data:n,width:r,height:s});const o=document.createElement("canvas");o.width=r,o.height=s;const a=o.getContext("2d"),l=a.createImageData(r,s);return l.data.set(n),a.putImageData(l,0,0),o.toDataURL()}function Gs(e){return e instanceof yo?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:vo(e),deleteFramebuffer:!0}}const Hs="WEBGL2",Ws="VERTEX_ARRAY_OBJECT",qs="TIMER_QUERY",Xs="INSTANCED_RENDERING",$s="MULTIPLE_RENDER_TARGETS",Zs="ELEMENT_INDEX_UINT32",Ys="BLEND_EQUATION_MINMAX",Js="FLOAT_BLEND",Ks="COLOR_ENCODING_SRGB",Qs="TEXTURE_DEPTH",eo="TEXTURE_FLOAT",to="TEXTURE_HALF_FLOAT",io="TEXTURE_FILTER_LINEAR_FLOAT",no="TEXTURE_FILTER_LINEAR_HALF_FLOAT",ro="TEXTURE_FILTER_ANISOTROPIC",so="COLOR_ATTACHMENT_RGBA32F",oo="COLOR_ATTACHMENT_FLOAT",ao="COLOR_ATTACHMENT_HALF_FLOAT",lo="GLSL_FRAG_DATA",co="GLSL_FRAG_DEPTH",uo="GLSL_DERIVATIVES",ho="GLSL_TEXTURE_LOD";var po={[Hs]:[!1,!0],[Ws]:["OES_vertex_array_object",!0],[qs]:["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],[Xs]:["ANGLE_instanced_arrays",!0],[$s]:["WEBGL_draw_buffers",!0],[Zs]:["OES_element_index_uint",!0],[Ys]:["EXT_blend_minmax",!0],[Js]:["EXT_float_blend"],[Ks]:["EXT_sRGB",!0],[Qs]:["WEBGL_depth_texture",!0],[eo]:["OES_texture_float",!0],[to]:["OES_texture_half_float",!0],[io]:["OES_texture_float_linear"],[no]:["OES_texture_half_float_linear"],[ro]:["EXT_texture_filter_anisotropic"],[so]:[function(e){const t=new Ls(e,{format:6408,type:5126,dataFormat:6408}),i=new yo(e,{id:"test-framebuffer",check:!1,attachments:{36064:t}}),n=i.getStatus();return t.delete(),i.delete(),36053===n},"EXT_color_buffer_float"],[oo]:[!1,"EXT_color_buffer_float"],[ao]:["EXT_color_buffer_half_float"],[lo]:["WEBGL_draw_buffers",!0],[co]:["EXT_frag_depth",!0],[uo]:["OES_standard_derivatives",!0],[ho]:["EXT_shader_texture_lod",!0]};function fo(e,t){return mo(e,t)}function mo(e,t){return(t=Array.isArray(t)?t:[t]).every(t=>go(e,t))}function go(e,t){return e.luma=e.luma||{},e.luma.caps=e.luma.caps||{},void 0===e.luma.caps[t]&&(e.luma.caps[t]=function(e,t){const i=po[t];let n;rs(i,t);const r=ir(e)&&i[1]||i[0];if("function"==typeof r)n=r(e);else if(Array.isArray(r)){n=!0;for(const t of r)n=n&&Boolean(e.getExtension(t))}else"string"==typeof r?n=Boolean(e.getExtension(r)):"boolean"==typeof r?n=r:rs(!1);return n}(e,t)),e.luma.caps[t]||Qn.log(2,"Feature: ".concat(t," not supported"))(),e.luma.caps[t]}const _o="Multiple render targets not supported";class yo extends ps{get[Symbol.toStringTag](){return"Framebuffer"}static isSupported(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{colorBufferFloat:i,colorBufferHalfFloat:n}=t;let r=!0;return i&&(r=Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("WEBGL_color_buffer_float")||e.getExtension("OES_texture_float"))),n&&(r=r&&Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))),r}static getDefaultFramebuffer(e){return e.luma=e.luma||{},e.luma.defaultFramebuffer=e.luma.defaultFramebuffer||new yo(e,{id:"default-framebuffer",handle:null,attachments:{}}),e.luma.defaultFramebuffer}get MAX_COLOR_ATTACHMENTS(){const e=rr(this.gl);return e.getParameter(e.MAX_COLOR_ATTACHMENTS)}get MAX_DRAW_BUFFERS(){const e=rr(this.gl);return e.getParameter(e.MAX_DRAW_BUFFERS)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,t),this.width=null,this.height=null,this.attachments={},this.readBuffer=36064,this.drawBuffers=[36064],this.ownResources=[],this.initialize(t),Object.seal(this)}get color(){return this.attachments[36064]||null}get texture(){return this.attachments[36064]||null}get depth(){return this.attachments[36096]||this.attachments[33306]||null}get stencil(){return this.attachments[36128]||this.attachments[33306]||null}initialize(e){let{width:t=1,height:i=1,attachments:n=null,color:r=!0,depth:s=!0,stencil:o=!1,check:a=!0,readBuffer:l,drawBuffers:c}=e;if(rs(t>=0&&i>=0,"Width and height need to be integers"),this.width=t,this.height=i,n)for(const e in n){const r=n[e];(Array.isArray(r)?r[0]:r).resize({width:t,height:i})}else n=this._createDefaultAttachments(r,s,o,t,i);this.update({clearAttachments:!0,attachments:n,readBuffer:l,drawBuffers:c}),n&&a&&this.checkStatus()}delete(){for(const e of this.ownResources)e.delete();return super.delete(),this}update(e){let{attachments:t={},readBuffer:i,drawBuffers:n,clearAttachments:r=!1,resizeAttachments:s=!0}=e;this.attach(t,{clearAttachments:r,resizeAttachments:s});const{gl:o}=this,a=o.bindFramebuffer(36160,this.handle);return i&&this._setReadBuffer(i),n&&this._setDrawBuffers(n),o.bindFramebuffer(36160,a||null),this}resize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{width:t,height:i}=e;if(null===this.handle)return rs(void 0===t&&void 0===i),this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;void 0===t&&(t=this.gl.drawingBufferWidth),void 0===i&&(i=this.gl.drawingBufferHeight),t!==this.width&&i!==this.height&&Qn.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(t,"x").concat(i))();for(const e in this.attachments)this.attachments[e].resize({width:t,height:i});return this.width=t,this.height=i,this}attach(e){let{clearAttachments:t=!1,resizeAttachments:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={};t&&Object.keys(this.attachments).forEach(e=>{n[e]=null}),Object.assign(n,e);const r=this.gl.bindFramebuffer(36160,this.handle);for(const e in n){rs(void 0!==e,"Misspelled framebuffer binding point?");const t=Number(e),r=n[t];let s=r;if(s)if(s instanceof Ns)this._attachRenderbuffer({attachment:t,renderbuffer:s});else if(Array.isArray(r)){const[e,i=0,n=0]=r;s=e,this._attachTexture({attachment:t,texture:e,layer:i,level:n})}else this._attachTexture({attachment:t,texture:s,layer:0,level:0});else this._unattach(t);i&&s&&s.resize({width:this.width,height:this.height})}this.gl.bindFramebuffer(36160,r||null),Object.assign(this.attachments,e),Object.keys(this.attachments).filter(e=>!this.attachments[e]).forEach(e=>{delete this.attachments[e]})}checkStatus(){const e=this.getStatus();if(36053!==e)throw new Error(function(e){const t=yo.STATUS||{};return t[e]||"Framebuffer error ".concat(e)}(e));return this}getStatus(){const{gl:e}=this,t=e.bindFramebuffer(36160,this.handle),i=e.checkFramebufferStatus(36160);return e.bindFramebuffer(36160,t||null),i}clear(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:t,depth:i,stencil:n,drawBuffers:r=[]}=e,s=this.gl.bindFramebuffer(36160,this.handle);return(t||i||n)&&Us(this.gl,{color:t,depth:i,stencil:n}),r.forEach((e,t)=>{!function(e){let{framebuffer:t=null,buffer:i=ks,drawBuffer:n=0,value:r=[0,0,0,0]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};rr(e),Wr(e,{framebuffer:t},()=>{switch(i){case ks:switch(r.constructor){case Int32Array:e.clearBufferiv(i,n,r);break;case Uint32Array:e.clearBufferuiv(i,n,r);break;case Float32Array:default:e.clearBufferfv(i,n,r)}break;case 6145:e.clearBufferfv(6145,0,[r]);break;case 6146:e.clearBufferiv(6146,0,[r]);break;case 34041:const[t,s]=r;e.clearBufferfi(34041,0,t,s);break;default:rs(!1,zs)}})}(this.gl,{drawBuffer:t,value:e})}),this.gl.bindFramebuffer(36160,s||null),this}readPixels(){return null}readPixelsToBuffer(){return null}copyToDataUrl(){return null}copyToImage(){return null}copyToTexture(){return null}blit(){return null}invalidate(e){let{attachments:t=[],x:i=0,y:n=0,width:r,height:s}=e;const o=rr(this.gl),a=o.bindFramebuffer(36008,this.handle);return 0===i&&0===n&&void 0===r&&void 0===s?o.invalidateFramebuffer(36008,t):o.invalidateFramebuffer(36008,t,i,n,r,s),o.bindFramebuffer(36008,a),this}getAttachmentParameter(e,t,i){let n=this._getAttachmentParameterFallback(t);return null===n&&(this.gl.bindFramebuffer(36160,this.handle),n=this.gl.getFramebufferAttachmentParameter(36160,e,t),this.gl.bindFramebuffer(36160,null)),i&&n>1e3&&(n=os(this.gl,n)),n}getAttachmentParameters(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36064,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constructor.ATTACHMENT_PARAMETERS||[];const n={};for(const r of i){n[t?os(this.gl,r):r]=this.getAttachmentParameter(e,r,t)}return n}getParameters(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=Object.keys(this.attachments),i={};for(const n of t){const t=Number(n);i[e?os(this.gl,t):t]=this.getAttachmentParameters(t,e)}return i}show(){return"undefined"!=typeof window&&window.open(js(this),"luma-debug-texture"),this}log(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e>Qn.level||"undefined"==typeof window)return this;t=t||"Framebuffer ".concat(this.id);const i=js(this,{targetMaxHeight:100});return Qn.image({logLevel:e,message:t,image:i},t)(),this}bind(){let{target:e=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(e,this.handle),this}unbind(){let{target:e=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(e,null),this}_createDefaultAttachments(e,t,i,n,r){let s=null;return e&&(s=s||{},s[36064]=new Ls(this.gl,{id:"".concat(this.id,"-color0"),pixels:null,format:6408,type:5121,width:n,height:r,mipmaps:!1,parameters:{10241:9729,10240:9729,10242:33071,10243:33071}}),this.ownResources.push(s[36064])),t&&i?(s=s||{},s[33306]=new Ns(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:n,height:111}),this.ownResources.push(s[33306])):t?(s=s||{},s[36096]=new Ns(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:n,height:r}),this.ownResources.push(s[36096])):i&&rs(!1),s}_unattach(e){const t=this.attachments[e];t&&(t instanceof Ns?this.gl.framebufferRenderbuffer(36160,e,36161,null):this.gl.framebufferTexture2D(36160,e,3553,null,0),delete this.attachments[e])}_attachRenderbuffer(e){let{attachment:t=36064,renderbuffer:i}=e;const{gl:n}=this;n.framebufferRenderbuffer(36160,t,36161,i.handle),this.attachments[t]=i}_attachTexture(e){let{attachment:t=36064,texture:i,layer:n,level:r}=e;const{gl:s}=this;switch(s.bindTexture(i.target,i.handle),i.target){case 35866:case 32879:rr(s).framebufferTextureLayer(36160,t,i.target,r,n);break;case 34067:const e=function(e){return e<34069?e+34069:e}(n);s.framebufferTexture2D(36160,t,e,i.handle,r);break;case 3553:s.framebufferTexture2D(36160,t,3553,i.handle,r);break;default:rs(!1,"Illegal texture type")}s.bindTexture(i.target,null),this.attachments[t]=i}_setReadBuffer(e){const t=ir(i=this.gl)?i:null;var i;t?t.readBuffer(e):rs(36064===e||1029===e,_o),this.readBuffer=e}_setDrawBuffers(e){const{gl:t}=this,i=rr(t);if(i)i.drawBuffers(e);else{const i=t.getExtension("WEBGL_draw_buffers");i?i.drawBuffersWEBGL(e):rs(1===e.length&&(36064===e[0]||1029===e[0]),_o)}this.drawBuffers=e}_getAttachmentParameterFallback(e){const t=function(e){e.luma=e.luma||{},e.luma.caps=e.luma.caps||{};for(const t in po)void 0===e.luma.caps[t]&&(e.luma.caps[t]=go(e,t));return e.luma.caps}(this.gl);switch(e){case 36052:return t.WEBGL2?null:0;case 33298:case 33299:case 33300:case 33301:case 33302:case 33303:return t.WEBGL2?null:8;case 33297:return t.WEBGL2?null:5125;case 33296:return t.WEBGL2||t.EXT_sRGB?null:9729;default:return null}}_createHandle(){return this.gl.createFramebuffer()}_deleteHandle(){this.gl.deleteFramebuffer(this.handle)}_bindHandle(e){return this.gl.bindFramebuffer(36160,e)}}function vo(e,t){const{gl:i,width:n,height:r,id:s}=e;return new yo(i,Object.assign({},t,{id:"framebuffer-for-".concat(s),width:n,height:r,attachments:{36064:e}}))}function xo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unnamed";const i=e.match(/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/);return i?i[1]:t}yo.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];function bo(e,t,i,n){const r=e.split(/\r?\n/),s={},o={},a=n||xo(t)||"(unnamed)",l="".concat(function(e){switch(e){case 35632:return"fragment";case 35633:return"vertex";default:return"unknown type"}}(i)," shader ").concat(a);for(let t=0;t<r.length;t++){const i=r[t];if(i.length<=1)continue;const n=i.split(":"),a=n[0],c=parseInt(n[2],10);if(isNaN(c))throw new Error("GLSL compilation error in ".concat(l,": ").concat(e));"WARNING"!==a?s[c]=i:o[c]=i}const c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:": ";const n=e.split(/\r?\n/),r=String(n.length+t-1).length;return n.map((e,n)=>{const s=String(n+t);return To(s,r-s.length)+i+e})}(t);return{shaderName:l,errors:wo(s,c),warnings:wo(o,c)}}function wo(e,t){let i="";for(let n=0;n<t.length;n++){if((e[n+3]||e[n+2]||e[n+1])&&(i+="".concat(t[n],"\n"),e[n+1])){const t=e[n+1],r=t.split(":",3),s=r[0],o=parseInt(r[1],10)||0,a=t.substring(r.join(":").length+1).trim();i+=To("^^^ ".concat(s,": ").concat(a,"\n\n"),o)}}return i}function To(e,t){let i="";for(let e=0;e<t;++e)i+=" ";return"".concat(i).concat(e)}function So(e){let t=100;const i=e.match(/[^\s]+/g);if(i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}return t}class Eo extends ps{get[Symbol.toStringTag](){return"Shader"}static getTypeName(e){switch(e){case 35633:return"vertex-shader";case 35632:return"fragment-shader";default:return rs(!1),"unknown"}}constructor(e,t){nr(e),rs("string"==typeof t.source,"Shader: GLSL source code must be a JavaScript string");super(e,{id:xo(t.source,null)||t.id||ls("unnamed ".concat(Eo.getTypeName(t.shaderType)))}),this.shaderType=t.shaderType,this.source=t.source,this.initialize(t)}initialize(e){let{source:t}=e;const i=xo(t,null);i&&(this.id=ls(i)),this._compile(t)}getParameter(e){return this.gl.getShaderParameter(this.handle,e)}toString(){return"".concat(Eo.getTypeName(this.shaderType),":").concat(this.id)}getName(){return xo(this.source)||"unnamed-shader"}getSource(){return this.gl.getShaderSource(this.handle)}getTranslatedSource(){const e=this.gl.getExtension("WEBGL_debug_shaders");return e?e.getTranslatedShaderSource(this.handle):"No translated source available. WEBGL_debug_shaders not implemented"}_compile(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.source;e.startsWith("#version ")||(e="#version 100\n".concat(e)),this.source=e,this.gl.shaderSource(this.handle,this.source),this.gl.compileShader(this.handle);if(!this.getParameter(35713)){const e=this.gl.getShaderInfoLog(this.handle),{shaderName:t,warnings:i}=bo(e,this.source,this.shaderType,this.id);throw Qn.warn("GLSL compilation warnings in ".concat(t,"\n").concat(i))(),new Error("GLSL compilation errors in ".concat(t))}}_deleteHandle(){this.gl.deleteShader(this.handle)}_getOptsFromHandle(){return{type:this.getParameter(35663),source:this.getSource()}}}class Ao extends Eo{get[Symbol.toStringTag](){return"VertexShader"}constructor(e,t){"string"==typeof t&&(t={source:t}),super(e,Object.assign({},t,{shaderType:35633}))}_createHandle(){return this.gl.createShader(35633)}}class Mo extends Eo{get[Symbol.toStringTag](){return"FragmentShader"}constructor(e,t){"string"==typeof t&&(t={source:t}),super(e,Object.assign({},t,{shaderType:35632}))}_createHandle(){return this.gl.createShader(35632)}}const Io={5126:jo.bind(null,"uniform1fv",Do,1,Go),35664:jo.bind(null,"uniform2fv",Do,2,Go),35665:jo.bind(null,"uniform3fv",Do,3,Go),35666:jo.bind(null,"uniform4fv",Do,4,Go),5124:jo.bind(null,"uniform1iv",Bo,1,Go),35667:jo.bind(null,"uniform2iv",Bo,2,Go),35668:jo.bind(null,"uniform3iv",Bo,3,Go),35669:jo.bind(null,"uniform4iv",Bo,4,Go),35670:jo.bind(null,"uniform1iv",Bo,1,Go),35671:jo.bind(null,"uniform2iv",Bo,2,Go),35672:jo.bind(null,"uniform3iv",Bo,3,Go),35673:jo.bind(null,"uniform4iv",Bo,4,Go),35674:jo.bind(null,"uniformMatrix2fv",Do,4,Ho),35675:jo.bind(null,"uniformMatrix3fv",Do,9,Ho),35676:jo.bind(null,"uniformMatrix4fv",Do,16,Ho),35678:Vo,35680:Vo,5125:jo.bind(null,"uniform1uiv",Fo,1,Go),36294:jo.bind(null,"uniform2uiv",Fo,2,Go),36295:jo.bind(null,"uniform3uiv",Fo,3,Go),36296:jo.bind(null,"uniform4uiv",Fo,4,Go),35685:jo.bind(null,"uniformMatrix2x3fv",Do,6,Ho),35686:jo.bind(null,"uniformMatrix2x4fv",Do,8,Ho),35687:jo.bind(null,"uniformMatrix3x2fv",Do,6,Ho),35688:jo.bind(null,"uniformMatrix3x4fv",Do,12,Ho),35689:jo.bind(null,"uniformMatrix4x2fv",Do,8,Ho),35690:jo.bind(null,"uniformMatrix4x3fv",Do,12,Ho),35678:Vo,35680:Vo,35679:Vo,35682:Vo,36289:Vo,36292:Vo,36293:Vo,36298:Vo,36299:Vo,36300:Vo,36303:Vo,36306:Vo,36307:Vo,36308:Vo,36311:Vo},Co={},Po={},Lo={},Ro=[0];function Oo(e,t,i,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Ro[0]=e,e=Ro);const r=e.length;if(r%t&&Qn.warn("Uniform size should be multiples of ".concat(t),e)(),e instanceof i)return e;let s=n[r];s||(s=new i(r),n[r]=s);for(let t=0;t<r;t++)s[t]=e[t];return s}function Do(e,t){return Oo(e,t,Float32Array,Co)}function Bo(e,t){return Oo(e,t,Int32Array,Po)}function Fo(e,t){return Oo(e,t,Uint32Array,Lo)}function No(e,t,i){const n=Io[i.type];if(!n)throw new Error("Unknown GLSL uniform type ".concat(i.type));return n().bind(null,e,t)}function ko(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=e.match(/([^[]*)(\[[0-9]+\])?/);if(!t||t.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:t[2]||1,isArray:Boolean(t[2])}}function zo(e){return Array.isArray(e)||ArrayBuffer.isView(e)?function(e){if(0===e.length)return!1;const t=Math.min(e.length,16);for(let i=0;i<t;++i)if(!Number.isFinite(e[i]))return!1;return!0}(e):!!isFinite(e)||(!0===e||!1===e||(e instanceof Ps||(e instanceof Ns||e instanceof yo&&Boolean(e.texture))))}function Uo(e,t,i){if(Array.isArray(i)||ArrayBuffer.isView(i))if(e[t]){const n=e[t];for(let e=0,t=i.length;e<t;++e)n[e]=i[e]}else e[t]=i.slice();else e[t]=i}function Vo(){let e=null;return(t,i,n)=>{const r=e!==n;return r&&(t.uniform1i(i,n),e=n),r}}function jo(e,t,i,n){let r=null,s=null;return(o,a,l)=>{const c=t(l,i),u=c.length;let h=!1;if(null===r)r=new Float32Array(u),s=u,h=!0;else{rs(s===u,"Uniform length cannot change.");for(let e=0;e<u;++e)if(c[e]!==r[e]){h=!0;break}}return h&&(n(o,e,a,c),r.set(c)),h}}function Go(e,t,i,n){e[t](i,n)}function Ho(e,t,i,n){e[t](i,!1,n)}const Wo=5126,qo=35664,Xo=35665,$o=35666,Zo=5124,Yo=35667,Jo=35668,Ko=35669,Qo=5125,ea=36294,ta=36295,ia=36296,na=35670,ra=35671,sa=35672,oa=35673,aa=35674,la=35675,ca=35676,ua=35685,ha=35686,da=35687,pa=35688,fa=35689,ma=35690,ga={[Wo]:[Wo,1,"float"],[qo]:[Wo,2,"vec2"],[Xo]:[Wo,3,"vec3"],[$o]:[Wo,4,"vec4"],[Zo]:[Zo,1,"int"],[Yo]:[Zo,2,"ivec2"],[Jo]:[Zo,3,"ivec3"],[Ko]:[Zo,4,"ivec4"],[Qo]:[Qo,1,"uint"],[ea]:[Qo,2,"uvec2"],[ta]:[Qo,3,"uvec3"],[ia]:[Qo,4,"uvec4"],[na]:[Wo,1,"bool"],[ra]:[Wo,2,"bvec2"],[sa]:[Wo,3,"bvec3"],[oa]:[Wo,4,"bvec4"],[aa]:[Wo,8,"mat2"],[ua]:[Wo,8,"mat2x3"],[ha]:[Wo,8,"mat2x4"],[la]:[Wo,12,"mat3"],[da]:[Wo,12,"mat3x2"],[pa]:[Wo,12,"mat3x4"],[ca]:[Wo,16,"mat4"],[fa]:[Wo,16,"mat4x2"],[ma]:[Wo,16,"mat4x3"]};function _a(e){const t=ga[e];if(!t)return null;const[i,n]=t;return{type:i,components:n}}function ya(e,t){switch(e){case 5120:case 5121:case 5122:case 5123:e=Wo}for(const i in ga){const[n,r,s]=ga[i];if(n===e&&r===t)return{glType:i,name:s}}return null}class va{constructor(e){this.id=e.id,this.attributeInfos=[],this.attributeInfosByName={},this.attributeInfosByLocation=[],this.varyingInfos=[],this.varyingInfosByName={},Object.seal(this),this._readAttributesFromProgram(e),this._readVaryingsFromProgram(e)}getAttributeInfo(e){const t=Number(e);return Number.isFinite(t)?this.attributeInfosByLocation[t]:this.attributeInfosByName[e]||null}getAttributeLocation(e){const t=this.getAttributeInfo(e);return t?t.location:-1}getAttributeAccessor(e){const t=this.getAttributeInfo(e);return t?t.accessor:null}getVaryingInfo(e){const t=Number(e);return Number.isFinite(t)?this.varyingInfos[t]:this.varyingInfosByName[e]||null}getVaryingIndex(e){const t=this.getVaryingInfo();return t?t.location:-1}getVaryingAccessor(e){const t=this.getVaryingInfo();return t?t.accessor:null}_readAttributesFromProgram(e){const{gl:t}=e,i=t.getProgramParameter(e.handle,35721);for(let n=0;n<i;n++){const{name:i,type:r,size:s}=t.getActiveAttrib(e.handle,n),o=t.getAttribLocation(e.handle,i);o>=0&&this._addAttribute(o,i,r,s)}this.attributeInfos.sort((e,t)=>e.location-t.location)}_readVaryingsFromProgram(e){const{gl:t}=e;if(!ir(t))return;const i=t.getProgramParameter(e.handle,35971);for(let n=0;n<i;n++){const{name:i,type:r,size:s}=t.getTransformFeedbackVarying(e.handle,n);this._addVarying(n,i,r,s)}this.varyingInfos.sort((e,t)=>e.location-t.location)}_addAttribute(e,t,i,n){const{type:r,components:s}=_a(i),o={type:r,size:n*s};this._inferProperties(e,t,o);const a={location:e,name:t,accessor:new xs(o)};this.attributeInfos.push(a),this.attributeInfosByLocation[e]=a,this.attributeInfosByName[a.name]=a}_inferProperties(e,t,i){/instance/i.test(t)&&(i.divisor=1)}_addVarying(e,t,i,n){const{type:r,components:s}=_a(i),o={location:e,name:t,accessor:new xs({type:r,size:n*s})};this.varyingInfos.push(o),this.varyingInfosByName[o.name]=o}}const xa=35981,ba=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"];class wa extends ps{get[Symbol.toStringTag](){return"Program"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,t),this.stubRemovedMethods("Program","v6.0",ba),this._isCached=!1,this.initialize(t),Object.seal(this),this._setId(t.id)}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{hash:t,vs:i,fs:n,varyings:r,bufferMode:s=xa}=e;return this.hash=t||"",this.vs="string"==typeof i?new Ao(this.gl,{id:"".concat(e.id,"-vs"),source:i}):i,this.fs="string"==typeof n?new Mo(this.gl,{id:"".concat(e.id,"-fs"),source:n}):n,rs(this.vs instanceof Ao),rs(this.fs instanceof Mo),this.uniforms={},this._textureUniforms={},r&&r.length>0&&(rr(this.gl),this.varyings=r,this.gl2.transformFeedbackVaryings(this.handle,r,s)),this._compileAndLink(),this._readUniformLocationsFromLinkedProgram(),this.configuration=new va(this),this.setProps(e)}delete(){return this._isCached?this:super.delete(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}setProps(e){return"uniforms"in e&&this.setUniforms(e.uniforms),this}draw(e){let{logPriority:t,drawMode:i=4,vertexCount:n,offset:r=0,start:s,end:o,isIndexed:a=!1,indexType:l=5123,instanceCount:c=0,isInstanced:u=c>0,vertexArray:h=null,transformFeedback:d,framebuffer:p,parameters:f={},uniforms:m,samplers:g}=e;if((m||g)&&(Qn.deprecated("Program.draw({uniforms})","Program.setUniforms(uniforms)")(),this.setUniforms(m||{})),Qn.priority>=t){const e=p?p.id:"default",r="mode=".concat(os(this.gl,i)," verts=").concat(n," ")+"instances=".concat(c," indexType=").concat(os(this.gl,l)," ")+"isInstanced=".concat(u," isIndexed=").concat(a," ")+"Framebuffer=".concat(e);Qn.log(t,r)()}return rs(h),this.gl.useProgram(this.handle),!(!this._areTexturesRenderable()||0===n||u&&0===c)&&(h.bindForDraw(n,c,()=>{if(void 0!==p&&(f=Object.assign({},f,{framebuffer:p})),d){const e=function(e){switch(e){case 0:return 0;case 1:case 3:case 2:return 1;case 4:case 5:case 6:return 4;default:return rs(!1),0}}(i);d.begin(e)}this._bindTextures(),Wr(this.gl,f,()=>{a&&u?this.gl2.drawElementsInstanced(i,n,l,r,c):a&&ir(this.gl)&&!isNaN(s)&&!isNaN(o)?this.gl2.drawRangeElements(i,s,o,n,l,r):a?this.gl.drawElements(i,n,l,r):u?this.gl2.drawArraysInstanced(i,r,n,c):this.gl.drawArrays(i,r,n)}),d&&d.end()}),!0)}setUniforms(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Qn.priority>=2&&function(e,t,i){for(const n in e){const r=e[n];if((!i||Boolean(i[n]))&&!zo(r))throw t=t?"".concat(t," "):"",new Error("".concat(t," Bad uniform ").concat(n))}}(e,this.id,this._uniformSetters),this.gl.useProgram(this.handle);for(const t in e){const i=e[t],n=this._uniformSetters[t];if(n){let e=i,r=!1;if(e instanceof yo&&(e=e.texture),e instanceof Ps)if(r=this.uniforms[t]!==i,r){void 0===n.textureIndex&&(n.textureIndex=this._textureIndexCounter++);const i=e,{textureIndex:r}=n;i.bind(r),e=r,this._textureUniforms[t]=i}else e=n.textureIndex;else this._textureUniforms[t]&&delete this._textureUniforms[t];(n(e)||r)&&Uo(this.uniforms,t,i)}}return this}_areTexturesRenderable(){let e=!0;for(const t in this._textureUniforms){const i=this._textureUniforms[t];i.update(),e=e&&i.loaded}return e}_bindTextures(){for(const e in this._textureUniforms){this._textureUniforms[e].bind(this._uniformSetters[e].textureIndex)}}_createHandle(){return this.gl.createProgram()}_deleteHandle(){this.gl.deleteProgram(this.handle)}_getOptionsFromHandle(e){const t=this.gl.getAttachedShaders(e),i={};for(const e of t){switch(this.gl.getShaderParameter(this.handle,35663)){case 35633:i.vs=new Ao({handle:e});break;case 35632:i.fs=new Mo({handle:e})}}return i}_getParameter(e){return this.gl.getProgramParameter(this.handle,e)}_setId(e){if(!e){const e=this._getName();this.id=ls(e)}}_getName(){let e=this.vs.getName()||this.fs.getName();return e=e.replace(/shader/i,""),e=e?"".concat(e,"-program"):"program",e}_compileAndLink(){const{gl:e}=this;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Qn.time(4,"linkProgram for ".concat(this._getName()))(),e.linkProgram(this.handle),Qn.timeEnd(4,"linkProgram for ".concat(this._getName()))(),e.debug||Qn.level>0){if(!e.getProgramParameter(this.handle,35714))throw new Error("Error linking: ".concat(e.getProgramInfoLog(this.handle)));e.validateProgram(this.handle);if(!e.getProgramParameter(this.handle,35715))throw new Error("Error validating: ".concat(e.getProgramInfoLog(this.handle)))}}_readUniformLocationsFromLinkedProgram(){const{gl:e}=this;this._uniformSetters={},this._uniformCount=this._getParameter(35718);for(let t=0;t<this._uniformCount;t++){const i=this.gl.getActiveUniform(this.handle,t),{name:n}=ko(i.name);let r=e.getUniformLocation(this.handle,n);if(this._uniformSetters[n]=No(e,r,i),i.size>1)for(let t=0;t<i.size;t++)r=e.getUniformLocation(this.handle,"".concat(n,"[").concat(t,"]")),this._uniformSetters["".concat(n,"[").concat(t,"]")]=No(e,r,i)}this._textureIndexCounter=0}getActiveUniforms(e,t){return this.gl2.getActiveUniforms(this.handle,e,t)}getUniformBlockIndex(e){return this.gl2.getUniformBlockIndex(this.handle,e)}getActiveUniformBlockParameter(e,t){return this.gl2.getActiveUniformBlockParameter(this.handle,e,t)}uniformBlockBinding(e,t){this.gl2.uniformBlockBinding(this.handle,e,t)}}class Ta extends ps{get[Symbol.toStringTag](){return"Query"}static isSupported(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const i=ir(e),n=mo(e,qs);let r=i||n;for(const e of t)switch(e){case"queries":r=r&&i;break;case"timers":r=r&&n;break;default:rs(!1)}return r}constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),this.target=null,this._queryPending=!1,this._pollingPromise=null,Object.seal(this)}beginTimeElapsedQuery(){return this.begin(35007)}beginOcclusionQuery(){let{conservative:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.begin(e?36202:35887)}beginTransformFeedbackQuery(){return this.begin(35976)}begin(e){return this._queryPending||(this.target=e,this.gl2.beginQuery(this.target,this.handle)),this}end(){return this._queryPending||this.target&&(this.gl2.endQuery(this.target),this.target=null,this._queryPending=!0),this}isResultAvailable(){if(!this._queryPending)return!1;const e=this.gl2.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.gl2.getParameter(36795)}getResult(){return this.gl2.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}createPoll(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY;if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((i,n)=>{const r=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):t++>e?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}_createHandle(){return Ta.isSupported(this.gl)?this.gl2.createQuery():null}_deleteHandle(){this.gl2.deleteQuery(this.handle)}}class Sa extends ps{get[Symbol.toStringTag](){return"TransformFeedback"}static isSupported(e){return ir(e)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};rr(e),super(e,t),this.initialize(t),this.stubRemovedMethods("TransformFeedback","v6.0",["pause","resume"]),Object.seal(this)}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.buffers={},this.unused={},this.configuration=null,this.bindOnUse=!0,us(this.buffers)||this.bind(()=>this._unbindBuffers()),this.setProps(e),this}setProps(e){"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"bindOnUse"in e&&(e=e.bindOnUse),"buffers"in e&&this.setBuffers(e.buffers)}setBuffers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bind(()=>{for(const t in e)this.setBuffer(t,e[t])}),this}setBuffer(e,t){const i=this._getVaryingIndex(e),{buffer:n,byteSize:r,byteOffset:s}=this._getBufferParams(t);return i<0?(this.unused[e]=n,Qn.warn("".concat(this.id," unused varying buffer ").concat(e))(),this):(this.buffers[i]=t,this.bindOnUse||this._bindBuffer(i,n,s,r),this)}begin(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.gl.bindTransformFeedback(36386,this.handle),this._bindBuffers(),this.gl.beginTransformFeedback(e),this}end(){return this.gl.endTransformFeedback(),this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null),this}_getBufferParams(e){let t,i,n;return e instanceof Ss==!1?(n=e.buffer,i=e.byteSize,t=e.byteOffset):n=e,void 0===t&&void 0===i||(t=t||0,i=i||n.byteLength-t),{buffer:n,byteOffset:t,byteSize:i}}_getVaryingInfo(e){return this.configuration&&this.configuration.getVaryingInfo(e)}_getVaryingIndex(e){if(this.configuration)return this.configuration.getVaryingInfo(e).location;const t=Number(e);return Number.isFinite(t)?t:-1}_bindBuffers(){if(this.bindOnUse)for(const e in this.buffers){const{buffer:t,byteSize:i,byteOffset:n}=this._getBufferParams(this.buffers[e]);this._bindBuffer(e,t,n,i)}}_unbindBuffers(){if(this.bindOnUse)for(const e in this.buffers)this._bindBuffer(e,null)}_bindBuffer(e,t){let i=arguments.length>3?arguments[3]:void 0;const n=t&&t.handle;return n&&void 0!==i?this.gl.bindBufferRange(35982,e,n,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i):this.gl.bindBufferBase(35982,e,n),this}_createHandle(){return this.gl.createTransformFeedback()}_deleteHandle(){this.gl.deleteTransformFeedback(this.handle)}_bindHandle(e){this.gl.bindTransformFeedback(36386,this.handle)}}let Ea=null;function Aa(e,t){var i;return new e((i=e.BYTES_PER_ELEMENT*t,(!Ea||Ea.byteLength<i)&&(Ea=new ArrayBuffer(i)),Ea),0,t)}class Ma extends ps{get[Symbol.toStringTag](){return"VertexArrayObject"}static isSupported(e){return!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).constantAttributeZero||(ir(e)||"Chrome"===Ei())}static getDefaultArray(e){return e.luma=e.luma||{},e.luma.defaultVertexArray||(e.luma.defaultVertexArray=new Ma(e,{handle:null,isDefaultArray:!0})),e.luma.defaultVertexArray}static getMaxAttributes(e){return Ma.MAX_ATTRIBUTES=Ma.MAX_ATTRIBUTES||e.getParameter(34921),Ma.MAX_ATTRIBUTES}static setConstant(e,t,i){switch(i.constructor){case Float32Array:Ma._setConstantFloatArray(e,t,i);break;case Int32Array:Ma._setConstantIntArray(e,t,i);break;case Uint32Array:Ma._setConstantUintArray(e,t,i);break;default:rs(!1)}}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,Object.assign({},t,{id:t.id||t.program&&t.program.id})),this.buffer=null,this.bufferValue=null,this.isDefaultArray=t.isDefaultArray||!1,this.gl2=e,this.initialize(t),Object.seal(this)}delete(){return super.delete(),this.buffer&&this.buffer.delete(),this}get MAX_ATTRIBUTES(){return Ma.getMaxAttributes(this.gl)}initialize(){return this.setProps(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}setProps(e){return this}setElementBuffer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return rs(!e||34963===e.target,"elements must be GL.ELEMENT_ARRAY_BUFFER"),this.bind(()=>{this.gl.bindBuffer(34963,e?e.handle:null)}),this}setBuffer(e,t,i){if(34963===t.target)return this.setElementBuffer(t,i);const{size:n,type:r,stride:s,offset:o,normalized:a,integer:l,divisor:c}=i,{gl:u,gl2:h}=this;return e=Number(e),this.bind(()=>{u.bindBuffer(34962,t.handle),l?(rs(ir(u)),h.vertexAttribIPointer(e,n,r,s,o)):u.vertexAttribPointer(e,n,r,a,s,o),u.enableVertexAttribArray(e),h.vertexAttribDivisor(e,c||0)}),this}enable(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return!t&&0===e&&!Ma.isSupported(this.gl,{constantAttributeZero:!0})||(e=Number(e),this.bind(()=>t?this.gl.enableVertexAttribArray(e):this.gl.disableVertexAttribArray(e))),this}getConstantBuffer(e,t){const i=this._normalizeConstantArrayValue(t),n=i.byteLength*e,r=i.length*e;let s=!this.buffer;if(this.buffer=this.buffer||new Ss(this.gl,n),s=s||this.buffer.reallocate(n),s=s||!this._compareConstantArrayValues(i,this.bufferValue),s){const e=Aa(t.constructor,r);!function(e){let{target:t,source:i,start:n=0,count:r=1}=e;const s=i.length,o=r*s;let a=0;for(let e=n;a<s;a++)t[e++]=i[a];for(;a<o;)a<o-a?(t.copyWithin(n+a,n,n+a),a*=2):(t.copyWithin(n+a,n,n+o-a),a=o)}({target:e,source:i,start:0,count:r}),this.buffer.subData(e),this.bufferValue=t}return this.buffer}_normalizeConstantArrayValue(e){return Array.isArray(e)?new Float32Array(e):e}_compareConstantArrayValues(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}static _setConstantFloatArray(e,t,i){switch(i.length){case 1:e.vertexAttrib1fv(t,i);break;case 2:e.vertexAttrib2fv(t,i);break;case 3:e.vertexAttrib3fv(t,i);break;case 4:e.vertexAttrib4fv(t,i);break;default:rs(!1)}}static _setConstantIntArray(e,t,i){switch(rs(ir(e)),i.length){case 1:e.vertexAttribI1iv(t,i);break;case 2:e.vertexAttribI2iv(t,i);break;case 3:e.vertexAttribI3iv(t,i);break;case 4:e.vertexAttribI4iv(t,i);break;default:rs(!1)}}static _setConstantUintArray(e,t,i){switch(rs(ir(e)),i.length){case 1:e.vertexAttribI1uiv(t,i);break;case 2:e.vertexAttribI2uiv(t,i);break;case 3:e.vertexAttribI3uiv(t,i);break;case 4:e.vertexAttribI4uiv(t,i);break;default:rs(!1)}}_createHandle(){return this.gl.createVertexArray()}_deleteHandle(e){return this.gl2.deleteVertexArray(e),[this.elements]}_bindHandle(e){this.gl2.bindVertexArray(e)}_getParameter(e,t){let{location:i}=t;return rs(Number.isFinite(i)),this.bind(()=>34373===e?this.gl.getVertexAttribOffset(i,e):this.gl.getVertexAttrib(i,e))}}const Ia=/^(.+)__LOCATION_([0-9]+)$/,Ca=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"];class Pa{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.id=t.id||t.program&&t.program.id,this.gl=e,this.configuration=null,this.elements=null,this.elementsAccessor=null,this.values=null,this.accessors=null,this.unused=null,this.drawParams=null,this.buffer=null,this.attributes={},this.vertexArrayObject=new Ma(e),hs(this,"VertexArray","v6.0",Ca),this.initialize(t),Object.seal(this)}delete(){this.buffer&&this.buffer.delete(),this.vertexArrayObject.delete()}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.reset(),this.configuration=null,this.bindOnUse=!1,this.setProps(e)}reset(){this.elements=null,this.elementsAccessor=null;const{MAX_ATTRIBUTES:e}=this.vertexArrayObject;return this.values=new Array(e).fill(null),this.accessors=new Array(e).fill(null),this.unused={},this.drawParams=null,this}setProps(e){return"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"attributes"in e&&this.setAttributes(e.attributes),"elements"in e&&this.setElementBuffer(e.elements),"bindOnUse"in e&&(e=e.bindOnUse),this}clearDrawParams(){this.drawParams=null}getDrawParams(){return this.drawParams=this.drawParams||this._updateDrawParams(),this.drawParams}setAttributes(e){return Object.assign(this.attributes,e),this.vertexArrayObject.bind(()=>{for(const t in e){this._setAttribute(t,e[t])}this.gl.bindBuffer(34962,null)}),this}setElementBuffer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.elements=e,this.elementsAccessor=t,this.clearDrawParams(),this.vertexArrayObject.setElementBuffer(e,t),this}setBuffer(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(34963===t.target)return this.setElementBuffer(t,i);const{location:n,accessor:r}=this._resolveLocationAndAccessor(e,t,t.accessor,i);return n>=0&&(this.values[n]=t,this.accessors[n]=r,this.clearDrawParams(),this.vertexArrayObject.setBuffer(n,t,r)),this}setConstant(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{location:n,accessor:r}=this._resolveLocationAndAccessor(e,t,Object.assign({size:t.length},i));return n>=0&&(t=this.vertexArrayObject._normalizeConstantArrayValue(t),this.values[n]=t,this.accessors[n]=r,this.clearDrawParams(),this.vertexArrayObject.enable(n,!1)),this}unbindBuffers(){return this.vertexArrayObject.bind(()=>{this.elements&&this.vertexArrayObject.setElementBuffer(null),this.buffer=this.buffer||new Ss(this.gl,{accessor:{size:4}});for(let e=0;e<this.vertexArrayObject.MAX_ATTRIBUTES;e++)this.values[e]instanceof Ss&&(this.gl.disableVertexAttribArray(e),this.gl.bindBuffer(34962,this.buffer.handle),this.gl.vertexAttribPointer(e,1,5126,!1,0,0))}),this}bindBuffers(){return this.vertexArrayObject.bind(()=>{this.elements&&this.setElementBuffer(this.elements);for(let e=0;e<this.vertexArrayObject.MAX_ATTRIBUTES;e++){const t=this.values[e];t instanceof Ss&&this.setBuffer(e,t)}}),this}bindForDraw(e,t,i){let n;return this.vertexArrayObject.bind(()=>{this._setConstantAttributes(e,t),n=i()}),n}_resolveLocationAndAccessor(e,t,i,n){const r={location:-1,accessor:null},{location:s,name:o}=this._getAttributeIndex(e);if(!Number.isFinite(s)||s<0)return this.unused[e]=t,Qn.once(3,()=>"unused value ".concat(e," in ").concat(this.id))(),r;const a=this._getAttributeInfo(o||s);if(!a)return r;const l=xs.resolve(a.accessor,this.accessors[s]||{},i,n),{size:c,type:u}=l;return rs(Number.isFinite(c)&&Number.isFinite(u)),{location:s,accessor:l}}_getAttributeInfo(e){return this.configuration&&this.configuration.getAttributeInfo(e)}_getAttributeIndex(e){const t=Number(e);if(Number.isFinite(t))return{location:t};const i=Ia.exec(e),n=i?i[1]:e,r=i?Number(i[2]):0;return this.configuration?{location:this.configuration.getAttributeLocation(n)+r,name:n}:{location:-1}}_setAttribute(e,t){if(t instanceof Ss)this.setBuffer(e,t);else if(Array.isArray(t)&&t.length&&t[0]instanceof Ss){this.setBuffer(e,t[0],t[1])}else if(ArrayBuffer.isView(t)||Array.isArray(t)){this.setConstant(e,t)}else{if(!(t.buffer instanceof Ss))throw new Error("VertexArray: attributes must be Buffers or constants (i.e. typed array)");this.setBuffer(e,t.buffer,t)}}_setConstantAttributes(e,t){const i=Math.max(0|e,0|t);let n=this.values[0];ArrayBuffer.isView(n)&&this._setConstantAttributeZero(n,i);for(let e=1;e<this.vertexArrayObject.MAX_ATTRIBUTES;e++)n=this.values[e],ArrayBuffer.isView(n)&&this._setConstantAttribute(e,n)}_setConstantAttributeZero(e,t){if(Ma.isSupported(this.gl,{constantAttributeZero:!0}))return void this._setConstantAttribute(0,e);const i=this.vertexArrayObject.getConstantBuffer(t,e);this.vertexArrayObject.setBuffer(0,i,this.accessors[0])}_setConstantAttribute(e,t){Ma.setConstant(this.gl,e,t)}_updateDrawParams(){const e={isIndexed:!1,isInstanced:!1,indexCount:1/0,vertexCount:1/0,instanceCount:1/0};for(let t=0;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++)this._updateDrawParamsForLocation(e,t);return this.elements&&(e.elementCount=this.elements.getElementCount(this.elements.accessor),e.isIndexed=!0,e.indexType=this.elementsAccessor.type||this.elements.accessor.type,e.indexOffset=this.elementsAccessor.offset||0),e.indexCount===1/0&&(e.indexCount=0),e.vertexCount===1/0&&(e.vertexCount=0),e.instanceCount===1/0&&(e.instanceCount=0),e}_updateDrawParamsForLocation(e,t){const i=this.values[t],n=this.accessors[t];if(!i)return;const{divisor:r}=n,s=r>0;if(e.isInstanced=e.isInstanced||s,i instanceof Ss){const t=i;if(s){const i=t.getVertexCount(n);e.instanceCount=Math.min(e.instanceCount,i)}else{const i=t.getVertexCount(n);e.vertexCount=Math.min(e.vertexCount,i)}}}setElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Qn.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(e,t)}}function La(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isInteger:i=!1}=t;if(Array.isArray(e)||ArrayBuffer.isView(e))return function(e,t){const{maxElts:i=16,size:n=1}=t;let r="[";for(let s=0;s<e.length&&s<i;++s)s>0&&(r+=",".concat(s%n===0?" ":"")),r+=La(e[s],t);const s=e.length>i?"...":"]";return"".concat(r).concat(s)}(e,t);if(!Number.isFinite(e))return String(e);if(Math.abs(e)<1e-16)return i?"0":"0.";if(i)return e.toFixed(0);if(Math.abs(e)>100&&Math.abs(e)<1e4)return e.toFixed(0);const n=e.toPrecision(2);return n.indexOf(".0")===n.length-2?n.slice(0,-1):n}function Ra(e){let{header:t="Uniforms",program:i,uniforms:n,undefinedOnly:r=!1}=e;rs(i);const s=".*Matrix",o={},a=Object.keys(i._uniformSetters).sort();let l=0;for(const e of a)e.match(".*_.*")||e.match(s)||Oa({table:o,header:t,uniforms:n,uniformName:e,undefinedOnly:r})&&l++;for(const e of a)e.match(s)&&Oa({table:o,header:t,uniforms:n,uniformName:e,undefinedOnly:r})&&l++;for(const e of a)o[e]||Oa({table:o,header:t,uniforms:n,uniformName:e,undefinedOnly:r})&&l++;let c=0;const u={};if(!r)for(const e in n){const i=n[e];o[e]||(c++,u[e]={Type:"NOT USED: ".concat(i),[t]:La(i)})}return{table:o,count:l,unusedTable:u,unusedCount:c}}function Oa(e){let{table:t,header:i,uniforms:n,uniformName:r,undefinedOnly:s}=e;const o=n[r],a=function(e){return null!=e}(o);return(!s||!a)&&(t[r]={[i]:a?La(o):"N/A","Uniform Type":a?o:"NOT PROVIDED"},!0)}function Da(e,t,i,n){const{gl:r}=e;if(!t)return{[n]:"null","Format ":"N/A"};let s,o,a,l="NOT PROVIDED",c=1,u=0,h=0;if(i&&(l=i.type,c=i.size,l=String(l).replace("Array",""),s=-1!==l.indexOf("nt")),t instanceof Ss){const e=t,{data:d,changed:p}=e.getDebugData();let f;if(o=p?"*":"",a=d,h=e.byteLength,u=h/d.BYTES_PER_ELEMENT/c,i){f="".concat(i.divisor>0?"I ":"P "," ").concat(u," (x").concat(c,"=").concat(h," bytes ").concat(os(r,l),")")}else s=!0,f="".concat(h," bytes");return{[n]:"".concat(o).concat(La(a,{size:c,isInteger:s})),"Format ":f}}return a=t,c=t.length,l=String(t.constructor.name).replace("Array",""),s=-1!==l.indexOf("nt"),{[n]:"".concat(La(a,{size:c,isInteger:s})," (constant)"),"Format ":"".concat(c,"x").concat(l," (constant)")}}function Ba(e,t){const{type:i,size:n}=t,r=ya(i,n);return r?"".concat(e," (").concat(r.name,")"):e}function Fa(e){const{type:t,size:i}=e.accessor,n=ya(t,i);return n?"".concat(n.name," ").concat(e.name):e.name}const Na=vi()&&"undefined"!=typeof document;let ka=0;class za{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{onCreateContext:t=e=>Qr(e),onAddHTML:i=null,onInitialize:n=()=>{},onRender:r=()=>{},onFinalize:s=()=>{},onError:o,gl:a=null,glOptions:l={},debug:c=!1,createFramebuffer:u=!1,autoResizeViewport:h=!0,autoResizeDrawingBuffer:d=!0,stats:p=ns.get("animation-loop-".concat(ka++))}=e;let{useDevicePixels:f=!0}=e;"useDevicePixelRatio"in e&&(Qn.deprecated("useDevicePixelRatio","useDevicePixels")(),f=e.useDevicePixelRatio),this.props={onCreateContext:t,onAddHTML:i,onInitialize:n,onRender:r,onFinalize:s,onError:o,gl:a,glOptions:l,debug:c,createFramebuffer:u},this.gl=a,this.needsRedraw=null,this.timeline=null,this.stats=p,this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this._initialized=!1,this._running=!1,this._animationFrameId=null,this._nextFramePromise=null,this._resolveNextFrame=null,this._cpuStartTime=0,this.setProps({autoResizeViewport:h,autoResizeDrawingBuffer:d,useDevicePixels:f}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._pageLoadPromise=null,this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}delete(){this.stop(),this._setDisplay(null)}setNeedsRedraw(e){return rs("string"==typeof e),this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.autoResizeViewport=e.autoResizeViewport),"autoResizeDrawingBuffer"in e&&(this.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer),"useDevicePixels"in e&&(this.useDevicePixels=e.useDevicePixels),this}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._running)return this;this._running=!0;const t=this._getPageLoadPromise().then(()=>!this._running||this._initialized?null:(this._createWebGLContext(e),this._createFramebuffer(),this._startEventHandling(),this._initializeCallbackData(),this._updateCallbackData(),this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._gpuTimeQuery=Ta.isSupported(this.gl,["timers"])?new Ta(this.gl):null,this._initialized=!0,this.onInitialize(this.animationProps))).then(e=>{this._running&&(this._addCallbackData(e||{}),!1!==e&&this._startLoop())});return this.props.onError&&t.catch(this.props.onError),this}redraw(){return this.isContextLost()||(this._beginTimers(),this._setupFrame(),this._updateCallbackData(),this._renderFrame(this.animationProps),this._clearNeedsRedraw(),this.offScreen&&this.gl.commit&&this.gl.commit(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endTimers()),this}stop(){return this._running&&(this._finalizeCallbackData(),this._cancelAnimationFrame(this._animationFrameId),this._nextFramePromise=null,this._resolveNextFrame=null,this._animationFrameId=null,this._running=!1),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(){return this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.gl.canvas.toDataURL()}isContextLost(){return this.gl.isContextLost()}onCreateContext(){return this.props.onCreateContext(...arguments)}onInitialize(){return this.props.onInitialize(...arguments)}onRender(){return this.props.onRender(...arguments)}onFinalize(){return this.props.onFinalize(...arguments)}getHTMLControlValue(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=document.getElementById(e);return i?Number(i.value):t}setViewParameters(){return Qn.removed("AnimationLoop.setViewParameters","AnimationLoop.setProps")(),this}_startLoop(){const e=()=>{this._running&&(this.redraw(),this._animationFrameId=this._requestAnimationFrame(e))};this._cancelAnimationFrame(this._animationFrameId),this._animationFrameId=this._requestAnimationFrame(e)}_getPageLoadPromise(){return this._pageLoadPromise||(this._pageLoadPromise=Na?new Promise((e,t)=>{Na&&"complete"===document.readyState?e(document):window.addEventListener("load",()=>{e(document)})}):Promise.resolve({})),this._pageLoadPromise}_setDisplay(e){this.display&&(this.display.delete(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_cancelAnimationFrame(e){return this.display&&this.display.cancelAnimationFrame?this.display.cancelAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t));var t}_requestAnimationFrame(e){if(this._running)return this.display&&this.display.requestAnimationFrame?this.display.requestAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60));var t}_renderFrame(){this.display?this.display._renderFrame(...arguments):this.onRender(...arguments)}_clearNeedsRedraw(){this.needsRedraw=null}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._resizeFramebuffer()}_initializeCallbackData(){this.animationProps={gl:this.gl,stop:this.stop,canvas:this.gl.canvas,framebuffer:this.framebuffer,useDevicePixels:this.useDevicePixels,needsRedraw:null,startTime:Date.now(),engineTime:0,tick:0,tock:0,time:0,_timeline:this.timeline,_loop:this,_animationLoop:this,_mousePosition:null}}_updateCallbackData(){const{width:e,height:t,aspect:i}=this._getSizeAndAspect();e===this.animationProps.width&&t===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=t,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,this.animationProps._offScreen=this.offScreen}_finalizeCallbackData(){this.onFinalize(this.animationProps)}_addCallbackData(e){"object"==typeof e&&null!==e&&(this.animationProps=Object.assign({},this.animationProps,e))}_createWebGLContext(e){if(this.offScreen=e.canvas&&"undefined"!=typeof OffscreenCanvas&&e.canvas instanceof OffscreenCanvas,e=Object.assign({},e,this.props.glOptions),this.gl=this.props.gl?es(this.props.gl,e):this.onCreateContext(e),!tr(this.gl))throw new Error("AnimationLoop.onCreateContext - illegal context returned");Hr(this.gl,Ar),this._createInfoDiv()}_createInfoDiv(){if(this.gl.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",e.appendChild(this.gl.canvas),e.appendChild(t);const i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){const e=this.gl.drawingBufferWidth,t=this.gl.drawingBufferHeight;let i=1;const{canvas:n}=this.gl;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:e>0&&t>0&&(i=e/t),{width:e,height:t,aspect:i}}_resizeViewport(){this.autoResizeViewport&&this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.autoResizeDrawingBuffer&&ts(this.gl,{useDevicePixels:this.useDevicePixels})}_createFramebuffer(){this.props.createFramebuffer&&(this.framebuffer=new yo(this.gl))}_resizeFramebuffer(){this.framebuffer&&this.framebuffer.resize({width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight})}_beginTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this._gpuTimeQuery&&this._gpuTimeQuery.isResultAvailable()&&!this._gpuTimeQuery.isTimerDisjoint()&&this.stats.get("GPU Time").addTime(this._gpuTimeQuery.getTimerMilliseconds()),this._gpuTimeQuery&&this._gpuTimeQuery.beginTimeElapsedQuery(),this.cpuTime.timeStart()}_endTimers(){this.cpuTime.timeEnd(),this._gpuTimeQuery&&this._gpuTimeQuery.end()}_startEventHandling(){const{canvas:e}=this.gl;e&&(e.addEventListener("mousemove",this._onMousemove),e.addEventListener("mouseleave",this._onMouseleave))}_onMousemove(e){this.animationProps._mousePosition=[e.offsetX,e.offsetY]}_onMouseleave(e){this.animationProps._mousePosition=null}}const Ua="vs",Va="fs";function ja(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const Ga={number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},array:{validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function Ha(e){let t=Wa(e);return"object"===t?e?"type"in e?Object.assign({},e,Ga[e.type]):"value"in e?(t=Wa(e.value),Object.assign({type:t},e,Ga[t])):{type:"object",value:e}:{type:"object",value:null}:Object.assign({type:t,value:e},Ga[t])}function Wa(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}class qa{constructor(e){let{name:t,vs:i,fs:n,dependencies:r=[],uniforms:s,getUniforms:o,deprecations:a=[],defines:l={},inject:c={},vertexShader:u,fragmentShader:h}=e;ja("string"==typeof t),this.name=t,this.vs=i||u,this.fs=n||h,this.getModuleUniforms=o,this.dependencies=r,this.deprecations=this._parseDeprecationDefinitions(a),this.defines=l,this.injections=function(e){const t={vs:{},fs:{}};for(const i in e){let n=e[i];"string"==typeof n&&(n={order:0,injection:n}),t[i.slice(0,2)][i]=n}return t}(c),s&&(this.uniforms=function(e){const t={};for(const i in e){const n=Ha(e[i]);t[i]=n}return t}(s))}getModuleSource(e){let t;switch(e){case"vs":t=this.vs||"";break;case"fs":t=this.fs||"";break;default:ja(!1)}return"#define MODULE_".concat(this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),"\n").concat(t,"// END MODULE_").concat(this.name,"\n\n")}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):this.uniforms?this._defaultGetUniforms(e):{}}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(i=>{i.regex.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp("\\b".concat(e.old,"\\("));else e.regex=new RegExp("".concat(e.type," ").concat(e.old,";"))}),e}_defaultGetUniforms(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={},i=this.uniforms;for(const n in i){const r=i[n];n in e&&!r.private?(r.validate&&ja(r.validate(e[n],r),"".concat(this.name,": invalid ").concat(n)),t[n]=e[n]):t[n]=r.value}return t}}function Xa(e){return function(e){const t={},i={};return $a({modules:e,level:0,moduleMap:t,moduleDepth:i}),Object.keys(i).sort((e,t)=>i[t]-i[e]).map(e=>t[e])}(Za(e))}function $a(e){let{modules:t,level:i,moduleMap:n,moduleDepth:r}=e;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)n[e.name]=e,(void 0===r[e.name]||r[e.name]<i)&&(r[e.name]=i);for(const e of t)e.dependencies&&$a({modules:e.dependencies,level:i+1,moduleMap:n,moduleDepth:r})}function Za(e,t){return e.map(e=>(e instanceof qa||(ja("string"!=typeof e,"Shader module use by name is deprecated. Import shader module '".concat(e,"' and use it directly.")),ja(e.name,"shader module has no name"),(e=new qa(e)).dependencies=Za(e.dependencies)),e))}const Ya={GLSL_FRAG_DATA:["WEBGL_draw_buffers",!0],GLSL_FRAG_DEPTH:["EXT_frag_depth",!0],GLSL_DERIVATIVES:["OES_standard_derivatives",!0],GLSL_TEXTURE_LOD:["EXT_shader_texture_lod",!0]},Ja={};Object.keys(Ya).forEach(e=>{Ja[e]=e});const Ka={};function Qa(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=Ya[t];if(ja(n,t),!function(){const e="undefined"!=typeof window&&window.navigator||{},t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).userAgent||e.userAgent||"",i=-1!==t.indexOf("MSIE "),n=-1!==t.indexOf("Trident/");return i||n}(i))return!0;if(t in Ka)return Ka[t];const r=i.behavior||"enable",s="#extension GL_".concat(n[0]," : ").concat(r,"\nvoid main(void) {}"),o=e.createShader(35633);e.shaderSource(o,s),e.compileShader(o);const a=e.getShaderParameter(o,35713);return e.deleteShader(o),Ka[t]=a,a}function el(e,t){const i=Ya[t];ja(i,t);const n=function(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}(e)&&i[1]||i[0],r="string"==typeof n?Boolean(e.getExtension(n)):n;return ja(!1===r||!0===r),r}function tl(e,t){return(t=Array.isArray(t)?t:[t]).every(t=>el(e,t))}const il={[Ua]:"#ifdef MODULE_LOGDEPTH\n  logdepth_adjustPosition(gl_Position);\n#endif\n",[Va]:"#ifdef MODULE_MATERIAL\n  gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n  gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n  gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n  gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n  gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n  logdepth_setFragDepth();\n#endif\n"},nl="__LUMA_INJECT_DECLARATIONS__",rl=/void\s+main\s*\([^)]*\)\s*\{\n?/,sl=/}\n?[^{}]*$/,ol=[];function al(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=t===Ua;for(const t in i){const n=i[t];n.sort((e,t)=>e.order-t.order),ol.length=n.length;for(let e=0,t=n.length;e<t;++e)ol[e]=n[e].injection;const s="".concat(ol.join("\n"),"\n");switch(t){case"vs:#decl":r&&(e=e.replace(nl,s));break;case"vs:#main-start":r&&(e=e.replace(rl,e=>e+s));break;case"vs:#main-end":r&&(e=e.replace(sl,e=>s+e));break;case"fs:#decl":r||(e=e.replace(nl,s));break;case"fs:#main-start":r||(e=e.replace(rl,e=>e+s));break;case"fs:#main-end":r||(e=e.replace(sl,e=>s+e));break;default:e=e.replace(t,e=>e+s)}}return e=e.replace(nl,""),n&&(e=e.replace(/\}\s*$/,e=>e+il[t])),e}function ll(e){const t={};return ja(Array.isArray(e)&&e.length>1),e.forEach(e=>{for(const i in e)t[i]=t[i]?"".concat(t[i],"\n").concat(e[i]):e[i]}),t}function cl(e){return new RegExp("\\b".concat(e,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}const ul=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],hl=[...ul,[cl("attribute"),"in $1"],[cl("varying"),"out $1"]],dl=[...ul,[cl("varying"),"in $1"]],pl=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],fl=[...pl,[cl("in"),"attribute $1"],[cl("out"),"varying $1"]],ml=[...pl,[cl("in"),"varying $1"]],gl="gl_FragColor",_l=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,yl=/void\s+main\s*\([^)]*\)\s*\{\n?/;function vl(e,t,i){switch(t){case 300:return i?xl(e,hl):function(e){e=xl(e,dl);const t=e.match(_l);if(t){const i=t[1];e=e.replace(new RegExp("\\b".concat(gl,"\\b"),"g"),i)}else{const t="fragmentColor";e=e.replace(yl,e=>"out vec4 ".concat(t,";\n").concat(e)).replace(new RegExp("\\b".concat(gl,"\\b"),"g"),t)}return e}(e);case 100:return i?xl(e,fl):function(e){e=xl(e,ml);const t=e.match(_l);if(t){const i=t[1];e=e.replace(_l,"").replace(new RegExp("\\b".concat(i,"\\b"),"g"),gl)}return e}(e);default:throw new Error("unknown GLSL version ".concat(t))}}function xl(e,t){for(const[i,n]of t)e=e.replace(i,n);return e}const bl="\n\n".concat(nl,"\n\n"),wl={[Ua]:"vertex",[Va]:"fragment"};function Tl(e,t){let{id:i,source:n,type:r,modules:s,defines:o={},hookFunctions:a=[],inject:l={},transpileToGLSL100:c=!1,prologue:u=!0,log:h}=t;ja("string"==typeof n,"shader source must be a string");const d=r===Ua,p=n.split("\n");let f=100,m="",g=n;0===p[0].indexOf("#version ")?(f=300,m=p[0],g=p.slice(1).join("\n")):m="#version ".concat(f);const _={};s.forEach(e=>{Object.assign(_,e.getDefines())}),Object.assign(_,o);let y=u?"".concat(m,"\n").concat(function(e){let{id:t,source:i,type:n}=e;const r=t&&"string"==typeof t&&-1===i.indexOf("SHADER_NAME");return r?"\n#define SHADER_NAME ".concat(t,"_").concat(wl[n],"\n\n"):""}({id:i,source:n,type:r}),"\n").concat(function(e){let{type:t}=e;return"\n#define SHADER_TYPE_".concat(wl[t].toUpperCase(),"\n")}({type:r}),"\n").concat(function(e){const t=function(e){const t=e.getExtension("WEBGL_debug_renderer_info"),i=e.getParameter(t&&t.UNMASKED_VENDOR_WEBGL||7936),n=e.getParameter(t&&t.UNMASKED_RENDERER_WEBGL||7937);return{gpuVendor:function(e,t){return e.match(/NVIDIA/i)||t.match(/NVIDIA/i)?"NVIDIA":e.match(/INTEL/i)||t.match(/INTEL/i)?"INTEL":e.match(/AMD/i)||t.match(/AMD/i)||e.match(/ATI/i)||t.match(/ATI/i)?"AMD":"UNKNOWN GPU"}(i,n),vendor:i,renderer:n,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e);switch(t.gpuVendor.toLowerCase()){case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e),"\n").concat(function(e){let t="#if (__VERSION__ > 120)\n\n# define FEATURE_GLSL_DERIVATIVES\n# define FEATURE_GLSL_DRAW_BUFFERS\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FEATURE_GLSL_TEXTURE_LOD\n\n// DEPRECATED FLAGS, remove in v9\n# define FRAG_DEPTH\n# define DERIVATIVES\n# define DRAW_BUFFERS\n# define TEXTURE_LOD\n\n#endif // __VERSION\n";return tl(e,Ja.GLSL_FRAG_DEPTH)&&(t+="\n// FRAG_DEPTH => gl_FragDepth is available\n#ifdef GL_EXT_frag_depth\n#extension GL_EXT_frag_depth : enable\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FRAG_DEPTH\n# define gl_FragDepth gl_FragDepthEXT\n#endif\n"),tl(e,Ja.GLSL_DERIVATIVES)&&Qa(e,Ja.GLSL_DERIVATIVES)&&(t+="\n// DERIVATIVES => dxdF, dxdY and fwidth are available\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n# define FEATURE_GLSL_DERIVATIVES\n# define DERIVATIVES\n#endif\n"),tl(e,Ja.GLSL_FRAG_DATA)&&Qa(e,Ja.GLSL_FRAG_DATA,{behavior:"require"})&&(t+="\n// DRAW_BUFFERS => gl_FragData[] is available\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers : require\n#define FEATURE_GLSL_DRAW_BUFFERS\n#define DRAW_BUFFERS\n#endif\n"),tl(e,Ja.GLSL_TEXTURE_LOD)&&(t+="// TEXTURE_LOD => texture2DLod etc are available\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod : enable\n\n# define FEATURE_GLSL_TEXTURE_LOD\n# define TEXTURE_LOD\n\n#endif\n"),t}(e),"\n").concat(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,i="";for(const n in e){0===t&&(i+="\n// APPLICATION DEFINES\n"),t++;const r=e[n];(r||Number.isFinite(r))&&(i+="#define ".concat(n.toUpperCase()," ").concat(e[n],"\n"))}0===t&&(i+="\n");return i}(_),"\n").concat(d?"":"precision highp float;\n\n","\n"):"".concat(m,"\n");const v=function(e){const t={vs:{},fs:{}};return e.forEach(e=>{let i;"string"!=typeof e?(i=e,e=i.hook):i={},e=e.trim();const[n,r]=e.split(":"),s=e.replace(/\(.+/,"");t[n][s]=Object.assign(i,{signature:r})}),t}(a),x={},b={},w={};for(const e in l){const t="string"==typeof l[e]?{injection:l[e],order:0}:l[e],i=e.match(/^(v|f)s:(#)?([\w-]+)$/);if(i){i[2]?"decl"===i[3]?b[e]=[t]:w[e]=[t]:x[e]=[t]}else w[e]=[t]}for(const e of s){h&&e.checkDeprecations(g,h);y+=e.getModuleSource(r,f);const t=e.injections[r];for(const e in t){const i=e.match(/^(v|f)s:#([\w-]+)$/);if(i){const n="decl"===i[2]?b:w;n[e]=n[e]||[],n[e].push(t[e])}else x[e]=x[e]||[],x[e].push(t[e])}}return y+=bl,y=al(y,r,b),y+=function(e,t){let i="";for(const n in e){const r=e[n];if(i+="void ".concat(r.signature," {\n"),r.header&&(i+="  ".concat(r.header)),t[n]){const e=t[n];e.sort((e,t)=>e.order-t.order);for(const t of e)i+="  ".concat(t.injection,"\n")}r.footer&&(i+="  ".concat(r.footer)),i+="}\n"}return i}(v[r],x),y+=g,y=al(y,r,w),y=vl(y,c?100:f,d),y}function Sl(e){return function(t){const i={};for(const n of e){const e=n.getUniforms(t,i);Object.assign(i,e)}return i}}const El="out vec4 transform_output;\nvoid main() {\n  transform_output = vec4(0);\n}",Al="#version 300 es\n".concat(El);function Ml(e,t){t=Array.isArray(t)?t:[t];const i=e.replace(/^\s+/,"").split(/\s+/),[n,r,s]=i;if(!t.includes(n)||!r||!s)return null;return{qualifier:n,type:r,name:s.split(";")[0]}}function Il(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{version:t=100,input:i,inputType:n,output:r}=e;if(!i)return 300===t?Al:t>300?"#version ".concat(t,"\n").concat(El):"void main() {gl_FragColor = vec4(0);}";const s=function(e,t){switch(t){case"float":return"vec4(".concat(e,", 0.0, 0.0, 1.0)");case"vec2":return"vec4(".concat(e,", 0.0, 1.0)");case"vec3":return"vec4(".concat(e,", 1.0)");case"vec4":return e;default:return ja(!1),null}}(i,n);return t>=300?"#version ".concat(t," ").concat(300===t?"es":"","\nin ").concat(n," ").concat(i,";\nout vec4 ").concat(r,";\nvoid main() {\n  ").concat(r," = ").concat(s,";\n}"):"varying ".concat(n," ").concat(i,";\nvoid main() {\n  gl_FragColor = ").concat(s,";\n}")}const Cl={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\n\nfloat sin_taylor_fp32(float a) {\n  float r, s, t, x;\n\n  if (a == 0.0) {\n    return 0.0;\n  }\n\n  x = -a * a;\n  s = a;\n  r = a;\n\n  r = r * x;\n  t = r * INVERSE_FACTORIAL_3;\n  s = s + t;\n\n  r = r * x;\n  t = r * INVERSE_FACTORIAL_5;\n  s = s + t;\n\n  r = r * x;\n  t = r * INVERSE_FACTORIAL_7;\n  s = s + t;\n\n  r = r * x;\n  t = r * INVERSE_FACTORIAL_9;\n  s = s + t;\n\n  return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n  if (a == 0.0) {\n    sin_t = 0.0;\n    cos_t = 1.0;\n  }\n  sin_t = sin_taylor_fp32(a);\n  cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n    float sin_a;\n    float cos_a;\n\n    if (a == 0.0) {\n        return 0.0;\n    }\n    float z = floor(a / TWO_PI);\n    float r = a - TWO_PI * z;\n\n    float t;\n    float q = floor(r / PI_2 + 0.5);\n    int j = int(q);\n\n    if (j < -2 || j > 2) {\n        return 1.0 / 0.0;\n    }\n\n    t = r - PI_2 * q;\n\n    q = floor(t / PI_16 + 0.5);\n    int k = int(q);\n    int abs_k = int(abs(float(k)));\n\n    if (abs_k > 4) {\n        return 1.0 / 0.0;\n    } else {\n        t = t - PI_16 * q;\n    }\n\n    float u = 0.0;\n    float v = 0.0;\n\n    float sin_t, cos_t;\n    float s, c;\n    sincos_taylor_fp32(t, sin_t, cos_t);\n\n    if (k == 0) {\n        s = sin_t;\n        c = cos_t;\n    } else {\n        if (abs(float(abs_k) - 1.0) < 0.5) {\n            u = COS_TABLE_0;\n            v = SIN_TABLE_0;\n        } else if (abs(float(abs_k) - 2.0) < 0.5) {\n            u = COS_TABLE_1;\n            v = SIN_TABLE_1;\n        } else if (abs(float(abs_k) - 3.0) < 0.5) {\n            u = COS_TABLE_2;\n            v = SIN_TABLE_2;\n        } else if (abs(float(abs_k) - 4.0) < 0.5) {\n            u = COS_TABLE_3;\n            v = SIN_TABLE_3;\n        }\n        if (k > 0) {\n            s = u * sin_t + v * cos_t;\n            c = u * cos_t - v * sin_t;\n        } else {\n            s = u * sin_t - v * cos_t;\n            c = u * cos_t + v * sin_t;\n        }\n    }\n\n    if (j == 0) {\n        sin_a = s;\n        cos_a = c;\n    } else if (j == 1) {\n        sin_a = c;\n        cos_a = -s;\n    } else if (j == -1) {\n        sin_a = -c;\n        cos_a = s;\n    } else {\n        sin_a = -s;\n        cos_a = -c;\n    }\n    return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n  return tan_taylor_fp32(a);\n#else\n  return tan(a);\n#endif\n}\n",fs:null};function Pl(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}const Ll=1/Math.PI*180,Rl=1/180*Math.PI,Ol={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function Dl(e,{precision:t=Ol.precision}={}){return e=function(e){return Math.round(e/Ol.EPSILON)*Ol.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function Bl(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Fl(e){return function(e,t){return jl(e,e=>e*Rl,t)}(e)}function Nl(e){return kl(e)}function kl(e,t){return jl(e,e=>e*Ll,t)}function zl(e,t,i){return jl(e,e=>Math.max(t,Math.min(i,e)))}function Ul(e,t,i){return Bl(e)?e.map((e,n)=>Ul(e,t[n],i)):i*t+(1-i)*e}function Vl(e,t,i){const n=Ol.EPSILON;i&&(Ol.EPSILON=i);try{if(e===t)return!0;if(Bl(e)&&Bl(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!Vl(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=Ol.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{Ol.EPSILON=n}}function jl(e,t,i){if(Bl(e)){const n=e;i=i||function(e){return e.clone?e.clone():new Array(e.length)}(n);for(let r=0;r<i.length&&r<n.length;++r)i[r]=t(e[r],r,i);return i}return t(e)}class Gl extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+t];return this.check()}toArray(e=[],t=0){for(let i=0;i<this.ELEMENTS;++i)e[t+i]=this[i];return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Bl(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Ol)}formatString(e){let t="";for(let i=0;i<this.ELEMENTS;++i)t+=(i>0?", ":"")+Dl(this[i],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Vl(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,i){if(void 0===i)return this.lerp(this,e,t);for(let n=0;n<this.ELEMENTS;++n){const r=e[n];this[n]=r+i*(t[n]-r)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),t[i]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(Ol.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),t);return this.check()}get elements(){return this}}function Hl(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function Wl(e,t,i=""){if(Ol.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error("math.gl: ".concat(i," some fields set to invalid numbers'"));return e}class ql extends Gl{get x(){return this[0]}set x(e){this[0]=Hl(e)}get y(){return this[1]}set y(e){this[1]=Hl(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let i=0;i<this.ELEMENTS;++i){const n=this[i]-e[i];t+=n*n}return Hl(t)}dot(e){let t=0;for(let i=0;i<this.ELEMENTS;++i)t+=this[i]*e[i];return Hl(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Pl(e>=0&&e<this.ELEMENTS,"index is out of range"),Hl(this[e])}setComponent(e,t){return Pl(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}var Xl=1e-6,$l="undefined"!=typeof Float32Array?Float32Array:Array;function Zl(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function Yl(e,t,i,n){var r=t[0],s=t[1];return e[0]=r+n*(i[0]-r),e[1]=s+n*(i[1]-s),e}function Jl(e,t,i){var n=t[0],r=t[1];return e[0]=i[0]*n+i[3]*r+i[6],e[1]=i[1]*n+i[4]*r+i[7],e}function Kl(e,t,i){var n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e}function Ql(e,t,i){const n=t[0],r=t[1],s=i[3]*n+i[7]*r||1;return e[0]=(i[0]*n+i[4]*r)/s,e[1]=(i[1]*n+i[5]*r)/s,e}function ec(e,t,i){const n=t[0],r=t[1],s=t[2],o=i[3]*n+i[7]*r+i[11]*s||1;return e[0]=(i[0]*n+i[4]*r+i[8]*s)/o,e[1]=(i[1]*n+i[5]*r+i[9]*s)/o,e[2]=(i[2]*n+i[6]*r+i[10]*s)/o,e}function tc(e,t,i){const n=t[0],r=t[1],s=t[2];return e[0]=i[0]*n+i[3]*r+i[6]*s,e[1]=i[1]*n+i[4]*r+i[7]*s,e[2]=i[2]*n+i[5]*r+i[8]*s,e[3]=t[3],e}!function(){var e,t=(e=new $l(2),$l!=Float32Array&&(e[0]=0,e[1]=0),e)}();let ic=class extends ql{constructor(e=0,t=0){super(2),Bl(e)&&1===arguments.length?this.copy(e):(Ol.debug&&(Hl(e),Hl(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Ol.debug&&(Hl(e.x),Hl(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Kl(this,this,e),this.check()}transformAsVector(e){return Ql(this,this,e),this.check()}transformByMatrix3(e){return Jl(this,this,e),this.check()}transformByMatrix2x3(e){return function(e,t,i){var n=t[0],r=t[1];e[0]=i[0]*n+i[2]*r+i[4],e[1]=i[1]*n+i[3]*r+i[5]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,i){var n=t[0],r=t[1];e[0]=i[0]*n+i[2]*r,e[1]=i[1]*n+i[3]*r}(this,this,e),this.check()}};function nc(){var e=new $l(3);return $l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rc(e){var t=e[0],i=e[1],n=e[2];return Math.sqrt(t*t+i*i+n*n)}function sc(e,t,i){var n=new $l(3);return n[0]=e,n[1]=t,n[2]=i,n}function oc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ac(e,t,i){var n=t[0],r=t[1],s=t[2],o=i[0],a=i[1],l=i[2];return e[0]=r*l-s*a,e[1]=s*o-n*l,e[2]=n*a-r*o,e}function lc(e,t,i){var n=t[0],r=t[1],s=t[2],o=i[3]*n+i[7]*r+i[11]*s+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*s+i[12])/(o=o||1),e[1]=(i[1]*n+i[5]*r+i[9]*s+i[13])/o,e[2]=(i[2]*n+i[6]*r+i[10]*s+i[14])/o,e}function cc(e,t,i){var n=t[0],r=t[1],s=t[2];return e[0]=n*i[0]+r*i[3]+s*i[6],e[1]=n*i[1]+r*i[4]+s*i[7],e[2]=n*i[2]+r*i[5]+s*i[8],e}function uc(e,t,i){var n=i[0],r=i[1],s=i[2],o=i[3],a=t[0],l=t[1],c=t[2],u=r*c-s*l,h=s*a-n*c,d=n*l-r*a;return e[0]=a+o*(u+=u)+r*(d+=d)-s*(h+=h),e[1]=l+o*h+s*u-n*d,e[2]=c+o*d+n*h-r*u,e}var hc=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},dc=rc;!function(){var e=nc()}();const pc=[0,0,0];let fc,mc,gc=class e extends ql{static get ZERO(){return fc||(fc=new e(0,0,0),Object.freeze(fc)),fc}constructor(e=0,t=0,i=0){super(-0,-0,-0),1===arguments.length&&Bl(e)?this.copy(e):(Ol.debug&&(Hl(e),Hl(t),Hl(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ol.debug&&(Hl(e.x),Hl(e.y),Hl(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Hl(e)}angle(e){return function(e,t){var i=e[0],n=e[1],r=e[2],s=t[0],o=t[1],a=t[2],l=Math.sqrt((i*i+n*n+r*r)*(s*s+o*o+a*a)),c=l&&oc(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))}(this,e)}cross(e){return ac(this,this,e),this.check()}rotateX({radians:e,origin:t=pc}){return function(e,t,i,n){var r=[],s=[];r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],s[0]=r[0],s[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),s[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2]}(this,this,t,e),this.check()}rotateY({radians:e,origin:t=pc}){return function(e,t,i,n){var r=[],s=[];r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],s[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),s[1]=r[1],s[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2]}(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=pc}){return function(e,t,i,n){var r=[],s=[];r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],s[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),s[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),s[2]=r[2],e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2]}(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return lc(this,this,e),this.check()}transformAsVector(e){return ec(this,this,e),this.check()}transformByMatrix3(e){return cc(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,i){const n=t[0],r=t[1];e[0]=i[0]*n+i[2]*r,e[1]=i[1]*n+i[3]*r,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return uc(this,this,e),this.check()}},_c=class e extends ql{static get ZERO(){return mc||(mc=new e(0,0,0,0),Object.freeze(mc)),mc}constructor(e=0,t=0,i=0,n=0){super(-0,-0,-0,-0),Bl(e)&&1===arguments.length?this.copy(e):(Ol.debug&&(Hl(e),Hl(t),Hl(i),Hl(n)),this[0]=e,this[1]=t,this[2]=i,this[3]=n)}set(e,t,i,n){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Ol.debug&&(Hl(e.x),Hl(e.y),Hl(e.z),Hl(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=Hl(e)}get w(){return this[3]}set w(e){this[3]=Hl(e)}transform(e){return lc(this,this,e),this.check()}transformByMatrix3(e){return tc(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,i){const n=t[0],r=t[1];e[0]=i[0]*n+i[2]*r,e[1]=i[1]*n+i[3]*r,e[2]=t[2],e[3]=t[3]}(this,this,e),this.check()}transformByQuaternion(e){return uc(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};class yc extends Gl{toString(){let e="[";if(Ol.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let i=0;i<this.RANK;++i)e+=" ".concat(this[i*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,i){return this[t*this.RANK+e]=Hl(i),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const i=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[i+e];return t}setColumn(e,t){const i=e*this.RANK;for(let e=0;e<this.RANK;++e)this[i+e]=t[e];return this}}function vc(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1],f=i[2],m=i[3],g=i[4],_=i[5],y=i[6],v=i[7],x=i[8];return e[0]=d*n+p*o+f*c,e[1]=d*r+p*a+f*u,e[2]=d*s+p*l+f*h,e[3]=m*n+g*o+_*c,e[4]=m*r+g*a+_*u,e[5]=m*s+g*l+_*h,e[6]=y*n+v*o+x*c,e[7]=y*r+v*a+x*u,e[8]=y*s+v*l+x*h,e}function xc(e,t,i){var n=i[0],r=i[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=r*t[3],e[4]=r*t[4],e[5]=r*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var bc;!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"}(bc||(bc={}));const wc=Object.freeze([1,0,0,0,1,0,0,0,1]);let Tc,Sc,Ec=class extends yc{static get IDENTITY(){return function(){Sc||(Sc=new Ec,Object.freeze(Sc));return Sc}()}static get ZERO(){return function(){Tc||(Tc=new Ec([0,0,0,0,0,0,0,0,0]),Object.freeze(Tc));return Tc}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return bc}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):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(wc)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i+i,a=n+n,l=r+r,c=i*o,u=n*o,h=n*a,d=r*o,p=r*a,f=r*l,m=s*o,g=s*a,_=s*l;e[0]=1-h-f,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,i,n,r,s,o,a,l){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=s,this[6]=o,this[7]=a,this[8]=l,this.check()}setRowMajor(e,t,i,n,r,s,o,a,l){return this[0]=e,this[1]=n,this[2]=o,this[3]=t,this[4]=r,this[5]=a,this[6]=i,this[7]=s,this[8]=l,this.check()}determinant(){return function(e){var t=e[3],i=e[4],n=e[5],r=e[6],s=e[7],o=e[8];return e[0]*(o*i-n*s)+e[1]*(-o*t+n*r)+e[2]*(s*t-i*r)}(this)}transpose(){return function(e,t){if(e===t){var i=t[1],n=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=n,e[7]=r}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=-u*s+a*l,p=c*s-o*l,f=i*h+n*d+r*p;f&&(e[0]=h*(f=1/f),e[1]=(-u*n+r*c)*f,e[2]=(a*n-r*o)*f,e[3]=d*f,e[4]=(u*i-r*l)*f,e[5]=(-a*i+r*s)*f,e[6]=p*f,e[7]=(-c*i+n*l)*f,e[8]=(o*i-n*s)*f)}(this,this),this.check()}multiplyLeft(e){return vc(this,e,this),this.check()}multiplyRight(e){return vc(this,this,e),this.check()}rotate(e){return function(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(i),p=Math.cos(i);e[0]=p*n+d*o,e[1]=p*r+d*a,e[2]=p*s+d*l,e[3]=p*o-d*n,e[4]=p*a-d*r,e[5]=p*l-d*s,e[6]=c,e[7]=u,e[8]=h}(this,this,e),this.check()}scale(e){return Array.isArray(e)?xc(this,this,e):xc(this,this,[e,e]),this.check()}translate(e){return function(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1];e[0]=n,e[1]=r,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=d*n+p*o+c,e[7]=d*r+p*a+u,e[8]=d*s+p*l+h}(this,this,e),this.check()}transform(e,t){let i;switch(e.length){case 2:i=Jl(t||[-0,-0],e,this);break;case 3:i=cc(t||[-0,-0,-0],e,this);break;case 4:i=tc(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Wl(i,e.length),i}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}};function Ac(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*a-n*o,v=i*l-r*o,x=i*c-s*o,b=n*l-r*a,w=n*c-s*a,T=r*c-s*l,S=u*m-h*f,E=u*g-d*f,A=u*_-p*f,M=h*g-d*m,I=h*_-p*m,C=d*_-p*g,P=y*C-v*I+x*M+b*A-w*E+T*S;return P?(e[0]=(a*C-l*I+c*M)*(P=1/P),e[1]=(r*I-n*C-s*M)*P,e[2]=(m*T-g*w+_*b)*P,e[3]=(d*w-h*T-p*b)*P,e[4]=(l*A-o*C-c*E)*P,e[5]=(i*C-r*A+s*E)*P,e[6]=(g*x-f*T-_*v)*P,e[7]=(u*T-d*x+p*v)*P,e[8]=(o*I-a*A+c*S)*P,e[9]=(n*A-i*I-s*S)*P,e[10]=(f*w-m*x+_*y)*P,e[11]=(h*x-u*w-p*y)*P,e[12]=(a*E-o*M-l*S)*P,e[13]=(i*M-n*E+r*S)*P,e[14]=(m*v-f*b-g*y)*P,e[15]=(u*b-h*v+d*y)*P,e):null}function Mc(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*n+x*a+b*h+w*m,e[1]=v*r+x*l+b*d+w*g,e[2]=v*s+x*c+b*p+w*_,e[3]=v*o+x*u+b*f+w*y,e[4]=(v=i[4])*n+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=v*r+x*l+b*d+w*g,e[6]=v*s+x*c+b*p+w*_,e[7]=v*o+x*u+b*f+w*y,e[8]=(v=i[8])*n+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=v*r+x*l+b*d+w*g,e[10]=v*s+x*c+b*p+w*_,e[11]=v*o+x*u+b*f+w*y,e[12]=(v=i[12])*n+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=v*r+x*l+b*d+w*g,e[14]=v*s+x*c+b*p+w*_,e[15]=v*o+x*u+b*f+w*y,e}function Ic(e,t,i){var n,r,s,o,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=s*m+c*g+p*_+t[14],e[15]=o*m+u*g+f*_+t[15]),e}function Cc(e,t,i){var n=i[0],r=i[1],s=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Pc(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[4],o=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*r+c*n,e[5]=o*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-s*n,e[9]=u*r-o*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function Lc(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=s*r+c*n,e[1]=o*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-s*n,e[5]=u*r-o*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}var Rc=function(e,t,i,n,r){var s=1/Math.tan(t/2);if(e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var o=1/(n-r);e[10]=(r+n)*o,e[14]=2*r*n*o}else e[10]=-1,e[14]=-2*n;return e};var Oc,Dc=function(e,t,i,n,r,s,o){var a=1/(t-i),l=1/(n-r),c=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(o+s)*c,e[15]=1,e};function Bc(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Fc(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*s+i[12]*o,e[1]=i[1]*n+i[5]*r+i[9]*s+i[13]*o,e[2]=i[2]*n+i[6]*r+i[10]*s+i[14]*o,e[3]=i[3]*n+i[7]*r+i[11]*s+i[15]*o,e}!function(){var e,t=(e=new $l(4),$l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}(),function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(Oc||(Oc={}));const Nc=45*Math.PI/180,kc=1,zc=.1,Uc=500,Vc=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);let jc,Gc,Hc=class extends yc{static get IDENTITY(){return function(){Gc||(Gc=new Hc,Object.freeze(Gc));return Gc}()}static get ZERO(){return function(){jc||(jc=new Hc([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(jc));return jc}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Oc}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):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[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=s,this[6]=o,this[7]=a,this[8]=l,this[9]=c,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=f,this[15]=m,this.check()}setRowMajor(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=r,this[2]=l,this[3]=d,this[4]=t,this[5]=s,this[6]=c,this[7]=p,this[8]=i,this[9]=o,this[10]=u,this[11]=f,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Vc)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i+i,a=n+n,l=r+r,c=i*o,u=n*o,h=n*a,d=r*o,p=r*a,f=r*l,m=s*o,g=s*a,_=s*l;e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:i,bottom:n,top:r,near:s=zc,far:o=Uc}=e;return o===1/0?function(e,t,i,n,r,s){const o=2*s/(i-t),a=2*s/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),u=-1,h=-1,d=-2*s;e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=l,e[9]=c,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,i,n,r,s):function(e,t,i,n,r,s,o){var a=1/(i-t),l=1/(r-n),c=1/(s-o);e[0]=2*s*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*s*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(r+n)*l,e[10]=(o+s)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*c,e[15]=0}(this,t,i,n,r,s,o),this.check()}lookAt(e){const{eye:t,center:i=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,i,n){var r,s,o,a,l,c,u,h,d,p,f=t[0],m=t[1],g=t[2],_=n[0],y=n[1],v=n[2],x=i[0],b=i[1],w=i[2];Math.abs(f-x)<Xl&&Math.abs(m-b)<Xl&&Math.abs(g-w)<Xl?function(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(e):(u=f-x,h=m-b,d=g-w,r=y*(d*=p=1/Math.sqrt(u*u+h*h+d*d))-v*(h*=p),s=v*(u*=p)-_*d,o=_*h-y*u,(p=Math.sqrt(r*r+s*s+o*o))?(r*=p=1/p,s*=p,o*=p):(r=0,s=0,o=0),a=h*o-d*s,l=d*r-u*o,c=u*s-h*r,(p=Math.sqrt(a*a+l*l+c*c))?(a*=p=1/p,l*=p,c*=p):(a=0,l=0,c=0),e[0]=r,e[1]=a,e[2]=u,e[3]=0,e[4]=s,e[5]=l,e[6]=h,e[7]=0,e[8]=o,e[9]=c,e[10]=d,e[11]=0,e[12]=-(r*f+s*m+o*g),e[13]=-(a*f+l*m+c*g),e[14]=-(u*f+h*m+d*g),e[15]=1)}(this,t,i,n),this.check()}ortho(e){const{left:t,right:i,bottom:n,top:r,near:s=zc,far:o=Uc}=e;return Dc(this,t,i,n,r,s,o),this.check()}orthographic(e){const{fovy:t=Nc,aspect:i=kc,focalDistance:n=1,near:r=zc,far:s=Uc}=e;Wc(t);const o=n*Math.tan(t/2),a=o*i;return this.ortho({left:-a,right:a,bottom:-o,top:o,near:r,far:s})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:i=1,near:n=.1,far:r=500}=e;return Wc(t),Rc(this,t,i,n,r),this.check()}determinant(){return function(e){var t=e[0],i=e[1],n=e[2],r=e[4],s=e[5],o=e[6],a=e[8],l=e[9],c=e[10],u=e[12],h=e[13],d=e[14],p=t*s-i*r,f=t*o-n*r,m=i*o-n*s,g=a*h-l*u,_=a*d-c*u,y=l*d-c*h;return e[7]*(t*y-i*_+n*g)-e[3]*(r*y-s*_+o*g)+e[15]*(a*m-l*f+c*p)-e[11]*(u*m-h*f+d*p)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0];const i=this.getScale(t=t||[-0,-0,-0]),n=1/i[0],r=1/i[1],s=1/i[2];return e[0]=this[0]*n,e[1]=this[1]*r,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*n,e[5]=this[5]*r,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*n,e[9]=this[9]*r,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0];const i=this.getScale(t=t||[-0,-0,-0]),n=1/i[0],r=1/i[1],s=1/i[2];return e[0]=this[0]*n,e[1]=this[1]*r,e[2]=this[2]*s,e[3]=this[4]*n,e[4]=this[5]*r,e[5]=this[6]*s,e[6]=this[8]*n,e[7]=this[9]*r,e[8]=this[10]*s,e}transpose(){return function(e,t){if(e===t){var i=t[1],n=t[2],r=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=r,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]}(this,this),this.check()}invert(){return Ac(this,this),this.check()}multiplyLeft(e){return Mc(this,e,this),this.check()}multiplyRight(e){return Mc(this,this,e),this.check()}rotateX(e){return Pc(this,this,e),this.check()}rotateY(e){return function(e,t,i){var n=Math.sin(i),r=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*r-c*n,e[1]=o*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=s*n+c*r,e[9]=o*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r}(this,this,e),this.check()}rotateZ(e){return Lc(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,i,n){var r,s,o,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S,E,A,M,I=n[0],C=n[1],P=n[2],L=Math.sqrt(I*I+C*C+P*P);L<Xl||(I*=L=1/L,C*=L,P*=L,r=Math.sin(i),s=Math.cos(i),l=t[1],c=t[2],u=t[3],d=t[5],p=t[6],f=t[7],g=t[9],_=t[10],y=t[11],w=I*C*(o=1-s)-P*r,T=C*C*o+s,S=P*C*o+I*r,E=I*P*o+C*r,A=C*P*o-I*r,M=P*P*o+s,e[0]=(a=t[0])*(v=I*I*o+s)+(h=t[4])*(x=C*I*o+P*r)+(m=t[8])*(b=P*I*o-C*r),e[1]=l*v+d*x+g*b,e[2]=c*v+p*x+_*b,e[3]=u*v+f*x+y*b,e[4]=a*w+h*T+m*S,e[5]=l*w+d*T+g*S,e[6]=c*w+p*T+_*S,e[7]=u*w+f*T+y*S,e[8]=a*E+h*A+m*M,e[9]=l*E+d*A+g*M,e[10]=c*E+p*A+_*M,e[11]=u*E+f*A+y*M,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return Cc(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ic(this,this,e),this.check()}transform(e,t){return 4===e.length?(Wl(t=Fc(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:i}=e;let n;switch(i){case 2:n=Kl(t||[-0,-0],e,this);break;case 3:n=lc(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Wl(n,e.length),n}transformAsVector(e,t){let i;switch(e.length){case 2:i=Ql(t||[-0,-0],e,this);break;case 3:i=ec(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Wl(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}};function Wc(e){if(e>2*Math.PI)throw Error("expected radians")}function qc(){var e=new $l(4);return $l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Xc(e,t,i){i*=.5;var n=Math.sin(i);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i),e}function $c(e,t,i){var n=t[0],r=t[1],s=t[2],o=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=n*u+o*a+r*c-s*l,e[1]=r*u+o*l+s*a-n*c,e[2]=s*u+o*c+n*l-r*a,e[3]=o*u-n*a-r*l-s*c,e}function Zc(e,t,i,n){var r,s,o,a,l,c=t[0],u=t[1],h=t[2],d=t[3],p=i[0],f=i[1],m=i[2],g=i[3];return(s=c*p+u*f+h*m+d*g)<0&&(s=-s,p=-p,f=-f,m=-m,g=-g),1-s>Xl?(r=Math.acos(s),o=Math.sin(r),a=Math.sin((1-n)*r)/o,l=Math.sin(n*r)/o):(a=1-n,l=n),e[0]=a*c+l*p,e[1]=a*u+l*f,e[2]=a*h+l*m,e[3]=a*d+l*g,e}function Yc(e,t){var i,n=t[0]+t[4]+t[8];if(n>0)i=Math.sqrt(n+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var r=0;t[4]>t[0]&&(r=1),t[8]>t[3*r+r]&&(r=2);var s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(t[3*r+r]-t[3*s+s]-t[3*o+o]+1),e[r]=.5*i,e[3]=(t[3*s+o]-t[3*o+s])*(i=.5/i),e[s]=(t[3*s+r]+t[3*r+s])*i,e[o]=(t[3*o+r]+t[3*r+o])*i}return e}var Jc,Kc,Qc,eu,tu=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},iu=Bc,nu=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ru=function(e,t,i,n){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=s+n*(i[1]-s),e[2]=o+n*(i[2]-o),e[3]=a+n*(i[3]-a),e},su=function(e){var t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)},ou=function(e){var t=e[0],i=e[1],n=e[2],r=e[3];return t*t+i*i+n*n+r*r},au=function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i*i+n*n+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=n*o,e[2]=r*o,e[3]=s*o,e},lu=(Jc=nc(),Kc=sc(1,0,0),Qc=sc(0,1,0),function(e,t,i){var n=oc(t,i);return n<-.999999?(ac(Jc,Kc,t),dc(Jc)<1e-6&&ac(Jc,Qc,t),function(e,t){var i=t[0],n=t[1],r=t[2],s=i*i+n*n+r*r;s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s}(Jc,Jc),Xc(e,Jc,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(ac(Jc,t,i),e[0]=Jc[0],e[1]=Jc[1],e[2]=Jc[2],e[3]=1+n,au(e,e))});qc(),qc(),eu=new $l(9),$l!=Float32Array&&(eu[1]=0,eu[2]=0,eu[3]=0,eu[5]=0,eu[6]=0,eu[7]=0),eu[0]=1,eu[4]=1,eu[8]=1;const cu=[0,0,0,1];let uu=class extends Gl{constructor(e=0,t=0,i=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,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,t,i,n){return this[0]=e,this[1]=t,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 Yc(this,e),this.check()}fromAxisRotation(e,t){return Xc(this,e,t),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=Hl(e)}get y(){return this[1]}set y(e){this[1]=Hl(e)}get z(){return this[2]}set z(e){this[2]=Hl(e)}get w(){return this[3]}set w(e){this[3]=Hl(e)}len(){return su(this)}lengthSquared(){return ou(this)}dot(e){return nu(this,e)}rotationTo(e,t){return lu(this,e,t),this.check()}add(e){return tu(this,this,e),this.check()}calculateW(){return function(e,t){var i=t[0],n=t[1],r=t[2];e[0]=i,e[1]=n,e[2]=r,e[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){var i=t[0],n=t[1],r=t[2],s=t[3],o=i*i+n*n+r*r+s*s,a=o?1/o:0;e[0]=-i*a,e[1]=-n*a,e[2]=-r*a,e[3]=s*a}(this,this),this.check()}lerp(e,t,i){return void 0===i?this.lerp(this,e,t):(ru(this,e,t,i),this.check())}multiplyRight(e){return $c(this,this,e),this.check()}multiplyLeft(e){return $c(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+o*a,e[1]=r*l+s*a,e[2]=s*l-r*a,e[3]=o*l-n*a}(this,this,e),this.check()}rotateY(e){return function(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l-s*a,e[1]=r*l+o*a,e[2]=s*l+n*a,e[3]=o*l-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,i){i*=.5;var n=t[0],r=t[1],s=t[2],o=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=s*l+o*a,e[3]=o*l-s*a}(this,this,e),this.check()}scale(e){return iu(this,this,e),this.check()}slerp(e,t,i){let n,r,s;switch(arguments.length){case 1:({start:n=cu,target:r,ratio:s}=e);break;case 2:n=this,r=e,s=t;break;default:n=e,r=t,s=i}return Zc(this,n,r,s),this.check()}transformVector4(e,t=new _c){return function(e,t,i){var n=i[0],r=i[1],s=i[2],o=i[3],a=t[0],l=t[1],c=t[2],u=r*c-s*l,h=s*a-n*c,d=n*l-r*a;e[0]=a+o*(u+=u)+r*(d+=d)-s*(h+=h),e[1]=l+o*h+s*u-n*d,e[2]=c+o*d+n*h-r*u,e[3]=t[3]}(t,e,this),Wl(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var hu=.1,du=1e-12,pu=1e-15,fu=1e-20,mu="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n  vec3 color;\n  vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n  return pointLight.attenuation.x\n       + pointLight.attenuation.y * distance\n       + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";const gu={lightSources:{}};function _u(){let{color:e=[0,0,0],intensity:t=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.map(e=>e*t/255)}const yu={name:"lights",vs:mu,fs:mu,getUniforms:function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:gu;if("lightSources"in t){const{ambientLight:e,pointLights:i,directionalLights:n}=t.lightSources||{};return e||i&&i.length>0||n&&n.length>0?Object.assign({},function(e){let{ambientLight:t,pointLights:i=[],directionalLights:n=[]}=e;const r={};return r["lighting_uAmbientLight.color"]=t?_u(t):[0,0,0],i.forEach((e,t)=>{r["lighting_uPointLight[".concat(t,"].color")]=_u(e),r["lighting_uPointLight[".concat(t,"].position")]=e.position,r["lighting_uPointLight[".concat(t,"].attenuation")]=e.attenuation||[1,0,0]}),r.lighting_uPointLightCount=i.length,n.forEach((e,t)=>{r["lighting_uDirectionalLight[".concat(t,"].color")]=_u(e),r["lighting_uDirectionalLight[".concat(t,"].direction")]=e.direction}),r.lighting_uDirectionalLightCount=n.length,r}({ambientLight:e,pointLights:i,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const i={pointLights:[],directionalLights:[]};for(const e of t.lights||[])switch(e.type){case"ambient":i.ambientLight=e;break;case"directional":i.directionalLights.push(e);break;case"point":i.pointLights.push(e)}return e({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}},vu={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};const xu={name:"picking",vs:"uniform bool picking_uActive;\nuniform bool picking_uAttribute;\nuniform vec3 picking_uSelectedColor;\nuniform bool picking_uSelectedColorValid;\n\nout vec4 picking_vRGBcolor_Avalid;\n\nconst float COLOR_SCALE = 1. / 255.;\n\nbool picking_isColorValid(vec3 color) {\n  return dot(color, vec3(1.0)) > 0.001;\n}\n\nbool isVertexPicked(vec3 vertexColor) {\n  return\n    picking_uSelectedColorValid &&\n    !picking_isColorValid(abs(vertexColor - picking_uSelectedColor));\n}\n\nvoid picking_setPickingColor(vec3 pickingColor) {\n  if (picking_uActive) {\n    picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n    if (!picking_uAttribute) {\n      picking_vRGBcolor_Avalid.rgb = pickingColor * COLOR_SCALE;\n    }\n  } else {\n    picking_vRGBcolor_Avalid.a = float(isVertexPicked(pickingColor));\n  }\n}\n\nvoid picking_setPickingAttribute(float value) {\n  if (picking_uAttribute) {\n    picking_vRGBcolor_Avalid.r = value;\n  }\n}\nvoid picking_setPickingAttribute(vec2 value) {\n  if (picking_uAttribute) {\n    picking_vRGBcolor_Avalid.rg = value;\n  }\n}\nvoid picking_setPickingAttribute(vec3 value) {\n  if (picking_uAttribute) {\n    picking_vRGBcolor_Avalid.rgb = value;\n  }\n}\n",fs:"uniform bool picking_uActive;\nuniform vec3 picking_uSelectedColor;\nuniform vec4 picking_uHighlightColor;\n\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\n  if (picking_uActive) {\n    return color;\n  }\n  bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n  if (selected) {\n    float highLightAlpha = picking_uHighlightColor.a;\n    float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n    float highLightRatio = highLightAlpha / blendedAlpha;\n\n    vec3 blendedRGB = mix(color.rgb, picking_uHighlightColor.rgb, highLightRatio);\n    return vec4(blendedRGB, blendedAlpha);\n  } else {\n    return color;\n  }\n}\nvec4 picking_filterPickingColor(vec4 color) {\n  if (picking_uActive) {\n    if (picking_vRGBcolor_Avalid.a == 0.0) {\n      discard;\n    }\n    return picking_vRGBcolor_Avalid;\n  }\n  return color;\n}\nvec4 picking_filterColor(vec4 color) {\n  vec4 highightColor = picking_filterHighlightColor(color);\n  return picking_filterPickingColor(highightColor);\n}\n\n",getUniforms:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vu;const t={};if(void 0!==e.pickingSelectedColor)if(e.pickingSelectedColor){const i=e.pickingSelectedColor.slice(0,3);t.picking_uSelectedColorValid=1,t.picking_uSelectedColor=i}else t.picking_uSelectedColorValid=0;if(e.pickingHighlightColor){const i=Array.from(e.pickingHighlightColor,e=>e/255);Number.isFinite(i[3])||(i[3]=1),t.picking_uHighlightColor=i}return void 0!==e.pickingActive&&(t.picking_uActive=Boolean(e.pickingActive),t.picking_uAttribute=Boolean(e.pickingAttribute)),t}};var bu="\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3  lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n    vec3 halfway_direction = normalize(light_direction + view_direction);\n    float lambertian = dot(light_direction, normal_worldspace);\n    float specular = 0.0;\n    if (lambertian > 0.0) {\n      float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n      specular = pow(specular_angle, lighting_uShininess);\n    }\n    lambertian = max(lambertian, 0.0);\n    return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n  vec3 lightColor = surfaceColor;\n\n  if (lighting_uEnabled) {\n    vec3 view_direction = normalize(cameraPosition - position_worldspace);\n    lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n    for (int i = 0; i < MAX_LIGHTS; i++) {\n      if (i >= lighting_uPointLightCount) {\n        break;\n      }\n      PointLight pointLight = lighting_uPointLight[i];\n      vec3 light_position_worldspace = pointLight.position;\n      vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n      lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n    }\n\n    for (int i = 0; i < MAX_LIGHTS; i++) {\n      if (i >= lighting_uDirectionalLightCount) {\n        break;\n      }\n      DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n      lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n    }\n  }\n  return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n  vec3 lightColor = vec3(0, 0, 0);\n  vec3 surfaceColor = vec3(0, 0, 0);\n\n  if (lighting_uEnabled) {\n    vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n    for (int i = 0; i < MAX_LIGHTS; i++) {\n      if (i >= lighting_uPointLightCount) {\n        break;\n      }\n      PointLight pointLight = lighting_uPointLight[i];\n      vec3 light_position_worldspace = pointLight.position;\n      vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n      lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n    }\n\n    for (int i = 0; i < MAX_LIGHTS; i++) {\n      if (i >= lighting_uDirectionalLightCount) {\n        break;\n      }\n      DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n      lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n    }\n  }\n  return lightColor;\n}\n";const wu={};function Tu(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wu;if(!("material"in e))return{};const{material:t}=e;return t?function(e){const{ambient:t=.35,diffuse:i=.6,shininess:n=32,specularColor:r=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:i,lighting_uShininess:n,lighting_uSpecularColor:r.map(e=>e/255)}}(t):{lighting_uEnabled:!1}}const Su={name:"gouraud-lighting",dependencies:[yu],vs:bu,defines:{LIGHTING_VERTEX:1},getUniforms:Tu},Eu={name:"phong-lighting",dependencies:[yu],fs:bu,defines:{LIGHTING_FRAGMENT:1},getUniforms:Tu};const Au={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n  vec4 pos = u_ModelMatrix * position;\n  pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n  vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n  vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n  pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n  pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n  pbr_vUV = uv;\n#else\n  pbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n\n#if (__VERSION__ < 300)\n  #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n  #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n\nstruct PBRInfo\n{\n  float NdotL;\n  float NdotV;\n  float NdotH;\n  float LdotH;\n  float VdotH;\n  float perceptualRoughness;\n  float metalness;\n  vec3 reflectance0;\n  vec3 reflectance90;\n  float alphaRoughness;\n  vec3 diffuseColor;\n  vec3 specularColor;\n  vec3 n;\n  vec3 v;\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n  vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\n  vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n  vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\n  return vec4(linOut,srgbIn.w);;\n#else\n  return srgbIn;\n#endif\n}\n\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\n  vec3 pos_dx = dFdx(pbr_vPosition);\n  vec3 pos_dy = dFdy(pbr_vPosition);\n  vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n  vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n  vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n  vec3 ng = normalize(pbr_vNormal);\n#else\n  vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n  t = normalize(t - ng * dot(ng, t));\n  vec3 b = normalize(cross(ng, t));\n  mat3 tbn = mat3(t, b, ng);\n#else\n  mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n  vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n  n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n  vec3 n = normalize(tbn[2].xyz);\n#endif\n\n  return n;\n}\n\n\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n  float mipCount = 9.0;\n  float lod = (pbrInputs.perceptualRoughness * mipCount);\n  vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n    vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n  vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n  vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n  vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n  vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n  vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n  diffuse *= u_ScaleIBLAmbient.x;\n  specular *= u_ScaleIBLAmbient.y;\n\n  return diffuse + specular;\n}\n#endif\n\n\nvec3 diffuse(PBRInfo pbrInputs)\n{\n  return pbrInputs.diffuseColor / M_PI;\n}\n\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n  return pbrInputs.reflectance0 +\n    (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n    pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n\n\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n  float NdotL = pbrInputs.NdotL;\n  float NdotV = pbrInputs.NdotV;\n  float r = pbrInputs.alphaRoughness;\n\n  float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n  float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n  return attenuationL * attenuationV;\n}\n\n\n\n\n\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n  float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n  float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n  return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n  pbrInputs.NdotL = 1.0;\n  pbrInputs.NdotH = 0.0;\n  pbrInputs.LdotH = 0.0;\n  pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n  vec3 n = pbrInputs.n;\n  vec3 v = pbrInputs.v;\n  vec3 l = normalize(lightDirection);\n  vec3 h = normalize(l+v);\n\n  pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n  pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n  pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n  pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n  vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n  PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n  vec3 F = specularReflection(pbrInputs);\n  float G = geometricOcclusion(pbrInputs);\n  float D = microfacetDistribution(pbrInputs);\n  vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n  vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n  return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\n  vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n  vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n  if (baseColor.a < u_AlphaCutoff) {\n    discard;\n  }\n#endif\n\n  vec3 color = vec3(0, 0, 0);\n\n  if(pbr_uUnlit){\n    color.rgb = baseColor.rgb;\n  }\n  else{\n\n\n    float perceptualRoughness = u_MetallicRoughnessValues.y;\n    float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n\n    vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n    perceptualRoughness = mrSample.g * perceptualRoughness;\n    metallic = mrSample.b * metallic;\n#endif\n    perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n    metallic = clamp(metallic, 0.0, 1.0);\n\n    float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n    vec3 f0 = vec3(0.04);\n    vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n    diffuseColor *= 1.0 - metallic;\n    vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n    float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n\n\n    float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n    vec3 specularEnvironmentR0 = specularColor.rgb;\n    vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n    vec3 n = getNormal();\n    vec3 v = normalize(u_Camera - pbr_vPosition);\n\n    float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n    vec3 reflection = -normalize(reflect(v, n));\n\n    PBRInfo pbrInputs = PBRInfo(\n      0.0,\n      NdotV,\n      0.0,\n      0.0,\n      0.0,\n      perceptualRoughness,\n      metallic,\n      specularEnvironmentR0,\n      specularEnvironmentR90,\n      alphaRoughness,\n      diffuseColor,\n      specularColor,\n      n,\n      v\n    );\n\n#ifdef USE_LIGHTS\n    PBRInfo_setAmbientLight(pbrInputs);\n    color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n    SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n      if (i < lighting_uDirectionalLightCount) {\n        PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n        color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n      }\n    }\n    SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n      if (i < lighting_uPointLightCount) {\n        PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n        float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n        color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n      }\n    }\n#endif\n#ifdef USE_IBL\n    color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\n    float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n    color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n    vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n    color += emissive;\n#endif\n\n#ifdef PBR_DEBUG\n\n\n\n\n\n    color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n    color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n    color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n  }\n\n  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[yu]},Mu={name:"transform",vs:"attribute float transform_elementID;\nvec2 transform_getPixelSizeHalf(vec2 size) {\n  return vec2(1.) / (2. * size);\n}\n\nvec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {\n  float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);\n  float xIndex = transform_elementID - (yIndex * texSize[0]);\n  return vec2(xIndex, yIndex);\n}\nvec2 transform_getTexCoord(vec2 size) {\n  vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);\n  vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);\n  vec2 coord = indices / size + pixelSizeHalf;\n  return coord;\n}\nvec2 transform_getPos(vec2 size) {\n  vec2 texCoord = transform_getTexCoord(size);\n  vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);\n  return pos;\n}\nvec4 transform_getInput(sampler2D texSampler, vec2 size) {\n  vec2 texCoord = transform_getTexCoord(size);\n  vec4 textureColor = texture2D(texSampler, texCoord);\n  return textureColor;\n}\n",fs:null};class Iu{static getDefaultProgramManager(e){return e.luma=e.luma||{},e.luma.defaultProgramManager=e.luma.defaultProgramManager||new Iu(e),e.luma.defaultProgramManager}constructor(e){this.gl=e,this._programCache={},this._getUniforms={},this._registeredModules={},this._hookFunctions=[],this._defaultModules=[],this._hashes={},this._hashCounter=0,this.stateHash=0,this._useCounts={}}addDefaultModule(e){this._defaultModules.find(t=>t.name===e.name)||this._defaultModules.push(e),this.stateHash++}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t),this.stateHash++}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e),this.stateHash++}get(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{vs:t="",fs:i="",defines:n={},inject:r={},varyings:s=[],bufferMode:o=35981,transpileToGLSL100:a=!1}=e,l=this._getModuleList(e.modules),c=this._getHash(t),u=this._getHash(i),h=l.map(e=>this._getHash(e.name)).sort(),d=s.map(e=>this._getHash(e)),p=Object.keys(n).sort(),f=Object.keys(r).sort(),m=[],g=[];for(const e of p)m.push(this._getHash(e)),m.push(this._getHash(n[e]));for(const e of f)g.push(this._getHash(e)),g.push(this._getHash(r[e]));const _="".concat(c,"/").concat(u,"D").concat(m.join("/"),"M").concat(h.join("/"),"I").concat(g.join("/"),"V").concat(d.join("/"),"H").concat(this.stateHash,"B").concat(o).concat(a?"T":"");if(!this._programCache[_]){const e=function(e,t){const{vs:i,fs:n}=t,r=Xa(t.modules||[]);return{gl:e,vs:Tl(e,Object.assign({},t,{source:i,type:Ua,modules:r})),fs:Tl(e,Object.assign({},t,{source:n,type:Va,modules:r})),getUniforms:Sl(r)}}(this.gl,{vs:t,fs:i,modules:l,inject:r,defines:n,hookFunctions:this._hookFunctions,transpileToGLSL100:a});this._programCache[_]=new wa(this.gl,{hash:_,vs:e.vs,fs:e.fs,varyings:s,bufferMode:o}),this._getUniforms[_]=e.getUniforms||(e=>{}),this._useCounts[_]=0}return this._useCounts[_]++,this._programCache[_]}getUniforms(e){return this._getUniforms[e.hash]||null}release(e){const t=e.hash;this._useCounts[t]--,0===this._useCounts[t]&&(this._programCache[t].delete(),delete this._programCache[t],delete this._getUniforms[t],delete this._useCounts[t])}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getModuleList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=new Array(this._defaultModules.length+e.length),i={};let n=0;for(let e=0,r=this._defaultModules.length;e<r;++e){const r=this._defaultModules[e],s=r.name;t[n++]=r,i[s]=!0}for(let r=0,s=e.length;r<s;++r){const s=e[r],o=s.name;i[o]||(t[n++]=s,i[o]=!0)}return t.length=n,t}}const Cu={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function Pu(e,t){const{attributeMap:i=Cu}={};return i&&i[e]||e}function Lu(e,t){let i;switch(e){case"texCoords":case"texCoord1":case"texCoord2":case"texCoord3":i="uvs";break;case"vertices":case"positions":case"normals":case"pickingColors":i="vectors"}switch(i){case"vectors":t.size=t.size||3;break;case"uvs":t.size=t.size||2}rs(Number.isFinite(t.size),"attribute ".concat(e," needs size"))}const Ru=()=>{},Ou={};class Du{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{id:i=ls("model")}=t;rs(tr(e)),this.id=i,this.gl=e,this.id=t.id||ls("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(t)}initialize(e){this.props={},this.programManager=e.programManager||Iu.getDefaultProgramManager(this.gl),this._programManagerState=-1,this._managedProgram=!1;const{program:t=null,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:l,transpileToGLSL100:c}=e;this.programProps={program:t,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:l,transpileToGLSL100:c},this.program=null,this.vertexArray=null,this._programDirty=!0,this.userData={},this.needsRedraw=!0,this._attributes={},this.attributes={},this.uniforms={},this.pickable=!0,this._checkProgram(),this.setUniforms(Object.assign({},this.getModuleUniforms(e.moduleSettings))),this.drawMode=void 0!==e.drawMode?e.drawMode:4,this.vertexCount=e.vertexCount||0,this.geometryBuffers={},this.isInstanced=e.isInstanced||e.instanced||e.instanceCount>0,this._setModelProps(e),this.geometry={},rs(void 0!==this.drawMode&&Number.isFinite(this.vertexCount),"Model needs drawMode and vertexCount")}setProps(e){this._setModelProps(e)}delete(){for(const e in this._attributes)this._attributes[e]!==this.attributes[e]&&this._attributes[e].delete();this._managedProgram&&(this.programManager.release(this.program),this._managedProgram=!1),this.vertexArray.delete(),this._deleteGeometryBuffers()}getDrawMode(){return this.drawMode}getVertexCount(){return this.vertexCount}getInstanceCount(){return this.instanceCount}getAttributes(){return this.attributes}getProgram(){return this.program}setProgram(e){const{program:t,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:l,transpileToGLSL100:c}=e;this.programProps={program:t,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:l,transpileToGLSL100:c},this._programDirty=!0}getUniforms(){return this.uniforms}setDrawMode(e){return this.drawMode=e,this}setVertexCount(e){return rs(Number.isFinite(e)),this.vertexCount=e,this}setInstanceCount(e){return rs(Number.isFinite(e)),this.instanceCount=e,this}setGeometry(e){return this.drawMode=e.drawMode,this.vertexCount=e.getVertexCount(),this._deleteGeometryBuffers(),this.geometryBuffers=function(e,t){const i={};let n=t.indices;for(const r in t.attributes){const s=t.attributes[r],o=Pu(r);if("indices"===r)n=s;else if(s.constant)i[o]=s.value;else{const t=s.value,n={...s};delete n.value,i[o]=[new Ss(e,t),n],Lu(r,n)}}if(n){const t=n.value||n;rs(t instanceof Uint16Array||t instanceof Uint32Array,'attribute array for "indices" must be of integer type');const r={size:1,isIndexed:void 0===n.isIndexed||n.isIndexed};i.indices=[new Ss(e,{data:t,target:34963}),r]}return i}(this.gl,e),this.vertexArray.setAttributes(this.geometryBuffers),this}setAttributes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(us(e))return this;const t={};for(const i in e){const n=e[i];t[i]=n.getValue?n.getValue():n}return this.vertexArray.setAttributes(t),this}setUniforms(){return Object.assign(this.uniforms,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this}getModuleUniforms(e){this._checkProgram();const t=this.programManager.getUniforms(this.program);return t?t(e):{}}updateModuleSettings(e){const t=this.getModuleUniforms(e||{});return this.setUniforms(t)}clear(e){return Us(this.program.gl,e),this}draw(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._checkProgram();const{moduleSettings:t=null,framebuffer:i,uniforms:n={},attributes:r={},transformFeedback:s=this.transformFeedback,parameters:o={},vertexArray:a=this.vertexArray}=e;let l;this.setAttributes(r),this.updateModuleSettings(t),this.setUniforms(n),Qn.priority>=2&&(l=this._logDrawCallStart(2));const c=this.vertexArray.getDrawParams(),{isIndexed:u=c.isIndexed,indexType:h=c.indexType,indexOffset:d=c.indexOffset,vertexArrayInstanced:p=c.isInstanced}=this.props;p&&!this.isInstanced&&Qn.warn("Found instanced attributes on non-instanced model",this.id)();const{isInstanced:f,instanceCount:m}=this,{onBeforeRender:g=Ru,onAfterRender:_=Ru}=this.props;g(),this.program.setUniforms(this.uniforms);const y=this.program.draw(Object.assign(Ou,e,{logPriority:l,uniforms:null,framebuffer:i,parameters:o,drawMode:this.getDrawMode(),vertexCount:this.getVertexCount(),vertexArray:a,transformFeedback:s,isIndexed:u,indexType:h,isInstanced:f,instanceCount:m,offset:u?d:0}));return _(),Qn.priority>=2&&this._logDrawCallEnd(l,a,i),y}transform(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{discard:t=!0,feedbackBuffers:i,unbindModels:n=[]}=e;let{parameters:r}=e;i&&this._setFeedbackBuffers(i),t&&(r=Object.assign({},r,{35977:t})),n.forEach(e=>e.vertexArray.unbindBuffers());try{this.draw(Object.assign({},e,{parameters:r}))}finally{n.forEach(e=>e.vertexArray.bindBuffers())}return this}render(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Qn.warn("Model.render() is deprecated. Use Model.setUniforms() and Model.draw()")(),this.setUniforms(e).draw()}_setModelProps(e){Object.assign(this.props,e),"uniforms"in e&&this.setUniforms(e.uniforms),"pickable"in e&&(this.pickable=e.pickable),"instanceCount"in e&&(this.instanceCount=e.instanceCount),"geometry"in e&&this.setGeometry(e.geometry),"attributes"in e&&this.setAttributes(e.attributes),"_feedbackBuffers"in e&&this._setFeedbackBuffers(e._feedbackBuffers)}_checkProgram(){if(!(this._programDirty||this.programManager.stateHash!==this._programManagerState))return;let{program:e}=this.programProps;if(e)this._managedProgram=!1;else{const{vs:t,fs:i,modules:n,inject:r,defines:s,varyings:o,bufferMode:a,transpileToGLSL100:l}=this.programProps;e=this.programManager.get({vs:t,fs:i,modules:n,inject:r,defines:s,varyings:o,bufferMode:a,transpileToGLSL100:l}),this.program&&this._managedProgram&&this.programManager.release(this.program),this._programManagerState=this.programManager.stateHash,this._managedProgram=!0}rs(e instanceof wa,"Model needs a program"),this._programDirty=!1,e!==this.program&&(this.program=e,this.vertexArray?this.vertexArray.setProps({program:this.program,attributes:this.vertexArray.attributes}):this.vertexArray=new Pa(this.gl,{program:this.program}),this.setUniforms(Object.assign({},this.getModuleUniforms())))}_deleteGeometryBuffers(){for(const e in this.geometryBuffers){const t=this.geometryBuffers[e][0]||this.geometryBuffers[e];t instanceof Ss&&t.delete()}}_setAnimationProps(e){this.animated&&rs(e,"Model.draw(): animated uniforms but no animationProps")}_setFeedbackBuffers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(us(e))return this;const{gl:t}=this.program;return this.transformFeedback=this.transformFeedback||new Sa(t,{program:this.program}),this.transformFeedback.setBuffers(e),this}_logDrawCallStart(e){const t=e>3?0:1e4;if(!(Date.now()-this.lastLogTime<t))return this.lastLogTime=Date.now(),Qn.group(2,">>> DRAWING MODEL ".concat(this.id),{collapsed:Qn.level<=2})(),e}_logDrawCallEnd(e,t,i,n){if(void 0===e)return;const r=function(e){let{vertexArray:t,header:i="Attributes"}=e;if(!t.configuration)return{};const n={};t.elements&&(n.ELEMENT_ARRAY_BUFFER=Da(t,t.elements,null,i));const r=t.values;for(const e in r){const s=t._getAttributeInfo(e);if(s){let o="".concat(e,": ").concat(s.name);const a=t.accessors[s.location];a&&(o="".concat(e,": ").concat(Ba(s.name,a))),n[o]=Da(t,r[e],a,i)}}return n}({vertexArray:t,header:"".concat(this.id," attributes"),attributes:this._attributes}),{table:s,unusedTable:o,unusedCount:a}=Ra({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,i)}),{table:l,count:c}=Ra({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,i),undefinedOnly:!0});c>0&&Qn.log("MISSING UNIFORMS",Object.keys(l))(),a>0&&Qn.log("UNUSED UNIFORMS",Object.keys(o))();const u=function(e){const t={},i="Accessors for ".concat(e.id);for(const n of e.attributeInfos)if(n){const e=Fa(n);t["in ".concat(e)]={[i]:JSON.stringify(n.accessor)}}for(const n of e.varyingInfos)if(n){const e=Fa(n);t["out ".concat(e)]={[i]:JSON.stringify(n.accessor)}}return t}(this.vertexArray.configuration);Qn.table(e,r)(),Qn.table(e,s)(),Qn.table(e+1,u)(),n&&n.log({logLevel:2,message:"Rendered to ".concat(n.id)}),Qn.groupEnd(2)()}}class Bu{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=e,this.currentIndex=0,this.feedbackMap={},this.varyings=null,this.bindings=[],this.resources={},this._initialize(t),Object.seal(this)}setupResources(e){for(const t of this.bindings)this._setupTransformFeedback(t,e)}updateModelProps(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyings:t}=this;return t.length>0&&(e=Object.assign({},e,{varyings:t})),e}getDrawOptions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.bindings[this.currentIndex],{sourceBuffers:i,transformFeedback:n}=t;return{attributes:Object.assign({},i,e.attributes),transformFeedback:n}}swap(){return!!this.feedbackMap&&(this.currentIndex=this._getNextIndex(),!0)}update(){this._setupBuffers(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}getBuffer(e){const{feedbackBuffers:t}=this.bindings[this.currentIndex],i=e?t[e]:null;return i?i instanceof Ss?i:i.buffer:null}getData(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyingName:t}=e,i=this.getBuffer(t);return i?i.getData():null}delete(){for(const e in this.resources)this.resources[e].delete()}_initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(e),this.varyings=e.varyings||Object.keys(this.bindings[this.currentIndex].feedbackBuffers),this.varyings.length>0&&rs(ir(this.gl))}_getFeedbackBuffers(e){const{sourceBuffers:t={}}=e,i={};if(this.bindings[this.currentIndex]&&Object.assign(i,this.bindings[this.currentIndex].feedbackBuffers),this.feedbackMap)for(const e in this.feedbackMap){e in t&&(i[this.feedbackMap[e]]=e)}Object.assign(i,e.feedbackBuffers);for(const e in i){const n=i[e];if("string"==typeof n){const r=t[n],{byteLength:s,usage:o,accessor:a}=r;i[e]=this._createNewBuffer(e,{byteLength:s,usage:o,accessor:a})}}return i}_setupBuffers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:t=null}=e;Object.assign(this.feedbackMap,e.feedbackMap);const i=this._getFeedbackBuffers(e);this._updateBindings({sourceBuffers:t,feedbackBuffers:i})}_setupTransformFeedback(e,t){let{model:i}=t;const{program:n}=i;e.transformFeedback=new Sa(this.gl,{program:n,buffers:e.feedbackBuffers})}_updateBindings(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this.feedbackMap){const{sourceBuffers:e,feedbackBuffers:t}=this._swapBuffers(this.bindings[this.currentIndex]),i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceBuffers:e,feedbackBuffers:t})}}_updateBinding(e,t){return e?(Object.assign(e.sourceBuffers,t.sourceBuffers),Object.assign(e.feedbackBuffers,t.feedbackBuffers),e.transformFeedback&&e.transformFeedback.setBuffers(e.feedbackBuffers),e):{sourceBuffers:Object.assign({},t.sourceBuffers),feedbackBuffers:Object.assign({},t.feedbackBuffers)}}_swapBuffers(e){if(!this.feedbackMap)return null;const t=Object.assign({},e.sourceBuffers),i=Object.assign({},e.feedbackBuffers);for(const n in this.feedbackMap){const r=this.feedbackMap[n];t[n]=e.feedbackBuffers[r],i[r]=e.sourceBuffers[n],rs(i[r]instanceof Ss)}return{sourceBuffers:t,feedbackBuffers:i}}_createNewBuffer(e,t){const i=new Ss(this.gl,t);return this.resources[e]&&this.resources[e].delete(),this.resources[e]=i,i}_getNextIndex(){return(this.currentIndex+1)%2}}const Fu="transform_uSampler_",Nu="transform_uSize_",ku="transform_position";function zu(e){let{vs:t,sourceTextureMap:i,targetTextureVarying:n,targetTexture:r}=e;let s=Object.keys(i).length,o=null;const a={};let l=t,c={};if(s>0||n){const e=l.split("\n"),t=e.slice();if(e.forEach((e,r,l)=>{if(s>0){const n=function(e,t){const i={},n=function(e){return Ml(e,["attribute","in"])}(e);if(!n)return null;const{type:r,name:s}=n;if(s&&t[s]){const t="// ".concat(e," => Replaced by Transform with a sampler"),{samplerName:n,sizeName:o,uniformDeclerations:a}=function(e){const t="".concat(Fu).concat(e),i="".concat(Nu).concat(e),n="  uniform sampler2D ".concat(t,";\n  uniform vec2 ").concat(i,";");return{samplerName:t,sizeName:i,uniformDeclerations:n}}(s),l=function(e){switch(e){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:return ja(!1),null}}(r),c="  ".concat(r," ").concat(s," = transform_getInput(").concat(n,", ").concat(o,").").concat(l,";\n");i[n]=s;return{updatedLine:t,inject:{"vs:#decl":a,"vs:#main-start":c},samplerTextureMap:i}}return null}(e,i);if(n){const{updatedLine:e,inject:i}=n;t[r]=e,c=ll([c,i]),Object.assign(a,n.samplerTextureMap),s--}}n&&!o&&(o=function(e,t){const i=Ml(e,["varying","out"]);if(!i)return null;return i.name===t?i.type:null}(e,n))}),n){rs(r);const e="".concat(Nu).concat(n),t="uniform vec2 ".concat(e,";\n"),i="     vec2 ".concat(ku," = transform_getPos(").concat(e,");\n     gl_Position = vec4(").concat(ku,", 0, 1.);\n");c=ll([c,{"vs:#decl":t,"vs:#main-start":i}])}l=t.join("\n")}return{vs:l,targetTextureType:o,inject:c,samplerTextureMap:a}}const Uu={10241:9728,10240:9728,10242:33071,10243:33071};class Vu{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=e,this.id=this.currentIndex=0,this._swapTexture=null,this.targetTextureVarying=null,this.targetTextureType=null,this.samplerTextureMap=null,this.bindings=[],this.resources={},this._initialize(t),Object.seal(this)}updateModelProps(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this._processVertexShader(e);return Object.assign({},e,t)}getDrawOptions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:t,sourceTextures:i,framebuffer:n,targetTexture:r}=this.bindings[this.currentIndex],s=Object.assign({},t,e.attributes),o=Object.assign({},e.uniforms),a=Object.assign({},e.parameters);let l=e.discard;if(this.hasSourceTextures||this.hasTargetTexture){s.transform_elementID=this.elementIDBuffer;for(const e in this.samplerTextureMap){o[e]=i[this.samplerTextureMap[e]]}this._setSourceTextureParameters();const e=function(e){let{sourceTextureMap:t,targetTextureVarying:i,targetTexture:n}=e;const r={};let s,o;i&&(({width:s,height:o}=n),r["".concat(Nu).concat(i)]=[s,o]);for(const e in t)({width:s,height:o}=t[e]),r["".concat(Nu).concat(e)]=[s,o];return r}({sourceTextureMap:i,targetTextureVarying:this.targetTextureVarying,targetTexture:r});Object.assign(o,e)}return this.hasTargetTexture&&(l=!1,a.viewport=[0,0,n.width,n.height]),{attributes:s,framebuffer:n,uniforms:o,discard:l,parameters:a}}swap(){return!!this._swapTexture&&(this.currentIndex=this._getNextIndex(),!0)}update(){this._setupTextures(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}getTargetTexture(){const{targetTexture:e}=this.bindings[this.currentIndex];return e}getData(){let{packed:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{framebuffer:t}=this.bindings[this.currentIndex],i=Vs(t);if(!e)return i;const n=i.constructor,r=function(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return ja(!1),null}}(this.targetTextureType),s=new n(i.length*r/4);let o=0;for(let e=0;e<i.length;e+=4)for(let t=0;t<r;t++)s[o++]=i[e+t];return s}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}delete(){this.ownTexture&&this.ownTexture.delete(),this.elementIDBuffer&&this.elementIDBuffer.delete()}_initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{_targetTextureVarying:t,_swapTexture:i}=e;this._swapTexture=i,this.targetTextureVarying=t,this.hasTargetTexture=t,this._setupTextures(e)}_createTargetTexture(e){const{sourceTextures:t,textureOrReference:i}=e;if(i instanceof Ls)return i;const n=t[i];return n?(this._targetRefTexName=i,this._createNewTexture(n)):null}_setupTextures(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:t,_sourceTextures:i={},_targetTexture:n}=e,r=this._createTargetTexture({sourceTextures:i,textureOrReference:n});this.hasSourceTextures=this.hasSourceTextures||i&&Object.keys(i).length>0,this._updateBindings({sourceBuffers:t,sourceTextures:i,targetTexture:r}),"elementCount"in e&&this._updateElementIDBuffer(e.elementCount)}_updateElementIDBuffer(e){if("number"!=typeof e||this.elementCount>=e)return;const t=new Float32Array(e);t.forEach((e,t,i)=>{i[t]=t}),this.elementIDBuffer?this.elementIDBuffer.setData({data:t}):this.elementIDBuffer=new Ss(this.gl,{data:t,accessor:{size:1}}),this.elementCount=e}_updateBindings(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this._swapTexture){const{sourceTextures:e,targetTexture:t}=this._swapTextures(this.bindings[this.currentIndex]),i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceTextures:e,targetTexture:t})}}_updateBinding(e,t){const{sourceBuffers:i,sourceTextures:n,targetTexture:r}=t;if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,i),r){e.targetTexture=r;const{width:t,height:i}=r,{framebuffer:n}=e;n?(n.update({attachments:{36064:r},resizeAttachments:!1}),n.resize({width:t,height:i})):e.framebuffer=new yo(this.gl,{id:"transform-framebuffer",width:t,height:i,attachments:{36064:r}})}return e}_setSourceTextureParameters(){const e=this.currentIndex,{sourceTextures:t}=this.bindings[e];for(const e in t)t[e].setParameters(Uu)}_swapTextures(e){if(!this._swapTexture)return null;const t=Object.assign({},e.sourceTextures);t[this._swapTexture]=e.targetTexture;return{sourceTextures:t,targetTexture:e.sourceTextures[this._swapTexture]}}_createNewTexture(e){const t=function(e,t){rs(e instanceof Ls||e instanceof Os||e instanceof Ds);const i=e.constructor,{gl:n,width:r,height:s,format:o,type:a,dataFormat:l,border:c,mipmaps:u}=e;return new i(n,Object.assign({width:r,height:s,format:o,type:a,dataFormat:l,border:c,mipmaps:u},t))}(e,{parameters:{10241:9728,10240:9728,10242:33071,10243:33071},pixelStore:{37440:!1}});return this.ownTexture&&this.ownTexture.delete(),this.ownTexture=t,t}_getNextIndex(){return(this.currentIndex+1)%2}_processVertexShader(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceTextures:t,targetTexture:i}=this.bindings[this.currentIndex],{vs:n,uniforms:r,targetTextureType:s,inject:o,samplerTextureMap:a}=zu({vs:e.vs,sourceTextureMap:t,targetTextureVarying:this.targetTextureVarying,targetTexture:i}),l=ll([e.inject||{},o]);this.targetTextureType=s,this.samplerTextureMap=a;return{vs:n,fs:e._fs||Il({version:So(n),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),modules:this.hasSourceTextures||this.targetTextureVarying?[Mu].concat(e.modules||[]):e.modules,uniforms:r,inject:l}}}class ju{static isSupported(e){return ir(e)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=e,this.model=null,this.elementCount=0,this.bufferTransform=null,this.textureTransform=null,this.elementIDBuffer=null,this._initialize(t),Object.seal(this)}delete(){const{model:e,bufferTransform:t,textureTransform:i}=this;e&&e.delete(),t&&t.delete(),i&&i.delete()}run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{clearRenderTarget:t=!0}=e,i=this._updateDrawOptions(e);t&&i.framebuffer&&i.framebuffer.clear({color:!0}),this.model.transform(i)}swap(){let e=!1;const t=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of t)e=e||i.swap();rs(e,"Nothing to swap")}getBuffer(){return this.bufferTransform&&this.bufferTransform.getBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)}getData(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of t){const t=i.getData(e);if(t)return t}return null}getFramebuffer(){return this.textureTransform&&this.textureTransform.getFramebuffer()}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"elementCount"in e&&this.model.setVertexCount(e.elementCount);const t=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of t)i.update(e)}_initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{gl:t}=this;this._buildResourceTransforms(t,e),e=this._updateModelProps(e),this.model=new Du(t,Object.assign({},e,{fs:e.fs||Il({version:So(e.vs)}),id:e.id||"transform-model",drawMode:e.drawMode||0,vertexCount:e.elementCount})),this.bufferTransform&&this.bufferTransform.setupResources({model:this.model})}_updateModelProps(e){let t=Object.assign({},e);const i=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const e of i)t=e.updateModelProps(t);return t}_buildResourceTransforms(e,t){(function(e){if(!us(e.feedbackBuffers)||!us(e.feedbackMap)||e.varyings&&e.varyings.length>0)return!0;return!1})(t)&&(this.bufferTransform=new Bu(e,t)),function(e){if(!us(e._sourceTextures)||e._targetTexture||e._targetTextureVarying)return!0;return!1}(t)&&(this.textureTransform=new Vu(e,t)),rs(this.bufferTransform||this.textureTransform,"must provide source/feedback buffers or source/target textures")}_updateDrawOptions(e){let t=Object.assign({},e);const i=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const e of i)t=Object.assign(t,e.getDrawOptions(t));return t}}const Gu={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Hu{static get DRAW_MODE(){return Gu}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t=ls("geometry"),drawMode:i=Gu.TRIANGLES,attributes:n={},indices:r=null,vertexCount:s=null}=e;this.id=t,this.drawMode=0|i,this.attributes={},this.userData={},this._setAttributes(n,r),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}get mode(){return this.drawMode}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return"Geometry ".concat(this.id," attribute ").concat(e)}_setAttributes(e,t){t&&(this.indices=ArrayBuffer.isView(t)?{value:t,size:1}:t);for(const t in e){let i=e[t];i=ArrayBuffer.isView(i)?{value:i}:i,rs(ArrayBuffer.isView(i.value),"".concat(this._print(t),": must be typed array or object with value as typed array")),"POSITION"!==t&&"positions"!==t||i.size||(i.size=3),"indices"===t?(rs(!this.indices),this.indices=i):this.attributes[t]=i}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(const t in e){const n=e[t],{value:r,size:s,constant:o}=n;!o&&r&&s>=1&&(i=Math.min(i,r.length/s))}return rs(Number.isFinite(i)),i}}let Wu=1,qu=1;class Xu{constructor(){this.time=0,this.channels=new Map,this.animations=new Map,this.playing=!1,this.lastEngineTime=-1}addChannel(e){const{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=e,s=Wu++,o={time:0,delay:t,duration:i,rate:n,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(s,o),s}removeChannel(e){this.channels.delete(e);for(const[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const i=this.animations.values();for(const e of i){const{animation:t,channel:i}=e;t.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const i=qu++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const i=t-e.delay;i>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}const $u=[255,255,255],Zu=1;let Yu=0,Ju=class{constructor(e={}){bt(this,"id",void 0),bt(this,"color",void 0),bt(this,"intensity",void 0),bt(this,"type","ambient");const{color:t=$u}=e,{intensity:i=Zu}=e;this.id=e.id||"ambient-".concat(Yu++),this.color=t,this.intensity=i}};const Ku=[255,255,255],Qu=1,eh=[0,0,-1];let th=0,ih=class{constructor(e={}){bt(this,"id",void 0),bt(this,"color",void 0),bt(this,"intensity",void 0),bt(this,"type","directional"),bt(this,"direction",void 0),bt(this,"shadow",void 0);const{color:t=Ku}=e,{intensity:i=Qu}=e,{direction:n=eh}=e,{_shadow:r=!1}=e;this.id=e.id||"directional-".concat(th++),this.color=t,this.intensity=i,this.type="directional",this.direction=new gc(n).normalize().toArray(),this.shadow=r}getProjectedLight(e){return this}};class nh{constructor(e,t={id:"pass"}){bt(this,"id",void 0),bt(this,"gl",void 0),bt(this,"props",void 0);const{id:i}=t;this.id=i,this.gl=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}class rh extends nh{constructor(...e){super(...e),bt(this,"_lastRenderIndex",-1)}render(e){return Hr(this.gl,{framebuffer:e.target}),this._drawLayers(e)}_drawLayers(e){const{target:t,moduleParameters:i,viewports:n,views:r,onViewportActive:s,clearStack:o=!0,clearCanvas:a=!0}=e;e.pass=e.pass||"unknown";const l=this.gl;a&&function(e,t){const i=t?t.width:e.drawingBufferWidth,n=t?t.height:e.drawingBufferHeight;Hr(e,{viewport:[0,0,i,n]}),e.clear(16640)}(l,t),o&&(this._lastRenderIndex=-1);const c=[];for(const o of n){const n=r&&r[o.id];null==s||s(o);const a=this._getDrawLayerParams(o,e),u=o.subViewports||[o];for(const r of u){const s=this._drawLayersInViewport(l,{target:t,moduleParameters:i,viewport:r,view:n,pass:e.pass,layers:e.layers},a);c.push(s)}}return c}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:n=!1,layerFilter:r,cullRect:s,effects:o,moduleParameters:a},l=!1){const c=[],u=sh(this._lastRenderIndex+1),h={layer:t[0],viewport:e,isPicking:n,renderPass:i,cullRect:s},d={};for(let n=0;n<t.length;n++){const s=t[n],p=this._shouldDrawLayer(s,h,r,d),f={shouldDrawLayer:p};p&&!l&&(f.layerRenderIndex=u(s,p),f.moduleParameters=this._getModuleParameters(s,o,i,a),f.layerParameters=this.getLayerParameters(s,n,e)),c[n]=f}return c}_drawLayersInViewport(e,{layers:t,moduleParameters:i,pass:n,target:r,viewport:s,view:o},a){const l=function(e,{moduleParameters:t,target:i,viewport:n}){const r=i&&"default-framebuffer"!==i.id,s=t&&t.devicePixelRatio||qr(e),o=r?i.height:e.drawingBufferHeight,a=n;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}(e,{moduleParameters:i,target:r,viewport:s});if(o&&o.props.clear){const t=!0===o.props.clear?{color:!0,depth:!0}:o.props.clear;Wr(e,{scissorTest:!0,scissor:l},()=>Us(e,t))}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};Hr(e,{viewport:l});for(let e=0;e<t.length;e++){const i=t[e],{shouldDrawLayer:r,layerRenderIndex:o,moduleParameters:l,layerParameters:u}=a[e];if(r&&i.props.pickable&&c.pickableCount++,i.isComposite)c.compositeCount++;else if(r){c.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,o),l.viewport=s;try{i._drawLayer({moduleParameters:l,uniforms:{layerIndex:o},parameters:u})}catch(e){i.raiseError(e,"drawing ".concat(i," to ").concat(n))}}}return c}shouldDrawLayer(e){return!0}getModuleParameters(e,t){return null}getLayerParameters(e,t,i){return e.props.parameters}_shouldDrawLayer(e,t,i,n){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let r=e.parent;for(;r;){if(!r.props.visible||!r.filterSubLayer(t))return!1;t.layer=r,r=r.parent}if(i){const e=t.layer.id;if(e in n||(n[e]=i(t)),!n[e])return!1}return e.activateViewport(t.viewport),!0}_getModuleParameters(e,t,i,n){var r;const s=Object.assign(Object.create((null===(r=e.internalState)||void 0===r?void 0:r.propsInTransition)||e.props),{autoWrapLongitude:e.wrapLongitude,viewport:e.context.viewport,mousePosition:e.context.mousePosition,pickingActive:0,devicePixelRatio:qr(this.gl)});if(t)for(const i of t){var o;Object.assign(s,null===(o=i.getModuleParameters)||void 0===o?void 0:o.call(i,e))}return Object.assign(s,this.getModuleParameters(e,t),n)}}function sh(e=0,t={}){const i={},n=(r,s)=>{const o=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in t)&&n(r.parent,!1),l in i){const e=i[l]=i[l]||sh(t[l],t);c=e(r,s),i[a]=e}else Number.isFinite(o)?(c=o+(t[l]||0),i[a]=null):c=e;return s&&c>=e&&(e=c+1),t[a]=c,c};return n}class oh extends rh{constructor(e,t){super(e,t),bt(this,"shadowMap",void 0),bt(this,"depthBuffer",void 0),bt(this,"fbo",void 0),this.shadowMap=new Ls(e,{width:1,height:1,parameters:{10241:9729,10240:9729,10242:33071,10243:33071}}),this.depthBuffer=new Ns(e,{format:33189,width:1,height:1}),this.fbo=new yo(e,{id:"shadowmap",width:1,height:1,attachments:{36064:this.shadowMap,36096:this.depthBuffer}})}render(e){const t=this.fbo;Wr(this.gl,{depthRange:[0,1],depthTest:!0,blend:!1,clearColor:[1,1,1,1]},()=>{const i=e.viewports[0],n=qr(this.gl),r=i.width*n,s=i.height*n;r===t.width&&s===t.height||t.resize({width:r,height:s}),super.render({...e,target:t,pass:"shadow"})})}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.delete(),this.fbo=null),this.shadowMap&&(this.shadowMap.delete(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.delete(),this.depthBuffer=null)}}const ah="#define SMOOTH_EDGE_RADIUS 0.5";var lh={name:"geometry",vs:"\n".concat(ah,"\n\nstruct VertexGeometry {\n  vec4 position;\n  vec3 worldPosition;\n  vec3 worldPositionAlt;\n  vec3 normal;\n  vec2 uv;\n  vec3 pickingColor;\n} geometry = VertexGeometry(\n  vec4(0.0, 0.0, 1.0, 0.0),\n  vec3(0.0),\n  vec3(0.0),\n  vec3(0.0),\n  vec2(0.0),\n  vec3(0.0)\n);\n"),fs:"\n".concat(ah,"\n\nstruct FragmentGeometry {\n  vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n  return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n")};const ch=Object.keys(Zn).map(e=>"const int COORDINATE_SYSTEM_".concat(e," = ").concat(Zn[e],";")).join(""),uh=Object.keys(Yn).map(e=>"const int PROJECTION_MODE_".concat(e," = ").concat(Yn[e],";")).join(""),hh=Object.keys(Jn).map(e=>"const int UNIT_".concat(e.toUpperCase()," = ").concat(Jn[e],";")).join("");var dh="".concat(ch,"\n").concat(uh,"\n").concat(hh,"\n\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\n\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\n  float y = clamp(lat, -89.9, 89.9);\n  return 1.0 / cos(radians(y));\n}\n\nfloat project_size() {\n  if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n    project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n    project_uPseudoMeters == false) {\n    \n    if (geometry.position.w == 0.0) {\n      return project_size_at_latitude(geometry.worldPosition.y);\n    }\n  \n    float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n    float y2 = y * y;\n    float y4 = y2 * y2;\n    float y6 = y4 * y2;\n    return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n  }\n  return 1.0;\n}\n\nfloat project_size_at_latitude(float meters, float lat) {\n  return meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\n  return meters * project_uCommonUnitsPerMeter.z * project_size();\n}\n\nvec2 project_size(vec2 meters) {\n  return meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\n\nvec3 project_size(vec3 meters) {\n  return meters * project_uCommonUnitsPerMeter * project_size();\n}\n\nvec4 project_size(vec4 meters) {\n  return vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\n  vec3 uz = normalize(up);\n  vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\n  vec3 uy = cross(uz, ux);\n  return mat3(ux, uy, uz);\n}\n\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\n  if (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\n    transform = project_get_orientation_matrix(commonPosition);\n    return true;\n  }\n  return false;\n}\nvec3 project_normal(vec3 vector) {\n  vec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\n  vec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\n  mat3 rotation;\n  if (project_needs_rotation(geometry.position.xyz, rotation)) {\n    n = rotation * n;\n  }\n  return n;\n}\n\nvec4 project_offset_(vec4 offset) {\n  float dy = offset.y;\n  vec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\n  return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\n  float x = lnglat.x;\n  if (project_uWrapLongitude) {\n    x = mod(x + 180., 360.0) - 180.;\n  }\n  float y = clamp(lnglat.y, -89.9, 89.9);\n  return vec2(\n    radians(x) + PI,\n    PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n  ) * WORLD_SCALE;\n}\n\nvec3 project_globe_(vec3 lnglatz) {\n  float lambda = radians(lnglatz.x);\n  float phi = radians(lnglatz.y);\n  float cosPhi = cos(phi);\n  float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n\n  return vec3(\n    sin(lambda) * cosPhi,\n    -cos(lambda) * cosPhi,\n    sin(phi)\n  ) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\n  vec4 position_world = project_uModelMatrix * position;\n  if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n    if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n      return vec4(\n        project_mercator_(position_world.xy),\n        project_size_at_latitude(position_world.z, position_world.y),\n        position_world.w\n      );\n    }\n    if (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n      position_world.xyz += project_uCoordinateOrigin;\n    }\n  }\n  if (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\n    if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n      return vec4(\n        project_globe_(position_world.xyz),\n        position_world.w\n      );\n    }\n  }\n  if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n    if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n      if (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\n        return vec4(\n          project_mercator_(position_world.xy) - project_uCommonOrigin.xy,\n          project_size(position_world.z),\n          position_world.w\n        );\n      }\n    }\n  }\n  if (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n    (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n    (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n     project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n    position_world.xyz -= project_uCoordinateOrigin;\n  }\n  return project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0));\n}\n\nvec4 project_position(vec4 position) {\n  return project_position(position, ZERO_64_LOW);\n}\n\nvec3 project_position(vec3 position, vec3 position64Low) {\n  vec4 projected_position = project_position(vec4(position, 1.0), position64Low);\n  return projected_position.xyz;\n}\n\nvec3 project_position(vec3 position) {\n  vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\n  return projected_position.xyz;\n}\n\nvec2 project_position(vec2 position) {\n  vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\n  return projected_position.xy;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n  return viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\n  return project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n  vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\n  return offset * project_uFocalDistance;\n}\n\nfloat project_size_to_pixel(float meters) {\n  return project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\n  if (unit == UNIT_METERS) return project_size_to_pixel(size);\n  if (unit == UNIT_COMMON) return size * project_uScale;\n  return size;\n}\nfloat project_pixel_size(float pixels) {\n  return pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\n  return pixels / project_uScale;\n}\n");function ph(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let n=0;n<i;n++)if(e[n]!==t[n])return!1;return!0}return!1}function fh(e){let t,i={};return n=>{for(const r in n)if(!ph(n[r],i[r])){t=e(n),i=n;break}return t}}const mh=[0,0,0,0],gh=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],_h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],yh=[0,0,0],vh=[0,0,0],xh=fh(function({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,i){const{viewMatrixUncentered:n,projectionMatrix:r}=e;let{viewMatrix:s,viewProjectionMatrix:o}=e,a=mh,l=mh,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=bh(e,t,i);d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=Fc([],l,o),s=n||s,o=Mc([],r,s),o=Mc([],o,gh));return{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,i,n),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=Fc([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={project_uCoordinateSystem:i,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:o.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:t,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:yh,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:s,project_uModelMatrix:_h,project_uCameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(i){case Zn.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=t.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case Zn.LNGLAT:case Zn.LNGLAT_OFFSETS:e._pseudoMeters||(p.project_uCommonUnitsPerMeter=t.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=t.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case Zn.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return p});function bh(e,t,i=vh){i.length<3&&(i=[i[0],i[1],0]);let n,r=i,s=!0;switch(n=t===Zn.LNGLAT_OFFSETS||t===Zn.METER_OFFSETS?i:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case Yn.WEB_MERCATOR:t!==Zn.LNGLAT&&t!==Zn.CARTESIAN||(n=[0,0,0],s=!1);break;case Yn.WEB_MERCATOR_AUTO_OFFSET:t===Zn.LNGLAT?r=n:t===Zn.CARTESIAN&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],n=e.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case Yn.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case Yn.GLOBE:s=!1,n=null;break;default:s=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:r,offsetMode:s}}const wh={};var Th={name:"project",dependencies:[Cl,lh],vs:dh,getUniforms:function(e=wh){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:i=null,coordinateSystem:n=Zn.DEFAULT,coordinateOrigin:r=vh,autoWrapLongitude:s=!1}){n===Zn.DEFAULT&&(n=e.isGeospatial?Zn.LNGLAT:Zn.CARTESIAN);const o=xh({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r});return o.project_uWrapLongitude=s,o.project_uModelMatrix=i||_h,o}(e):{}}};function Sh(e,t){const i=Fc([],t,e);return Bc(i,i,1/i[3]),i}function Eh(e,t){const i=e%t;return i<0?t+i:i}function Ah(e,t,i){return e<t?t:e>i?i:e}const Mh=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Ih(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Ch=Math.PI,Ph=Ch/4,Lh=Ch/180,Rh=180/Ch,Oh=512,Dh=4003e4,Bh=85.051129,Fh=1.5;function Nh(e){const[t,i]=e;Ih(Number.isFinite(t)),Ih(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");return[Oh*(t*Lh+Ch)/(2*Ch),Oh*(Ch+Math.log(Math.tan(Ph+.5*(i*Lh))))/(2*Ch)]}function kh(e){const[t,i]=e,n=t/Oh*(2*Ch)-Ch,r=2*(Math.atan(Math.exp(i/Oh*(2*Ch)-Ch))-Ph);return[n*Rh,r*Rh]}function zh(e){const{latitude:t}=e;Ih(Number.isFinite(t));const i=Math.cos(t*Lh);return function(e){return Mh(e)}(Dh*i)-9}function Uh(e){return 12790407194604047e-21/Math.cos(e*Lh)}function Vh(e){const{latitude:t,longitude:i,highPrecision:n=!1}=e;Ih(Number.isFinite(t)&&Number.isFinite(i));const r=Oh,s=Math.cos(t*Lh),o=r/360,a=o/s,l=12790407194604047e-21/s,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[o,a,l],degreesPerUnit:[.703125,1/a,1/l]};if(n){const e=Lh*Math.tan(t*Lh)/s,i=12790407194604047e-21*e,n=i/a*l;c.unitsPerDegree2=[0,o*e/2,i],c.unitsPerMeter2=[n,0,n]}return c}function jh(e,t){const[i,n,r]=e,[s,o,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=Vh({longitude:i,latitude:n,highPrecision:!0}),u=Nh(e);u[0]+=s*(l[0]+c[0]*o),u[1]+=o*(l[1]+c[1]*o);const h=kh(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function Gh(e){return 2*Math.atan(.5/e)*Rh}function Hh(e){return.5/Math.tan(.5*e*Lh)}function Wh(e,t){const[i,n,r=0]=e;return Ih(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)),Sh(t,[i,n,r,1])}function qh(e,t,i=0){const[n,r,s]=e;if(Ih(Number.isFinite(n)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s)){return Sh(t,[n,r,s,1])}const o=Sh(t,[n,r,0,1]),a=Sh(t,[n,r,1,1]),l=o[2],c=a[2];return Yl([],o,a,l===c?0:((i||0)-l)/(c-l))}function Xh(e){const{width:t,height:i,bounds:n,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=e,[[a,l],[c,u]]=n,h=function(e=0){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return Ih(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e}(e.padding),d=Nh([a,Ah(u,-85.051129,Bh)]),p=Nh([c,Ah(l,-85.051129,Bh)]),f=[Math.max(Math.abs(p[0]-d[0]),r),Math.max(Math.abs(p[1]-d[1]),r)],m=[t-h.left-h.right-2*Math.abs(o[0]),i-h.top-h.bottom-2*Math.abs(o[1])];Ih(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],y=kh([(p[0]+d[0])/2+(h.right-h.left)/2/g,(p[1]+d[1])/2+(h.top-h.bottom)/2/_]),v=Math.min(s,Mh(Math.abs(Math.min(g,_))));return Ih(Number.isFinite(v)),{longitude:y[0],latitude:y[1],zoom:v}}const $h=Math.PI/180;function Zh(e,t,i){const{pixelUnprojectionMatrix:n}=e,r=Sh(n,[t,0,1,1]),s=Sh(n,[t,e.height,1,1]),o=kh(Yl([],r,s,(i*e.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2])));return o.push(i),o}const Yh=fh(function({viewport:e,center:t}){return new Hc(e.viewProjectionMatrix).invert().transform(t)}),Jh=fh(function({viewport:e,shadowMatrices:t}){const i=[],n=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,s=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[i,n,r]=e,s=qh([i,n,r],t);if(Number.isFinite(r))return s;return[s[0],s[1],0]}(e,n));for(const n of t){const t=n.clone().translate(new gc(e.center).negate()),r=s.map(e=>t.transform(e)),o=(new Hc).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});i.push(o.multiplyRight(n))}return i}),Kh=[0,0,0,1],Qh=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var ed={name:"shadow",dependencies:[Th],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nvarying vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n  if (shadow_uDrawShadowMap) {\n    return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n  }\n  if (shadow_uUseShadowMap) {\n    for (int i = 0; i < max_lights; i++) {\n      if(i < int(shadow_uLightCount)) {\n        vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n        shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n      }\n    }\n  }\n  return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nvarying vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0,  0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n  vec4 rgbaDepth = texture2D(shadowMap, position.xy);\n\n  float z = dot(rgbaDepth, bitUnpackShift);\n  return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n  if (shadow_uDrawShadowMap) {\n    vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n    rgbaDepth -= rgbaDepth.gbaa * bitMask;\n    return rgbaDepth;\n  }\n  if (shadow_uUseShadowMap) {\n    float shadowAlpha = 0.0;\n    shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n    if(shadow_uLightCount > 1.0) {\n      shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n    }\n    shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n    float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n    return vec4(\n      mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n      blendedAlpha\n    );\n  }\n  return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n    position = shadow_setVertexPosition(geometry.position);\n    ","fs:DECKGL_FILTER_COLOR":"\n    color = shadow_filterShadowColor(color);\n    "},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?function(e,t){const{shadowEnabled:i=!0}=e;if(!i||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1};const n={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,shadow_uColor:e.shadowColor||Kh,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},r=Yh({viewport:e.viewport,center:t.project_uCenter}),s=[],o=Jh({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let i=0;i<e.shadowMatrices.length;i++){const n=o[i],a=n.clone().translate(new gc(e.viewport.center).negate());t.project_uCoordinateSystem===Zn.LNGLAT&&t.project_uProjectionMode===Yn.WEB_MERCATOR?(o[i]=a,s[i]=r):(o[i]=n.clone().multiplyRight(Qh),s[i]=a.transform(r))}for(let t=0;t<o.length;t++)n["shadow_uViewProjectionMatrices[".concat(t,"]")]=o[t],n["shadow_uProjectCenters[".concat(t,"]")]=s[t],n["shadow_uShadowMap".concat(t)]=e.shadowMaps&&e.shadowMaps.length>0?e.shadowMaps[t]:e.dummyShadowMap;return n}(e,t):{}};const td={color:[255,255,255],intensity:1},id=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],nd=[0,0,0,200/255];class rd{constructor(e={}){bt(this,"id","lighting-effect"),bt(this,"props",void 0),bt(this,"shadowColor",nd),bt(this,"shadow",void 0),bt(this,"ambientLight",void 0),bt(this,"directionalLights",void 0),bt(this,"pointLights",void 0),bt(this,"shadowPasses",[]),bt(this,"shadowMaps",[]),bt(this,"dummyShadowMap",null),bt(this,"programManager",void 0),bt(this,"shadowMatrices",void 0),this.setProps(e)}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const t in e){const i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.props=e}preRender(e,{layers:t,layerFilter:i,viewports:n,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices(),0===this.shadowPasses.length&&this._createShadowPasses(e),this.programManager||(this.programManager=Iu.getDefaultProgramManager(e),ed&&this.programManager.addDefaultModule(ed)),this.dummyShadowMap||(this.dummyShadowMap=new Ls(e,{width:1,height:1}));for(let e=0;e<this.shadowPasses.length;e++){this.shadowPasses[e].render({layers:t,layerFilter:i,viewports:n,onViewportActive:r,views:s,moduleParameters:{shadowLightId:e,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}})}}}getModuleParameters(e){const t=this.shadow?{shadowMaps:this.shadowMaps,dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{};return t.lightSources={ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(t=>t.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},t}cleanup(){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.delete(),this.dummyShadowMap=null),this.shadow&&this.programManager&&(this.programManager.removeDefaultModule(ed),this.programManager=null)}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const i=(new Hc).lookAt({eye:new gc(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){const i=new oh(e);this.shadowPasses[t]=i,this.shadowMaps[t]=i.shadowMap}}_applyDefaultLights(){const{ambientLight:e,pointLights:t,directionalLights:i}=this;e||0!==t.length||0!==i.length||(this.ambientLight=new Ju(td),this.directionalLights.push(new ih(id[0]),new ih(id[1])))}}var sd=new class{constructor(e={}){bt(this,"_pool",[]),bt(this,"opts",{overAlloc:2,poolSize:100}),this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:i=1,type:n,padding:r=0,copy:s=!1,initialize:o=!1,maxCount:a}){const l=n||e&&e.constructor||Float32Array,c=t*i+r;if(ArrayBuffer.isView(e)){if(c<=e.length)return e;if(c*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,c)}let u=1/0;a&&(u=a*i+r);const h=this._allocate(l,c,o,u);return e&&s?h.set(e):o||h.fill(0,0,4),this._release(e),h}release(e){this._release(e)}_allocate(e,t,i,n){let r=Math.max(Math.ceil(t*this.opts.overAlloc),1);r>n&&(r=n);const s=this._pool,o=e.BYTES_PER_ELEMENT*r,a=s.findIndex(e=>e.byteLength>=o);if(a>=0){const t=new e(s.splice(a,1)[0],0,r);return i&&t.fill(0),t}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:i}=e,{byteLength:n}=i,r=t.findIndex(e=>e.byteLength>=n);r<0?t.push(i):(r>0||t.length<this.opts.poolSize)&&t.splice(r,0,i),t.length>this.opts.poolSize&&t.shift()}};const od=new gc;function ad(e,t,i,n){od.set(e,t,i);const r=od.len();return{distance:n/r,normal:new gc(-e/r,-t/r,-i/r)}}function ld(e){return e-Math.fround(e)}let cd;function ud(e,t){const{size:i=1,startIndex:n=0}=t,r=void 0!==t.endIndex?t.endIndex:e.length,s=(r-n)/i;cd=sd.allocate(cd,s,{type:Float32Array,size:2*i});let o=n,a=0;for(;o<r;){for(let t=0;t<i;t++){const n=e[o++];cd[a+t]=n,cd[a+t+i]=ld(n)}a+=2*i}return cd.subarray(0,s*i*2)}function hd(e){let t=null,i=!1;for(const n of e)n&&(t?(i||(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],i=!0),t[0][0]=Math.min(t[0][0],n[0][0]),t[0][1]=Math.min(t[0][1],n[0][1]),t[1][0]=Math.max(t[1][0],n[1][0]),t[1][1]=Math.max(t[1][1],n[1][1])):t=n);return t}const dd=Math.PI/180,pd=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],fd=[0,0,0],md={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};class gd{constructor(e={}){bt(this,"id",void 0),bt(this,"x",void 0),bt(this,"y",void 0),bt(this,"width",void 0),bt(this,"height",void 0),bt(this,"padding",void 0),bt(this,"isGeospatial",void 0),bt(this,"zoom",void 0),bt(this,"focalDistance",void 0),bt(this,"position",void 0),bt(this,"modelMatrix",void 0),bt(this,"distanceScales",void 0),bt(this,"scale",void 0),bt(this,"center",void 0),bt(this,"cameraPosition",void 0),bt(this,"projectionMatrix",void 0),bt(this,"viewMatrix",void 0),bt(this,"viewMatrixUncentered",void 0),bt(this,"viewMatrixInverse",void 0),bt(this,"viewProjectionMatrix",void 0),bt(this,"pixelProjectionMatrix",void 0),bt(this,"pixelUnprojectionMatrix",void 0),bt(this,"resolution",void 0),bt(this,"_frustumPlanes",{}),this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||md,this.focalDistance=e.focalDistance||1,this.position=e.position||fd,this.modelMatrix=e.modelMatrix||null;const{longitude:t,latitude:i}=e;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Yn.WEB_MERCATOR:Yn.WEB_MERCATOR_AUTO_OFFSET:Yn.IDENTITY}equals(e){return e instanceof gd&&(this===e||e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Vl(e.projectionMatrix,this.projectionMatrix)&&Vl(e.viewMatrix,this.viewMatrix))}project(e,{topLeft:t=!0}={}){const i=Wh(this.projectPosition(e),this.pixelProjectionMatrix),[n,r]=i,s=t?r:this.height-r;return 2===e.length?[n,s]:[n,s,i[2]]}unproject(e,{topLeft:t=!0,targetZ:i}={}){const[n,r,s]=e,o=qh([n,t?r:this.height-r,s],this.pixelUnprojectionMatrix,i&&i*this.distanceScales.unitsPerMeter[2]),[a,l,c]=this.unprojectPosition(o);return Number.isFinite(s)?[a,l,c]:Number.isFinite(i)?[a,l,i]:[a,l]}projectPosition(e){const[t,i]=this.projectFlat(e);return[t,i,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){const[t,i]=this.unprojectFlat(e);return[t,i,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){const t=Nh(e);return t[1]=zl(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?kh(e):e}getBounds(e={}){const t={targetZ:e.z||0},i=this.unproject([0,0],t),n=this.unproject([this.width,0],t),r=this.unproject([0,this.height],t),s=this.unproject([this.width,this.height],t);return[Math.min(i[0],n[0],r[0],s[0]),Math.min(i[1],n[1],r[1],s[1]),Math.max(i[0],n[0],r[0],s[0]),Math.max(i[1],n[1],r[1],s[1])]}getDistanceScales(e){return e?Vh({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:i=1,height:n=1}){return e<this.x+this.width&&this.x<e+i&&t<this.y+this.height&&this.y<t+n}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,{left:ad((e=this.viewProjectionMatrix)[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:ad(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:ad(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:ad(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:ad(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:ad(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}),this._frustumPlanes;var e}panByPosition(e,t){return null}_initProps(e){const t=e.longitude,i=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=zh({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Vh({latitude:i,longitude:t}));const n=Math.pow(2,this.zoom);this.scale=n;const{position:r,modelMatrix:s}=e;let o=fd;if(r&&(o=s?new Hc(s).transformAsVector(r,[]):r),this.isGeospatial){const e=this.projectPosition([t,i,0]);this.center=new gc(o).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(o)}_initMatrices(e){const{viewMatrix:t=pd,projectionMatrix:i=null,orthographic:n=!1,fovyRadians:r,fovy:s=75,near:o=.1,far:a=1e3,padding:l=null,focalDistance:c=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=(new Hc).multiplyRight(t).translate(new gc(this.center).negate()),this.projectionMatrix=i||function({width:e,height:t,orthographic:i,fovyRadians:n,focalDistance:r,padding:s,near:o,far:a}){const l=e/t,c=i?(new Hc).orthographic({fovy:n,aspect:l,focalDistance:r,near:o,far:a}):(new Hc).perspective({fovy:n,aspect:l,near:o,far:a});if(s){const{left:i=0,right:n=0,top:r=0,bottom:o=0}=s,a=zl((i+e-n)/2,0,e)-e/2,l=zl((r+t-o)/2,0,t)-t/2;c[8]-=2*a/e,c[9]+=2*l/t}return c}({width:this.width,height:this.height,orthographic:n,fovyRadians:r||s*dd,focalDistance:c,padding:l,near:o,far:a});const u=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var h;Mc(u,u,this.projectionMatrix),Mc(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=Ac([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=[(h=this.viewMatrixInverse)[12],h[13],h[14]];const d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],p=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];Cc(d,d,[this.width/2,-this.height/2,1]),Ic(d,d,[1,-1,0]),Mc(p,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=p,this.pixelUnprojectionMatrix=Ac([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||Gn.warn("Pixel project matrix not invertible")()}}bt(gd,"displayName","Viewport");class _d extends gd{constructor(e={}){const{latitude:t=0,longitude:i=0,zoom:n=0,pitch:r=0,bearing:s=0,nearZMultiplier:o=.1,farZMultiplier:a=1.01,nearZ:l,farZ:c,orthographic:u=!1,projectionMatrix:h,repeat:d=!1,worldOffset:p=0,position:f,padding:m,legacyMeterSizes:g=!1}=e;let{width:_,height:y,altitude:v=1.5}=e;const x=Math.pow(2,n);let b;_=_||1,y=y||1;let w=null;if(h)v=h[5]/2,b=Gh(v);else{let i;if(e.fovy?(b=e.fovy,v=Hh(b)):b=Gh(v),m){const{top:e=0,bottom:t=0}=m;i=[0,zl((e+y-t)/2,0,y)-y/2]}w=function(e){const{width:t,height:i,altitude:n,pitch:r=0,center:s,scale:o,nearZMultiplier:a=1,unitsPerMeter:l}=e;let{fovy:c=Gh(Fh)}=e;void 0!==n&&(c=Gh(n));const u=c*Lh,h=r*Lh,d=Hh(c);let p=d;return s&&(p+=s[2]*o/Math.cos(h)/i),{fov:u,aspect:t/i,focalDistance:d,near:a,far:Math.max(10*p,p+1e3*l/Math.cos(h))}}({width:_,height:y,scale:x,center:f&&[0,0,f[2]*Uh(t)],offset:i,pitch:r,fovy:b,nearZMultiplier:o,unitsPerMeter:x*Uh(t)/y}),Number.isFinite(l)&&(w.near=l),Number.isFinite(c)&&(w.far=c)}let T=function(e){const{height:t,pitch:i,bearing:n,altitude:r,scale:s,center:o}=e,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];Ic(a,a,[0,0,-r]),Pc(a,a,-i*Lh),Lc(a,a,n*Lh);const l=s/t;return Cc(a,a,[l,l,l]),o&&Ic(a,a,function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}([],o)),a}({height:y,pitch:r,bearing:s,scale:x,altitude:v});if(p){T=(new Hc).translate([512*p,0,0]).multiplyLeft(T)}super({...e,width:_,height:y,viewMatrix:T,longitude:i,latitude:t,zoom:n,...w,fovy:b,focalDistance:v}),bt(this,"longitude",void 0),bt(this,"latitude",void 0),bt(this,"pitch",void 0),bt(this,"bearing",void 0),bt(this,"altitude",void 0),bt(this,"fovy",void 0),bt(this,"orthographic",void 0),bt(this,"_subViewports",void 0),bt(this,"_pseudoMeters",void 0),this.latitude=t,this.longitude=i,this.zoom=n,this.pitch=r,this.bearing=s,this.altitude=v,this.fovy=b,this.orthographic=u,this._subViewports=d?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const e=this.getBounds(),t=Math.floor((e[0]+180)/360),i=Math.ceil((e[2]-180)/360);for(let e=t;e<=i;e++){const t=e?new _d({...this,worldOffset:e}):this;this._subViewports.push(t)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);const[t,i]=this.projectFlat(e);return[t,i,(e[2]||0)*Uh(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);const[t,i]=this.unprojectFlat(e);return[t,i,(e[2]||0)/Uh(i)]}addMetersToLngLat(e,t){return jh(e,t)}panByPosition(e,t){const i=qh(t,this.pixelUnprojectionMatrix),n=Zl([],this.projectFlat(e),function(e,t){return e[0]=-t[0],e[1]=-t[1],e}([],i)),r=Zl([],this.center,n),[s,o]=this.unprojectFlat(r);return{longitude:s,latitude:o}}getBounds(e={}){const t=function(e,t=0){const{width:i,height:n,unproject:r}=e,s={targetZ:t},o=r([0,n],s),a=r([i,n],s);let l,c;return(e.fovy?.5*e.fovy*$h:Math.atan(.5/e.altitude))>(90-e.pitch)*$h-.01?(l=Zh(e,0,t),c=Zh(e,i,t)):(l=r([0,0],s),c=r([i,0],s)),[o,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:i,height:n}=this,{longitude:r,latitude:s,zoom:o}=Xh({width:i,height:n,bounds:e,...t});return new _d({width:i,height:n,longitude:r,latitude:s,zoom:o})}}bt(_d,"displayName","WebMercatorViewport");const yd=[0,0,0];function vd(e,t,i=!1){const n=t.projectPosition(e);if(i&&t instanceof _d){const[i,r,s=0]=e,o=t.getDistanceScales([i,r]);n[2]=s*o.unitsPerMeter[2]}return n}function xd(e,{viewport:t,modelMatrix:i,coordinateSystem:n,coordinateOrigin:r,offsetMode:s}){let[o,a,l=0]=e;switch(i&&([o,a,l]=Fc([],[o,a,l,1],i)),n){case Zn.LNGLAT:return vd([o,a,l],t,s);case Zn.LNGLAT_OFFSETS:return vd([o+r[0],a+r[1],l+(r[2]||0)],t,s);case Zn.METER_OFFSETS:return vd(jh(r,[o,a,l]),t,s);default:return t.isGeospatial?[o+r[0],a+r[1],l+r[2]]:t.projectPosition([o,a,l])}}function bd(e,t){const{viewport:i,coordinateSystem:n,coordinateOrigin:r,modelMatrix:s,fromCoordinateSystem:o,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:i,coordinateOrigin:n}=e;let{coordinateSystem:r,fromCoordinateSystem:s,fromCoordinateOrigin:o}=e;return r===Zn.DEFAULT&&(r=t.isGeospatial?Zn.LNGLAT:Zn.CARTESIAN),void 0===s&&(s=r),void 0===o&&(o=n),{viewport:t,coordinateSystem:r,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:s,fromCoordinateOrigin:o}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=yd,shaderCoordinateOrigin:u=yd,offsetMode:h=!1}=l?bh(i,n,r):{},d=xd(e,{viewport:i,modelMatrix:s,coordinateSystem:o,coordinateOrigin:a,offsetMode:h});if(h){const e=i.projectPosition(c||u);hc(d,d,e)}return d}const wd={blendFunc:[1,0,32771,0],blendEquation:32774};class Td extends rh{constructor(...e){super(...e),bt(this,"pickZ",void 0),bt(this,"_colorEncoderState",null)}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,pickingFBO:s,deviceRect:{x:o,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:p,moduleParameters:f}){const m=this.gl;this.pickZ=p;const g=this._resetColorEncoder(p),_=Wr(m,{scissorTest:!0,scissor:[o,a,l,c],clearColor:[0,0,0,0],depthMask:!0,depthTest:!0,depthRange:[0,1],colorMask:[!0,!0,!0,!0],...wd,blend:!p},()=>super.render({target:s,layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,cullRect:u,effects:null==h?void 0:h.filter(e=>e.useInPicking),pass:d,isPicking:!0,moduleParameters:f}));this._colorEncoderState=null;return{decodePickingColor:g&&Sd.bind(null,g),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{pickingActive:1,pickingAttribute:this.pickZ,lightSources:{}}}getLayerParameters(e,t,i){const n={...e.props.parameters},{pickable:r,operation:s}=e.props;return this._colorEncoderState?r&&s.includes("draw")&&(Object.assign(n,wd),n.blend=!0,n.blendColor=function(e,t,i){const{byLayer:n,byAlpha:r}=e;let s,o=n.get(t);o?(o.viewports.push(i),s=o.a):(s=n.size+1,s<=255?(o={a:s,layer:t,viewports:[i]},n.set(t,o),r[s]=o):(Gn.warn("Too many pickable layers, only picking the first 255")(),s=0));return[0,0,0,s/255]}(this._colorEncoderState,e,i)):n.blend=!1,s.includes("terrain")&&(n.blend=!1),n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function Sd(e,t){const i=e.byAlpha[t[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(t)}}const Ed="Awaiting state",Ad="Matched. State transferred from previous layer",Md="Initialized",Id="Discarded. Awaiting garbage collection",Cd="No longer matched. Awaiting garbage collection",Pd="Finalized! Awaiting garbage collection",Ld=Symbol.for("component"),Rd=Symbol.for("propTypes"),Od=Symbol.for("deprecatedProps"),Dd=Symbol.for("asyncPropDefaults"),Bd=Symbol.for("asyncPropOriginal"),Fd=Symbol.for("asyncPropResolved");function Nd(e,t=()=>!0){return Array.isArray(e)?kd(e,t,[]):t(e)?[e]:[]}function kd(e,t,i){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?kd(r,t,i):t(r)&&i.push(r)}return i}function zd({target:e,source:t,start:i=0,count:n=1}){const r=t.length,s=n*r;let o=0;for(let n=i;o<r;o++)e[n++]=t[o];for(;o<s;)o<s-o?(e.copyWithin(i+o,i,i+o),o*=2):(e.copyWithin(i+o,i,i+s-o),o=s);return e}class Ud{constructor(e,t,i){bt(this,"id",void 0),bt(this,"context",void 0),bt(this,"isLoaded",void 0),bt(this,"persistent",void 0),bt(this,"_loadCount",0),bt(this,"_subscribers",new Set),bt(this,"_data",void 0),bt(this,"_loader",void 0),bt(this,"_error",void 0),bt(this,"_content",void 0),this.id=e,this.context=i,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const i=++this._loadCount;let n=e;"string"==typeof e&&(n=yn(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class Vd{constructor({gl:e,protocol:t}){bt(this,"protocol",void 0),bt(this,"_context",void 0),bt(this,"_resources",void 0),bt(this,"_consumers",void 0),bt(this,"_pruneRequest",void 0),this.protocol=t||"resource://",this._context={gl:e,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:n=!0}){let r=this._resources[e];r?r.setData(t,i):(r=new Ud(e,t,this._context),this._resources[e]=r),r.persistent=n}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const i=t[e],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:n="default"}){const{_resources:r,protocol:s}=this;e.startsWith(s)&&(r[e=e.replace(s,"")]||this.add({resourceId:e,data:null,persistent:!1}));const o=r[e];if(this._track(i,n,o,t),o)return o.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,i,n){const r=this._consumers,s=r[e]=r[e]||{},o=s[t]||{},a=o.resourceId&&this._resources[o.resourceId];a&&(a.unsubscribe(o),this.prune()),i&&(s[t]=o,o.onChange=n,o.resourceId=i.id,i.subscribe(o))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}var jd={name:"project32",dependencies:[Th],vs:"\nvec4 project_position_to_clipspace(\n  vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n  vec3 projectedPosition = project_position(position, position64Low);\n  mat3 rotation;\n  if (project_needs_rotation(projectedPosition, rotation)) {\n    // offset is specified as ENU\n    // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n    offset = rotation * offset;\n  }\n  commonPosition = vec4(projectedPosition + offset, 1.0);\n  return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n  vec3 position, vec3 position64Low, vec3 offset\n) {\n  vec4 commonPosition;\n  return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"},Gd={inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n    // for picking depth values\n    picking_setPickingAttribute(position.z / position.w);\n  ","vs:DECKGL_FILTER_COLOR":"\n  picking_setPickingColor(geometry.pickingColor);\n  ","fs:#decl":"\nuniform bool picking_uAttribute;\n  ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n  // use highlight color if this fragment belongs to the selected object.\n  color = picking_filterHighlightColor(color);\n\n  // use picking color if rendering to picking FBO.\n  color = picking_filterPickingColor(color);\n    "}},...xu};const Hd=[Th],Wd=["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 qd(e){const t=Iu.getDefaultProgramManager(e);for(const e of Hd)t.addDefaultModule(e);for(const e of Wd)t.addShaderHook(e);return t}class Xd{constructor(e,{deck:t,stats:i,viewport:n,timeline:r}={}){bt(this,"layers",void 0),bt(this,"context",void 0),bt(this,"resourceManager",void 0),bt(this,"_lastRenderedLayers",[]),bt(this,"_needsRedraw",!1),bt(this,"_needsUpdate",!1),bt(this,"_nextLayers",null),bt(this,"_debug",!1),bt(this,"activateViewport",e=>{qn("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)}),this.layers=[],this.resourceManager=new Vd({gl:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,gl:e,deck:t,programManager:e&&qd(e),stats:i||new Yt({id:"deck.gl"}),viewport:n||new gd({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:r||new Xu,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const n=i.getNeedsRedraw(e);t=t||n}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers 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(t=>e.find(e=>0===t.id.indexOf(e))):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,t){qn("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const i=Nd(e,Boolean);for(const e of i)e.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw("updating layers: ".concat(e)),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}_handleError(e,t,i){i.raiseError(t,"".concat(e," of ").concat(i))}_updateLayers(e,t){const i={};for(const t of e)i[t.id]?Gn.warn("Multiple old layers with same id ".concat(t.id))():i[t.id]=t;const n=[];this._updateSublayersRecursively(t,i,n),this._finalizeOldLayers(i);let r=!1;for(const e of n)if(e.hasUniformTransition()){r="Uniform transition in ".concat(e);break}this._needsUpdate=r,this.layers=n}_updateSublayersRecursively(e,t,i){for(const n of e){n.context=this.context;const e=t[n.id];null===e&&Gn.warn("Multiple new layers with same id ".concat(n.id))(),t[n.id]=null;let r=null;try{this._debug&&e!==n&&n.validateProps(),e?(this._transferLayerState(e,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),r=n.isComposite?n.getSubLayers():null}catch(e){this._handleError("matching",e,n)}r&&this._updateSublayersRecursively(r,t,i)}}_finalizeOldLayers(e){for(const t in e){const i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Md}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ad,t!==e&&(e.lifecycle=Id)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||"finalized ".concat(e),e.lifecycle=Cd;try{e._finalize(),e.lifecycle=Pd}catch(t){this._handleError("finalization",t,e)}}}function $d(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!$d(e[n],t[n],i-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!t.hasOwnProperty(r))return!1;if(!$d(e[r],t[r],i-1))return!1}return!0}return!1}class Zd{constructor(e){bt(this,"width",void 0),bt(this,"height",void 0),bt(this,"views",void 0),bt(this,"viewState",void 0),bt(this,"controllers",void 0),bt(this,"timeline",void 0),bt(this,"_viewports",void 0),bt(this,"_viewportMap",void 0),bt(this,"_isUpdating",void 0),bt(this,"_needsRedraw",void 0),bt(this,"_needsUpdate",void 0),bt(this,"_eventManager",void 0),bt(this,"_eventCallbacks",void 0),this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},Object.seal(this),this.setProps(e)}finalize(){for(const e in this.controllers){const t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(const e in this.controllers){const t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,t){const i=this.getViewports(),n={x:e[0],y:e[1]};for(let r=i.length-1;r>=0;--r){const s=i[r];if(s.containsPixel(n)){const i=e.slice();return i[0]-=s.x,i[1]-=s.y,s.unproject(i,t)}}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,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Nd(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!$d(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else Gn.warn("missing `viewState` or `initialViewState`")()}_onViewStateChange(e,t){this._eventCallbacks.onViewStateChange&&this._eventCallbacks.onViewStateChange({...t,viewId:e})}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._onViewStateChange.bind(this,t.id),onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>{var i;return null===(i=this.getView(e.id))||void 0===i?void 0:i.makeViewport({viewState:t,width:this.width,height:this.height})}})}_updateController(e,t,i,n){const r=e.controller;if(r&&i){const s={...t,...r,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return n&&n.constructor===r.type||(n=this._createController(e,s)),n&&n.setProps(s),n}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=e.length;n--;){const r=e[n],s=this.getViewState(r),o=r.makeViewport({viewState:s,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(i=!0),!i&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,s,o,a),o&&this._viewports.unshift(o)}for(const e in t){const i=t[e];i&&!this.controllers[e]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((i,n)=>!e[n].equals(t[n]))}}const Yd=/([0-9]+\.?[0-9]*)(%|px)/;function Jd(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=Yd.exec(e);if(t&&t.length>=3){const e="%"===t[2],i=parseFloat(t[1]);return{position:e?i/100:i,relative:e}}default:throw new Error("Could not parse position string ".concat(e))}}function Kd(e,t){return e.relative?Math.round(e.position*t):e.position}function Qd(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class ep{constructor(e){bt(this,"id",void 0),bt(this,"viewportInstance",void 0),bt(this,"_x",void 0),bt(this,"_y",void 0),bt(this,"_width",void 0),bt(this,"_height",void 0),bt(this,"_padding",void 0),bt(this,"props",void 0);const{id:t,x:i=0,y:n=0,width:r="100%",height:s="100%",padding:o=null,viewportInstance:a}=e||{};Qd(!a||a instanceof gd),this.viewportInstance=a,this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Jd(i),this._y=Jd(n),this._width=Jd(r),this._height=Jd(s),this._padding=o&&{left:Jd(o.left||0),right:Jd(o.right||0),top:Jd(o.top||0),bottom:Jd(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||(this.viewportInstance?!!e.viewportInstance&&this.viewportInstance.equals(e.viewportInstance):this.ViewportType===e.ViewportType&&$d(this.props,e.props,2))}makeViewport({width:e,height:t,viewState:i}){if(this.viewportInstance)return this.viewportInstance;i=this.filterViewState(i);const n=this.getDimensions({width:e,height:t});return n.height&&n.width?new this.ViewportType({...i,...this.props,...n}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:(null==e?void 0:e.id)||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const i={x:Kd(this._x,e),y:Kd(this._y,t),width:Kd(this._width,e),height:Kd(this._height,t)};return this._padding&&(i.padding={left:Kd(this._padding.left,e),top:Kd(this._padding.top,t),right:Kd(this._padding.right,e),bottom:Kd(this._padding.bottom,t)}),i}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class tp{constructor(e){bt(this,"_inProgress",void 0),bt(this,"_handle",void 0),bt(this,"_timeline",void 0),bt(this,"time",void 0),bt(this,"settings",void 0),this._inProgress=!1,this._handle=null,this._timeline=e,this.time=0,this.settings={duration:0}}get inProgress(){return this._inProgress}start(e){var t,i;this.cancel(),this.settings=e,this._inProgress=!0,null===(t=(i=this.settings).onStart)||void 0===t||t.call(i,this)}end(){var e,t;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,null===(e=(t=this.settings).onEnd)||void 0===e||e.call(t,this))}cancel(){var e,t;this._inProgress&&(null===(e=(t=this.settings).onInterrupt)||void 0===e||e.call(t,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var e,t;if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),null===(e=(t=this.settings).onUpdate)||void 0===e||e.call(t,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const ip=()=>{},np=2,rp=3,sp=e=>e,op=1;class ap{constructor(e){bt(this,"getControllerState",void 0),bt(this,"props",void 0),bt(this,"propsInTransition",void 0),bt(this,"transition",void 0),bt(this,"onViewStateChange",void 0),bt(this,"onStateChange",void 0),bt(this,"_onTransitionUpdate",e=>{const{time:t,settings:{interpolator:i,startProps:n,endProps:r,duration:s,easing:o}}=e,a=o(t/s),l=i.interpolateProps(n,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})}),this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new tp(e.timeline),this.onViewStateChange=e.onViewStateChange||ip,this.onStateChange=e.onStateChange||ip}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const 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){const{interruption:e,endProps:t}=this.transition.settings;n={...i,...e===np?t:this.propsInTransition||i}}this._triggerTransition(n,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||"auto"===t)&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===rp||this._isUpdateDueToCurrentTransition(t):!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const i=this.getControllerState(e),n=this.getControllerState(t).shortestPathFrom(i),r=t.transitionInterpolator,s=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===s)return;const o=r.initializeProps(e,n);this.propsInTransition={};const a={duration:s,easing:t.transitionEasing||sp,interpolator:r,interruption:t.transitionInterruption||op,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),null==e||e(t)}}}class lp{constructor(e){bt(this,"_propsToCompare",void 0),bt(this,"_propsToExtract",void 0),bt(this,"_requiredProps",void 0);const{compare:t,extract:i,required:n}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=n}arePropsEqual(e,t){for(const i of this._propsToCompare)if(!(i in e)||!(i in t)||!Vl(e[i],t[i]))return!1;return!0}initializeProps(e,t){const i={},n={};for(const r of this._propsToExtract)(r in e||r in t)&&(i[r]=e[r],n[r]=t[r]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const i=e[t];Qd(Number.isFinite(i)||Array.isArray(i),"".concat(t," is required for transition"))})}}const cp=["longitude","latitude","zoom","bearing","pitch"],up=["longitude","latitude","zoom"];class hp extends lp{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:cp,required:up},super(i.transitionProps),bt(this,"opts",void 0),this.opts=i}initializeProps(e,t){const i=super.initializeProps(e,t),{makeViewport:n,around:r}=this.opts;if(n&&r){const s=n(e),o=n(t),a=s.unproject(r);i.start.around=r,Object.assign(i.end,{around:o.project(a),aroundPosition:a,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){const n={};for(const r of this._propsToExtract)n[r]=Ul(e[r]||0,t[r]||0,i);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...n});Object.assign(n,r.panByPosition(t.aroundPosition,Ul(e.around,t.around,i)))}return n}}const dp={transitionDuration:0},pp=e=>1-(1-e)*(1-e),fp=["wheel"],mp=["panstart","panmove","panend"],gp=["pinchstart","pinchmove","pinchend"],_p=["tripanstart","tripanmove","tripanend"],yp=["doubletap"],vp=["keydown"],xp={};class bp{constructor(e){bt(this,"props",void 0),bt(this,"state",{}),bt(this,"transitionManager",void 0),bt(this,"eventManager",void 0),bt(this,"onViewStateChange",void 0),bt(this,"onStateChange",void 0),bt(this,"makeViewport",void 0),bt(this,"_controllerState",void 0),bt(this,"_events",{}),bt(this,"_interactionState",{isDragging:!1}),bt(this,"_customEvents",[]),bt(this,"_eventStartBlocked",null),bt(this,"_panMove",!1),bt(this,"invertPan",!1),bt(this,"dragMode","rotate"),bt(this,"inertia",0),bt(this,"scrollZoom",!0),bt(this,"dragPan",!0),bt(this,"dragRotate",!0),bt(this,"doubleClickZoom",!0),bt(this,"touchZoom",!0),bt(this,"touchRotate",!1),bt(this,"keyboard",!0),this.transitionManager=new ap({...e,getControllerState:e=>new this.ControllerState(e),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(const t in this._events){var e;if(this._events[t])null===(e=this.eventManager)||void 0===e||e.off(t,this.handleEvent)}this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return!t&&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){const{x:t,y:i}=this.props,{offsetCenter:n}=e;return[n.x-t,n.y-i]}isPointInBounds(e,t){const{width:i,height:n}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=n;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:i=!0,dragPan:n=!0,dragRotate:r=!0,doubleClickZoom:s=!0,touchZoom:o=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(fp,c&&i),this.toggleEvents(mp,c),this.toggleEvents(gp,c&&(o||a)),this.toggleEvents(_p,c&&a),this.toggleEvents(yp,c&&s),this.toggleEvents(vp,c&&l),this.scrollZoom=i,this.dragPan=n,this.dragRotate=r,this.doubleClickZoom=s,this.touchZoom=o,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,i={}){const n={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:e})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const n=this.controllerState[i?"panStart":"rotateStart"]({pos:t});return this._panMove=i,this.updateViewport(n,dp,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),i=this.controllerState.pan({pos:t});return this.updateViewport(i,dp,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const i=this.getCenter(e),n=this.controllerState.pan({pos:[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2]}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:pp},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),i=this.controllerState.rotate({pos:t});return this.updateViewport(i,dp,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const i=this.getCenter(e),n=this.controllerState.rotate({pos:[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2]}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:pp},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:i=.01,smooth:n=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let s=2/(1+Math.exp(-Math.abs(r*i)));r<0&&0!==s&&(s=1/s);const o=this.controllerState.zoom({pos:t,scale:s});return this.updateViewport(o,{...this._getTransitionProps({around:t}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.rotateStart({pos:t});return this.updateViewport(i,dp,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const i=this.controllerState.rotate({pos:t});return this.updateViewport(i,dp,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const i=this.getCenter(e),n=[i[0],i[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:n});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:pp},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return xp._startPinchRotation=e.rotation,xp._lastPinchEvent=e,this.updateViewport(i,dp,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:i}=e,n=this.getCenter(e);t=t.zoom({pos:n,scale:i})}if(this.touchRotate){const{rotation:i}=e;t=t.rotate({deltaAngleX:xp._startPinchRotation-i})}return this.updateViewport(t,dp,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),xp._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:i}=xp;if(this.touchZoom&&t&&i&&e.scale!==i.scale){const n=this.getCenter(e);let r=this.controllerState.rotateEnd();const s=Math.log2(e.scale),o=(s-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),a=Math.pow(2,s+o*t/2);r=r.zoom({pos:n,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:n}),transitionDuration:t,transitionEasing:pp},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return xp._startPinchRotation=null,xp._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:t,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:r,rotateSpeedY:s}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?o.zoomOut(i).zoomOut(i):o.zoomOut(i),l.isZooming=!0;break;case"Equal":a=t?o.zoomIn(i).zoomIn(i):o.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":t?(a=o.rotateLeft(r),l.isRotating=!0):(a=o.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":t?(a=o.rotateRight(r),l.isRotating=!0):(a=o.moveRight(n),l.isPanning=!0);break;case"ArrowUp":t?(a=o.rotateUp(s),l.isRotating=!0):(a=o.moveUp(n),l.isPanning=!0);break;case"ArrowDown":t?(a=o.rotateDown(s),l.isRotating=!0):(a=o.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new hp({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:dp}}class wp{constructor(e,t){bt(this,"_viewportProps",void 0),bt(this,"_state",void 0),this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Tp extends wp{constructor(e){const{width:t,height:i,latitude:n,longitude:r,zoom:s,bearing:o=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:y,startZoom:v,normalize:x=!0}=e;Qd(Number.isFinite(r)),Qd(Number.isFinite(n)),Qd(Number.isFinite(s)),super({width:t,height:i,latitude:n,longitude:r,zoom:s,bearing:o,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:p,normalize:x,position:c},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:y,startZoom:v}),bt(this,"makeViewport",void 0),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const 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:t=0,deltaAngleY:i=0}){const{startRotatePos:n,startBearing:r,startPitch:s}=this.getState();if(!n||void 0===r||void 0===s)return this;let o;return o=e?this._getNewRotation(e,n,s,r):{bearing:r+t,pitch:s+i},this._getUpdatedState(o)}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:t,scale:i}){let{startZoom:n,startZoomLngLat:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const{maxZoom:s,minZoom:o}=this.getViewportProps();let a=n+Math.log2(i);a=zl(a,o,s);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,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){const t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:r}=i;return Math.abs(n-t.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(r-t.longitude)>180&&(i.longitude=r<0?r+360:r-360),i}applyConstraints(e){const{maxZoom:t,minZoom:i,zoom:n}=e;e.zoom=zl(n,i,t);const{maxPitch:r,minPitch:s,pitch:o}=e;e.pitch=zl(o,s,r);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:i,pitch:n=0}=e;let{longitude:r,latitude:s,zoom:o,bearing:a=0}=e;(r<-180||r>180)&&(r=Eh(r+180,360)-180),(a<-180||a>180)&&(a=Eh(a+180,360)-180);const l=Mh(i/512);if(o<=l)o=l,s=0;else{const e=i/2/Math.pow(2,o),t=kh([0,e])[1];if(s<t)s=t;else{const t=kh([0,512-e])[1];s>t&&(s=t)}}return{width:t,height:i,longitude:r,latitude:s,zoom:o,pitch:n,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.zoom({pos:[t/2,i/2],scale:e})}_panFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.pan({startPos:[t/2,i/2],pos:[t/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,i,n){const r=e[0]-t[0],s=e[1]-t[1],o=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;s>0?Math.abs(c-a)>5&&(h=s/(a-c)*1.2):s<0&&a>5&&(h=1-o/a),h=zl(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=i;return h>0?f=i+h*(p-i):h<0&&(f=i-h*(d-i)),{pitch:f,bearing:n+180*u}}}class Sp extends bp{constructor(...e){super(...e),bt(this,"ControllerState",Tp),bt(this,"transition",{transitionDuration:300,transitionInterpolator:new hp({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})}),bt(this,"dragMode","pan")}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e);(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class Ep extends ep{get ViewportType(){return _d}get ControllerType(){return Sp}}bt(Ep,"displayName","MapView");const Ap=new rd;class Mp{constructor(){bt(this,"effects",void 0),bt(this,"_resolvedEffects",[]),bt(this,"_defaultEffects",[]),bt(this,"_needsRedraw",void 0),this.effects=[],this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const i=t.findIndex(t=>{return(null!==(i=t.order)&&void 0!==i?i:1/0)-(null!==(n=e.order)&&void 0!==n?n:1/0)>0;var i,n});i<0?t.push(e):t.splice(i,0,e),this._setEffects(this.effects)}}setProps(e){"effects"in e&&($d(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const i=[];for(const n of e){const e=t[n.id];e&&e!==n?e.setProps?(e.setProps(n.props),i.push(e)):(e.cleanup(),i.push(n)):i.push(n),delete t[n.id]}for(const e in t)t[e].cleanup();this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(e=>e instanceof rd)||this._resolvedEffects.push(Ap),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup();this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class Ip extends rh{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Cp{constructor(e){bt(this,"gl",void 0),bt(this,"layerFilter",void 0),bt(this,"drawPickingColors",void 0),bt(this,"drawLayersPass",void 0),bt(this,"pickLayersPass",void 0),bt(this,"renderCount",void 0),bt(this,"_needsRedraw",void 0),bt(this,"renderBuffers",void 0),bt(this,"lastPostProcessEffect",void 0),this.gl=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Ip(e),this.pickLayersPass=new Td(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;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e,target:e.target||yo.getDefaultFramebuffer(this.gl)};i.effects&&this._preRender(i.effects,i);const n=this.lastPostProcessEffect?this.renderBuffers[0]:i.target,r=t.render({...i,target:n});i.effects&&this._postRender(i.effects,i),this.renderCount++,qn("deckRenderer.renderLayers",this,r,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const i of e)t.preRenderStats[i.id]=i.preRender(this.gl,t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this;0===e.length&&e.push(new yo(this.gl),new yo(this.gl));for(const t of e)t.resize()}_postRender(e,t){const{renderBuffers:i}=this,n={...t,inputBuffer:i[0],swapBuffer:i[1],target:null};for(const r of e)if(r.postRender){if(r.id===this.lastPostProcessEffect){n.target=t.target,r.postRender(this.gl,n);break}const e=r.postRender(this.gl,n);n.inputBuffer=e,n.swapBuffer=e===i[0]?i[1]:i[0]}}}const Pp={pickedColor:null,pickedObjectIndex:-1};function Lp({pickedColors:e,decodePickingColor:t,deviceX:i,deviceY:n,deviceRadius:r,deviceRect:s}){const{x:o,y:a,width:l,height:c}=s;let u=r*r,h=-1,d=0;for(let t=0;t<c;t++){const r=t+a-n,s=r*r;if(s>u)d+=4*l;else for(let t=0;t<l;t++){if(e[d+3]-1>=0){const e=t+o-i,n=e*e+s;n<=u&&(u=n,h=d)}d+=4}}if(h>=0){const i=e.slice(h,h+4),n=t(i);if(n){const e=Math.floor(h/4/l),t=h/4-e*l;return{...n,pickedColor:i,pickedX:o+t,pickedY:a+e}}}return Pp}function Rp({pickInfo:e,viewports:t,pixelRatio:i,x:n,y:r,z:s}){let o,a=t[0];if(t.length>1&&(a=function(e,t){for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.containsPixel(t))return n}return e[0]}((null==e?void 0:e.pickedViewports)||t,{x:n,y:r})),a){const e=[n-a.x,r-a.y];void 0!==s&&(e[2]=s),o=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:n,y:r,pixel:[n,r],coordinate:o,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:i}}function Op(e){const{pickInfo:t,lastPickedInfo:i,mode:n,layers:r}=e,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=t,l=o?[o]:[];if("hover"===n){const e=i.layerId,t=o?o.props.id:null;if(t!==e||a!==i.index){if(t!==e){const t=r.find(t=>t.props.id===e);t&&l.unshift(t)}i.layerId=t,i.index=a,i.info=null}}const c=Rp(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===o&&(t.color=s,t.index=a,t.picked=!0),t=Dp({layer:e,info:t,mode:n});const r=t.layer;e===o&&"hover"===n&&(i.info=t),u.set(r.id,t),"hover"===n&&r.updateAutoHighlight(t)}),u}function Dp({layer:e,info:t,mode:i}){for(;e&&t;){const n=t.layer||null;t.sourceLayer=n,t.layer=e,t=e.getPickingInfo({info:t,mode:i,sourceLayer:n}),e=e.parent}return t}class Bp{constructor(e){bt(this,"gl",void 0),bt(this,"pickingFBO",void 0),bt(this,"depthFBO",void 0),bt(this,"pickLayersPass",void 0),bt(this,"layerFilter",void 0),bt(this,"lastPickedInfo",void 0),bt(this,"_pickable",!0),this.gl=e,this.pickLayersPass=new Td(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.delete(),this.depthFBO&&(this.depthFBO.color.delete(),this.depthFBO.delete())}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:n},r=this.lastPickedInfo.info){const s=r&&r.layer&&r.layer.id,o=r&&r.viewport&&r.viewport.id,a=s?i.find(e=>e.id===s):null,l=o&&n.find(e=>e.id===o)||n[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){var e,t;const{gl:i}=this;if(!this.pickingFBO&&(this.pickingFBO=new yo(i),yo.isSupported(i,{colorBufferFloat:!0}))){const e=new yo(i);e.attach({36064:new Ls(i,{format:ir(i)?34836:6408,type:5126})}),this.depthFBO=e}null===(e=this.pickingFBO)||void 0===e||e.resize({width:i.canvas.width,height:i.canvas.height}),null===(t=this.depthFBO)||void 0===t||t.resize({width:i.canvas.width,height:i.canvas.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}_pickClosestObject({layers:e,views:t,viewports:i,x:n,y:r,radius:s=0,depth:o=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this._getPickable(e),d=qr(this.gl);if(!h)return{result:[],emptyInfo:Rp({viewports:i,x:n,y:r,pixelRatio:d})};this._resizeBuffer();const p=Xr(this.gl,[n,r],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*d),{width:g,height:_}=this.pickingFBO,y=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),v={x:n-s,y:r-s,width:2*s+1,height:2*s+1};let x;const b=[],w=new Set;for(let e=0;e<o;e++){let s,p;if(y){s=Lp({...this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:y,cullRect:v,effects:u,pass:"picking:".concat(a)}),deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceRect:y})}else s={pickedColor:null,pickedObjectIndex:-1};if(s.pickedLayer&&l&&this.depthFBO){const{pickedColors:e}=this._drawAndSample({layers:[s.pickedLayer],views:t,viewports:i,onViewportActive:c,deviceRect:{x:s.pickedX,y:s.pickedY,width:1,height:1},cullRect:v,effects:u,pass:"picking:".concat(a,":z")},!0);e[3]&&(p=e[0])}s.pickedLayer&&e+1<o&&(w.add(s.pickedLayer),s.pickedLayer.disablePickingIndex(s.pickedObjectIndex)),x=Op({pickInfo:s,lastPickedInfo:this.lastPickedInfo,mode:a,layers:h,viewports:i,x:n,y:r,z:p,pixelRatio:d});for(const e of x.values())e.layer&&b.push(e);if(!s.pickedColor)break}for(const e of w)e.restorePickingColors();return{result:b,emptyInfo:x.get(null)}}_pickVisibleObjects({layers:e,views:t,viewports:i,x:n,y:r,width:s=1,height:o=1,mode:a="query",maxObjects:l=null,onViewportActive:c,effects:u}){const h=this._getPickable(e);if(!h)return[];this._resizeBuffer();const d=qr(this.gl),p=Xr(this.gl,[n,r],!0),f=p.x,m=p.y+p.height,g=Xr(this.gl,[n+s,r+o],!0),_=g.y,y=function({pickedColors:e,decodePickingColor:t}){const i=new Map;if(e)for(let n=0;n<e.length;n+=4)if(e[n+3]-1>=0){const r=e.slice(n,n+4),s=r.join(",");if(!i.has(s)){const e=t(r);e&&i.set(s,{...e,color:r})}}return Array.from(i.values())}(this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:{x:f,y:_,width:g.x+g.width-f,height:m-_},cullRect:{x:n,y:r,width:s,height:o},effects:u,pass:"picking:".concat(a)})),v=new Map,x=Number.isFinite(l);for(let e=0;e<y.length;e++){var b;if(x&&l&&v.size>=l)break;const t=y[e];let i={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:n,y:r,pixelRatio:d};i=Dp({layer:t.pickedLayer,info:i,mode:a});const s=null!==(b=i.object)&&void 0!==b?b:"".concat(i.layer.id,"[").concat(i.index,"]");v.has(s)||v.set(s,i)}return Array.from(v.values())}_drawAndSample({layers:e,views:t,viewports:i,onViewportActive:n,deviceRect:r,cullRect:s,effects:o,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:n,pickingFBO:c,deviceRect:r,cullRect:s,effects:o,pass:a,pickZ:l,preRenderStats:{}};for(const e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(this.gl,u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:p,width:f,height:m}=r,g=new(l?Float32Array:Uint8Array)(f*m*4);return Vs(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:n,deviceHeight:r}){const s=Math.max(0,e-i),o=Math.max(0,t-i),a=Math.min(n,e+i+1)-s,l=Math.min(r,t+i+1)-o;return a<=0||l<=0?null:{x:s,y:o,width:a,height:l}}}const Fp={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Np{constructor(e){bt(this,"el",null),bt(this,"isVisible",!1);const t=e.parentElement;t&&(this.el=document.createElement("div"),this.el.className="deck-tooltip",Object.assign(this.el.style,Fp),t.appendChild(this.el))}setTooltip(e,t,i){const n=this.el;if(n){if("string"==typeof e)n.innerText=e;else{if(!e)return this.isVisible=!1,void(n.style.display="none");e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className)}this.isVisible=!0,n.style.display="block",n.style.transform="translate(".concat(t,"px, ").concat(i,"px)"),e&&"object"==typeof e&&"style"in e&&Object.assign(n.style,e.style)}}remove(){this.el&&(this.el.remove(),this.el=null)}}var kp,zp={exports:{}};
/*! Hammer.JS - v2.0.7 - 2016-04-22
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */var Up=(kp||(kp=1,function(e){!function(t,i,n,r){var s,o=["","webkit","Moz","MS","ms","o"],a=i.createElement("div"),l=Math.round,c=Math.abs,u=Date.now;function h(e,t,i){return setTimeout(y(e,i),t)}function d(e,t,i){return!!Array.isArray(e)&&(p(e,i[t],i),!0)}function p(e,t,i){var n;if(e)if(e.forEach)e.forEach(t,i);else if(e.length!==r)for(n=0;n<e.length;)t.call(i,e[n],n,e),n++;else for(n in e)e.hasOwnProperty(n)&&t.call(i,e[n],n,e)}function f(e,i,n){var r="DEPRECATED METHOD: "+i+"\n"+n+" AT \n";return function(){var i=new Error("get-stack-trace"),n=i&&i.stack?i.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",s=t.console&&(t.console.warn||t.console.log);return s&&s.call(t.console,r,n),e.apply(this,arguments)}}s="function"!=typeof Object.assign?function(e){if(e===r||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(n!==r&&null!==n)for(var s in n)n.hasOwnProperty(s)&&(t[s]=n[s])}return t}:Object.assign;var m=f(function(e,t,i){for(var n=Object.keys(t),s=0;s<n.length;)(!i||i&&e[n[s]]===r)&&(e[n[s]]=t[n[s]]),s++;return e},"extend","Use `assign`."),g=f(function(e,t){return m(e,t,!0)},"merge","Use `assign`.");function _(e,t,i){var n,r=t.prototype;(n=e.prototype=Object.create(r)).constructor=e,n._super=r,i&&s(n,i)}function y(e,t){return function(){return e.apply(t,arguments)}}function v(e,t){return"function"==typeof e?e.apply(t&&t[0]||r,t):e}function x(e,t){return e===r?t:e}function b(e,t,i){p(E(t),function(t){e.addEventListener(t,i,!1)})}function w(e,t,i){p(E(t),function(t){e.removeEventListener(t,i,!1)})}function T(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function S(e,t){return e.indexOf(t)>-1}function E(e){return e.trim().split(/\s+/g)}function A(e,t,i){if(e.indexOf&&!i)return e.indexOf(t);for(var n=0;n<e.length;){if(i&&e[n][i]==t||!i&&e[n]===t)return n;n++}return-1}function M(e){return Array.prototype.slice.call(e,0)}function I(e,t,i){for(var n=[],r=[],s=0;s<e.length;){var o=e[s][t];A(r,o)<0&&n.push(e[s]),r[s]=o,s++}return n=n.sort(function(e,i){return e[t]>i[t]}),n}function C(e,t){for(var i,n,s=t[0].toUpperCase()+t.slice(1),a=0;a<o.length;){if((n=(i=o[a])?i+s:t)in e)return n;a++}return r}var P=1;function L(e){var i=e.ownerDocument||e;return i.defaultView||i.parentWindow||t}var R="ontouchstart"in t,O=C(t,"PointerEvent")!==r,D=R&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),B="touch",F="mouse",N=24,k=["x","y"],z=["clientX","clientY"];function U(e,t){var i=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){v(e.options.enable,[e])&&i.handler(t)},this.init()}function V(e,t,i){var n=i.pointers.length,s=i.changedPointers.length,o=1&t&&n-s===0,a=12&t&&n-s===0;i.isFirst=!!o,i.isFinal=!!a,o&&(e.session={}),i.eventType=t,function(e,t){var i=e.session,n=t.pointers,s=n.length;i.firstInput||(i.firstInput=j(t)),s>1&&!i.firstMultiple?i.firstMultiple=j(t):1===s&&(i.firstMultiple=!1);var o=i.firstInput,a=i.firstMultiple,l=a?a.center:o.center,h=t.center=G(n);t.timeStamp=u(),t.deltaTime=t.timeStamp-o.timeStamp,t.angle=X(l,h),t.distance=q(l,h),function(e,t){var i=t.center,n=e.offsetDelta||{},r=e.prevDelta||{},s=e.prevInput||{};1!==t.eventType&&4!==s.eventType||(r=e.prevDelta={x:s.deltaX||0,y:s.deltaY||0},n=e.offsetDelta={x:i.x,y:i.y}),t.deltaX=r.x+(i.x-n.x),t.deltaY=r.y+(i.y-n.y)}(i,t),t.offsetDirection=W(t.deltaX,t.deltaY);var d,p,f=H(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=f.x,t.overallVelocityY=f.y,t.overallVelocity=c(f.x)>c(f.y)?f.x:f.y,t.scale=a?(d=a.pointers,q((p=n)[0],p[1],z)/q(d[0],d[1],z)):1,t.rotation=a?function(e,t){return X(t[1],t[0],z)+X(e[1],e[0],z)}(a.pointers,n):0,t.maxPointers=i.prevInput?t.pointers.length>i.prevInput.maxPointers?t.pointers.length:i.prevInput.maxPointers:t.pointers.length,function(e,t){var i,n,s,o,a=e.lastInterval||t,l=t.timeStamp-a.timeStamp;if(8!=t.eventType&&(l>25||a.velocity===r)){var u=t.deltaX-a.deltaX,h=t.deltaY-a.deltaY,d=H(l,u,h);n=d.x,s=d.y,i=c(d.x)>c(d.y)?d.x:d.y,o=W(u,h),e.lastInterval=t}else i=a.velocity,n=a.velocityX,s=a.velocityY,o=a.direction;t.velocity=i,t.velocityX=n,t.velocityY=s,t.direction=o}(i,t);var m=e.element;T(t.srcEvent.target,m)&&(m=t.srcEvent.target),t.target=m}(e,i),e.emit("hammer.input",i),e.recognize(i),e.session.prevInput=i}function j(e){for(var t=[],i=0;i<e.pointers.length;)t[i]={clientX:l(e.pointers[i].clientX),clientY:l(e.pointers[i].clientY)},i++;return{timeStamp:u(),pointers:t,center:G(t),deltaX:e.deltaX,deltaY:e.deltaY}}function G(e){var t=e.length;if(1===t)return{x:l(e[0].clientX),y:l(e[0].clientY)};for(var i=0,n=0,r=0;r<t;)i+=e[r].clientX,n+=e[r].clientY,r++;return{x:l(i/t),y:l(n/t)}}function H(e,t,i){return{x:t/e||0,y:i/e||0}}function W(e,t){return e===t?1:c(e)>=c(t)?e<0?2:4:t<0?8:16}function q(e,t,i){i||(i=k);var n=t[i[0]]-e[i[0]],r=t[i[1]]-e[i[1]];return Math.sqrt(n*n+r*r)}function X(e,t,i){return i||(i=k),180*Math.atan2(t[i[1]]-e[i[1]],t[i[0]]-e[i[0]])/Math.PI}U.prototype={handler:function(){},init:function(){this.evEl&&b(this.element,this.evEl,this.domHandler),this.evTarget&&b(this.target,this.evTarget,this.domHandler),this.evWin&&b(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)}};var $={mousedown:1,mousemove:2,mouseup:4},Z="mousedown",Y="mousemove mouseup";function J(){this.evEl=Z,this.evWin=Y,this.pressed=!1,U.apply(this,arguments)}_(J,U,{handler:function(e){var t=$[e.type];1&t&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:F,srcEvent:e}))}});var K={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:B,3:"pen",4:F,5:"kinect"},ee="pointerdown",te="pointermove pointerup pointercancel";function ie(){this.evEl=ee,this.evWin=te,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}t.MSPointerEvent&&!t.PointerEvent&&(ee="MSPointerDown",te="MSPointerMove MSPointerUp MSPointerCancel"),_(ie,U,{handler:function(e){var t=this.store,i=!1,n=e.type.toLowerCase().replace("ms",""),r=K[n],s=Q[e.pointerType]||e.pointerType,o=s==B,a=A(t,e.pointerId,"pointerId");1&r&&(0===e.button||o)?a<0&&(t.push(e),a=t.length-1):12&r&&(i=!0),a<0||(t[a]=e,this.callback(this.manager,r,{pointers:t,changedPointers:[e],pointerType:s,srcEvent:e}),i&&t.splice(a,1))}});var ne={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function re(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,U.apply(this,arguments)}function se(e,t){var i=M(e.touches),n=M(e.changedTouches);return 12&t&&(i=I(i.concat(n),"identifier")),[i,n]}_(re,U,{handler:function(e){var t=ne[e.type];if(1===t&&(this.started=!0),this.started){var i=se.call(this,e,t);12&t&&i[0].length-i[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:i[0],changedPointers:i[1],pointerType:B,srcEvent:e})}}});var oe={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ae="touchstart touchmove touchend touchcancel";function le(){this.evTarget=ae,this.targetIds={},U.apply(this,arguments)}function ce(e,t){var i=M(e.touches),n=this.targetIds;if(3&t&&1===i.length)return n[i[0].identifier]=!0,[i,i];var r,s,o=M(e.changedTouches),a=[],l=this.target;if(s=i.filter(function(e){return T(e.target,l)}),1===t)for(r=0;r<s.length;)n[s[r].identifier]=!0,r++;for(r=0;r<o.length;)n[o[r].identifier]&&a.push(o[r]),12&t&&delete n[o[r].identifier],r++;return a.length?[I(s.concat(a),"identifier"),a]:void 0}function ue(){U.apply(this,arguments);var e=y(this.handler,this);this.touch=new le(this.manager,e),this.mouse=new J(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}function he(e,t){1&e?(this.primaryTouch=t.changedPointers[0].identifier,de.call(this,t)):12&e&&de.call(this,t)}function de(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var i={x:t.clientX,y:t.clientY};this.lastTouches.push(i);var n=this.lastTouches;setTimeout(function(){var e=n.indexOf(i);e>-1&&n.splice(e,1)},2500)}}function pe(e){for(var t=e.srcEvent.clientX,i=e.srcEvent.clientY,n=0;n<this.lastTouches.length;n++){var r=this.lastTouches[n],s=Math.abs(t-r.x),o=Math.abs(i-r.y);if(s<=25&&o<=25)return!0}return!1}_(le,U,{handler:function(e){var t=oe[e.type],i=ce.call(this,e,t);i&&this.callback(this.manager,t,{pointers:i[0],changedPointers:i[1],pointerType:B,srcEvent:e})}}),_(ue,U,{handler:function(e,t,i){var n=i.pointerType==F;if(!(n&&i.sourceCapabilities&&i.sourceCapabilities.firesTouchEvents)){if(i.pointerType==B)he.call(this,t,i);else if(n&&pe.call(this,i))return;this.callback(e,t,i)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var fe=C(a.style,"touchAction"),me=fe!==r,ge="compute",_e="auto",ye="manipulation",ve="none",xe="pan-x",be="pan-y",we=function(){if(!me)return!1;var e={},i=t.CSS&&t.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(n){e[n]=!i||t.CSS.supports("touch-action",n)}),e}();function Te(e,t){this.manager=e,this.set(t)}Te.prototype={set:function(e){e==ge&&(e=this.compute()),me&&this.manager.element.style&&we[e]&&(this.manager.element.style[fe]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return p(this.manager.recognizers,function(t){v(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),function(e){if(S(e,ve))return ve;var t=S(e,xe),i=S(e,be);return t&&i?ve:t||i?t?xe:be:S(e,ye)?ye:_e}(e.join(" "))},preventDefaults:function(e){var t=e.srcEvent,i=e.offsetDirection;if(this.manager.session.prevented)t.preventDefault();else{var n=this.actions,r=S(n,ve)&&!we[ve],s=S(n,be)&&!we[be],o=S(n,xe)&&!we[xe];if(r&&1===e.pointers.length&&e.distance<2&&e.deltaTime<250)return;if(!o||!s)return r||s&&6&i||o&&i&N?this.preventSrc(t):void 0}},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};var Se=32;function Ee(e){this.options=s({},this.defaults,e||{}),this.id=P++,this.manager=null,this.options.enable=x(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function Ae(e){return 16&e?"cancel":8&e?"end":4&e?"move":2&e?"start":""}function Me(e){return 16==e?"down":8==e?"up":2==e?"left":4==e?"right":""}function Ie(e,t){var i=t.manager;return i?i.get(e):e}function Ce(){Ee.apply(this,arguments)}function Pe(){Ce.apply(this,arguments),this.pX=null,this.pY=null}function Le(){Ce.apply(this,arguments)}function Re(){Ee.apply(this,arguments),this._timer=null,this._input=null}function Oe(){Ce.apply(this,arguments)}function De(){Ce.apply(this,arguments)}function Be(){Ee.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Fe(e,t){return(t=t||{}).recognizers=x(t.recognizers,Fe.defaults.preset),new Ne(e,t)}function Ne(e,t){var i;this.options=s({},Fe.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new((i=this).options.inputClass||(O?ie:D?le:R?ue:J))(i,V),this.touchAction=new Te(this,this.options.touchAction),ke(this,!0),p(this.options.recognizers,function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])},this)}function ke(e,t){var i,n=e.element;n.style&&(p(e.options.cssProps,function(r,s){i=C(n.style,s),t?(e.oldCssProps[i]=n.style[i],n.style[i]=r):n.style[i]=e.oldCssProps[i]||""}),t||(e.oldCssProps={}))}Ee.prototype={defaults:{},set:function(e){return s(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(d(e,"recognizeWith",this))return this;var t=this.simultaneous;return t[(e=Ie(e,this)).id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return d(e,"dropRecognizeWith",this)||(e=Ie(e,this),delete this.simultaneous[e.id]),this},requireFailure:function(e){if(d(e,"requireFailure",this))return this;var t=this.requireFail;return-1===A(t,e=Ie(e,this))&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(d(e,"dropRequireFailure",this))return this;e=Ie(e,this);var t=A(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,i=this.state;function n(i){t.manager.emit(i,e)}i<8&&n(t.options.event+Ae(i)),n(t.options.event),e.additionalEvent&&n(e.additionalEvent),i>=8&&n(t.options.event+Ae(i))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=Se},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(33&this.requireFail[e].state))return!1;e++}return!0},recognize:function(e){var t=s({},e);if(!v(this.options.enable,[this,t]))return this.reset(),void(this.state=Se);56&this.state&&(this.state=1),this.state=this.process(t),30&this.state&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}},_(Ce,Ee,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return 0===t||e.pointers.length===t},process:function(e){var t=this.state,i=e.eventType,n=6&t,r=this.attrTest(e);return n&&(8&i||!r)?16|t:n||r?4&i?8|t:2&t?4|t:2:Se}}),_(Pe,Ce,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var e=this.options.direction,t=[];return 6&e&&t.push(be),e&N&&t.push(xe),t},directionTest:function(e){var t=this.options,i=!0,n=e.distance,r=e.direction,s=e.deltaX,o=e.deltaY;return r&t.direction||(6&t.direction?(r=0===s?1:s<0?2:4,i=s!=this.pX,n=Math.abs(e.deltaX)):(r=0===o?1:o<0?8:16,i=o!=this.pY,n=Math.abs(e.deltaY))),e.direction=r,i&&n>t.threshold&&r&t.direction},attrTest:function(e){return Ce.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=Me(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),_(Le,Ce,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ve]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){1!==e.scale&&(e.additionalEvent=this.options.event+(e.scale<1?"in":"out")),this._super.emit.call(this,e)}}),_(Re,Ee,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[_e]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,n=e.distance<t.threshold,r=e.deltaTime>t.time;if(this._input=e,!n||!i||12&e.eventType&&!r)this.reset();else if(1&e.eventType)this.reset(),this._timer=h(function(){this.state=8,this.tryEmit()},t.time,this);else if(4&e.eventType)return 8;return Se},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&4&e.eventType?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=u(),this.manager.emit(this.options.event,this._input)))}}),_(Oe,Ce,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ve]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),_(De,Ce,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Pe.prototype.getTouchAction.call(this)},attrTest:function(e){var t,i=this.options.direction;return 30&i?t=e.overallVelocity:6&i?t=e.overallVelocityX:i&N&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&i&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&c(t)>this.options.velocity&&4&e.eventType},emit:function(e){var t=Me(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),_(Be,Ee,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[ye]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,n=e.distance<t.threshold,r=e.deltaTime<t.time;if(this.reset(),1&e.eventType&&0===this.count)return this.failTimeout();if(n&&r&&i){if(4!=e.eventType)return this.failTimeout();var s=!this.pTime||e.timeStamp-this.pTime<t.interval,o=!this.pCenter||q(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,o&&s?this.count+=1:this.count=1,this._input=e,0===this.count%t.taps)return this.hasRequireFailures()?(this._timer=h(function(){this.state=8,this.tryEmit()},t.interval,this),2):8}return Se},failTimeout:function(){return this._timer=h(function(){this.state=Se},this.options.interval,this),Se},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Fe.VERSION="2.0.7",Fe.defaults={domEvents:!1,touchAction:ge,enable:!0,inputTarget:null,inputClass:null,preset:[[Oe,{enable:!1}],[Le,{enable:!1},["rotate"]],[De,{direction:6}],[Pe,{direction:6},["swipe"]],[Be],[Be,{event:"doubletap",taps:2},["tap"]],[Re]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Ne.prototype={set:function(e){return s(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?2:1},recognize:function(e){var t=this.session;if(!t.stopped){var i;this.touchAction.preventDefaults(e);var n=this.recognizers,r=t.curRecognizer;(!r||r&&8&r.state)&&(r=t.curRecognizer=null);for(var s=0;s<n.length;)i=n[s],2===t.stopped||r&&i!=r&&!i.canRecognizeWith(r)?i.reset():i.recognize(e),!r&&14&i.state&&(r=t.curRecognizer=i),s++}},get:function(e){if(e instanceof Ee)return e;for(var t=this.recognizers,i=0;i<t.length;i++)if(t[i].options.event==e)return t[i];return null},add:function(e){if(d(e,"add",this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(d(e,"remove",this))return this;if(e=this.get(e)){var t=this.recognizers,i=A(t,e);-1!==i&&(t.splice(i,1),this.touchAction.update())}return this},on:function(e,t){if(e!==r&&t!==r){var i=this.handlers;return p(E(e),function(e){i[e]=i[e]||[],i[e].push(t)}),this}},off:function(e,t){if(e!==r){var i=this.handlers;return p(E(e),function(e){t?i[e]&&i[e].splice(A(i[e],t),1):delete i[e]}),this}},emit:function(e,t){this.options.domEvents&&function(e,t){var n=i.createEvent("Event");n.initEvent(e,!0,!0),n.gesture=t,t.target.dispatchEvent(n)}(e,t);var n=this.handlers[e]&&this.handlers[e].slice();if(n&&n.length){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var r=0;r<n.length;)n[r](t),r++}},destroy:function(){this.element&&ke(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},s(Fe,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Se,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:N,DIRECTION_ALL:30,Manager:Ne,Input:U,TouchAction:Te,TouchInput:le,MouseInput:J,PointerEventInput:ie,TouchMouseInput:ue,SingleTouchInput:re,Recognizer:Ee,AttrRecognizer:Ce,Tap:Be,Pan:Pe,Swipe:De,Pinch:Le,Rotate:Oe,Press:Re,on:b,off:w,each:p,merge:g,extend:m,assign:s,inherit:_,bindFn:y,prefixed:C}),(void 0!==t?t:"undefined"!=typeof self?self:{}).Hammer=Fe,e.exports?e.exports=Fe:t.Hammer=Fe}(window,document)}(zp)),zp.exports),Vp=i({__proto__:null},[Up]);const jp={mousedown:1,mousemove:2,mouseup:4};!function(e){const t=e.prototype.handler;e.prototype.handler=function(e){const i=this.store;e.button>0&&"pointerdown"===e.type&&(function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return!0;return!1}(i,t=>t.pointerId===e.pointerId)||i.push(e)),t.call(this,e)}}(Up.PointerEventInput),Up.MouseInput.prototype.handler=function(e){let t=jp[e.type];1&t&&e.button>=0&&(this.pressed=!0),2&t&&0===e.buttons&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:"mouse",srcEvent:e}))};const Gp=Up.Manager;class Hp{constructor(e,t,i){this.element=e,this.callback=t,this.options={enable:!0,...i}}}const Wp=Vp?[[Vp.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Vp.Rotate,{enable:!1}],[Vp.Pinch,{enable:!1}],[Vp.Swipe,{enable:!1}],[Vp.Pan,{threshold:0,enable:!1}],[Vp.Press,{enable:!1}],[Vp.Tap,{event:"doubletap",taps:2,enable:!1}],[Vp.Tap,{event:"anytap",enable:!1}],[Vp.Tap,{enable:!1}]]:null,qp={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Xp={doubletap:["tap"]},$p={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Zp={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},Yp={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"},Jp={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},Kp="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Qp="undefined"!=typeof window?window:global;let ef=!1;try{Qp.addEventListener("test",null,{get passive(){return ef=!0,!0}}),Qp.removeEventListener("test",null)}catch(L){ef=!1}const tf=-1!==Kp.indexOf("firefox"),{WHEEL_EVENTS:nf}=Zp,rf="wheel",sf=4.000244140625;class of extends Hp{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;Qp.WheelEvent&&(tf&&e.deltaMode===Qp.WheelEvent.DOM_DELTA_PIXEL&&(t/=Qp.devicePixelRatio),e.deltaMode===Qp.WheelEvent.DOM_DELTA_LINE&&(t*=40)),0!==t&&t%sf===0&&(t=Math.floor(t/sf)),e.shiftKey&&t&&(t*=.25),this.callback({type:rf,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:"mouse",target:e.target})},this.events=(this.options.events||[]).concat(nf),this.events.forEach(t=>e.addEventListener(t,this.handleEvent,!!ef&&{passive:!1}))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===rf&&(this.options.enable=t)}}const{MOUSE_EVENTS:af}=Zp,lf="pointermove",cf="pointerover",uf="pointerout",hf="pointerenter",df="pointerleave";class pf extends Hp{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{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(af),this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===lf&&(this.enableMoveEvent=t),e===cf&&(this.enableOverEvent=t),e===uf&&(this.enableOutEvent=t),e===hf&&(this.enableEnterEvent=t),e===df&&(this.enableLeaveEvent=t)}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit(cf,e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit(uf,e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit(hf,e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit(df,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit(lf,e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const{KEY_EVENTS:ff}=Zp,mf="keydown",gf="keyup";class _f extends Hp{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:mf,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:gf,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(ff),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===mf&&(this.enableDownEvent=t),e===gf&&(this.enableUpEvent=t)}}const yf="contextmenu";class vf extends Hp{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.options.enable&&this.callback({type:yf,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){e===yf&&(this.options.enable=t)}}const xf={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function bf(e){const t=xf[e.srcEvent.type];if(!t)return null;const{buttons:i,button:n}=e.srcEvent;let r=!1,s=!1,o=!1;return 2===t?(r=Boolean(1&i),s=Boolean(4&i),o=Boolean(2&i)):(r=0===n,s=1===n,o=2===n),{leftButton:r,middleButton:s,rightButton:o}}function wf(e,t){const i=e.center;if(!i)return null;const n=t.getBoundingClientRect();return{center:i,offsetCenter:{x:(i.x-n.left-t.clientLeft)/(n.width/t.offsetWidth||1),y:(i.y-n.top-t.clientTop)/(n.height/t.offsetHeight||1)}}}const Tf={srcElement:"root",priority:0};class Sf{constructor(e){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let i=e.srcEvent.target;for(;i&&i!==t.rootElement;){if(this._emit(t,i),t.handled)return;i=i.parentNode}this._emit(t,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,n=!1,r=!1){const{handlers:s,handlersByElement:o}=this;let a=Tf;"string"==typeof i||i&&i.addEventListener?a={...Tf,srcElement:i}:i&&(a={...Tf,...i});let l=o.get(a.srcElement);l||(l=[],o.set(a.srcElement,l));const c={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};n&&(c.once=!0),r&&(c.passive=!0),s.push(c),this._active=this._active||!c.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=c.priority);)u--;l.splice(u+1,0,c)}remove(e,t){const{handlers:i,handlersByElement:n}=this;for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.type===e&&s.handler===t){i.splice(r,1);const e=n.get(s.srcElement);e.splice(e.indexOf(s),1),0===e.length&&n.delete(s.srcElement)}}this._active=i.some(e=>!e.passive)}_emit(e,t){const i=this.handlersByElement.get(t);if(i){let t=!1;const n=()=>{e.handled=!0},r=()=>{e.handled=!0,t=!0},s=[];for(let o=0;o<i.length;o++){const{type:a,handler:l,once:c}=i[o];if(l({...e,type:a,stopPropagation:n,stopImmediatePropagation:r}),c&&s.push(i[o]),t)break}for(let e=0;e<s.length;e++){const{type:t,handler:i}=s[e];this.remove(t,i)}}}_normalizeEvent(e){const t=this.eventManager.getElement();return{...e,...bf(e),...wf(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}const Ef={events:null,recognizers:null,recognizerOptions:{},Manager:Gp,touchAction:"none",tabIndex:0};class Af{constructor(e=null,t){this._onBasicInput=e=>{const{srcEvent:t}=e,i=$p[t.type];i&&this.manager.emit(i,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={...Ef,...t},this.events=new Map,this.setElement(e);const{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;const{options:t}=this;this.manager=new(0,t.Manager)(e,{touchAction:t.touchAction,recognizers:t.recognizers||Wp}).on("hammer.input",this._onBasicInput),t.recognizers||Object.keys(qp).forEach(e=>{const t=this.manager.get(e);t&&qp[e].forEach(e=>{t.recognizeWith(e)})});for(const e in t.recognizerOptions){const i=this.manager.get(e);if(i){const n=t.recognizerOptions[e];delete n.enable,i.set(n)}}this.wheelInput=new of(e,this._onOtherEvent,{enable:!1}),this.moveInput=new pf(e,this._onOtherEvent,{enable:!1}),this.keyInput=new _f(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new vf(e,this._onOtherEvent,{enable:!1});for(const[e,t]of this.events)t.isEmpty()||(this._toggleRecognizer(t.recognizerName,!0),this.manager.on(e,t.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,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){const{manager:i}=this;if(!i)return;const n=i.get(e);if(n&&n.options.enable!==t){n.set({enable:t});const r=Xp[e];r&&!this.options.recognizers&&r.forEach(r=>{const s=i.get(r);t?(s.requireFailure(e),n.dropRequireFailure(r)):s.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,t),this.moveInput.enableEventType(e,t),this.keyInput.enableEventType(e,t),this.contextmenuInput.enableEventType(e,t)}_addEventHandler(e,t,i,n,r){if("string"!=typeof e){i=t;for(const t in e)this._addEventHandler(t,e[t],i,n,r);return}const{manager:s,events:o}=this,a=Jp[e]||e;let l=o.get(a);l||(l=new Sf(this),o.set(a,l),l.recognizerName=Yp[a]||a,s&&s.on(a,l.handleEvent)),l.add(e,t,i,n,r),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const t in e)this._removeEventHandler(t,e[t]);return}const{events:i}=this,n=i.get(Jp[e]||e);if(n&&(n.remove(e,t),n.isEmpty())){const{recognizerName:e}=n;let t=!1;for(const n of i.values())if(n.recognizerName===e&&!n.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}}function Mf(){}const If={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,glOptions:{},parameters:{},parent:null,gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,onWebGLInitialized:Mf,onResize:Mf,onViewStateChange:Mf,onInteractionStateChange:Mf,onBeforeRender:Mf,onAfterRender:Mf,onLoad:Mf,onError:e=>{},onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class Cf{constructor(e){bt(this,"props",void 0),bt(this,"width",0),bt(this,"height",0),bt(this,"userData",{}),bt(this,"canvas",null),bt(this,"viewManager",null),bt(this,"layerManager",null),bt(this,"effectManager",null),bt(this,"deckRenderer",null),bt(this,"deckPicker",null),bt(this,"eventManager",null),bt(this,"tooltip",null),bt(this,"metrics",void 0),bt(this,"animationLoop",void 0),bt(this,"stats",void 0),bt(this,"viewState",void 0),bt(this,"cursorState",void 0),bt(this,"_needsRedraw",void 0),bt(this,"_pickRequest",void 0),bt(this,"_lastPointerDownInfo",null),bt(this,"_metricsCounter",void 0),bt(this,"_onPointerMove",e=>{const{_pickRequest:t}=this;if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0;else{if(e.leftButton||e.rightButton)return;{const i=e.offsetCenter;if(!i)return;t.x=i.x,t.y=i.y,t.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e}),bt(this,"_onEvent",e=>{const t=Kn[e.type],i=e.offsetCenter;if(!t||!i||!this.layerManager)return;const n=this.layerManager.getLayers(),r=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:n,viewports:this.getViewports(i)},this._lastPointerDownInfo),{layer:s}=r,o=s&&(s[t.handler]||s.props[t.handler]),a=this.props[t.handler];let l=!1;o&&(l=o.call(s,r,e)),!l&&a&&a(r,e)}),bt(this,"_onPointerDown",e=>{const t=e.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:t.x,y:t.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo}),this.props={...If,...e},e=this.props,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this.cursorState={isHovering:!1,isDragging:!1},e.viewState&&e.initialViewState&&Gn.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),"IE"===Ei()&&Gn.warn("IE 11 is not supported")(),this.viewState=e.initialViewState,e.gl||"undefined"!=typeof document&&(this.canvas=this._createCanvas(e)),this.animationLoop=this._createAnimationLoop(e),this.stats=new Yt({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.setProps(e),e._typedArrayManagerProps&&sd.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){var e,t,i,n,r,s,o,a,l;(null===(e=this.animationLoop)||void 0===e||e.stop(),this.animationLoop=null,this._lastPointerDownInfo=null,null===(t=this.layerManager)||void 0===t||t.finalize(),this.layerManager=null,null===(i=this.viewManager)||void 0===i||i.finalize(),this.viewManager=null,null===(n=this.effectManager)||void 0===n||n.finalize(),this.effectManager=null,null===(r=this.deckRenderer)||void 0===r||r.finalize(),this.deckRenderer=null,null===(s=this.deckPicker)||void 0===s||s.finalize(),this.deckPicker=null,null===(o=this.eventManager)||void 0===o||o.destroy(),this.eventManager=null,null===(a=this.tooltip)||void 0===a||a.remove(),this.tooltip=null,this.props.canvas||this.props.gl||!this.canvas)||(null===(l=this.canvas.parentElement)||void 0===l||l.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&Gn.removed("onLayerHover","onHover")(),"onLayerClick"in e&&Gn.removed("onLayerClick","onClick")(),e.initialViewState&&!$d(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);const t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop.setProps(t),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const i=this.viewManager.needsRedraw(e),n=this.layerManager.needsRedraw(e),r=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return t=t||i||n||r||s,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return null!==this.viewManager}getViews(){return Qd(this.viewManager),this.viewManager.views}getViewports(e){return Qd(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){const t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[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,t=!1){for(const i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(const t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_pick(e,t,i){Qd(this.deckPicker);const{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(t).timeStart();const r=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(t).timeEnd(),r}_createCanvas(e){let t=e.canvas;if("string"==typeof t&&(t=document.getElementById(t),Qd(t)),!t){t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay";(e.parent||document.body).appendChild(t)}return Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;const{width:t,height:i}=e;if(t||0===t){const e=Number.isFinite(t)?"".concat(t,"px"):t;this.canvas.style.width=e}if(i||0===i){var n;const t=Number.isFinite(i)?"".concat(i,"px"):i;this.canvas.style.position=(null===(n=e.style)||void 0===n?void 0:n.position)||"absolute",this.canvas.style.height=t}}_updateCanvasSize(){var e,t;const{canvas:i}=this;if(!i)return;const n=null!==(e=i.clientWidth)&&void 0!==e?e:i.width,r=null!==(t=i.clientHeight)&&void 0!==t?t:i.height;var s,o;n===this.width&&r===this.height||(this.width=n,this.height=r,null===(s=this.viewManager)||void 0===s||s.setProps({width:n,height:r}),null===(o=this.layerManager)||void 0===o||o.activateViewport(this.getViewports()[0]),this.props.onResize({width:n,height:r}))}_createAnimationLoop(e){const{width:t,height:i,gl:n,glOptions:r,debug:s,onError:o,onBeforeRender:a,onAfterRender:l,useDevicePixels:c}=e;return new za({width:t,height:i,useDevicePixels:c,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,gl:n,onCreateContext:e=>Qr({...r,...e,canvas:this.canvas,debug:s,onContextLost:()=>this._onContextLost()}),onInitialize:e=>this._setGLContext(e.gl),onRender:this._onRenderFrame.bind(this),onBeforeRender:a,onAfterRender:l,onError:o})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let e=this.props.views||[new Ep({id:"default-view"})];return e=Array.isArray(e)?e:[e],e.length&&this.props.controller&&(e[0].props.controller=this.props.controller),e}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:e}=this;if(e.event){const{result:i,emptyInfo:n}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=i.length>0;let r=n,s=!1;for(const n of i){var t;r=n,s=(null===(t=n.layer)||void 0===t?void 0:t.onHover(n,e.event))||s}if(!s&&this.props.onHover&&this.props.onHover(r,e.event),this.props.getTooltip&&this.tooltip){const e=this.props.getTooltip(r);this.tooltip.setTooltip(e,r.x,r.y)}e.event=null}}_updateCursor(){const e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setGLContext(e){if(this.layerManager)return;this.canvas||(this.canvas=e.canvas,es(e,{enable:!0,copyState:!0})),this.tooltip=new Np(this.canvas),Hr(e,{blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onWebGLInitialized(e);const t=new Xu;t.play(),this.animationLoop.attachTimeline(t),this.eventManager=new Af(this.props.parent||e.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const e in Kn)this.eventManager.on(e,this._onEvent);this.viewManager=new Zd({timeline:t,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});const i=this.viewManager.getViewports()[0];this.layerManager=new Xd(e,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Mp,this.deckRenderer=new Cp(e),this.deckPicker=new Bp(e),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){const{gl:i}=this.layerManager.context;Hr(i,this.props.parameters),this.props.onBeforeRender({gl:i}),this.deckRenderer.renderLayers({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(),...t}),this.props.onAfterRender({gl:i})}_onRenderFrame(e){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),Gn.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.tooltip.isVisible&&this.viewManager.needsRedraw()&&this.tooltip.setTooltip(null),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();const i=ns.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}}bt(Cf,"defaultProps",If),bt(Cf,"VERSION",$n);class Pf{constructor(e,t){bt(this,"opts",void 0),bt(this,"source",void 0),this.opts=t,this.source=e}get value(){return this.source.value}getValue(){const e=this.source.getBuffer(),t=this.getAccessor();if(e)return[e,t];const{value:i}=this.source,{size:n}=t;let r=i;if(i&&i.length!==n){r=new Float32Array(n);const e=t.elementOffset||0;for(let t=0;t<n;++t)r[t]=i[e+t]}return r}getAccessor(){return{...this.source.getAccessor(),...this.opts}}}function Lf(e){return e.stride||e.size*e.bytesPerElement}function Rf(e,t){t.offset&&Gn.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=Lf(e),n=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*i+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:n,stride:i}}class Of{constructor(e,t,i){bt(this,"gl",void 0),bt(this,"id",void 0),bt(this,"size",void 0),bt(this,"settings",void 0),bt(this,"value",void 0),bt(this,"doublePrecision",void 0),bt(this,"_buffer",void 0),bt(this,"state",void 0),this.gl=e,this.id=t.id||"",this.size=t.size||1;const n=t.logicalType||t.type,r=5130===n;let s,{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0),s=r?5126:!n&&t.isIndexed?e&&fo(e,Zs)?5125:5123:n||5126;let a=function(e){switch(e){case 5126:return Float32Array;case 5130:return Float64Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return Uint8ClampedArray;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Unknown GL type")}}(n||s||5126);this.doublePrecision=r,r&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:o,logicalType:n,type:s,size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1},this._buffer=null}get isConstant(){return this.state.constant}get buffer(){if(!this._buffer){const{isIndexed:e,type:t}=this.settings;this._buffer=new Ss(this.gl,{id:this.id,target:e?34963:34962,accessor:{type:t}})}return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Lf(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),sd.release(this.state.allocatedValue)}getShaderAttributes(e,t){if(this.doublePrecision){const i={},n=this.value instanceof Float64Array,r=function(e,t){const i=Rf(e,t);return{high:i,low:{...i,offset:i.offset+4*e.size}}}(this.getAccessor(),t||{});return i[e]=new Pf(this,r.high),i["".concat(e,"64Low")]=n?new Pf(this,r.low):new Float32Array(this.size),i}if(t){const i=Rf(this.getAccessor(),t);return{[e]:new Pf(this,i)}}return{[e]:this}}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(){return this.state.constant?this.value:[this.getBuffer(),this.getAccessor()]}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:i,size:n}=this,r=i*n;if(t&&r&&t.length>=r){const i=new Array(n).fill(1/0),s=new Array(n).fill(-1/0);for(let e=0;e<r;)for(let r=0;r<n;r++){const n=t[e++];n<i[r]&&(i[r]=n),n>s[r]&&(s[r]=n)}e=[i,s]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let i;i=ArrayBuffer.isView(e)?{value:e}:e instanceof Ss?{buffer:e}:e;const n={...this.settings,...i};if(t.bufferAccessor=n,t.bounds=null,i.constant){let e=i.value;e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e));if(!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=e}else if(i.buffer){const e=i.buffer;t.externalBuffer=e,t.constant=!1,this.value=i.value||null;const r=i.value instanceof Float64Array;n.type=i.type||e.accessor.type,n.bytesPerElement=e.accessor.BYTES_PER_ELEMENT*(r?2:1),n.stride=Lf(n)}else if(i.value){this._checkExternalBuffer(i);let e=i.value;t.externalBuffer=null,t.constant=!1,this.value=e,n.bytesPerElement=e.BYTES_PER_ELEMENT,n.stride=Lf(n);const{buffer:r,byteOffset:s}=this;this.doublePrecision&&e instanceof Float64Array&&(e=ud(e,n));const o=e.byteLength+s+2*n.stride;r.byteLength<o&&r.reallocate(o),r.setAccessor(null),r.subData({data:e,offset:s}),n.type=i.type||r.accessor.type}return!0}updateSubBuffer(e={}){this.state.bounds=null;const t=this.value,{startOffset:i=0,endOffset:n}=e;this.buffer.subData({data:this.doublePrecision&&t instanceof Float64Array?ud(t,{size:this.size,startIndex:i,endIndex:n}):t.subarray(i,n),offset:i*t.BYTES_PER_ELEMENT+this.byteOffset})}allocate(e,t=!1){const{state:i}=this,n=i.allocatedValue,r=sd.allocate(n,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=r;const{buffer:s,byteOffset:o}=this;return s.byteLength<r.byteLength+o&&(s.reallocate(r.byteLength+o),t&&n&&s.subData({data:n instanceof Float64Array?ud(n,this):n,offset:o})),i.allocatedValue=r,i.constant=!1,i.externalBuffer=null,i.bufferAccessor=this.settings,!0}_checkExternalBuffer(e){const{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error("Attribute ".concat(this.id," value is not TypedArray"));const i=this.settings.defaultType;let n=!1;if(this.doublePrecision&&(n=t.BYTES_PER_ELEMENT<4),n)throw new Error("Attribute ".concat(this.id," does not support ").concat(t.constructor.name));t instanceof i||!this.settings.normalized||"normalized"in e||Gn.warn("Attribute ".concat(this.id," is normalized"))()}normalizeConstant(e){switch(this.settings.type){case 5120:return new Float32Array(e).map(e=>(e+128)/255*2-1);case 5122:return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case 5121:return new Float32Array(e).map(e=>e/255);case 5123:return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,i){const{defaultValue:n,size:r}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let e=r;for(;--e>=0;)t[i+e]=n[e];return t}switch(r){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:n[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:n[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:n[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:n[0];break;default:let s=r;for(;--s>=0;)t[i+s]=Number.isFinite(e[s])?e[s]:n[s]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:i}=this;for(let n=0;n<i;n++)if(e[n]!==t[n])return!1;return!0}}const Df=[],Bf=[];function Ff(e,t=0,i=1/0){let n=Df;const r={index:-1,data:e,target:[]};return e?"function"==typeof e[Symbol.iterator]?n=e:e.length>0&&(Bf.length=e.length,n=Bf):n=Df,(t>0||Number.isFinite(i))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(t,i),r.index=t-1),{iterable:n,objectInfo:r}}function Nf(e){return e&&e[Symbol.asyncIterator]}function kf(e,t){const{size:i,stride:n,offset:r,startIndices:s,nested:o}=t,a=e.BYTES_PER_ELEMENT,l=n?n/a:i,c=r?r/a:0,u=Math.floor((e.length-c)/l);return(t,{index:n,target:r})=>{if(!s){const t=n*l+c;for(let n=0;n<i;n++)r[n]=e[t+n];return r}const a=s[n],h=s[n+1]||u;let d;if(o){d=new Array(h-a);for(let t=a;t<h;t++){const n=t*l+c;r=new Array(i);for(let t=0;t<i;t++)r[t]=e[n+t];d[t-a]=r}}else if(l===i)d=e.subarray(a*i+c,h*i+c);else{d=new e.constructor((h-a)*i);let t=0;for(let n=a;n<h;n++){const r=n*l+c;for(let n=0;n<i;n++)d[t++]=e[r+n]}}return d}}const zf=[],Uf=[[0,1/0]];function Vf(e){const{source:t,target:i,start:n=0,size:r,getData:s}=e,o=t.length,a=(e.end||i.length)-n;if(o>a)return void i.set(t.subarray(0,a),n);if(i.set(t,n),!s)return;let l=o;for(;l<a;){const e=s(l,t);for(let t=0;t<r;t++)i[n+l]=e[t]||0,l++}}const jf={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function Gf(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const i=e.type||"interpolation";return{...jf[i],...t,...e,type:i}}function Hf(e,t){const i=t.getBuffer();return i?[i,{divisor:0,size:t.size,normalized:t.settings.normalized}]:t.value}function Wf(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error('No defined attribute type for size "'.concat(e,'"'))}}function qf(e){e.push(e.shift())}function Xf(e,t){const{doublePrecision:i,settings:n,value:r,size:s}=e,o=i&&r instanceof Float64Array?2:1;return(n.noAlloc?r.length:t*s)*o}function $f({buffer:e,numInstances:t,attribute:i,fromLength:n,fromStartIndices:r,getData:s=e=>e}){const o=i.doublePrecision&&i.value instanceof Float64Array?2:1,a=i.size*o,l=i.byteOffset,c=i.startIndices,u=r&&c,h=Xf(i,t),d=i.isConstant;if(!u&&n>=h)return;const p=d?i.value:i.getBuffer().getData({srcByteOffset:l});if(i.settings.normalized&&!d){const e=s;s=(t,n)=>i.normalizeConstant(e(t,n))}const f=d?(e,t)=>s(p,t):(e,t)=>s(p.subarray(e,e+a),t),m=e.getData({length:n}),g=new Float32Array(h);!function({source:e,target:t,size:i,getData:n,sourceStartIndices:r,targetStartIndices:s}){if(!Array.isArray(s))return Vf({source:e,target:t,size:i,getData:n}),t;let o=0,a=0;const l=n&&((e,t)=>n(e+a,t)),c=Math.min(r.length,s.length);for(let n=1;n<c;n++){const c=r[n]*i,u=s[n]*i;Vf({source:e.subarray(o,c),target:t,start:a,end:u,size:i,getData:l}),o=c,a=u}a<t.length&&Vf({source:[],target:t,start:a,size:i,getData:l})}({source:m,target:g,sourceStartIndices:r,targetStartIndices:c,size:a,getData:f}),e.byteLength<g.byteLength+l&&e.reallocate(g.byteLength+l),e.subData({data:g,offset:l})}class Zf extends Of{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,updateRanges:Uf}),bt(this,"constant",!1),this.settings.update=t.update||(t.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}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,i=this.settings.transition,n=Array.isArray(t)?e[t.find(t=>e[t])]:e[t];return Gf(n,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:i=1/0}=t;this.state.updateRanges=function(e,t){if(e===Uf)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const i=[],n=e.length;let r=0;for(let s=0;s<n;s++){const n=e[s];n[1]<t[0]?(i.push(n),r=s+1):n[0]>t[1]?i.push(n):t=[Math.min(n[0],t[0]),Math.max(n[1],t[1])]}return i.splice(r,0,t),i}(this.state.updateRanges,[e,i])}else this.state.updateRanges=Uf}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=zf}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:i}=this;return!i.noAlloc&&(!!i.update&&(super.allocate(e,t.updateRanges!==Uf),!0))}updateBuffer({numInstances:e,data:t,props:i,context:n}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:s,noAlloc:o}}=this;let a=!0;if(s){for(const[o,a]of r)s.call(n,this,{data:t,startRow:o,endRow:a,props:i,numInstances:e});if(this.value)if(this.constant||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[t,i]of r){const n=Number.isFinite(t)?this.getVertexOffset(t):0,r=Number.isFinite(i)?this.getVertexOffset(i):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:n,endOffset:r})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(e){if(void 0===e||"function"==typeof e)return!1;return this.setData({constant:!0,value:e})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){const{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){const{state:i,settings:n}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(n.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;i.binaryValue=e,this.setNeedsRedraw();if(n.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const r=e;Qd(ArrayBuffer.isView(r.value),"invalid ".concat(n.accessor));const s=Boolean(r.size)&&r.size!==this.size;return i.binaryAccessor=kf(r.value,{size:r.size||this.size,stride:r.stride,offset:r.offset,startIndices:t,nested:s}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){const{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getShaderAttributes(){const e=this.settings.shaderAttributes||{[this.id]:null},t={};for(const i in e)Object.assign(t,super.getShaderAttributes(i,e[i]));return t}_autoUpdater(e,{data:t,startRow:i,endRow:n,props:r,numInstances:s}){if(e.constant)return;const{settings:o,state:a,value:l,size:c,startIndices:u}=e,{accessor:h,transform:d}=o,p=a.binaryAccessor||("function"==typeof h?h:r[h]);Qd("function"==typeof p,'accessor "'.concat(h,'" is not a function'));let f=e.getVertexOffset(i);const{iterable:m,objectInfo:g}=Ff(t,i,n);for(const t of m){g.index++;let i=p(t,g);if(d&&(i=d.call(this,i)),u){const t=(g.index<u.length-1?u[g.index+1]:s)-u[g.index];if(i&&Array.isArray(i[0])){let t=f;for(const n of i)e._normalizeValue(n,l,t),t+=c}else i&&i.length>c?l.set(i,f):(e._normalizeValue(i,g.target,0),zd({target:l,source:g.target,start:f,count:t}));f+=t*c}else e._normalizeValue(i,l,f),f+=c}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||"function"==typeof e.update))throw new Error("Attribute ".concat(this.id," missing update or accessor"))}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){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 ".concat(this.id))}}}const Yf="\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nuniform float time;\nattribute ATTRIBUTE_TYPE aFrom;\nattribute ATTRIBUTE_TYPE aTo;\nvarying ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n  vCurrent = mix(aFrom, aTo, time);\n  gl_Position = vec4(0.0);\n}\n";const Jf={interpolation:class{constructor({gl:e,attribute:t,timeline:i}){bt(this,"gl",void 0),bt(this,"type","interpolation"),bt(this,"attributeInTransition",void 0),bt(this,"settings",void 0),bt(this,"attribute",void 0),bt(this,"transition",void 0),bt(this,"currentStartIndices",void 0),bt(this,"currentLength",void 0),bt(this,"transform",void 0),bt(this,"buffers",void 0),this.gl=e,this.transition=new tp(i),this.attribute=t,this.attributeInTransition=new Zf(e,t.settings),this.currentStartIndices=t.startIndices,this.currentLength=0,this.transform=function(e,t){const i=Wf(t.size);return new ju(e,{vs:Yf,defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"]})}(e,t);const n={byteLength:0,usage:35050};this.buffers=[new Ss(e,n),new Ss(e,n)]}get inProgress(){return this.transition.inProgress}start(e,t){if(e.duration<=0)return void this.transition.cancel();this.settings=e;const{gl:i,buffers:n,attribute:r}=this;qf(n);const s={numInstances:t,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:e.enter};for(const e of n)$f({buffer:e,...s});this.currentStartIndices=r.startIndices,this.currentLength=Xf(r,t),this.attributeInTransition.setData({buffer:n[1],value:r.value}),this.transition.start(e),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aFrom:n[0],aTo:Hf(0,r)},feedbackBuffers:{vCurrent:n[1]}})}update(){const e=this.transition.update();if(e){const{duration:e,easing:t}=this.settings,{time:i}=this.transition;let n=i/e;t&&(n=t(n)),this.transform.run({uniforms:{time:n}})}return e}cancel(){this.transition.cancel(),this.transform.delete();for(const e of this.buffers)e.delete();this.buffers.length=0}},spring:class{constructor({gl:e,attribute:t,timeline:i}){bt(this,"gl",void 0),bt(this,"type","spring"),bt(this,"attributeInTransition",void 0),bt(this,"settings",void 0),bt(this,"attribute",void 0),bt(this,"transition",void 0),bt(this,"currentStartIndices",void 0),bt(this,"currentLength",void 0),bt(this,"texture",void 0),bt(this,"framebuffer",void 0),bt(this,"transform",void 0),bt(this,"buffers",void 0),this.gl=e,this.type="spring",this.transition=new tp(i),this.attribute=t,this.attributeInTransition=new Zf(e,{...t.settings,normalized:!1}),this.currentStartIndices=t.startIndices,this.currentLength=0,this.texture=function(e){return new Ls(e,{data:new Uint8Array(4),format:6408,type:5121,border:0,mipmaps:!1,dataFormat:6408,width:1,height:1})}(e),this.framebuffer=function(e,t){return new yo(e,{id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,attachments:{36064:t}})}(e,this.texture),this.transform=function(e,t,i){const n=Wf(t.size);return new ju(e,{framebuffer:i,vs:"\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nuniform float stiffness;\nuniform float damping;\nattribute ATTRIBUTE_TYPE aPrev;\nattribute ATTRIBUTE_TYPE aCur;\nattribute ATTRIBUTE_TYPE aTo;\nvarying ATTRIBUTE_TYPE vNext;\nvarying float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n  ATTRIBUTE_TYPE velocity = cur - prev;\n  ATTRIBUTE_TYPE delta = dest - cur;\n  ATTRIBUTE_TYPE spring = delta * stiffness;\n  ATTRIBUTE_TYPE damper = velocity * -1.0 * damping;\n  return spring + damper + velocity + cur;\n}\n\nvoid main(void) {\n  bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n  vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n  vNext = getNextValue(aCur, aPrev, aTo);\n  gl_Position = vec4(0, 0, 0, 1);\n  gl_PointSize = 100.0;\n}\n",fs:"\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nvarying float vIsTransitioningFlag;\n\nvoid main(void) {\n  if (vIsTransitioningFlag == 0.0) {\n    discard;\n  }\n  gl_FragColor = vec4(1.0);\n}",defines:{ATTRIBUTE_TYPE:n},varyings:["vNext"]})}(e,t,this.framebuffer);const n={byteLength:0,usage:35050};this.buffers=[new Ss(e,n),new Ss(e,n),new Ss(e,n)]}get inProgress(){return this.transition.inProgress}start(e,t){const{gl:i,buffers:n,attribute:r}=this,s={numInstances:t,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:e.enter};for(const e of n)$f({buffer:e,...s});this.settings=e,this.currentStartIndices=r.startIndices,this.currentLength=Xf(r,t),this.attributeInTransition.setData({buffer:n[1],value:r.value}),this.transition.start({...e,duration:1/0}),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aTo:Hf(0,r)}})}update(){const{buffers:e,transform:t,framebuffer:i,transition:n}=this;if(!n.update())return!1;const r=this.settings;t.update({sourceBuffers:{aPrev:e[0],aCur:e[1]},feedbackBuffers:{vNext:e[2]}}),t.run({framebuffer:i,discard:!1,clearRenderTarget:!0,uniforms:{stiffness:r.stiffness,damping:r.damping},parameters:{depthTest:!1,blend:!0,viewport:[0,0,1,1],blendFunc:[1,1],blendEquation:[32776,32776]}}),qf(e),this.attributeInTransition.setData({buffer:e[1],value:this.attribute.value});return Vs(i)[0]>0||n.end(),!0}cancel(){this.transition.cancel(),this.transform.delete();for(const e of this.buffers)e.delete();this.buffers.length=0,this.texture.delete(),this.framebuffer.delete()}}};class Kf{constructor(e,{id:t,timeline:i}){bt(this,"id",void 0),bt(this,"isSupported",void 0),bt(this,"gl",void 0),bt(this,"timeline",void 0),bt(this,"transitions",void 0),bt(this,"needsRedraw",void 0),bt(this,"numInstances",void 0),this.id=t,this.gl=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1,this.isSupported=ju.isSupported(e)}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(const i in e){const n=e[i],r=n.getTransitionSetting(t);r&&this._updateAttribute(i,n,r)}for(const i in this.transitions){const n=e[i];n&&n.getTransitionSetting(t)||this._removeTransition(i)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(!this.isSupported||0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].cancel(),delete this.transitions[e]}_updateAttribute(e,t,i){const n=this.transitions[e];let r=!n||n.type!==i.type;if(r){if(!this.isSupported)return void Gn.warn("WebGL2 not supported by this browser. Transition for ".concat(e," is disabled."))();n&&this._removeTransition(e);const s=Jf[i.type];s?this.transitions[e]=new s({attribute:t,timeline:this.timeline,gl:this.gl}):(("unsupported transition type '".concat(i.type,"'"),()=>{})(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}}const Qf="attributeManager.invalidate";class em{constructor(e,{id:t="attribute-manager",stats:i,timeline:n}={}){bt(this,"id",void 0),bt(this,"gl",void 0),bt(this,"attributes",void 0),bt(this,"updateTriggers",void 0),bt(this,"needsRedraw",void 0),bt(this,"userData",void 0),bt(this,"stats",void 0),bt(this,"attributeTransitionManager",void 0),bt(this,"mergeBoundsMemoized",fh(hd)),this.id=t,this.gl=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Kf(e,{id:"".concat(t,"-transitions"),timeline:n}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{instanced:1})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const i=this._invalidateTrigger(e,t);qn(Qf,this,e,i)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);qn(Qf,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:n,props:r={},buffers:s={},context:o={}}){let a=!1;qn("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const n in this.attributes){const l=this.attributes[n],c=l.settings.accessor;l.startIndices=i,l.numInstances=t,r[n]&&Gn.removed("props.".concat(n),"data.attributes.".concat(n))(),l.setExternalBuffer(s[n])||l.setBinaryValue("string"==typeof c?s[c]:void 0,e.startIndices)||"string"==typeof c&&!s[c]&&l.setConstantValue(r[c])||l.needsUpdate()&&(a=!0,this._updateAttribute({attribute:l,numInstances:t,data:e,props:r,context:o})),this.needsRedraw=this.needsRedraw||l.needsRedraw()}a&&qn("attributeManager.updateEnd",this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:n})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return this.attributes}getBounds(e){const t=e.map(e=>{var t;return null===(t=this.attributes[e])||void 0===t?void 0:t.getBounds()});return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:i}=this,n={...i.getAttributes()};for(const r in t){const s=t[r];s.needsRedraw(e)&&!i.hasAttribute(r)&&(n[r]=s)}return n}getShaderAttributes(e,t={}){e||(e=this.getAttributes());const i={};for(const n in e)t[n]||Object.assign(i,e[n].getShaderAttributes());return i}_add(e,t={}){for(const i in e){this.attributes[i]=this._createAttribute(i,e[i],t)}this._mapUpdateTriggersToAttributes()}_createAttribute(e,t,i){const n={...t,id:e,size:(t.isIndexed?1:t.size)||1,divisor:i.instanced?1:t.divisor||0};return new Zf(this.gl,n)}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes){this.attributes[t].getUpdateTriggers().forEach(i=>{e[i]||(e[i]=[]),e[i].push(t)})}this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:i,updateTriggers:n}=this,r=n[e];return r&&r.forEach(e=>{const n=i[e];n&&n.setNeedsUpdate(n.id,t)}),r}_updateAttribute(e){const{attribute:t,numInstances:i}=e;if(qn("attribute.updateStart",t),t.constant)return void t.setConstantValue(t.value);t.allocate(i)&&qn("attribute.allocate",t,i);t.updateBuffer(e)&&(this.needsRedraw=!0,qn("attribute.updateEnd",t,i))}}const tm=1e-5;function im(e,t,i,n,r){const s=t-e;return(i-t)*r+-s*n+s+t}function nm(e,t){if(Array.isArray(e)){let i=0;for(let n=0;n<e.length;n++){const r=e[n]-t[n];i+=r*r}return Math.sqrt(i)}return Math.abs(e-t)}const rm={interpolation:class extends tp{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:t,toValue:i,duration:n,easing:r}}=this,s=r(e/n);this._value=Ul(t,i,s)}},spring:class extends tp{get value(){return this._currValue}_onUpdate(){const{fromValue:e,toValue:t,damping:i,stiffness:n}=this.settings,{_prevValue:r=e,_currValue:s=e}=this;let o=function(e,t,i,n,r){if(Array.isArray(i)){const s=[];for(let o=0;o<i.length;o++)s[o]=im(e[o],t[o],i[o],n,r);return s}return im(e,t,i,n,r)}(r,s,t,i,n);const a=nm(o,t),l=nm(o,s);a<tm&&l<tm&&(o=t,this.end()),this._prevValue=s,this._currValue=o}}};class sm{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,i,n){const{transitions:r}=this;if(r.has(e)){const i=r.get(e),{value:n=i.settings.fromValue}=i;t=n,this.remove(e)}if(!(n=Gf(n)))return;const s=rm[n.type];if(!s)return void("unsupported transition type '".concat(n.type,"'"),()=>{})();const o=new s(this.timeline);o.start({...n,fromValue:t,toValue:i}),r.set(e,o)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function om(e,t){const i=lm({newProps:e,oldProps:t,propTypes:e[Rd],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=function(e,t){if(null===t)return"oldProps is null, initial diff";let i=!1;const{dataComparator:n,_dataDiff:r}=e;n?n(e.data,t.data)||(i="Data comparator detected a change"):e.data!==t.data&&(i="A new data container was supplied");i&&r&&(i=r(e.data,t.data)||i);return i}(e,t);let r=!1;return n||(r=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers){if(hm(e,t,"all"))return{all:!0}}const i={};let n=!1;for(const r in e.updateTriggers)if("all"!==r){hm(e,t,r)&&(i[r]=!0,n=!0)}return!!n&&i}(e,t)),{dataChanged:n,propsChanged:i,updateTriggersChanged:r,extensionsChanged:um(e,t),transitionsChanged:am(e,t)}}function am(e,t){if(!e.transitions)return!1;const i={},n=e[Rd];let r=!1;for(const s in e.transitions){const o=n[s],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&cm(e[s],t[s],o)&&(i[s]=!0,r=!0)}return!!r&&i}function lm({newProps:e,oldProps:t,ignoreProps:i={},propTypes:n={},triggerName:r="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return"".concat(r," changed shallowly");if("object"!=typeof t||null===t)return"".concat(r," changed shallowly");for(const s of Object.keys(e))if(!(s in i)){if(!(s in t))return"".concat(r,".").concat(s," added");const i=cm(e[s],t[s],n[s]);if(i)return"".concat(r,".").concat(s," ").concat(i)}for(const s of Object.keys(t))if(!(s in i)){if(!(s in e))return"".concat(r,".").concat(s," dropped");if(!Object.hasOwnProperty.call(e,s)){const i=cm(e[s],t[s],n[s]);if(i)return"".concat(r,".").concat(s," ").concat(i)}}return!1}function cm(e,t,i){let n=i&&i.equal;return n&&!n(e,t,i)?"changed deeply":n||(n=e&&t&&e.equals,!n||n.call(e,t))?n||t===e?null:"changed shallowly":"changed deeply"}function um(e,t){if(null===t)return!0;const i=t.extensions,{extensions:n}=e;if(n===i)return!1;if(!i||!n)return!0;if(n.length!==i.length)return!0;for(let e=0;e<n.length;e++)if(!n[e].equals(i[e]))return!0;return!1}function hm(e,t,i){let n=e.updateTriggers[i];n=null==n?{}:n;let r=t.updateTriggers[i];r=null==r?{}:r;return lm({oldProps:r,newProps:n,triggerName:i})}function dm(e){if(null===(t=e)||"object"!=typeof t)throw new Error("count(): argument not an object");var t;if("function"==typeof e.count)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(function(e){return null!==e&&"object"==typeof e&&e.constructor===Object}(e))return Object.keys(e).length;throw new Error("count(): argument not a container")}function pm(e,t){if(!t)return e;const i={...e,...t};if("defines"in t&&(i.defines={...e.defines,...t.defines}),"modules"in t&&(i.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>"project64"===e.name))){const e=i.modules.findIndex(e=>"project32"===e.name);e>=0&&i.modules.splice(e,1)}if("inject"in t)if(e.inject){const n={...e.inject};for(const e in t.inject)n[e]=(n[e]||"")+t.inject[e];i.inject=n}else i.inject=t.inject;return i}const fm={10241:9987,10240:9729,10242:33071,10243:33071},mm={};const gm={boolean:{validate:(e,t)=>!0,equal:(e,t,i)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||vm(e)&&(3===e.length||4===e.length),equal:(e,t,i)=>$d(e,t,1)},accessor:{validate(e,t){const i=xm(e);return"function"===i||i===xm(t.value)},equal:(e,t,i)=>"function"==typeof t||$d(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||vm(e),equal(e,t,i){const{compare:n}=i,r=Number.isInteger(n)?n:n?1:0;return n?$d(e,t,r):e===t}},object:{equal(e,t,i){if(i.ignore)return!0;const{compare:n}=i,r=Number.isInteger(n)?n:n?1:0;return n?$d(e,t,r):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,i)=>!i.compare&&!1!==i.ignore||e===t},data:{transform:(e,t,i)=>{const{dataTransform:n}=i.props;return n&&e?n(e):e}},image:{transform:(e,t,i)=>{const n=i.context;return n&&n.gl?function(e,t,i,n){if(i instanceof Ls)return i;i.constructor&&"Object"!==i.constructor.name&&(i={data:i});let r=null;i.compressed&&(r={10241:i.data.length>1?9985:9729});const s=new Ls(t,{...i,parameters:{...fm,...r,...n}});return mm[s.id]=e,s}(i.id,n.gl,e,{...t.parameters,...i.props.textureParameters}):null},release:(e,t,i)=>{var n,r;n=i.id,(r=e)&&r instanceof Ls&&mm[r.id]===n&&(r.delete(),delete mm[r.id])}}};function _m(e,t){switch(xm(t)){case"object":return ym(e,t);case"array":return ym(e,{type:"array",value:t,compare:!1});case"boolean":return ym(e,{type:"boolean",value:t});case"number":return ym(e,{type:"number",value:t});case"function":return ym(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function ym(e,t){return"type"in t?{name:e,...gm[t.type],...t}:"value"in t?{name:e,type:xm(t.value),...t}:{name:e,type:"object",value:t}}function vm(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function xm(e){return vm(e)?"array":null===e?"null":typeof e}const bm="_mergedDefaultProps";function wm(e,t){let i=bm;if(t)for(const e of t){const t=e.constructor;t&&(i+=":".concat(t.extensionName||t.name))}const n=Em(e,i);return n||(e[i]=function(e,t){const i=e.prototype;if(!i)return null;const n=Object.getPrototypeOf(e),r=wm(n),s=Em(e,"defaultProps")||{},o=function(e){const t={},i={},n={};for(const[r,s]of Object.entries(e)){const e=null==s?void 0:s.deprecatedFor;if(e)n[r]=Array.isArray(e)?e:[e];else{const e=_m(r,s);t[r]=e,i[r]=e.value}}return{propTypes:t,defaultProps:i,deprecatedProps:n}}(s),a=Object.assign(Object.create(null),r,o.defaultProps),l=Object.assign(Object.create(null),null==r?void 0:r[Rd],o.propTypes),c=Object.assign(Object.create(null),null==r?void 0:r[Od],o.deprecatedProps);for(const e of t){const t=wm(e.constructor);t&&(Object.assign(a,t),Object.assign(l,t[Rd]),Object.assign(c,t[Od]))}(function(e,t){const i=function(e){const t=e.componentName;t||Gn.warn("".concat(e.name,".componentName not specified"))();return t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:i}})})(a,e),function(e,t){const i={},n={};for(const e in t){const r=t[e],{name:s,value:o}=r;r.async&&(i[s]=o,n[s]=Tm(s))}e[Dd]=i,e[Bd]={},Object.defineProperties(e,n)}(a,l),function(e,t){for(const i in t)Object.defineProperty(e,i,{enumerable:!1,set(e){const n="".concat(this.id,": ").concat(i);for(const n of t[i])Sm(this,n)||(this[n]=e);Gn.deprecated(n,t[i].join("/"))()}})}(a,c),a[Rd]=l,a[Od]=c,0!==t.length||Sm(e,"_propTypes")||(e._propTypes=l);return a}(e,t||[]))}function Tm(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||Nf(t)?this[Bd][e]=t:this[Fd][e]=t},get(){if(this[Fd]){if(e in this[Fd]){return this[Fd][e]||this[Dd][e]}if(e in this[Bd]){const t=this[Ld]&&this[Ld].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[Dd][e]}}return this[Dd][e]}}}function Sm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Em(e,t){return Sm(e,t)&&e[t]}let Am=0;class Mm{constructor(...e){bt(this,"id",void 0),bt(this,"props",void 0),bt(this,"count",void 0),this.props=function(e,t){let i;for(let e=t.length-1;e>=0;e--){const n=t[e];"extensions"in n&&(i=n.extensions)}const n=wm(e.constructor,i),r=Object.create(n);r[Ld]=e,r[Bd]={},r[Fd]={};for(let e=0;e<t.length;++e){const i=t[e];for(const e in i)r[e]=i[e]}return Object.freeze(r),r}(this,e),this.id=this.props.id,this.count=Am++}clone(e){const{props:t}=this,i={};for(const e in t[Dd])e in t[Fd]?i[e]=t[Fd][e]:e in t[Bd]&&(i[e]=t[Bd][e]);return new this.constructor({...t,...i,...e})}}bt(Mm,"componentName","Component"),bt(Mm,"defaultProps",{});const Im=Object.freeze({});class Cm{constructor(e){bt(this,"component",void 0),bt(this,"onAsyncPropUpdated",void 0),bt(this,"asyncProps",void 0),bt(this,"oldProps",void 0),bt(this,"oldAsyncProps",void 0),this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||Im}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Ld]||this.component;const t=e[Fd]||{},i=e[Bd]||e,n=e[Dd]||{};for(const e in t){const i=t[e];this._createAsyncPropData(e,n[e]),this._updateAsyncProp(e,i),t[e]=this.getAsyncProp(e)}for(const e in i){const t=i[e];this._createAsyncPropData(e,n[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):Nf(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const i=this.asyncProps[e];return t!==i.resolvedValue&&t!==i.lastValue&&(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){const n=this.asyncProps[e];n&&i>=n.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),n.resolvedValue=t,n.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const i=this.asyncProps[e];if(i){i.pendingLoadCount++;const n=i.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(i,t),this._setAsyncPropValue(e,t,n),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;const n=i.pendingLoadCount;let r=[],s=0;for await(const i of t){if(!this.component)return;const{dataTransform:t}=this.component.props;r=t?t(i,r):r.concat(i),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:s,endRow:r.length}]}),s=r.length,this._setAsyncPropValue(e,r,n)}this._onResolve(e,r)}_postProcessValue(e,t){const i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const i=this.component&&this.component.props[Rd];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class Pm extends Cm{constructor({attributeManager:e,layer:t}){super(t),bt(this,"attributeManager",void 0),bt(this,"needsRedraw",void 0),bt(this,"needsUpdate",void 0),bt(this,"subLayers",void 0),bt(this,"usesPickingColorCache",void 0),bt(this,"hasPickingBuffer",void 0),bt(this,"changeFlags",void 0),bt(this,"viewport",void 0),bt(this,"uniformTransitions",void 0),bt(this,"propsInTransition",void 0),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){const i=this.layer,n=null==i?void 0:i.props.fetch;return n?n(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){const i=this.layer;if(i){const n=i.props.onDataLoad;"data"===e&&n&&n(t,{propName:e,layer:i})}}_onError(e,t){const i=this.layer;i&&i.raiseError(t,"loading ".concat(e," of ").concat(this.layer))}}const Lm=2**24-1,Rm=Object.freeze([]),Om=fh(({oldViewport:e,viewport:t})=>e.equals(t));let Dm=new Uint8ClampedArray(0);const Bm={data:{type:"data",value:Rm,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__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:(e,{propName:t,layer:i,loaders:n,loadOptions:r,signal:s})=>{const{resourceManager:o}=i.context;var a;(r=r||i.getLoadOptions(),n=n||i.props.loaders,s)&&(r={...r,fetch:{...null===(a=r)||void 0===a?void 0:a.fetch,signal:s}});let l=o.contains(e);return l||r||(o.add({resourceId:e,data:yn(e,n),persistent:!1}),l=!0),l?o.subscribe({resourceId:e,onChange:e=>{var n;return null===(n=i.internalState)||void 0===n?void 0:n.reloadAsyncProp(t,e)},consumerId:i.id,requestId:t}):yn(e,n,r)}},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:Zn.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:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class Fm extends Mm{constructor(...e){super(...e),bt(this,"internalState",null),bt(this,"lifecycle",Ed),bt(this,"context",void 0),bt(this,"state",void 0),bt(this,"parent",null)}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"".concat(this.constructor.layerName||this.constructor.name,"({id: '").concat(this.props.id,"'})")}project(e){Qd(this.internalState);const t=this.internalState.viewport||this.context.viewport,i=xd(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,r,s]=Wh(i,t.pixelProjectionMatrix);return 2===e.length?[n,r]:[n,r,s]}unproject(e){Qd(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){Qd(this.internalState);return bd(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}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()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){return this.state&&(this.state.models||this.state.model&&[this.state.model])||[]}setModuleParameters(e){for(const t of this.getModels())t.updateModuleSettings(e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return e===Zn.DEFAULT||e===Zn.LNGLAT||e===Zn.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){Qd(e instanceof Uint8Array);const[t,i,n]=e;return t+256*i+65536*n-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:dm(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var e;return null===(e=this.getAttributeManager())||void 0===e?void 0:e.getBounds(["positions","instancePositions"])}getShaders(e){for(const t of this.props.extensions)e=pm(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(const e of i)t.invalidateAll(e);else t.invalidateAll();if(t){const{props:i}=e,n=this.internalState.hasPickingBuffer,r=Number.isInteger(i.highlightedObjectIndex)||i.pickable||i.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(n!==r){this.internalState.hasPickingBuffer=r;const{pickingColors:e,instancePickingColors:i}=t.attributes,n=e||i;n&&(r&&n.constant&&(n.constant=!1,t.invalidate(n.id)),n.value||r||(n.constant=!0,n.value=[0,0,0]))}}}finalizeState(e){for(const e of this.getModels())e.delete();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e)}getPickingInfo({info:e}){const{index:t}=e;return t>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[t]),e}raiseError(e,t){var i,n,r,s;(t&&(e=new Error("".concat(t,": ").concat(e.message),{cause:e})),null!==(i=(n=this.props).onError)&&void 0!==i&&i.call(n,e))||(null===(r=this.context)||void 0===r||null===(s=r.onError)||void 0===s||s.call(r,e,this))}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){var e;return(null===(e=this.internalState)||void 0===e?void 0:e.uniformTransitions.active)||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&Om({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){for(const t of this.getModels())this._setModelAttributes(t,e)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,i=this.getNumInstances(),n=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:n,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),i=Object.create(this.props);for(const e in t)Object.defineProperty(i,e,{value:t[e]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const i=Math.floor(Dm.length/3);if(this.internalState.usesPickingColorCache=!0,i<t){t>Lm&&Gn.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Dm=sd.allocate(Dm,t,{size:3,copy:!0,maxCount:Math.max(t,Lm)});const e=Math.floor(Dm.length/3),n=[];for(let t=i;t<e;t++)this.encodePickingColor(t,n),Dm[3*t+0]=n[0],Dm[3*t+1]=n[1],Dm[3*t+2]=n[2]}e.value=Dm.subarray(0,3*t)}_setModelAttributes(e,t){const i=this.getAttributeManager().getShaderAttributes(t,e.userData.excludeAttributes||{});e.setAttributes(i)}disablePickingIndex(e){const t=this.props.data;if(!("attributes"in t))return void this._disablePickingIndex(e);const{pickingColors:i,instancePickingColors:n}=this.getAttributeManager().attributes,r=i||n,s=r&&t.attributes&&t.attributes[r.id];if(s&&s.value){const i=s.value,n=this.encodePickingColor(e);for(let e=0;e<t.length;e++){const t=r.getVertexOffset(e);i[t]===n[0]&&i[t+1]===n[1]&&i[t+2]===n[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){const{pickingColors:t,instancePickingColors:i}=this.getAttributeManager().attributes,n=t||i;if(!n)return;const r=n.getVertexOffset(e),s=n.getVertexOffset(e+1);n.buffer.subData({data:new Uint8Array(s-r),offset:r})}restorePickingColors(){const{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,i=e||t;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==Dm.buffer&&(i.value=Dm.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){Qd(!this.internalState),Qd(Number.isFinite(this.props.coordinateSystem)),qn("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:5121,size:3,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Pm({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(Gn.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new sm(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){qn("layer.matched",this,this===e);const{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(qn("layer.update",this,e),!e)return;const t=this.props,i=this.context,n=this.internalState,r=i.viewport,s=this._updateUniformTransition();n.propsInTransition=s,i.viewport=n.viewport||r,this.props=s;try{const e=this._getUpdateParams(),t=this.getModels();if(i.gl)this.updateState(e);else try{this.updateState(e)}catch(e){}for(const t of this.props.extensions)t.updateState.call(this,e,t);const n=this.getModels()[0]!==t[0];this._postUpdate(e,n)}finally{i.viewport=r,this.props=t,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){qn("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({moduleParameters:e=null,uniforms:t={},parameters:i={}}){this._updateAttributeTransition();const n=this.props,r=this.context;this.props=this.internalState.propsInTransition||n;t.opacity=Math.pow(this.props.opacity,1/2.2);try{e&&this.setModuleParameters(e);const{getPolygonOffset:n}=this.props,s=n&&n(t)||[0,0];Hr(r.gl,{polygonOffset:s}),Wr(r.gl,i,()=>{const n={moduleParameters:e,uniforms:t,parameters:i,context:r};for(const e of this.props.extensions)e.draw.call(this,n,e);this.draw(n)})}finally{this.props=n}}getChangeFlags(){var e;return null===(e=this.internalState)||void 0===e?void 0:e.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const i in e)if(e[i]){let n=!1;if("dataChanged"===i){const r=e[i],s=t[i];r&&Array.isArray(s)&&(t.dataChanged=Array.isArray(r)?s.concat(r):r,n=!0)}t[i]||(t[i]=e[i],n=!0),n&&qn("layer.changeFlag",this,i,e)}const i=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){const i=om(e,t);if(i.updateTriggersChanged)for(const e in i.updateTriggersChanged)i.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(i.transitionsChanged)for(const r in i.transitionsChanged){var n;this.internalState.uniformTransitions.add(r,t[r],e[r],null===(n=e.transitions)||void 0===n?void 0:n[r])}return this.setChangeFlags(i)}validateProps(){!function(e){const t=e[Rd];for(const i in t){const n=t[i],{validate:r}=n;if(r&&!r(e[i],n))throw new Error("Invalid prop ".concat(i,": ").concat(e[i]))}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={pickingSelectedColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&"function"==typeof i&&(t.pickingHighlightColor=i(e)),this.setModuleParameters(t),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new em(e.gl,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:i,oldProps:n}=e;this.setNeedsRedraw(),this._updateAttributes();const{model:r}=this.state;null==r||r.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:o,highlightColor:a}=i;if(t||n.autoHighlight!==s||n.highlightedObjectIndex!==o||n.highlightColor!==a){const e={};s||(e.pickingSelectedColor=null),Array.isArray(a)&&(e.pickingHighlightColor=a),(t||o!==n.highlightedObjectIndex)&&(e.pickingSelectedColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setModuleParameters(e)}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const i=this.getAttributeManager(),n=!!i&&i.getNeedsRedraw(e);if(t=t||n,t)for(const e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}bt(Fm,"defaultProps",Bm),bt(Fm,"layerName","Layer");class Nm extends Fm{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}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||t}getSubLayerRow(e,t,i){return e.__source={parent:this,object:t,index:i},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(i,n)=>i&&i.__source?(t.index=i.__source.index,e(i.__source.object,t)):e(i,n)}return e}getSubLayerProps(e={}){var t;const{opacity:i,pickable:n,visible:r,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:h,wrapLongitude:d,positionFormat:p,modelMatrix:f,extensions:m,fetch:g,operation:_,_subLayerProps:y}=this.props,v={id:"",updateTriggers:{},opacity:i,pickable:n,visible:r,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:h,wrapLongitude:d,positionFormat:p,modelMatrix:f,extensions:m,fetch:g,operation:_},x=y&&e.id&&y[e.id],b=x&&x.updateTriggers,w=e.id||"sublayer";if(x){const t=this.props[Rd],i=e.type?e.type._propTypes:{};for(const e in x){const n=i[e]||t[e];n&&"accessor"===n.type&&(x[e]=this.getSubLayerAccessor(x[e]))}}Object.assign(v,e,x),v.id="".concat(this.props.id,"-").concat(w),v.updateTriggers={all:null===(t=this.props.updateTriggers)||void 0===t?void 0:t.all,...e.updateTriggers,...b};for(const e of m){const t=e.getSubLayerProps.call(this,e);t&&Object.assign(v,t,{updateTriggers:Object.assign(v.updateTriggers,t.updateTriggers)})}return v}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let i=this.internalState.subLayers;const n=!i||this.needsUpdate();if(n){i=Nd(this.renderLayers(),Boolean),this.internalState.subLayers=i}qn("compositeLayer.renderLayers",this,n,i);for(const e of i)e.parent=this}}bt(Nm,"layerName","CompositeLayer");class km{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){bt(this,"opts",void 0),e&&(this.opts=e)}equals(e){return this===e||this.constructor===e.constructor&&$d(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){const{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(const e in t)if(e in this.props){const n=t[e],r=this.props[e];i[e]=r,n&&"accessor"===n.type&&(i.updateTriggers[e]=this.props.updateTriggers[e],"function"==typeof r&&(i[e]=this.getSubLayerAccessor(r)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}}bt(km,"defaultProps",{}),bt(km,"extensionName","LayerExtension");class zm{constructor(e){bt(this,"opts",void 0),bt(this,"typedArrayManager",void 0),bt(this,"indexStarts",[0]),bt(this,"vertexStarts",[0]),bt(this,"vertexCount",0),bt(this,"instanceCount",0),bt(this,"attributes",void 0),bt(this,"_attributeDefs",void 0),bt(this,"data",void 0),bt(this,"getGeometry",void 0),bt(this,"geometryBuffer",void 0),bt(this,"buffers",void 0),bt(this,"positionSize",void 0),bt(this,"normalize",void 0);const{attributes:t={}}=e;this.typedArrayManager=sd,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:i={},getGeometry:n,geometryBuffer:r,positionFormat:s,dataChanged:o,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=n,this.positionSize=r&&r.size||("XY"===s?2:3),this.buffers=i,this.normalize=a,r&&(Qd(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(i.positions=r)),this.geometryBuffer=i.positions,Array.isArray(o))for(const e of o)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){const t=e.value||e;return ArrayBuffer.isView(t)?kf(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:i,buffers:n,_attributeDefs:r,typedArrayManager:s}=this;for(const o in r)if(o in n)s.release(i[o]),i[o]=null;else{const n=r[o];n.copy=t,i[o]=s.allocate(i[o],e,n)}}_forEachGeometry(e,t,i){const{data:n,getGeometry:r}=this,{iterable:s,objectInfo:o}=Ff(n,t,i);for(const t of s){o.index++;e(r?r(t,o):null,o.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:n}=this;const{data:r,geometryBuffer:s}=this,{startRow:o=0,endRow:a=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!s)this._forEachGeometry((e,t)=>{const n=e&&this.normalizeGeometry(e);l[t]=n,i[t+1]=i[t]+(n?this.getGeometrySize(n):0)},o,a),n=i[i.length-1];else if(i=r.startIndices,n=i[r.length]||0,ArrayBuffer.isView(s))n=n||s.length/this.positionSize;else if(s instanceof Ss){n=n||s.byteLength/(s.accessor.stride||4*this.positionSize)}else if(s.buffer){n=n||s.buffer.byteLength/(s.stride||4*this.positionSize)}else if(s.value){const e=s.value;n=n||e.length/(s.stride/e.BYTES_PER_ELEMENT||this.positionSize)}this._allocate(n,Boolean(e)),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=n;const c={};this._forEachGeometry((e,r)=>{const s=l[r]||e;c.vertexStart=i[r],c.indexStart=t[r];c.geometrySize=(r<i.length-1?i[r+1]:n)-i[r],c.geometryIndex=r,this.updateGeometryAttributes(s,c)},o,a),this.vertexCount=t[t.length-1]}}function Um(e,t,i){if(e.deckPicker){const n=e.pickObject({x:i.x,y:i.y,layerIds:[t]});if(n)return n.object}}function Vm(e,t,i){const n=new Ju(t),r=new ih(i);e.setProps({effects:[new rd({ambientLight:n,directionalLight:r})]})}function jm(e){if(!e)throw new Error("coord is required");if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates;if(Array.isArray(e)&&e.length>=2&&void 0===e[0].length&&void 0===e[1].length)return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Gm(e){if(!e)throw new Error("coords is required");if("Feature"===e.type&&null!==e.geometry)return e.geometry.coordinates;if(e.coordinates)return e.coordinates;if(Array.isArray(e))return e;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Hm(e,t,i){if(!ye(i=i||{}))throw new Error("options is invalid");if(!0===i.final)return function(e,t){var i=Hm(t,e);return i=(i+180)%360}(e,t);var n=jm(e),r=jm(t),s=ge(n[0]),o=ge(r[0]),a=ge(n[1]),l=ge(r[1]),c=Math.sin(o-s)*Math.cos(l),u=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(o-s);return me(Math.atan2(c,u))}function Wm(e,t,i=0,n=e.length-1,r=Xm){for(;n>i;){if(n-i>600){const s=n-i+1,o=t-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Wm(e,t,Math.max(i,Math.floor(t-o*l/s+c)),Math.min(n,Math.floor(t+(s-o)*l/s+c)),r)}const s=e[t];let o=i,a=n;for(qm(e,i,t),r(e[n],s)>0&&qm(e,i,n);o<a;){for(qm(e,o,a),o++,a--;r(e[o],s)<0;)o++;for(;r(e[a],s)>0;)a--}0===r(e[i],s)?qm(e,i,a):(a++,qm(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function qm(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Xm(e,t){return e<t?-1:e>t?1:0}class $m{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!og(e,t))return i;const n=this.toBBox,r=[];for(;t;){for(let s=0;s<t.children.length;s++){const o=t.children[s],a=t.leaf?n(o):o;og(e,a)&&(t.leaf?i.push(o):sg(e,a)?this._all(o,i):r.push(o))}t=r.pop()}return i}collides(e){let t=this.data;if(!og(e,t))return!1;const i=[];for(;t;){for(let n=0;n<t.children.length;n++){const r=t.children[n],s=t.leaf?this.toBBox(r):r;if(og(e,s)){if(t.leaf||sg(e,s))return!0;i.push(r)}}t=i.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=ag([]),this}remove(e,t){if(!e)return this;let i=this.data;const n=this.toBBox(e),r=[],s=[];let o,a,l;for(;i||r.length;){if(i||(i=r.pop(),a=r[r.length-1],o=s.pop(),l=!0),i.leaf){const n=Zm(e,i.children,t);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}l||i.leaf||!sg(i,n)?a?(o++,i=a.children[o],l=!1):i=null:(r.push(i),s.push(o),o=0,a=i,i=i.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){const r=i-t+1;let s,o=this._maxEntries;if(r<=o)return s=ag(e.slice(t,i+1)),Ym(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),s=ag([]),s.leaf=!1,s.height=n;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));lg(e,t,i,l,this.compareMinX);for(let r=t;r<=i;r+=l){const t=Math.min(r+l-1,i);lg(e,r,t,a,this.compareMinY);for(let i=r;i<=t;i+=a){const r=Math.min(i+a-1,t);s.children.push(this._build(e,i,r,n-1))}}return Ym(s,this.toBBox),s}_chooseSubtree(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){let i,n=1/0,r=1/0;for(let s=0;s<t.children.length;s++){const o=t.children[s],a=tg(o),l=ng(e,o)-a;l<r?(r=l,n=a<n?a:n,i=o):l===r&&a<n&&(n=a,i=o)}t=i||t.children[0]}return t}_insert(e,t,i){const n=i?e:this.toBBox(e),r=[],s=this._chooseSubtree(n,this.data,t,r);for(s.children.push(e),Km(s,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)}_split(e,t){const i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),o=ag(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,Ym(i,this.toBBox),Ym(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(i,o)}_splitRoot(e,t){this.data=ag([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Ym(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,r=1/0,s=1/0;for(let o=t;o<=i-t;o++){const t=Jm(e,0,o,this.toBBox),a=Jm(e,o,i,this.toBBox),l=rg(t,a),c=tg(t)+tg(a);l<r?(r=l,n=o,s=c<s?c:s):l===r&&c<s&&(s=c,n=o)}return n||i-t}_chooseSplitAxis(e,t,i){const n=e.leaf?this.compareMinX:Qm,r=e.leaf?this.compareMinY:eg;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);const r=this.toBBox,s=Jm(e,0,t,r),o=Jm(e,i-t,i,r);let a=ig(s)+ig(o);for(let n=t;n<i-t;n++){const t=e.children[n];Km(s,e.leaf?r(t):t),a+=ig(s)}for(let n=i-t-1;n>=t;n--){const t=e.children[n];Km(o,e.leaf?r(t):t),a+=ig(o)}return a}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)Km(t[n],e)}_condense(e){for(let t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children,t.splice(t.indexOf(e[i]),1)):this.clear():Ym(e[i],this.toBBox)}}function Zm(e,t,i){if(!i)return t.indexOf(e);for(let n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function Ym(e,t){Jm(e,0,e.children.length,t,e)}function Jm(e,t,i,n,r){r||(r=ag(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<i;s++){const t=e.children[s];Km(r,e.leaf?n(t):t)}return r}function Km(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Qm(e,t){return e.minX-t.minX}function eg(e,t){return e.minY-t.minY}function tg(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ig(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ng(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function rg(e,t){const i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),s=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function sg(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function og(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function ag(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function lg(e,t,i,n,r){const s=[t,i];for(;s.length;){if((i=s.pop())-(t=s.pop())<=n)continue;const o=t+Math.ceil((i-t)/n/2)*n;Wm(e,o,t,i,r),s.push(t,o,o,i)}}class cg{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,s=t[r];if(i(n,s)>=0)break;t[e]=s,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1);const s=n+1;if(s<this.length&&i(t[s],t[n])<0&&(n=s),i(t[n],r)>=0)break;t[e]=t[n],e=n}t[e]=r}}var ug,hg,dg,pg,fg,mg={exports:{}};var gg=function(){if(fg)return mg.exports;fg=1;var e=(hg||(hg=1,ug=function(e,t,i,n){var r=e[0],s=e[1],o=!1;void 0===i&&(i=0),void 0===n&&(n=t.length);for(var a=(n-i)/2,l=0,c=a-1;l<a;c=l++){var u=t[i+2*l+0],h=t[i+2*l+1],d=t[i+2*c+1];h>s!=d>s&&r<(t[i+2*c+0]-u)*(s-h)/(d-h)+u&&(o=!o)}return o}),ug),t=(pg||(pg=1,dg=function(e,t,i,n){var r=e[0],s=e[1],o=!1;void 0===i&&(i=0),void 0===n&&(n=t.length);for(var a=n-i,l=0,c=a-1;l<a;c=l++){var u=t[l+i][0],h=t[l+i][1],d=t[c+i][1];h>s!=d>s&&r<(t[c+i][0]-u)*(s-h)/(d-h)+u&&(o=!o)}return o}),dg);return mg.exports=function(i,n,r,s){return n.length>0&&Array.isArray(n[0])?t(i,n,r,s):e(i,n,r,s)},mg.exports.nested=t,mg.exports.flat=e,mg.exports}(),_g=ne(gg);const yg=11102230246251565e-32,vg=134217729,xg=(3+8*yg)*yg;function bg(e,t,i,n,r){let s,o,a,l,c=t[0],u=n[0],h=0,d=0;u>c==u>-c?(s=c,c=t[++h]):(s=u,u=n[++d]);let p=0;if(h<e&&d<i)for(u>c==u>-c?(o=c+s,a=s-(o-c),c=t[++h]):(o=u+s,a=s-(o-u),u=n[++d]),s=o,0!==a&&(r[p++]=a);h<e&&d<i;)u>c==u>-c?(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=t[++h]):(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=n[++d]),s=o,0!==a&&(r[p++]=a);for(;h<e;)o=s+c,l=o-s,a=s-(o-l)+(c-l),c=t[++h],s=o,0!==a&&(r[p++]=a);for(;d<i;)o=s+u,l=o-s,a=s-(o-l)+(u-l),u=n[++d],s=o,0!==a&&(r[p++]=a);return 0===s&&0!==p||(r[p++]=s),p}function wg(e){return new Float64Array(e)}const Tg=wg(4),Sg=wg(8),Eg=wg(12),Ag=wg(16),Mg=wg(4);function Ig(e,t,i,n,r,s){const o=(t-s)*(i-r),a=(e-r)*(n-s),l=o-a,c=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,i,n,r,s,o){let a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,w,T,S;const E=e-r,A=i-r,M=t-s,I=n-s;x=E*I,d=vg*E,p=d-(d-E),f=E-p,d=vg*I,m=d-(d-I),g=I-m,b=f*g-(x-p*m-f*m-p*g),w=M*A,d=vg*M,p=d-(d-M),f=M-p,d=vg*A,m=d-(d-A),g=A-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,Tg[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,Tg[1]=v-(_+h)+(h-w),S=y+_,h=S-y,Tg[2]=y-(S-h)+(_-h),Tg[3]=S;let C=function(e,t){let i=t[0];for(let n=1;n<e;n++)i+=t[n];return i}(4,Tg),P=22204460492503146e-32*o;if(C>=P||-C>=P)return C;if(h=e-E,a=e-(E+h)+(h-r),h=i-A,c=i-(A+h)+(h-r),h=t-M,l=t-(M+h)+(h-s),h=n-I,u=n-(I+h)+(h-s),0===a&&0===l&&0===c&&0===u)return C;if(P=11093356479670487e-47*o+xg*Math.abs(C),C+=E*u+I*a-(M*c+A*l),C>=P||-C>=P)return C;x=a*I,d=vg*a,p=d-(d-a),f=a-p,d=vg*I,m=d-(d-I),g=I-m,b=f*g-(x-p*m-f*m-p*g),w=l*A,d=vg*l,p=d-(d-l),f=l-p,d=vg*A,m=d-(d-A),g=A-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,Mg[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,Mg[1]=v-(_+h)+(h-w),S=y+_,h=S-y,Mg[2]=y-(S-h)+(_-h),Mg[3]=S;const L=bg(4,Tg,4,Mg,Sg);x=E*u,d=vg*E,p=d-(d-E),f=E-p,d=vg*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=M*c,d=vg*M,p=d-(d-M),f=M-p,d=vg*c,m=d-(d-c),g=c-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,Mg[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,Mg[1]=v-(_+h)+(h-w),S=y+_,h=S-y,Mg[2]=y-(S-h)+(_-h),Mg[3]=S;const R=bg(L,Sg,4,Mg,Eg);x=a*u,d=vg*a,p=d-(d-a),f=a-p,d=vg*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=l*c,d=vg*l,p=d-(d-l),f=l-p,d=vg*c,m=d-(d-c),g=c-m,T=f*g-(w-p*m-f*m-p*g),_=b-T,h=b-_,Mg[0]=b-(_+h)+(h-T),y=x+_,h=y-x,v=x-(y-h)+(_-h),_=v-w,h=v-_,Mg[1]=v-(_+h)+(h-w),S=y+_,h=S-y,Mg[2]=y-(S-h)+(_-h),Mg[3]=S;const O=bg(R,Eg,4,Mg,Ag);return Ag[O-1]}(e,t,i,n,r,s,c)}function Cg(e,t,i){t=Math.max(0,void 0===t?2:t),i=i||0;const n=function(e){let t=e[0],i=e[0],n=e[0],r=e[0];for(let s=0;s<e.length;s++){const o=e[s];o[0]<t[0]&&(t=o),o[0]>n[0]&&(n=o),o[1]<i[1]&&(i=o),o[1]>r[1]&&(r=o)}const s=[t,i,n,r],o=s.slice();for(let t=0;t<e.length;t++)_g(e[t],s)||o.push(e[t]);return function(e){e.sort(jg);const t=[];for(let i=0;i<e.length;i++){for(;t.length>=2&&Bg(t[t.length-2],t[t.length-1],e[i])<=0;)t.pop();t.push(e[i])}const i=[];for(let t=e.length-1;t>=0;t--){for(;i.length>=2&&Bg(i[i.length-2],i[i.length-1],e[t])<=0;)i.pop();i.push(e[t])}return i.pop(),t.pop(),t.concat(i)}(o)}(e),r=new $m(16);r.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},r.compareMinX=function(e,t){return e[0]-t[0]},r.compareMinY=function(e,t){return e[1]-t[1]},r.load(e);const s=[];let o;for(let e=0;e<n.length;e++){const t=n[e];r.remove(t),o=kg(t,o),s.push(o)}const a=new $m(16);for(let e=0;e<s.length;e++)a.insert(Ng(s[e]));const l=t*t,c=i*i;for(;s.length;){const e=s.shift(),t=e.p,i=e.next.p,n=zg(t,i);if(n<c)continue;const o=n/l,u=Pg(r,e.prev.p,t,i,e.next.next.p,o,a);u&&Math.min(zg(u,t),zg(u,i))<=o&&(s.push(e),s.push(kg(u,e)),r.remove(u),a.remove(e),a.insert(Ng(e)),a.insert(Ng(e.next)))}let u=o;const h=[];do{h.push(u.p),u=u.next}while(u!==o);return h.push(u.p),h}function Pg(e,t,i,n,r,s,o){const a=new cg([],Lg);let l=e.data;for(;l;){for(let e=0;e<l.children.length;e++){const t=l.children[e],r=l.leaf?Ug(t,i,n):Rg(i,n,t);r>s||a.push({node:t,dist:r})}for(;a.length&&!a.peek().node.children;){const e=a.pop(),s=e.node,l=Ug(s,t,i),c=Ug(s,n,r);if(e.dist<l&&e.dist<c&&Dg(i,s,o)&&Dg(n,s,o))return s}l=a.pop(),l&&(l=l.node)}return null}function Lg(e,t){return e.dist-t.dist}function Rg(e,t,i){if(Og(e,i)||Og(t,i))return 0;const n=Vg(e[0],e[1],t[0],t[1],i.minX,i.minY,i.maxX,i.minY);if(0===n)return 0;const r=Vg(e[0],e[1],t[0],t[1],i.minX,i.minY,i.minX,i.maxY);if(0===r)return 0;const s=Vg(e[0],e[1],t[0],t[1],i.maxX,i.minY,i.maxX,i.maxY);if(0===s)return 0;const o=Vg(e[0],e[1],t[0],t[1],i.minX,i.maxY,i.maxX,i.maxY);return 0===o?0:Math.min(n,r,s,o)}function Og(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function Dg(e,t,i){const n=Math.min(e[0],t[0]),r=Math.min(e[1],t[1]),s=Math.max(e[0],t[0]),o=Math.max(e[1],t[1]),a=i.search({minX:n,minY:r,maxX:s,maxY:o});for(let i=0;i<a.length;i++)if(Fg(a[i].p,a[i].next.p,e,t))return!1;return!0}function Bg(e,t,i){return Ig(e[0],e[1],t[0],t[1],i[0],i[1])}function Fg(e,t,i,n){return e!==n&&t!==i&&Bg(e,t,i)>0!=Bg(e,t,n)>0&&Bg(i,n,e)>0!=Bg(i,n,t)>0}function Ng(e){const t=e.p,i=e.next.p;return e.minX=Math.min(t[0],i[0]),e.minY=Math.min(t[1],i[1]),e.maxX=Math.max(t[0],i[0]),e.maxY=Math.max(t[1],i[1]),e}function kg(e,t){const i={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(i.next=t.next,i.prev=t,t.next.prev=i,t.next=i):(i.prev=i,i.next=i),i}function zg(e,t){const i=e[0]-t[0],n=e[1]-t[1];return i*i+n*n}function Ug(e,t,i){let n=t[0],r=t[1],s=i[0]-n,o=i[1]-r;if(0!==s||0!==o){const t=((e[0]-n)*s+(e[1]-r)*o)/(s*s+o*o);t>1?(n=i[0],r=i[1]):t>0&&(n+=s*t,r+=o*t)}return s=e[0]-n,o=e[1]-r,s*s+o*o}function Vg(e,t,i,n,r,s,o,a){const l=i-e,c=n-t,u=o-r,h=a-s,d=e-r,p=t-s,f=l*l+c*c,m=l*u+c*h,g=u*u+h*h,_=l*d+c*p,y=u*d+h*p,v=f*g-m*m;let x,b,w=v,T=v;0===v?(x=0,w=1,b=y,T=g):(x=m*y-g*_,b=f*y-m*_,x<0?(x=0,b=y,T=g):x>w&&(x=w,b=y+m,T=g)),b<0?(b=0,-_<0?x=0:-_>f?x=w:(x=-_,w=f)):b>T&&(b=T,-_+m<0?x=0:-_+m>f?x=w:(x=-_+m,w=f));const S=0===x?0:x/w,E=0===b?0:b/T,A=(1-E)*r+E*o-((1-S)*e+S*i),M=(1-E)*s+E*a-((1-S)*t+S*n);return A*A+M*M}function jg(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function Gg(e,t){if(!ye(t=t||{}))throw new Error("options is invalid");var i=t.concavity||1/0,n=[];if(be(e,function(e){n.push([e[0],e[1]])}),!n.length)return null;var r=Cg(n,i);return r.length>3?function(e,t,i){if(!e)throw new Error("coordinates is required");for(var n=0;n<e.length;n++){var r=e[n];if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<r[r.length-1].length;s++){if(0===n&&0===s&&!_e(r[0][0])||!_e(r[0][1]))throw new Error("coordinates must contain numbers");if(r[r.length-1][s]!==r[0][s])throw new Error("First and last Position are not equivalent.")}}return he({type:"Polygon",coordinates:e},t,i)}([r]):null}function Hg(e,t){var i=0,n=0,r=0;return be(e,function(e){i+=e[0],n+=e[1],r++},!0),de([i/r,n/r],t)}function Wg(e,t){switch(function(e){if(!e)throw new Error("geojson is required");if(e.geometry&&e.geometry.type)return e.geometry.type;if(e.type)return e.type;throw new Error("geojson is invalid")}(e)){case"Point":return e;case"Polygon":var i=[];be(e,function(e){i.push(e)});var n,r,s,o,a,l,c,u,h=Hg(e,t),d=h.geometry.coordinates,p=0,f=0,m=0,g=i.map(function(e){return[e[0]-d[0],e[1]-d[1]]});for(n=0;n<i.length-1;n++)m+=u=(o=(r=g[n])[0])*(c=(s=g[n+1])[1])-(a=s[0])*(l=r[1]),p+=(o+a)*u,f+=(l+c)*u;if(0===m)return h;var _=1/(6*(.5*m));return de([d[0]+_*p,d[1]+_*f],t);default:var y=Gg(e);return y?Wg(y,t):Hg(e,t)}}function qg(e,t,i){if(!ye(i=i||{}))throw new Error("options is invalid");var n=i.units,r=jm(e),s=jm(t),o=ge(s[1]-r[1]),a=ge(s[0]-r[0]),l=ge(r[1]),c=ge(s[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(l)*Math.cos(c);return function(e,t){if(null==e)throw new Error("radians is required");if(t&&"string"!=typeof t)throw new Error("units must be a string");var i=ue[t||"kilometers"];if(!i)throw new Error(t+" units is invalid");return e*i}(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n)}function Xg(e,t){const i=[];return we(e,e=>{t(e.properties)&&i.push(e)}),fe(i)}function $g(){return fe([])}var Zg,Yg={};var Jg=function(){if(Zg)return Yg;Zg=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function i(e){return e<0?0:e>1?1:e}function n(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function r(e){return i("%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))}function s(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{Yg.parseCSSColor=function(i){var o,a=i.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),d=1;switch(u){case"rgba":if(4!==h.length)return null;d=r(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),d];case"hsla":if(4!==h.length)return null;d=r(h.pop());case"hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=r(h[1]),m=r(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[t(255*s(_,g,p+1/3)),t(255*s(_,g,p)),t(255*s(_,g,p-1/3)),d];default:return null}}return null}}catch(e){}return Yg}();const{PI:Kg,sin:Qg,cos:e_,tan:t_,asin:i_,atan2:n_,acos:r_,sqrt:s_,abs:o_,round:a_}=Math,l_=Kg/180,c_=864e5,u_=2440588,h_=2451545;function d_(e){return new Date((e+.5-u_)*c_)}function p_(e){return e.valueOf()/c_-.5+u_-h_}function f_(e){return e+function(e){const t=2e3+e/365.2425;let i;return t<1920?(i=t-1900,i*(1.494119+i*(i*(.0061966-197e-6*i)-.0598939))-2.79):t<1941?(i=t-1920,21.2+i*(.84493+i*(.0020936*i-.0761))):t<1961?(i=t-1950,29.07+i*(.407+i*(-1/233+i/2547))):t<1986?(i=t-1975,45.45+i*(1.067+i*(-1/260-i/718))):t<2005?(i=t-2e3,63.86+i*(.3345+i*(i*(.0017275+i*(651814e-9+2373599e-11*i))-.060374))):t<2050?(i=t-2e3,62.92+i*(.32217+.005589*i)):(i=(t-1820)/100,32*i*i-20-.5628*(2150-t))}(e)/86400}function m_(e,t,i){return(n_(Qg(e),e_(e)*Qg(t)-t_(i)*e_(t))/l_+540)%360}function g_(e,t,i){return i_(Qg(t)*Qg(i)+e_(t)*e_(i)*e_(e))}function __(e,t){return l_*(280.46061837+360.98564736629*e)-t}function y_(e){return e<0&&(e=0),2967e-7/t_(e+.00312536/(e+.08901179))}function v_(e){const t=e/36525,i=l_*(280.46646+t*(36000.76983+3032e-7*t)),n=l_*(357.52911+t*(35999.05029-1537e-7*t)),r=Qg(n),s=e_(n),o=l_*(125.04-1934.136*t),a=i+l_*((1.914602-t*(.004817+14e-6*t))*r+2*(.019993-101e-6*t)*r*s+289e-6*r*(3-4*r*r))-l_*(.00569+.00478*Qg(o)),l=l_*(23.439291-t*(.0130042+t*(16e-8-504e-9*t)))+.00256*l_*e_(o);return{ra:n_(e_(l)*Qg(a),e_(a)),dec:i_(Qg(l)*Qg(a))}}function x_(e,t,i){const n=l_*-i,r=l_*t,s=p_(e),o=v_(f_(s)),a=__(s,n)-o.ra,l=g_(a,r,o.dec);return{azimuth:m_(a,r,o.dec),altitude:(l+y_(l))/l_}}const b_=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]],w_=9e-4;function T_(e){return e-2*Kg*a_(e/(2*Kg))}function S_(e,t,i,n,r,s){const o=(Qg(e)-Qg(r)*Qg(s))/(e_(r)*e_(s));if(o<-1||o>1)return NaN;let a=t+i*r_(o)/(2*Kg);for(let t=0;t<2;t++){const t=v_(f_(a)),i=T_(__(a,n)-t.ra),s=g_(i,r,t.dec),o=e_(r)*e_(t.dec)*Qg(i);if(o_(o)<1e-6)break;a+=(s-e)/(2*Kg*o)}return a}function E_(e,t,i,n=0){const r=l_*-i,s=l_*t,o=function(e){return-2.076*s_(e)/60}(n),a=function(e,t){for(let i=0;i<3;i++)e-=T_(__(e,t)-v_(f_(e)).ra)/(2*Kg);return e}(a_(a_(p_(e))-w_-r/(2*Kg))+w_+r/(2*Kg),r),l=v_(f_(a)).dec,c={solarNoon:d_(a+h_),nadir:d_(a+h_-.5)};for(const[e,t,i]of b_){const n=(e+o)*l_,u=S_(n,a,-1,r,s,l),h=S_(n,a,1,r,s,l);c[t]=Number.isNaN(u)?null:d_(u+h_),c[i]=Number.isNaN(h)?null:d_(h+h_)}if(null===c.sunrise){const e=g_(0,s,l),t=(b_[0][0]+o)*l_;c.alwaysUp=e>t,c.alwaysDown=e<=t}return c}const A_=36e5,M_=["background","background-underground"],I_=180/Math.PI,C_=[{brightness:.01,color:[6,14,25,.9]},{brightness:.2,color:[237,204,171,.7]},{brightness:.4,color:[247,251,253,.9]}];function P_(e){const t=new ae.LngLatBounds;for(const i of e)t.extend(i);return t}function L_(e,t,i){e.getLayer(t).setProps(i)}function R_(e,t){const{properties:i}=e.style[`${t}Light`],[n,r,s]=Jg.parseCSSColor(i.get("color").toString()),o={color:[n,r,s],intensity:.2126*n/255+.7152*r/255+.0722*s/255};if("directional"===t){const{x:e,y:t,z:n}=i.get("direction"),r=Math.sqrt(e*e+t*t+n*n),s=r>0?Math.acos(n/r)*I_:0;let a=0!==e||0!==t?Math.atan2(-t,-e)*I_+90:0;a<0&&(a+=360),o.direction=[a,s]}return o}function O_(e){return R_(e,"directional")}function D_(e){return R_(e,"ambient")}function B_(e){return e.style.getBrightness()||0}function F_(e){const t=B_(e),i=C_;for(let e=1;e<i.length;e++){const n=i[e];if(t<=n.brightness||e===i.length-1){const r=i[e-1],s=G((t-r.brightness)/(n.brightness-r.brightness),0,1);return[j(r.color[0],n.color[0],s),j(r.color[1],n.color[1],s),j(r.color[2],n.color[2],s),j(r.color[3],n.color[3],s)]}}}function N_(e,t){const i=(t-e)/20;return[e+1*i,e+10*i]}function k_(e,t,i,n,r){const s=e.getCenter(),{sunrise:o,sunset:a}=function(e,t){return E_(t+e.lng/15*A_,e.lat,e.lng)}(s,t),l=o?o.getTime():NaN,c=a?a.getTime():NaN,{azimuth:u,altitude:h}=x_(t,s.lat,s.lng),d=u,p=90-h;let f,m,g,_;if((isNaN(l)||isNaN(c))&&h>0)m={r:255,g:255,b:255,i:.7},g={r:255,g:255,b:255,i:.3,w:1},_={azimuth:d,altitude:p};else if(t>=l-A_/2&&t<l){const e=x_(l,s.lat,s.lng);f=(t-l)/(A_/2)+1,m={r:j(0,153,f),g:j(22,179,f),b:j(56,204,f),i:j(.5,.65,f)},g={r:74,g:74,b:74,i:j(.5,1,f),w:0},_={azimuth:j(210,e.azimuth,f),altitude:20}}else if(t>=l&&t<l+A_)f=(t-l)/A_,m={r:j(153,255,f),g:j(179,255,f),b:j(204,255,f),i:j(.65,.7,f)},g={r:j(254,255,f),g:j(202,255,f),b:j(139,255,f),i:j(.6,.3,f),w:1},_={azimuth:d,altitude:p};else if(t>=l+A_&&t<c-A_)m={r:255,g:255,b:255,i:.7},g={r:255,g:255,b:255,i:.3,w:1},_={azimuth:d,altitude:p};else if(t>=c-A_&&t<c)f=(t-c)/A_+1,m={r:j(255,235,f),g:j(255,197,f),b:j(255,173,f),i:j(.7,.65,f)},g={r:j(255,254,f),g:j(255,194,f),b:j(255,134,f),i:j(.3,.6,f),w:1},_={azimuth:d,altitude:p};else if(t>=c&&t<c+A_/2){const e=x_(c,s.lat,s.lng);f=(t-c)/(A_/2),m={r:j(235,0,f),g:j(197,22,f),b:j(173,56,f),i:j(.65,.5,f)},g={r:74,g:74,b:74,i:j(1,.5,f),w:0},_={azimuth:j(e.azimuth,210,f),altitude:20}}else m={r:0,g:22,b:56,i:.5},g={r:74,g:74,b:74,i:.5,w:0},_={azimuth:210,altitude:20};const y=g.w*i;if(n){const t=e.getLights();for(const e of t)"directional"===e.type&&(e.properties=Object.assign({},e.properties,{"shadow-intensity":y}));e.setLights(t)}else{const t=e.style.transition,i=t.duration;t.duration=r?i:0,e.setLights([{id:"ambient",type:"ambient",properties:{color:`rgb(${m.r}, ${m.g}, ${m.b})`,intensity:m.i}},{id:"directional",type:"directional",properties:{direction:["literal",[_.azimuth,_.altitude]],color:`rgb(${g.r}, ${g.g}, ${g.b})`,intensity:g.i,"cast-shadows":!0,"shadow-intensity":y}}]),t.duration=i}e.getLayer("sky")?e.setPaintProperty("sky","sky-atmosphere-sun",[d,p]):e.addLayer({id:"sky",type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-color":"hsl(220, 100%, 70%)","sky-atmosphere-sun-intensity":20,"sky-atmosphere-sun":[d,p]}},"background")}function z_(e,t){const i=e.getLights().filter(({type:e})=>"ambient"===e)[0],n=Jg.parseCSSColor(i.properties.color),r=i.properties.intensity,s=n[0]/255*r,o=n[1]/255*r,a=n[2]/255*r;return t?M_.reduce((t,i)=>{const n=e.style.getOwnLayer(i).paint,{r:r,g:l,b:c}=n.get("background-color"),u=n.get("background-opacity");return t+J({r:r*s*u,g:l*o*u,b:c*a*u})},0)<.5:M_.reduce((t,i)=>{const[n,r,l]=Jg.parseCSSColor(e.getPaintProperty(i,"background-color")),c=q(e.getPaintProperty(i,"background-opacity"),1);return t+J({r:n*s*c,g:r*o*c,b:l*a*c})},0)<127.5}function U_(e,t){const{_layers:i,_order:n}=e.style,r={"background-underground":1,"building-underground-underground":["interpolate",["linear"],["zoom"],14.5,0,15,1]},s=[];return n.map(e=>i[e]).filter(({metadata:e})=>e&&e[t]).forEach(({id:t,type:i,metadata:n})=>{if("custom"===i)return void s.push({id:t,metadata:n});const o=`${i.replace("symbol","icon")}-opacity`,a=r[t]||q(e.getPaintProperty(t,o),1);if(isNaN(a)){if(H(["match","step","interpolate"],a[0])){const e=[];a.forEach((t,i)=>{i%2!=("match"===a[0]?1:0)&&i!==a.length-1||isNaN(t)||e.push({index:i,value:t})}),s.push({id:t,key:o,opacity:e,metadata:n})}}else s.push({id:t,key:o,opacity:a,metadata:n})}),s}const V_=()=>{},j_={10241:9987,10240:9729,10242:33071,10243:33071};function G_(e,t,i,n){const r=Math.min(i/t.width,n/t.height),s=Math.floor(t.width*r),o=Math.floor(t.height*r);return 1===r?{data:t,width:s,height:o}:(e.canvas.height=o,e.canvas.width=s,e.clearRect(0,0,s,o),e.drawImage(t,0,0,t.width,t.height,0,0,s,o),{data:e.canvas,width:s,height:o})}function H_(e){return e&&(e.id||e.url)}function W_(e,t,i,n){const r=e.width,s=e.height,o=new Ls(e.gl,{width:t,height:i,parameters:n});return function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{sourceX:n=0,sourceY:r=0,targetMipmaplevel:s=0,targetInternalFormat:o=6408}=i;let{targetX:a,targetY:l,targetZ:c,width:u,height:h}=i;const{framebuffer:d,deleteFramebuffer:p}=Gs(e);rs(d);const{gl:f,handle:m}=d,g=void 0!==a||void 0!==l||void 0!==c;a=a||0,l=l||0,c=c||0;const _=f.bindFramebuffer(36160,m);rs(t);let y=null;if(t instanceof Ps&&(y=t,u=Number.isFinite(u)?u:y.width,h=Number.isFinite(h)?h:y.height,y.bind(0),t=y.target),g)switch(t){case 3553:case 34067:f.copyTexSubImage2D(t,s,a,l,n,r,u,h);break;case 35866:case 32879:rr(f).copyTexSubImage3D(t,s,a,l,c,n,r,u,h)}else f.copyTexImage2D(t,s,o,n,r,u,h,0);y&&y.unbind(),f.bindFramebuffer(36160,_||null),p&&d.delete()}(e,o,{targetY:0,width:r,height:s}),e.delete(),o}function q_(e,t,i){for(let n=0;n<t.length;n++){const{icon:r,xOffset:s}=t[n];e[H_(r)]={...r,x:s,y:i}}}class X_{constructor(e,{onUpdate:t=V_,onError:i=V_}){bt(this,"gl",void 0),bt(this,"onUpdate",void 0),bt(this,"onError",void 0),bt(this,"_loadOptions",null),bt(this,"_texture",null),bt(this,"_externalTexture",null),bt(this,"_mapping",{}),bt(this,"_textureParameters",null),bt(this,"_pendingCount",0),bt(this,"_autoPacking",!1),bt(this,"_xOffset",0),bt(this,"_yOffset",0),bt(this,"_rowHeight",0),bt(this,"_buffer",4),bt(this,"_canvasWidth",1024),bt(this,"_canvasHeight",0),bt(this,"_canvas",null),this.gl=e,this.onUpdate=t,this.onError=i}finalize(){var e;null===(e=this._texture)||void 0===e||e.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){const t=this._autoPacking?H_(e):e;return this._mapping[t]||{}}setProps({loadOptions:e,autoPacking:t,iconAtlas:i,iconMapping:n,textureParameters:r}){var s;(e&&(this._loadOptions=e),void 0!==t&&(this._autoPacking=t),n&&(this._mapping=n),i)&&(null===(s=this._texture)||void 0===s||s.delete(),this._texture=null,this._externalTexture=i);r&&(this._textureParameters=r)}get isLoaded(){return 0===this._pendingCount}packIcons(e,t){if(!this._autoPacking||"undefined"==typeof document)return;const i=Object.values(function(e,t,i){if(!e||!t)return null;i=i||{};const n={},{iterable:r,objectInfo:s}=Ff(e);for(const e of r){s.index++;const r=t(e,s),o=H_(r);if(!r)throw new Error("Icon is missing.");if(!r.url)throw new Error("Icon url is missing.");n[o]||i[o]&&r.url===i[o].url||(n[o]={...r,source:e,sourceIndex:s.index})}return n}(e,t,this._mapping)||{});if(i.length>0){const{mapping:e,xOffset:t,yOffset:n,rowHeight:r,canvasHeight:s}=function({icons:e,buffer:t,mapping:i={},xOffset:n=0,yOffset:r=0,rowHeight:s=0,canvasWidth:o}){let a=[];for(let l=0;l<e.length;l++){const c=e[l];if(!i[H_(c)]){const{height:e,width:l}=c;n+l+t>o&&(q_(i,a,r),n=0,r=s+r+t,s=0,a=[]),a.push({icon:c,xOffset:n}),n=n+l+t,s=Math.max(s,e)}}return a.length>0&&q_(i,a,r),{mapping:i,rowHeight:s,xOffset:n,yOffset:r,canvasWidth:o,canvasHeight:(l=s+r+t,Math.pow(2,Math.ceil(Math.log2(l))))};var l}({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=r,this._mapping=e,this._xOffset=t,this._yOffset=n,this._canvasHeight=s,this._texture||(this._texture=new Ls(this.gl,{width:this._canvasWidth,height:this._canvasHeight,parameters:this._textureParameters||j_})),this._texture.height!==this._canvasHeight&&(this._texture=W_(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||j_)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(e){const t=this._canvas.getContext("2d",{willReadFrequently:!0});for(const i of e)this._pendingCount++,yn(i.url,this._loadOptions).then(e=>{const n=H_(i),r=this._mapping[n],{x:s,y:o,width:a,height:l}=r,{data:c,width:u,height:h}=G_(t,e,a,l);this._texture.setSubImageData({data:c,x:s+(a-u)/2,y:o+(l-h)/2,width:u,height:h}),r.width=u,r.height=h,this._texture.generateMipmap(),this.onUpdate()}).catch(e=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}const $_=[0,0,0,255],Z_={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:e=>e.position},getIcon:{type:"accessor",value:e=>e.icon},getColor:{type:"accessor",value:$_},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}};class Y_ extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){return super.getShaders({vs:"#define SHADER_NAME icon-layer-vertex-shader\n\nattribute vec2 positions;\n\nattribute vec3 instancePositions;\nattribute vec3 instancePositions64Low;\nattribute float instanceSizes;\nattribute float instanceAngles;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\nattribute vec4 instanceIconFrames;\nattribute float instanceColorModes;\nattribute vec2 instanceOffsets;\nattribute vec2 instancePixelOffset;\n\nuniform float sizeScale;\nuniform vec2 iconsTextureDim;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform bool billboard;\nuniform int sizeUnits;\n\nvarying float vColorMode;\nvarying vec4 vColor;\nvarying vec2 vTextureCoords;\nvarying vec2 uv;\n\nvec2 rotate_by_angle(vec2 vertex, float angle) {\n  float angle_radian = angle * PI / 180.0;\n  float cos_angle = cos(angle_radian);\n  float sin_angle = sin(angle_radian);\n  mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\n  return rotationMatrix * vertex;\n}\n\nvoid main(void) {\n  geometry.worldPosition = instancePositions;\n  geometry.uv = positions;\n  geometry.pickingColor = instancePickingColors;\n  uv = positions;\n\n  vec2 iconSize = instanceIconFrames.zw;\n  float sizePixels = clamp(\n    project_size_to_pixel(instanceSizes * sizeScale, sizeUnits), \n    sizeMinPixels, sizeMaxPixels\n  );\n  float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y;\n  vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\n  pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\n  pixelOffset += instancePixelOffset;\n  pixelOffset.y *= -1.0;\n\n  if (billboard)  {\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n    vec3 offset = vec3(pixelOffset, 0.0);\n    DECKGL_FILTER_SIZE(offset, geometry);\n    gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n\n  } else {\n    vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\n    DECKGL_FILTER_SIZE(offset_common, geometry);\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); \n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n  }\n\n  vTextureCoords = mix(\n    instanceIconFrames.xy,\n    instanceIconFrames.xy + iconSize,\n    (positions.xy + 1.0) / 2.0\n  ) / iconsTextureDim;\n\n  vColor = instanceColors;\n  DECKGL_FILTER_COLOR(vColor, geometry);\n\n  vColorMode = instanceColorModes;\n}\n",fs:"#define SHADER_NAME icon-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D iconsTexture;\nuniform float alphaCutoff;\n\nvarying float vColorMode;\nvarying vec4 vColor;\nvarying vec2 vTextureCoords;\nvarying vec2 uv;\n\nvoid main(void) {\n  geometry.uv = uv;\n\n  vec4 texColor = texture2D(iconsTexture, vTextureCoords);\n  vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\n  float a = texColor.a * opacity * vColor.a;\n\n  if (a < alphaCutoff) {\n    discard;\n  }\n\n  gl_FragColor = vec4(color, a);\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",modules:[jd,Gd]})}initializeState(){this.state={iconManager:new X_(this.context.gl,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,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:5121,accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getColor",defaultValue:$_},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:n}=e,r=this.getAttributeManager(),{iconAtlas:s,iconMapping:o,data:a,getIcon:l,textureParameters:c}=t,{iconManager:u}=this.state,h=s||this.internalState.isAsyncPropLoading("iconAtlas");if(u.setProps({loadOptions:t.loadOptions,autoPacking:!h,iconAtlas:s,iconMapping:h?o:null,textureParameters:c}),h?i.iconMapping!==t.iconMapping&&r.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&u.packIcons(a,l),n.extensionsChanged){var d;const{gl:e}=this.context;null===(d=this.state.model)||void 0===d||d.delete(),this.state.model=this._getModel(e),r.invalidateAll()}}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:t,sizeMinPixels:i,sizeMaxPixels:n,sizeUnits:r,billboard:s,alphaCutoff:o}=this.props,{iconManager:a}=this.state,l=a.getTexture();l&&this.state.model.setUniforms(e).setUniforms({iconsTexture:l,iconsTextureDim:[l.width,l.height],sizeUnits:Jn[r],sizeScale:t,sizeMinPixels:i,sizeMaxPixels:n,billboard:s,alphaCutoff:o}).draw()}_getModel(e){return new Du(e,{...this.getShaders(),id:this.props.id,geometry:new Hu({drawMode:6,attributes:{positions:{size:2,value:new Float32Array([-1,-1,-1,1,1,1,1,-1])}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){var t;const i=null===(t=this.getCurrentLayer())||void 0===t?void 0:t.props.onIconError;i&&i(e)}getInstanceOffset(e){const{width:t,height:i,anchorX:n=t/2,anchorY:r=i/2}=this.state.iconManager.getIconMapping(e);return[t/2-n,i/2-r]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){const{x:t,y:i,width:n,height:r}=this.state.iconManager.getIconMapping(e);return[t,i,n,r]}}bt(Y_,"defaultProps",Z_),bt(Y_,"layerName","IconLayer");const J_=[0,0,0,255],K_=[0,0,1],Q_={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:K_},getColor:{type:"accessor",value:J_},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class ey extends Fm{getShaders(){return super.getShaders({vs:"#define SHADER_NAME point-cloud-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec3 instanceNormals;\nattribute vec4 instanceColors;\nattribute vec3 instancePositions;\nattribute vec3 instancePositions64Low;\nattribute vec3 instancePickingColors;\n\nuniform float opacity;\nuniform float radiusPixels;\nuniform int sizeUnits;\n\nvarying vec4 vColor;\nvarying vec2 unitPosition;\n\nvoid main(void) {\n  geometry.worldPosition = instancePositions;\n  geometry.normal = project_normal(instanceNormals);\n  unitPosition = positions.xy;\n  geometry.uv = unitPosition;\n  geometry.pickingColor = instancePickingColors;\n  vec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0);\n  DECKGL_FILTER_SIZE(offset, geometry);\n\n  gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\n  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n  gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n  vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);\n  vColor = vec4(lightColor, instanceColors.a * opacity);\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#define SHADER_NAME point-cloud-layer-fragment-shader\n\nprecision highp float;\n\nvarying vec4 vColor;\nvarying vec2 unitPosition;\n\nvoid main(void) {\n  geometry.uv = unitPosition;\n\n  float distToCenter = length(unitPosition);\n\n  if (distToCenter > 1.0) {\n    discard;\n  }\n\n  gl_FragColor = vColor;\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",modules:[jd,Su,Gd]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:K_},instanceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getColor",defaultValue:J_}})}updateState(e){const{changeFlags:t,props:i}=e;if(super.updateState(e),t.extensionsChanged){var n;const{gl:e}=this.context;null===(n=this.state.model)||void 0===n||n.delete(),this.state.model=this._getModel(e),this.getAttributeManager().invalidateAll()}t.dataChanged&&function(e){const{header:t,attributes:i}=e;t&&i&&(e.length=t.vertexCount,i.POSITION&&(i.instancePositions=i.POSITION),i.NORMAL&&(i.instanceNormals=i.NORMAL),i.COLOR_0&&(i.instanceColors=i.COLOR_0))}(i.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:i}=this.props;this.state.model.setUniforms(e).setUniforms({sizeUnits:Jn[i],radiusPixels:t}).draw()}_getModel(e){const t=[];for(let e=0;e<3;e++){const i=e/3*Math.PI*2;t.push(2*Math.cos(i),2*Math.sin(i),0)}return new Du(e,{...this.getShaders(),id:this.props.id,geometry:new Hu({drawMode:4,attributes:{positions:new Float32Array(t)}}),isInstanced:!0})}}bt(ey,"layerName","PointCloudLayer"),bt(ey,"defaultProps",Q_);const ty=[0,0,0,255],iy={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:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:ty},getLineColor:{type:"accessor",value:ty},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ny extends Fm{getShaders(){return super.getShaders({vs:"#define SHADER_NAME scatterplot-layer-vertex-shader\n\nattribute vec3 positions;\n\nattribute vec3 instancePositions;\nattribute vec3 instancePositions64Low;\nattribute float instanceRadius;\nattribute float instanceLineWidths;\nattribute vec4 instanceFillColors;\nattribute vec4 instanceLineColors;\nattribute vec3 instancePickingColors;\n\nuniform float opacity;\nuniform float radiusScale;\nuniform float radiusMinPixels;\nuniform float radiusMaxPixels;\nuniform float lineWidthScale;\nuniform float lineWidthMinPixels;\nuniform float lineWidthMaxPixels;\nuniform float stroked;\nuniform bool filled;\nuniform bool antialiasing;\nuniform bool billboard;\nuniform int radiusUnits;\nuniform int lineWidthUnits;\n\nvarying vec4 vFillColor;\nvarying vec4 vLineColor;\nvarying vec2 unitPosition;\nvarying float innerUnitRadius;\nvarying float outerRadiusPixels;\n\n\nvoid main(void) {\n  geometry.worldPosition = instancePositions;\n  outerRadiusPixels = clamp(\n    project_size_to_pixel(radiusScale * instanceRadius, radiusUnits),\n    radiusMinPixels, radiusMaxPixels\n  );\n  float lineWidthPixels = clamp(\n    project_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits),\n    lineWidthMinPixels, lineWidthMaxPixels\n  );\n  outerRadiusPixels += stroked * lineWidthPixels / 2.0;\n  float edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\n  unitPosition = edgePadding * positions.xy;\n  geometry.uv = unitPosition;\n  geometry.pickingColor = instancePickingColors;\n\n  innerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels;\n  \n  if (billboard) {\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n    vec3 offset = edgePadding * positions * outerRadiusPixels;\n    DECKGL_FILTER_SIZE(offset, geometry);\n    gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n  } else {\n    vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\n    DECKGL_FILTER_SIZE(offset, geometry);\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n  }\n  vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);\n  DECKGL_FILTER_COLOR(vFillColor, geometry);\n  vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);\n  DECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#define SHADER_NAME scatterplot-layer-fragment-shader\n\nprecision highp float;\n\nuniform bool filled;\nuniform float stroked;\nuniform bool antialiasing;\n\nvarying vec4 vFillColor;\nvarying vec4 vLineColor;\nvarying vec2 unitPosition;\nvarying float innerUnitRadius;\nvarying float outerRadiusPixels;\n\nvoid main(void) {\n  geometry.uv = unitPosition;\n\n  float distToCenter = length(unitPosition) * outerRadiusPixels;\n  float inCircle = antialiasing ? \n    smoothedge(distToCenter, outerRadiusPixels) : \n    step(distToCenter, outerRadiusPixels);\n\n  if (inCircle == 0.0) {\n    discard;\n  }\n\n  if (stroked > 0.5) {\n    float isLine = antialiasing ? \n      smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\n      step(innerUnitRadius * outerRadiusPixels, distToCenter);\n\n    if (filled) {\n      gl_FragColor = mix(vFillColor, vLineColor, isLine);\n    } else {\n      if (isLine == 0.0) {\n        discard;\n      }\n      gl_FragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n    }\n  } else if (!filled) {\n    discard;\n  } else {\n    gl_FragColor = vFillColor;\n  }\n\n  gl_FragColor.a *= inCircle;\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",modules:[jd,Gd]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,normalized:!0,type:5121,accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,normalized:!0,type:5121,accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){if(super.updateState(e),e.changeFlags.extensionsChanged){var t;const{gl:e}=this.context;null===(t=this.state.model)||void 0===t||t.delete(),this.state.model=this._getModel(e),this.getAttributeManager().invalidateAll()}}draw({uniforms:e}){const{radiusUnits:t,radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,stroked:s,filled:o,billboard:a,antialiasing:l,lineWidthUnits:c,lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props;this.state.model.setUniforms(e).setUniforms({stroked:s?1:0,filled:o,billboard:a,antialiasing:l,radiusUnits:Jn[t],radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,lineWidthUnits:Jn[c],lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}).draw()}_getModel(e){return new Du(e,{...this.getShaders(),id:this.props.id,geometry:new Hu({drawMode:6,vertexCount:4,attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0])}}}),isInstanced:!0})}}bt(ny,"defaultProps",iy),bt(ny,"layerName","ScatterplotLayer");const ry=1,sy=-1;function oy(e,t,i={}){const n=function(e,t={}){return Math.sign(function(e,t={}){const{start:i=0,end:n=e.length}=t,r=t.size||2;let s=0;for(let t=i,o=n-r;t<n;t+=r)s+=(e[t]-e[o])*(e[t+1]+e[o+1]),o=t;return s/2}(e,t))}(e,i);return n!==t&&(function(e,t){const{start:i=0,end:n=e.length,size:r=2}=t,s=(n-i)/r,o=Math.floor(s/2);for(let t=0;t<o;++t){const n=i+t*r,o=i+(s-1-t)*r;for(let t=0;t<r;++t){const i=e[n+t];e[n+t]=e[o+t],e[o+t]=i}}}(e,i),!0)}function ay(e,t){const i=t.length,n=e.length;if(n>0){let r=!0;for(let s=0;s<i;s++)if(e[n-i+s]!==t[s]){r=!1;break}if(r)return!1}for(let r=0;r<i;r++)e[n+r]=t[r];return!0}function ly(e,t){const i=t.length;for(let n=0;n<i;n++)e[n]=t[n]}function cy(e,t,i,n,r=[]){const s=n+t*i;for(let t=0;t<i;t++)r[t]=e[s+t];return r}function uy(e,t,i,n,r=[]){let s,o;if(8&i)s=(n[3]-e[1])/(t[1]-e[1]),o=3;else if(4&i)s=(n[1]-e[1])/(t[1]-e[1]),o=1;else if(2&i)s=(n[2]-e[0])/(t[0]-e[0]),o=2;else{if(!(1&i))return null;s=(n[0]-e[0])/(t[0]-e[0]),o=0}for(let i=0;i<e.length;i++)r[i]=(1&o)===i?n[o]:s*(t[i]-e[i])+e[i];return r}function hy(e,t){let i=0;return e[0]<t[0]?i|=1:e[0]>t[2]&&(i|=2),e[1]<t[1]?i|=4:e[1]>t[3]&&(i|=8),i}function dy(e,t){const{size:i=2,broken:n=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=e.length}=t||{},l=(a-o)/i;let c=[];const u=[c],h=cy(e,0,i,o);let d,p;const f=gy(h,r,s,[]),m=[];ay(c,h);for(let t=1;t<l;t++){for(d=cy(e,t,i,o,d),p=hy(d,f);p;){uy(h,d,p,f,m);const e=hy(m,f);e&&(uy(h,m,e,f,m),p=e),ay(c,m),ly(h,m),_y(f,r,p),n&&c.length>i&&(c=[],u.push(c),ay(c,h)),p=hy(d,f)}ay(c,d),ly(h,d)}return n?u:u[0]}function py(e,t){for(let i=0;i<t.length;i++)e.push(t[i]);return e}function fy(e,t=null,i){if(!e.length)return[];const{size:n=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=i||{},a=[],l=[{pos:e,types:o?new Array(e.length/n).fill(1):null,holes:t||[]}],c=[[],[]];let u=[];for(;l.length;){const{pos:e,types:t,holes:i}=l.shift();yy(e,n,i[0]||e.length,c),u=gy(c[0],r,s,u);const h=hy(c[1],u);if(h){let r=my(e,t,n,0,i[0]||e.length,u,h);const s={pos:r[0].pos,types:r[0].types,holes:[]},a={pos:r[1].pos,types:r[1].types,holes:[]};l.push(s,a);for(let l=0;l<i.length;l++)r=my(e,t,n,i[l],i[l+1]||e.length,u,h),r[0]&&(s.holes.push(s.pos.length),s.pos=py(s.pos,r[0].pos),o&&(s.types=py(s.types,r[0].types))),r[1]&&(a.holes.push(a.pos.length),a.pos=py(a.pos,r[1].pos),o&&(a.types=py(a.types,r[1].types)))}else{const n={positions:e};o&&(n.edgeTypes=t),i.length&&(n.holeIndices=i),a.push(n)}}return a}function my(e,t,i,n,r,s,o){const a=(r-n)/i,l=[],c=[],u=[],h=[],d=[];let p,f,m;const g=cy(e,a-1,i,n);let _=Math.sign(8&o?g[1]-s[3]:g[0]-s[2]),y=t&&t[a-1],v=0,x=0;for(let r=0;r<a;r++)p=cy(e,r,i,n,p),f=Math.sign(8&o?p[1]-s[3]:p[0]-s[2]),m=t&&t[n/i+r],f&&_&&_!==f&&(uy(g,p,o,s,d),ay(l,d)&&u.push(y),ay(c,d)&&h.push(y)),f<=0?(ay(l,p)&&u.push(m),v-=f):u.length&&(u[u.length-1]=0),f>=0?(ay(c,p)&&h.push(m),x+=f):h.length&&(h[h.length-1]=0),ly(g,p),_=f,y=m;return[v?{pos:l,types:t&&u}:null,x?{pos:c,types:t&&h}:null]}function gy(e,t,i,n){const r=Math.floor((e[0]-i[0])/t)*t+i[0],s=Math.floor((e[1]-i[1])/t)*t+i[1];return n[0]=r,n[1]=s,n[2]=r+t,n[3]=s+t,n}function _y(e,t,i){8&i?(e[1]+=t,e[3]+=t):4&i?(e[1]-=t,e[3]-=t):2&i?(e[0]+=t,e[2]+=t):1&i&&(e[0]-=t,e[2]-=t)}function yy(e,t,i,n){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let n=0;n<i;n+=t){const t=e[n],i=e[n+1];r=t<r?t:r,s=t>s?t:s,o=i<o?i:o,a=i>a?i:a}return n[0][0]=r,n[0][1]=o,n[1][0]=s,n[1][1]=a,n}function vy(e,t,i,n){let r=-1,s=-1;for(let o=i+1;o<n;o+=t){const t=Math.abs(e[o]);t>r&&(r=t,s=o-1)}return s}function xy(e,t,i,n,r=85.051129){const s=e[i],o=e[n-t];if(Math.abs(s-o)>180){const n=cy(e,0,t,i);n[0]+=360*Math.round((o-s)/360),ay(e,n),n[1]=Math.sign(n[1])*r,ay(e,n),n[0]=s,ay(e,n)}}function by(e,t,i,n){let r,s=e[0];for(let o=i;o<n;o+=t){r=e[o];const t=r-s;(t>180||t<-180)&&(r-=360*Math.round(t/360)),e[o]=s=r}}function wy(e,t){let i;const n=e.length/t;for(let r=0;r<n&&(i=e[r*t],(i+180)%360==0);r++);const r=360*-Math.round(i/360);if(0!==r)for(let i=0;i<n;i++)e[i*t]+=r}function Ty(e,t,i,n){let r;if(Array.isArray(e[0])){r=new Array(e.length*t);for(let i=0;i<e.length;i++)for(let n=0;n<t;n++)r[i*t+n]=e[i][n]||0}else r=e;return i?dy(r,{size:t,gridResolution:i}):n?function(e,t){const{size:i=2,startIndex:n=0,endIndex:r=e.length,normalize:s=!0}=t||{},o=e.slice(n,r);by(o,i,0,r-n);const a=dy(o,{size:i,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(s)for(const e of a)wy(e,i);return a}(r,{size:t}):r}class Sy extends zm{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?Ty(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Ey(e)){let t=0;for(const i of e)t+=this.getGeometrySize(i);return t}const t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(0!==t.geometrySize)if(e&&Ey(e))for(const i of e){const e=this.getGeometrySize(i);t.geometrySize=e,this.updateGeometryAttributes(i,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){const i=this.attributes.segmentTypes,n=!!e&&this.isClosed(e),{vertexStart:r,geometrySize:s}=t;i.fill(0,r,r+s),n?(i[r]=4,i[r+s-2]=4):(i[r]+=1,i[r+s-2]+=2),i[r+s-1]=4}_updatePositions(e,t){const{positions:i}=this.attributes;if(!i||!e)return;const{vertexStart:n,geometrySize:r}=t,s=new Array(3);for(let t=n,o=0;o<r;t++,o++)this.getPointOnPath(e,o,s),i[3*t]=s[0],i[3*t+1]=s[1],i[3*t+2]=s[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,i=[]){const{positionSize:n}=this;t*n>=e.length&&(t+=1-e.length/n);const r=t*n;return i[0]=e[r],i[1]=e[r+1],i[2]=3===n&&e[r+2]||0,i}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(2===t||e[2]===e[i+2])}}function Ey(e){return Array.isArray(e[0])}const Ay=[0,0,0,255],My={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:e=>e.path},getColor:{type:"accessor",value:Ay},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Iy={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class Cy extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){return super.getShaders({vs:"#define SHADER_NAME path-layer-vertex-shader\n\nattribute vec2 positions;\n\nattribute float instanceTypes;\nattribute vec3 instanceStartPositions;\nattribute vec3 instanceEndPositions;\nattribute vec3 instanceLeftPositions;\nattribute vec3 instanceRightPositions;\nattribute vec3 instanceLeftPositions64Low;\nattribute vec3 instanceStartPositions64Low;\nattribute vec3 instanceEndPositions64Low;\nattribute vec3 instanceRightPositions64Low;\nattribute float instanceStrokeWidths;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\n\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float capType;\nuniform float miterLimit;\nuniform bool billboard;\nuniform int widthUnits;\n\nuniform float opacity;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vPathPosition;\nvarying float vPathLength;\nvarying float vJointType;\n\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\n\nfloat flipIfTrue(bool flag) {\n  return -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\n  vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n  vec2 width\n) {\n  bool isEnd = positions.x > 0.0;\n  float sideOfPath = positions.y;\n  float isJoint = float(sideOfPath == 0.0);\n\n  vec3 deltaA3 = (currPoint - prevPoint);\n  vec3 deltaB3 = (nextPoint - currPoint);\n\n  mat3 rotationMatrix;\n  bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix);\n  if (needsRotation) {\n    deltaA3 = deltaA3 * rotationMatrix;\n    deltaB3 = deltaB3 * rotationMatrix;\n  }\n  vec2 deltaA = deltaA3.xy / width;\n  vec2 deltaB = deltaB3.xy / width;\n\n  float lenA = length(deltaA);\n  float lenB = length(deltaB);\n\n  vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\n  vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\n\n  vec2 perpA = vec2(-dirA.y, dirA.x);\n  vec2 perpB = vec2(-dirB.y, dirB.x);\n  vec2 tangent = dirA + dirB;\n  tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n  vec2 miterVec = vec2(-tangent.y, tangent.x);\n  vec2 dir = isEnd ? dirA : dirB;\n  vec2 perp = isEnd ? perpA : perpB;\n  float L = isEnd ? lenA : lenB;\n  float sinHalfA = abs(dot(miterVec, perp));\n  float cosHalfA = abs(dot(dirA, miterVec));\n  float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\n  float cornerPosition = sideOfPath * turnDirection;\n\n  float miterSize = 1.0 / max(sinHalfA, EPSILON);\n  miterSize = mix(\n    min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\n    miterSize,\n    step(0.0, cornerPosition)\n  );\n\n  vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n    * (sideOfPath + isJoint * turnDirection);\n  bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\n  bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\n  bool isCap = isStartCap || isEndCap;\n  if (isCap) {\n    offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint);\n    vJointType = capType;\n  } else {\n    vJointType = jointType;\n  }\n  vPathLength = L;\n  vCornerOffset = offsetVec;\n  vMiterLength = dot(vCornerOffset, miterVec * turnDirection);\n  vMiterLength = isCap ? isJoint : vMiterLength;\n\n  vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\n  vPathPosition = vec2(\n    dot(offsetFromStartOfPath, perp),\n    dot(offsetFromStartOfPath, dir)\n  );\n  geometry.uv = vPathPosition;\n\n  float isValid = step(instanceTypes, 3.5);\n  vec3 offset = vec3(offsetVec * width * isValid, 0.0);\n\n  if (needsRotation) {\n    offset = rotationMatrix * offset;\n  }\n  return offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\n  if (position.w < EPSILON) {\n    float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\n    position = refPosition + (position - refPosition) * r;\n  }\n}\n\nvoid main() {\n  geometry.pickingColor = instancePickingColors;\n\n  vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);\n\n  float isEnd = positions.x;\n\n  vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\n  vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\n\n  vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\n  vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\n\n  vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\n  vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\n\n  geometry.worldPosition = currPosition;\n  vec2 widthPixels = vec2(clamp(\n    project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),\n    widthMinPixels, widthMaxPixels) / 2.0);\n  vec3 width;\n\n  if (billboard) {\n    vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\n    vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\n    vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\n\n    clipLine(prevPositionScreen, currPositionScreen);\n    clipLine(nextPositionScreen, currPositionScreen);\n    clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\n\n    width = vec3(widthPixels, 0.0);\n    DECKGL_FILTER_SIZE(width, geometry);\n\n    vec3 offset = getLineJoinOffset(\n      prevPositionScreen.xyz / prevPositionScreen.w,\n      currPositionScreen.xyz / currPositionScreen.w,\n      nextPositionScreen.xyz / nextPositionScreen.w,\n      project_pixel_size_to_clipspace(width.xy)\n    );\n\n    DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\n    gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n  } else {\n    prevPosition = project_position(prevPosition, prevPosition64Low);\n    currPosition = project_position(currPosition, currPosition64Low);\n    nextPosition = project_position(nextPosition, nextPosition64Low);\n\n    width = vec3(project_pixel_size(widthPixels), 0.0);\n    DECKGL_FILTER_SIZE(width, geometry);\n\n    vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\n    geometry.position = vec4(currPosition + offset, 1.0);\n    gl_Position = project_common_position_to_clipspace(geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n  }\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#define SHADER_NAME path-layer-fragment-shader\n\nprecision highp float;\n\nuniform float miterLimit;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vPathPosition;\nvarying float vPathLength;\nvarying float vJointType;\n\nvoid main(void) {\n  geometry.uv = vPathPosition;\n\n  if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\n    if (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\n      discard;\n    }\n    if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) {\n      discard;\n    }\n  }\n  gl_FragColor = vColor;\n\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",modules:[jd,Gd]})}get wrapLongitude(){return!1}initializeState(){const e=!0;this.getAttributeManager().addInstanced({positions:{size:3,vertexOffset:1,type:5130,fp64:this.use64bitPositions(),transition:Iy,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:5121,update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Iy,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,accessor:"getColor",transition:Iy,defaultValue:Ay},instancePickingColors:{size:3,type:5121,accessor:(e,{index:t,target:i})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,i)}}),this.setState({pathTesselator:new Sy({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);const{props:t,changeFlags:i}=e,n=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){const{pathTesselator:e}=this.state,r=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:r.getPath,buffers:r,normalize:!t._pathType,loop:"loop"===t._pathType,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),i.dataChanged||n.invalidateAll()}if(i.extensionsChanged){var r;const{gl:e}=this.context;null===(r=this.state.model)||void 0===r||r.delete(),this.state.model=this._getModel(e),n.invalidateAll()}}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i}=t,{data:n}=this.props;return n[0]&&n[0].__source&&(t.object=n.find(e=>e.__source.index===i)),t}disablePickingIndex(e){const{data:t}=this.props;if(t[0]&&t[0].__source)for(let i=0;i<t.length;i++)t[i].__source.index===e&&this._disablePickingIndex(i);else super.disablePickingIndex(e)}draw({uniforms:e}){const{jointRounded:t,capRounded:i,billboard:n,miterLimit:r,widthUnits:s,widthScale:o,widthMinPixels:a,widthMaxPixels:l}=this.props;this.state.model.setUniforms(e).setUniforms({jointType:Number(t),capType:Number(i),billboard:n,widthUnits:Jn[s],widthScale:o,miterLimit:r,widthMinPixels:a,widthMaxPixels:l}).draw()}_getModel(e){return new Du(e,{...this.getShaders(),id:this.props.id,geometry:new Hu({drawMode:4,attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateSegmentTypes(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("segmentTypes")}}bt(Cy,"defaultProps",My),bt(Cy,"layerName","PathLayer");var Py,Ly={exports:{}};var Ry=function(){if(Py)return Ly.exports;function e(e,i,r){r=r||2;var s,o,a,u,h,p,f,m=i&&i.length,g=m?i[0]*r:e.length,_=t(e,0,g,r,!0),y=[];if(!_||_.next===_.prev)return y;if(m&&(_=function(e,i,n,r){var s,o,a,u=[];for(s=0,o=i.length;s<o;s++)(a=t(e,i[s]*r,s<o-1?i[s+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),u.push(d(a));for(u.sort(l),s=0;s<u.length;s++)n=c(u[s],n);return n}(e,i,_,r)),e.length>80*r){s=a=e[0],o=u=e[1];for(var v=r;v<g;v+=r)(h=e[v])<s&&(s=h),(p=e[v+1])<o&&(o=p),h>a&&(a=h),p>u&&(u=p);f=0!==(f=Math.max(a-s,u-o))?32767/f:0}return n(_,y,r,s,o,f,0),y}function t(e,t,i,n,r){var s,o;if(r===E(e,t,i,n)>0)for(s=t;s<i;s+=n)o=w(s,e[s],e[s+1],o);else for(s=i-n;s>=t;s-=n)o=w(s,e[s],e[s+1],o);return o&&g(o,o.next)&&(T(o),o=o.next),o}function i(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!g(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(T(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function n(e,t,l,c,u,d,p){if(e){!p&&d&&function(e,t,i,n){var r=e;do{0===r.z&&(r.z=h(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,n,r,s,o,a,l,c=1;do{for(i=e,e=null,s=null,o=0;i;){for(o++,n=i,a=0,t=0;t<c&&(a++,n=n.nextZ);t++);for(l=c;a>0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=n}s.nextZ=null,c*=2}while(o>1)}(r)}(e,c,u,d);for(var f,m,g=e;e.prev!==e.next;)if(f=e.prev,m=e.next,d?s(e,c,u,d):r(e))t.push(f.i/l|0),t.push(e.i/l|0),t.push(m.i/l|0),T(e),e=m.next,g=m.next;else if((e=m)===g){p?1===p?n(e=o(i(e),t,l),t,l,c,u,d,2):2===p&&a(e,t,l,c,u,d):n(i(e),t,l,c,u,d,1);break}}}function r(e){var t=e.prev,i=e,n=e.next;if(m(t,i,n)>=0)return!1;for(var r=t.x,s=i.x,o=n.x,a=t.y,l=i.y,c=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=r>s?r>o?r:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,g=n.next;g!==t;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=f&&p(r,a,s,l,o,c,g.x,g.y)&&m(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function s(e,t,i,n){var r=e.prev,s=e,o=e.next;if(m(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,c=o.x,u=r.y,d=s.y,f=o.y,g=a<l?a<c?a:c:l<c?l:c,_=u<d?u<f?u:f:d<f?d:f,y=a>l?a>c?a:c:l>c?l:c,v=u>d?u>f?u:f:d>f?d:f,x=h(g,_,t,i,n),b=h(y,v,t,i,n),w=e.prevZ,T=e.nextZ;w&&w.z>=x&&T&&T.z<=b;){if(w.x>=g&&w.x<=y&&w.y>=_&&w.y<=v&&w!==r&&w!==o&&p(a,u,l,d,c,f,w.x,w.y)&&m(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,T.x>=g&&T.x<=y&&T.y>=_&&T.y<=v&&T!==r&&T!==o&&p(a,u,l,d,c,f,T.x,T.y)&&m(T.prev,T,T.next)>=0)return!1;T=T.nextZ}for(;w&&w.z>=x;){if(w.x>=g&&w.x<=y&&w.y>=_&&w.y<=v&&w!==r&&w!==o&&p(a,u,l,d,c,f,w.x,w.y)&&m(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;T&&T.z<=b;){if(T.x>=g&&T.x<=y&&T.y>=_&&T.y<=v&&T!==r&&T!==o&&p(a,u,l,d,c,f,T.x,T.y)&&m(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function o(e,t,n){var r=e;do{var s=r.prev,o=r.next.next;!g(s,o)&&_(s,r,r.next,o)&&x(s,o)&&x(o,s)&&(t.push(s.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),T(r),T(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function a(e,t,r,s,o,a){var l=e;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&f(l,c)){var u=b(l,c);return l=i(l,l.next),u=i(u,u.next),n(l,t,r,s,o,a,0),void n(u,t,r,s,o,a,0)}c=c.next}l=l.next}while(l!==e)}function l(e,t){return e.x-t.x}function c(e,t){var n=function(e,t){var i,n=t,r=e.x,s=e.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o&&(o=a,i=n.x<n.next.x?n:n.next,a===r))return i}n=n.next}while(n!==t);if(!i)return null;var l,c=i,h=i.x,d=i.y,f=1/0;n=i;do{r>=n.x&&n.x>=h&&r!==n.x&&p(s<d?r:o,s,h,d,s<d?o:r,s,n.x,n.y)&&(l=Math.abs(s-n.y)/(r-n.x),x(n,e)&&(l<f||l===f&&(n.x>i.x||n.x===i.x&&u(i,n)))&&(i=n,f=l)),n=n.next}while(n!==c);return i}(e,t);if(!n)return t;var r=b(n,e);return i(r,r.next),i(n,n.next)}function u(e,t){return m(e.prev,e,t.prev)<0&&m(t.next,e,e.next)<0}function h(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function p(e,t,i,n,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(n-a)>=(i-o)*(t-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function f(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(x(e,t)&&x(t,e)&&function(e,t){var i=e,n=!1,r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||g(e,t)&&m(e.prev,e,e.next)>0&&m(t.prev,t,t.next)>0)}function m(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function g(e,t){return e.x===t.x&&e.y===t.y}function _(e,t,i,n){var r=v(m(e,t,i)),s=v(m(e,t,n)),o=v(m(i,n,e)),a=v(m(i,n,t));return r!==s&&o!==a||(!(0!==r||!y(e,i,t))||(!(0!==s||!y(e,n,t))||(!(0!==o||!y(i,e,n))||!(0!==a||!y(i,t,n)))))}function y(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function v(e){return e>0?1:e<0?-1:0}function x(e,t){return m(e.prev,e,e.next)<0?m(e,t,e.next)>=0&&m(e,e.prev,t)>=0:m(e,t,e.prev)<0||m(e,e.next,t)<0}function b(e,t){var i=new S(e.i,e.x,e.y),n=new S(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function w(e,t,i,n){var r=new S(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function T(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function S(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function E(e,t,i,n){for(var r=0,s=t,o=i-n;s<i;s+=n)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}return Py=1,Ly.exports=e,Ly.exports.default=e,e.deviation=function(e,t,i,n){var r=t&&t.length,s=Math.abs(E(e,0,r?t[0]*i:e.length,i));if(r)for(var o=0,a=t.length;o<a;o++){s-=Math.abs(E(e,t[o]*i,o<a-1?t[o+1]*i:e.length,i))}var l=0;for(o=0;o<n.length;o+=3){var c=n[o]*i,u=n[o+1]*i,h=n[o+2]*i;l+=Math.abs((e[c]-e[h])*(e[u+1]-e[c+1])-(e[c]-e[u])*(e[h+1]-e[c+1]))}return 0===s&&0===l?0:Math.abs((l-s)/s)},e.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},n=0,r=0;r<e.length;r++){for(var s=0;s<e[r].length;s++)for(var o=0;o<t;o++)i.vertices.push(e[r][s][o]);r>0&&i.holes.push(n+=e[r-1].length)}return i},Ly.exports}(),Oy=ne(Ry);const Dy=ry,By=sy,Fy={};function Ny(e){return"positions"in e?e.positions:e}function ky(e){return"holeIndices"in e?e.holeIndices:null}function zy(e,t,i,n,r){let s=t;const o=i.length;for(let t=0;t<o;t++)for(let r=0;r<n;r++)e[s++]=i[t][r]||0;if(!function(e){const t=e[0],i=e[e.length-1];return t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]}(i))for(let t=0;t<n;t++)e[s++]=i[0][t]||0;return Fy.start=t,Fy.end=s,Fy.size=n,oy(e,r,Fy),s}function Uy(e,t,i,n,r=0,s,o){const a=(s=s||i.length)-r;if(a<=0)return t;let l=t;for(let t=0;t<a;t++)e[l++]=i[r+t];if(!function(e,t,i,n){for(let r=0;r<t;r++)if(e[i+r]!==e[n-t+r])return!1;return!0}(i,n,r,s))for(let t=0;t<n;t++)e[l++]=i[r+t];return Fy.start=t,Fy.end=l,Fy.size=n,oy(e,o,Fy),l}function Vy(e,t){!function(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error("invalid polygon")}(e);const i=[],n=[];if("positions"in e){const{positions:r,holeIndices:s}=e;if(s){let e=0;for(let o=0;o<=s.length;o++)e=Uy(i,e,r,t,s[o-1],s[o],0===o?Dy:By),n.push(e);return n.pop(),{positions:i,holeIndices:n}}e=r}if(!function(e){return Array.isArray(e[0])}(e))return Uy(i,0,e,t,0,i.length,Dy),i;if(!function(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}(e)){let r=0;for(const[s,o]of e.entries())r=zy(i,r,o,t,0===s?Dy:By),n.push(r);return n.pop(),{positions:i,holeIndices:n}}return zy(i,0,e,t,Dy),i}function jy(e,t,i){const n=e.length/3;let r=0;for(let s=0;s<n;s++){const o=(s+1)%n;r+=e[3*s+t]*e[3*o+i],r-=e[3*o+t]*e[3*s+i]}return Math.abs(r/2)}function Gy(e,t,i,n){const r=e.length/3;for(let s=0;s<r;s++){const r=3*s,o=e[r+1],a=e[r+2];e[r+t]=e[r+0],e[r+i]=o,e[r+n]=a}}class Hy extends zm{constructor(e){const{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint8ClampedArray,size:1},indices:{type:i,size:1}}})}get(e){const{attributes:t}=this;return"indices"===e?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);const t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){const t=Vy(e,this.positionSize);return this.opts.resolution?fy(Ny(t),ky(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(e,t=null,i){const{size:n=2,normalize:r=!0,edgeTypes:s=!1}=i||{};t=t||[];const o=[],a=[];let l=0,c=0;for(let r=0;r<=t.length;r++){const s=t[r]||e.length,u=c,h=vy(e,n,l,s);for(let t=h;t<s;t++)o[c++]=e[t];for(let t=l;t<h;t++)o[c++]=e[t];by(o,n,u,c),xy(o,n,u,c,null==i?void 0:i.maxLatitude),l=s,a[r]=c}a.pop();const u=fy(o,a,{size:n,gridResolution:360,gridOffset:[-180,-180],edgeTypes:s});if(r)for(const e of u)wy(e.positions,n);return u}(Ny(t),ky(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(Wy(e)){let t=0;for(const i of e)t+=this.getGeometrySize(i);return t}return Ny(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&Wy(e))for(const i of e){const e=this.getGeometrySize(i);t.geometrySize=e,this.updateGeometryAttributes(i,t),t.vertexStart+=e,t.indexStart=this.indexStarts[t.geometryIndex+1]}else this._updateIndices(e,t),this._updatePositions(e,t),this._updateVertexValid(e,t)}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:n}){const{attributes:r,indexStarts:s,typedArrayManager:o}=this;let a=r.indices;if(!a||!e)return;let l=n;const c=function(e,t,i,n){let r=ky(e);r&&(r=r.map(e=>e/t));let s=Ny(e);const o=n&&3===t;if(i){const e=s.length;s=s.slice();const n=[];for(let r=0;r<e;r+=t){n[0]=s[r],n[1]=s[r+1],o&&(n[2]=s[r+2]);const e=i(n);s[r]=e[0],s[r+1]=e[1],o&&(s[r+2]=e[2])}}if(o){const e=jy(s,0,1),t=jy(s,0,2),n=jy(s,1,2);if(!e&&!t&&!n)return[];e>t&&e>n||(t>n?(i||(s=s.slice()),Gy(s,0,2,1)):(i||(s=s.slice()),Gy(s,2,0,1)))}return Oy(s,r,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);a=o.allocate(a,n+c.length,{copy:!0});for(let e=0;e<c.length;e++)a[l++]=c[e]+i;s[t+1]=n+c.length,r.indices=a}_updatePositions(e,{vertexStart:t,geometrySize:i}){const{attributes:{positions:n},positionSize:r}=this;if(!n||!e)return;const s=Ny(e);for(let e=t,o=0;o<i;e++,o++){const t=s[o*r+1],i=r>2?s[o*r+2]:0;n[3*e]=s[o*r],n[3*e+1]=t,n[3*e+2]=i}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){const{positionSize:n}=this,r=this.attributes.vertexValid,s=e&&ky(e);if(e&&e.edgeTypes?r.set(e.edgeTypes,t):r.fill(1,t,t+i),s)for(let e=0;e<s.length;e++)r[t+s[e]/n-1]=0;r[t+i-1]=0}}function Wy(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}var qy="\nattribute vec2 vertexPositions;\nattribute float vertexValid;\n\nuniform bool extruded;\nuniform bool isWireframe;\nuniform float elevationScale;\nuniform float opacity;\n\nvarying vec4 vColor;\n\nstruct PolygonProps {\n  vec4 fillColors;\n  vec4 lineColors;\n  vec3 positions;\n  vec3 nextPositions;\n  vec3 pickingColors;\n  vec3 positions64Low;\n  vec3 nextPositions64Low;\n  float elevations;\n};\n\nvec3 project_offset_normal(vec3 vector) {\n  if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n    project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\n    return normalize(vector * project_uCommonUnitsPerWorldUnit);\n  }\n  return project_normal(vector);\n}\n\nvoid calculatePosition(PolygonProps props) {\n#ifdef IS_SIDE_VERTEX\n  if(vertexValid < 0.5){\n    gl_Position = vec4(0.);\n    return;\n  }\n#endif\n\n  vec3 pos;\n  vec3 pos64Low;\n  vec3 normal;\n  vec4 colors = isWireframe ? props.lineColors : props.fillColors;\n\n  geometry.worldPosition = props.positions;\n  geometry.worldPositionAlt = props.nextPositions;\n  geometry.pickingColor = props.pickingColors;\n\n#ifdef IS_SIDE_VERTEX\n  pos = mix(props.positions, props.nextPositions, vertexPositions.x);\n  pos64Low = mix(props.positions64Low, props.nextPositions64Low, vertexPositions.x);\n#else\n  pos = props.positions;\n  pos64Low = props.positions64Low;\n#endif\n\n  if (extruded) {\n    pos.z += props.elevations * vertexPositions.y * elevationScale;\n  }\n  gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\n\n  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n  if (extruded) {\n  #ifdef IS_SIDE_VERTEX\n    normal = vec3(\n      props.positions.y - props.nextPositions.y + (props.positions64Low.y - props.nextPositions64Low.y),\n      props.nextPositions.x - props.positions.x + (props.nextPositions64Low.x - props.positions64Low.x),\n      0.0);\n    normal = project_offset_normal(normal);\n  #else\n    normal = project_normal(vec3(0.0, 0.0, 1.0));\n  #endif\n    geometry.normal = normal;\n    vec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, normal);\n    vColor = vec4(lightColor, colors.a * opacity);\n  } else {\n    vColor = vec4(colors.rgb, colors.a * opacity);\n  }\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",Xy="#define SHADER_NAME solid-polygon-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec3 positions64Low;\nattribute float elevations;\nattribute vec4 fillColors;\nattribute vec4 lineColors;\nattribute vec3 pickingColors;\n\n".concat(qy,"\n\nvoid main(void) {\n  PolygonProps props;\n\n  props.positions = positions;\n  props.positions64Low = positions64Low;\n  props.elevations = elevations;\n  props.fillColors = fillColors;\n  props.lineColors = lineColors;\n  props.pickingColors = pickingColors;\n\n  calculatePosition(props);\n}\n"),$y="#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\n\n\nattribute vec3 instancePositions;\nattribute vec3 nextPositions;\nattribute vec3 instancePositions64Low;\nattribute vec3 nextPositions64Low;\nattribute float instanceElevations;\nattribute vec4 instanceFillColors;\nattribute vec4 instanceLineColors;\nattribute vec3 instancePickingColors;\n\n".concat(qy,"\n\nvoid main(void) {\n  PolygonProps props;\n\n  #if RING_WINDING_ORDER_CW == 1\n    props.positions = instancePositions;\n    props.positions64Low = instancePositions64Low;\n    props.nextPositions = nextPositions;\n    props.nextPositions64Low = nextPositions64Low;\n  #else\n    props.positions = nextPositions;\n    props.positions64Low = nextPositions64Low;\n    props.nextPositions = instancePositions;\n    props.nextPositions64Low = instancePositions64Low;\n  #endif\n  props.elevations = instanceElevations;\n  props.fillColors = instanceFillColors;\n  props.lineColors = instanceLineColors;\n  props.pickingColors = instancePickingColors;\n\n  calculatePosition(props);\n}\n");const Zy=[0,0,0,255],Yy={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:Zy},getLineColor:{type:"accessor",value:Zy},material:!0},Jy={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class Ky extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(e){return super.getShaders({vs:"top"===e?Xy:$y,fs:"#define SHADER_NAME solid-polygon-layer-fragment-shader\n\nprecision highp float;\n\nvarying vec4 vColor;\n\nvoid main(void) {\n  gl_FragColor = vColor;\n\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[jd,Su,Gd]})}get wrapLongitude(){return!1}initializeState(){const{gl:e,viewport:t}=this.context;let{coordinateSystem:i}=this.props;const{_full3d:n}=this.props;let r;t.isGeospatial&&i===Zn.DEFAULT&&(i=Zn.LNGLAT),i===Zn.LNGLAT&&(r=n?t.projectPosition.bind(t):t.projectFlat.bind(t)),this.setState({numInstances:0,polygonTesselator:new Hy({preproject:r,fp64:this.use64bitPositions(),IndexType:!e||mo(e,Zs)?Uint32Array:Uint16Array})});const s=this.getAttributeManager(),o=!0;s.remove(["instancePickingColors"]),s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},positions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:Jy,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{positions:{vertexOffset:0,divisor:0},instancePositions:{vertexOffset:0,divisor:1},nextPositions:{vertexOffset:1,divisor:1}}},vertexValid:{size:1,divisor:1,type:5121,update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,transition:Jy,accessor:"getElevation",shaderAttributes:{elevations:{divisor:0},instanceElevations:{divisor:1}}},fillColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:Jy,accessor:"getFillColor",defaultValue:Zy,shaderAttributes:{fillColors:{divisor:0},instanceFillColors:{divisor:1}}},lineColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:Jy,accessor:"getLineColor",defaultValue:Zy,shaderAttributes:{lineColors:{divisor:0},instanceLineColors:{divisor:1}}},pickingColors:{size:3,type:5121,accessor:(e,{index:t,target:i})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,i),shaderAttributes:{pickingColors:{divisor:0},instancePickingColors:{divisor:1}}}})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i}=t,{data:n}=this.props;return n[0]&&n[0].__source&&(t.object=n.find(e=>e.__source.index===i)),t}disablePickingIndex(e){const{data:t}=this.props;if(t[0]&&t[0].__source)for(let i=0;i<t.length;i++)t[i].__source.index===e&&this._disablePickingIndex(i);else super.disablePickingIndex(e)}draw({uniforms:e}){const{extruded:t,filled:i,wireframe:n,elevationScale:r}=this.props,{topModel:s,sideModel:o,polygonTesselator:a}=this.state,l={...e,extruded:Boolean(t),elevationScale:r};o&&(o.setInstanceCount(a.instanceCount-1),o.setUniforms(l),n&&(o.setDrawMode(3),o.setUniforms({isWireframe:!0}).draw()),i&&(o.setDrawMode(6),o.setUniforms({isWireframe:!1}).draw())),s&&(s.setVertexCount(a.vertexCount),s.setUniforms(l).draw())}updateState(e){super.updateState(e),this.updateGeometry(e);const{props:t,oldProps:i,changeFlags:n}=e,r=this.getAttributeManager();var s;(n.extensionsChanged||t.filled!==i.filled||t.extruded!==i.extruded)&&(null===(s=this.state.models)||void 0===s||s.forEach(e=>e.delete()),this.setState(this._getModels(this.context.gl)),r.invalidateAll())}updateGeometry({props:e,changeFlags:t}){if(t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon)){const{polygonTesselator:i}=this.state,n=e.data.attributes||{};i.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:n.getPolygon,buffers:n,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:t.dataChanged,full3d:e._full3d}),this.setState({numInstances:i.instanceCount,startIndices:i.vertexStarts}),t.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(e){const{id:t,filled:i,extruded:n}=this.props;let r,s;if(i){const i=this.getShaders("top");i.defines.NON_INSTANCED_MODEL=1,r=new Du(e,{...i,id:"".concat(t,"-top"),drawMode:4,attributes:{vertexPositions:new Float32Array([0,1])},uniforms:{isWireframe:!1,isSideVertex:!1},vertexCount:0,isIndexed:!0})}return n&&(s=new Du(e,{...this.getShaders("side"),id:"".concat(t,"-side"),geometry:new Hu({drawMode:1,vertexCount:4,attributes:{vertexPositions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),instanceCount:0,isInstanced:1}),s.userData.excludeAttributes={indices:!0}),{models:[s,r].filter(Boolean),topModel:r,sideModel:s}}calculateIndices(e){const{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){const{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}}function Qy({data:e,getIndex:t,dataRange:i,replace:n}){const{startRow:r=0,endRow:s=1/0}=i,o=e.length;let a=o,l=o;for(let i=0;i<o;i++){const n=t(e[i]);if(a>i&&n>=r&&(a=i),n>=s){l=i;break}}let c=a;const u=l-a!==n.length?e.slice(l):void 0;for(let t=0;t<n.length;t++)e[c++]=n[t];if(u){for(let t=0;t<u.length;t++)e[c++]=u[t];e.length=c}return{startRow:a,endRow:a+n.length}}bt(Ky,"defaultProps",Yy),bt(Ky,"layerName","SolidPolygonLayer");const ev=.75,tv=[];class iv extends Y_{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){return{...super.getShaders(),fs:"#define SHADER_NAME multi-icon-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D iconsTexture;\nuniform float gamma;\nuniform bool sdf;\nuniform float alphaCutoff;\nuniform float sdfBuffer;\nuniform float outlineBuffer;\nuniform vec4 outlineColor;\n\nvarying vec4 vColor;\nvarying vec2 vTextureCoords;\nvarying vec2 uv;\n\nvoid main(void) {\n  geometry.uv = uv;\n\n  if (!picking_uActive) {\n    float alpha = texture2D(iconsTexture, vTextureCoords).a;\n    vec4 color = vColor;\n    if (sdf) {\n      float distance = alpha;\n      alpha = smoothstep(sdfBuffer - gamma, sdfBuffer + gamma, distance);\n\n      if (outlineBuffer > 0.0) {\n        float inFill = alpha;\n        float inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance);\n        color = mix(outlineColor, vColor, inFill);\n        alpha = inBorder;\n      }\n    }\n    float a = alpha * color.a;\n    \n    if (a < alphaCutoff) {\n      discard;\n    }\n\n    gl_FragColor = vec4(color.rgb, a * opacity);\n  }\n\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n"}}initializeState(){super.initializeState();this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:5121,size:3,accessor:(e,{index:t,target:i})=>this.encodePickingColor(t,i)}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;let{outlineColor:n}=t;n!==i.outlineColor&&(n=n.map(e=>e/255),n[3]=Number.isFinite(n[3])?n[3]:1,this.setState({outlineColor:n})),!t.sdf&&t.outlineWidth&&Gn.warn("".concat(this.id,": fontSettings.sdf is required to render outline"))()}draw(e){const{sdf:t,smoothing:i,outlineWidth:n}=this.props,{outlineColor:r}=this.state,s=n?Math.max(i,ev*(1-n)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:ev,outlineBuffer:s,gamma:i,sdf:Boolean(t),outlineColor:r},super.draw(e),t&&n){const{iconManager:e}=this.state;e.getTexture()&&this.state.model.draw({uniforms:{outlineBuffer:ev}})}}getInstanceOffset(e){return e?Array.from(e).flatMap(e=>super.getInstanceOffset(e)):tv}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(e=>super.getInstanceIconFrame(e)):tv}}bt(iv,"defaultProps",{getIconOffsets:{type:"accessor",value:e=>e.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}}),bt(iv,"layerName","MultiIconLayer");const nv=1e20,rv=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);rv[e]=t*Math.abs(t)}rv[255]=-nv;class sv{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=t,this.radius=i,this.cutoff=n,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${o} ${s} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:s}=this.ctx.measureText(e),o=Math.ceil(i),a=Math.floor(-r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-a)),c=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(n))),u=l+2*this.buffer,h=c+2*this.buffer,d=Math.max(u*h,0),p=new Uint8ClampedArray(d),f={data:p,width:u,height:h,glyphWidth:l,glyphHeight:c,glyphTop:o,glyphLeft:a,glyphAdvance:t};if(0===l||0===c)return f;const{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,c),m.fillText(e,g-a,g+o);const v=m.getImageData(g,g,l,c);y.fill(nv,0,d),_.fill(0,0,d);let x=3;for(let e=0;e<c;e++){let t=(e+g)*u+g;for(let e=0;e<l;e++,x+=4,t++){const e=v.data[x];if(0===e)continue;const i=rv[e];y[t]=Math.max(0,i),_[t]=Math.max(0,-i)}}ov(y,0,0,u,h,u,this.f,this.v,this.z);const b=Math.min(g,1);ov(_,g-b,g-b,l+2*b,c+2*b,u,this.f,this.v,this.z);const w=255/this.radius,T=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(y[e])-Math.sqrt(_[e]);p[e]=Math.round(T-w*t)}return f}}function ov(e,t,i,n,r,s,o,a,l){for(let c=t;c<t+n;c++)av(e,i*s+c,s,r,o,a,l);for(let c=i;c<i+r;c++)av(e,c*s+t,1,n,o,a,l)}function av(e,t,i,n,r,s,o){s[0]=0,o[0]=-nv,o[1]=nv,r[0]=e[t];for(let a=1,l=0,c=0;a<n;a++){r[a]=e[t+a*i];const n=a*a;do{const e=s[l];c=(r[a]-r[e]+n-e*e)/(a-e)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=nv}for(let a=0,l=0;a<n;a++){for(;o[l+1]<a;)l++;const n=s[l],c=a-n;e[t+a*i]=r[n]+c*c}}const lv=[];function cv(e,t,i,n){let r=0;for(let o=t;o<i;o++){var s;r+=(null===(s=n[e[o]])||void 0===s?void 0:s.layoutWidth)||0}return r}function uv(e,t,i,n,r,s){let o=t,a=0;for(let l=t;l<i;l++){const t=cv(e,l,l+1,r);a+t>n&&(o<l&&s.push(l),o=l,a=0),a+=t}return a}function hv(e,t,i,n,r=0,s){void 0===s&&(s=e.length);const o=[];return"break-all"===t?uv(e,r,s,i,n,o):function(e,t,i,n,r,s){let o=t,a=t,l=t,c=0;for(let u=t;u<i;u++)if(" "===e[u]?l=u+1:" "!==e[u+1]&&u+1!==i||(l=u+1),l>a){let t=cv(e,a,l,r);c+t>n&&(o<a&&(s.push(a),o=a,c=0),t>n&&(t=uv(e,a,l,n,r,s),o=s[s.length-1])),a=l,c+=t}}(e,r,s,i,n,o),o}function dv(e,t,i,n,r,s){let o=0,a=0;for(let s=t;s<i;s++){const t=e[s],i=n[t];i?(a||(a=i.layoutHeight),r[s]=o+i.layoutWidth/2,o+=i.layoutWidth):(Gn.warn("Missing character: ".concat(t," (").concat(t.codePointAt(0),")"))(),r[s]=o,o+=32)}s[0]=o,s[1]=a}class pv{constructor(e=5){bt(this,"limit",void 0),bt(this,"_cache",{}),bt(this,"_order",[]),this.limit=e}get(e){const t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){const t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}const fv={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let mv=new pv(3);function gv(e,t){for(let i=0;i<e.length;i++)t.data[4*i+3]=e[i]}function _v(e,t,i,n){e.font="".concat(n," ").concat(i,"px ").concat(t),e.fillStyle="#000",e.textBaseline="alphabetic",e.textAlign="left"}class yv{constructor(){bt(this,"props",{...fv}),bt(this,"_key",void 0),bt(this,"_atlas",void 0)}get texture(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){const{fontSize:e,buffer:t}=this.props;return(1.2*e+2*t)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();const t=function(e,t){let i;i="string"==typeof t?new Set(Array.from(t)):new Set(t);const n=mv.get(e);if(!n)return i;for(const e in n.mapping)i.has(e)&&i.delete(e);return i}(this._key,this.props.characterSet),i=mv.get(this._key);if(i&&0===t.size)return void(this._atlas!==i&&(this._atlas=i));const n=this._generateFontAtlas(t,i);this._atlas=n,mv.set(this._key,n)}_generateFontAtlas(e,t){const{fontFamily:i,fontWeight:n,fontSize:r,buffer:s,sdf:o,radius:a,cutoff:l}=this.props;let c=t&&t.data;c||(c=document.createElement("canvas"),c.width=1024);const u=c.getContext("2d",{willReadFrequently:!0});_v(u,i,r,n);const{mapping:h,canvasHeight:d,xOffset:p,yOffset:f}=function({characterSet:e,getFontWidth:t,fontHeight:i,buffer:n,maxCanvasWidth:r,mapping:s={},xOffset:o=0,yOffset:a=0}){let l=0,c=o;const u=i+2*n;for(const o of e)if(!s[o]){const e=t(o);c+e+2*n>r&&(c=0,l++),s[o]={x:c+n,y:a+l*u+n,width:e,height:u,layoutWidth:e,layoutHeight:i},c+=e+2*n}return{mapping:s,xOffset:c,yOffset:a+l*u,canvasHeight:(h=a+(l+1)*u,Math.pow(2,Math.ceil(Math.log2(h))))};var h}({getFontWidth:e=>u.measureText(e).width,fontHeight:1.2*r,buffer:s,characterSet:e,maxCanvasWidth:1024,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffset:t.yOffset}});if(c.height!==d){const e=u.getImageData(0,0,c.width,c.height);c.height=d,u.putImageData(e,0,0)}if(_v(u,i,r,n),o){const t=new sv({fontSize:r,buffer:s,radius:a,cutoff:l,fontFamily:i,fontWeight:"".concat(n)});for(const i of e){const{data:e,width:n,height:s,glyphTop:o}=t.draw(i);h[i].width=n,h[i].layoutOffsetY=.9*r-o;const a=u.createImageData(n,s);gv(e,a),u.putImageData(a,h[i].x,h[i].y)}}else for(const t of e)u.fillText(t,h[t].x,h[t].y+s+.9*r);return{xOffset:p,yOffset:f,mapping:h,data:c,width:c.width,height:c.height}}_getKey(){const{fontFamily:e,fontWeight:t,fontSize:i,buffer:n,sdf:r,radius:s,cutoff:o}=this.props;return r?"".concat(e," ").concat(t," ").concat(i," ").concat(n," ").concat(s," ").concat(o):"".concat(e," ").concat(t," ").concat(i," ").concat(n)}}const vv={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:e=>e.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}};class xv extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){return super.getShaders({vs:"#define SHADER_NAME text-background-layer-vertex-shader\n\nattribute vec2 positions;\n\nattribute vec3 instancePositions;\nattribute vec3 instancePositions64Low;\nattribute vec4 instanceRects;\nattribute float instanceSizes;\nattribute float instanceAngles;\nattribute vec2 instancePixelOffsets;\nattribute float instanceLineWidths;\nattribute vec4 instanceFillColors;\nattribute vec4 instanceLineColors;\nattribute vec3 instancePickingColors;\n\nuniform bool billboard;\nuniform float opacity;\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform vec4 padding;\nuniform int sizeUnits;\n\nvarying vec4 vFillColor;\nvarying vec4 vLineColor;\nvarying float vLineWidth;\nvarying vec2 uv;\nvarying vec2 dimensions;\n\nvec2 rotate_by_angle(vec2 vertex, float angle) {\n  float angle_radian = radians(angle);\n  float cos_angle = cos(angle_radian);\n  float sin_angle = sin(angle_radian);\n  mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\n  return rotationMatrix * vertex;\n}\n\nvoid main(void) {\n  geometry.worldPosition = instancePositions;\n  geometry.uv = positions;\n  geometry.pickingColor = instancePickingColors;\n  uv = positions;\n  vLineWidth = instanceLineWidths;\n  float sizePixels = clamp(\n    project_size_to_pixel(instanceSizes * sizeScale, sizeUnits),\n    sizeMinPixels, sizeMaxPixels\n  );\n\n  dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw;\n\n  vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions);\n  pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\n  pixelOffset += instancePixelOffsets;\n  pixelOffset.y *= -1.0;\n\n  if (billboard)  {\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n    vec3 offset = vec3(pixelOffset, 0.0);\n    DECKGL_FILTER_SIZE(offset, geometry);\n    gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n  } else {\n    vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\n    DECKGL_FILTER_SIZE(offset_common, geometry);\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\n    DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n  }\n  vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);\n  DECKGL_FILTER_COLOR(vFillColor, geometry);\n  vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);\n  DECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#define SHADER_NAME text-background-layer-fragment-shader\n\nprecision highp float;\n\nuniform bool stroked;\n\nvarying vec4 vFillColor;\nvarying vec4 vLineColor;\nvarying float vLineWidth;\nvarying vec2 uv;\nvarying vec2 dimensions;\n\nvoid main(void) {\n  geometry.uv = uv;\n\n  vec2 pixelPosition = uv * dimensions;\n  if (stroked) {\n    float distToEdge = min(\n      min(pixelPosition.x, dimensions.x - pixelPosition.x),\n      min(pixelPosition.y, dimensions.y - pixelPosition.y)\n    );\n    float isBorder = smoothedge(distToEdge, vLineWidth);\n    gl_FragColor = mix(vFillColor, vLineColor, isBorder);\n  } else {\n    gl_FragColor = vFillColor;\n  }\n\n  DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n",modules:[jd,Gd]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,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,normalized:!0,type:5121,accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,normalized:!0,type:5121,accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);const{changeFlags:t}=e;if(t.extensionsChanged){var i;const{gl:e}=this.context;null===(i=this.state.model)||void 0===i||i.delete(),this.state.model=this._getModel(e),this.getAttributeManager().invalidateAll()}}draw({uniforms:e}){const{billboard:t,sizeScale:i,sizeUnits:n,sizeMinPixels:r,sizeMaxPixels:s,getLineWidth:o}=this.props;let{padding:a}=this.props;a.length<4&&(a=[a[0],a[1],a[0],a[1]]),this.state.model.setUniforms(e).setUniforms({billboard:t,stroked:Boolean(o),padding:a,sizeUnits:Jn[n],sizeScale:i,sizeMinPixels:r,sizeMaxPixels:s}).draw()}_getModel(e){return new Du(e,{...this.getShaders(),id:this.props.id,geometry:new Hu({drawMode:6,vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,1,1,0,1])}}}),isInstanced:!0})}}bt(xv,"defaultProps",vv),bt(xv,"layerName","TextBackgroundLayer");const bv={start:1,middle:0,end:-1},wv={top:1,center:0,bottom:-1},Tv=[0,0,0,255],Sv={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:Tv},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:fv.characterSet},fontFamily:fv.fontFamily,fontWeight:fv.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:Tv},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:e=>e.text},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:Tv},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"]}};class Ev extends Nm{constructor(...e){super(...e),bt(this,"state",void 0),bt(this,"getBoundingRect",(e,t)=>{let{size:[i,n]}=this.transformParagraph(e,t);const{fontSize:r}=this.state.fontAtlasManager.props;i/=r,n/=r;const{getTextAnchor:s,getAlignmentBaseline:o}=this.props;return[(bv["function"==typeof s?s(e,t):s]-1)*i/2,(wv["function"==typeof o?o(e,t):o]-1)*n/2,i,n]}),bt(this,"getIconOffsets",(e,t)=>{const{getTextAnchor:i,getAlignmentBaseline:n}=this.props,{x:r,y:s,rowWidth:o,size:[a,l]}=this.transformParagraph(e,t),c=bv["function"==typeof i?i(e,t):i],u=wv["function"==typeof n?n(e,t):n],h=r.length,d=new Array(2*h);let p=0;for(let e=0;e<h;e++){d[p++]=(c-1)*a/2+(1-c)*(a-o[e])/2+r[e],d[p++]=(u-1)*l/2+s[e]}return d})}initializeState(){this.state={styleVersion:0,fontAtlasManager:new yv},this.props.maxWidth>0&&Gn.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:t,oldProps:i,changeFlags:n}=e;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||t.lineHeight!==i.lineHeight||t.wordBreak!==i.wordBreak||t.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(){const{fontSettings:e,fontFamily:t,fontWeight:i}=this.props,{fontAtlasManager:n,characterSet:r}=this.state,s={...e,characterSet:r,fontFamily:t,fontWeight:i};if(!n.mapping)return n.setProps(s),!0;for(const e in s)if(s[e]!==n.props[e])return n.setProps(s),!0;return!1}_updateText(){var e;const{data:t,characterSet:i}=this.props,n=null===(e=t.attributes)||void 0===e?void 0:e.getText;let r,{getText:s}=this.props,o=t.startIndices;const a="auto"===i&&new Set;if(n&&o){const{texts:e,characterCount:i}=function({value:e,length:t,stride:i,offset:n,startIndices:r,characterSet:s}){const o=e.BYTES_PER_ELEMENT,a=i?i/o:1,l=n?n/o:0,c=r[t]||Math.ceil((e.length-l)/a),u=s&&new Set,h=new Array(t);let d=e;if(a>1||l>0){d=new(0,e.constructor)(c);for(let t=0;t<c;t++)d[t]=e[t*a+l]}for(let e=0;e<t;e++){const t=d.subarray(r[e],r[e+1]||c);h[e]=String.fromCodePoint.apply(null,t),u&&t.forEach(u.add,u)}if(u)for(const e of u)s.add(String.fromCodePoint(e));return{texts:h,characterCount:c}}({...ArrayBuffer.isView(n)?{value:n}:n,length:t.length,startIndices:o,characterSet:a});r=i,s=(t,{index:i})=>e[i]}else{const{iterable:e,objectInfo:i}=Ff(t);o=[0],r=0;for(const t of e){i.index++;const e=Array.from(s(t,i)||"");a&&e.forEach(a.add,a),r+=e.length,o.push(r)}}this.setState({getText:s,startIndices:o,numInstances:r,characterSet:a||i})}transformParagraph(e,t){const{fontAtlasManager:i}=this.state,n=i.mapping,r=this.state.getText,{wordBreak:s,lineHeight:o,maxWidth:a}=this.props;return function(e,t,i,n,r){const s=Array.from(e),o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=("break-word"===i||"break-all"===i)&&isFinite(n)&&n>0,h=[0,0],d=[0,0];let p=0,f=0,m=0;for(let e=0;e<=o;e++){const _=s[e];if("\n"!==_&&e!==o||(m=e),m>f){const e=u?hv(s,i,n,r,f,m):lv;for(let i=0;i<=e.length;i++){const n=0===i?f:e[i-1],o=i<e.length?e[i]:m;dv(s,n,o,r,a,d);for(let e=n;e<o;e++){var g;const t=(null===(g=r[s[e]])||void 0===g?void 0:g.layoutOffsetY)||0;l[e]=p+d[1]/2+t,c[e]=d[0]}p+=d[1]*t,h[0]=Math.max(h[0],d[0])}f=m}"\n"===_&&(a[f]=0,l[f]=0,c[f]=0,f++)}return h[1]=p,{x:a,y:l,rowWidth:c,size:h}}(r(e,t)||"",o,s,a*i.props.fontSize,n)}renderLayers(){const{startIndices:e,numInstances:t,getText:i,fontAtlasManager:{scale:n,texture:r,mapping:s},styleVersion:o}=this.state,{data:a,_dataDiff:l,getPosition:c,getColor:u,getSize:h,getAngle:d,getPixelOffset:p,getBackgroundColor:f,getBorderColor:m,getBorderWidth:g,backgroundPadding:_,background:y,billboard:v,fontSettings:x,outlineWidth:b,outlineColor:w,sizeScale:T,sizeUnits:S,sizeMinPixels:E,sizeMaxPixels:A,transitions:M,updateTriggers:I}=this.props,C=this.getSubLayerClass("characters",iv),P=this.getSubLayerClass("background",xv);return[y&&new P({getFillColor:f,getLineColor:m,getLineWidth:g,padding:_,getPosition:c,getSize:h,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:T,sizeUnits:S,sizeMinPixels:E,sizeMaxPixels:A,transitions:M&&{getPosition:M.getPosition,getAngle:M.getAngle,getSize:M.getSize,getFillColor:M.getBackgroundColor,getLineColor:M.getBorderColor,getLineWidth:M.getBorderWidth,getPixelOffset:M.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:I.getPosition,getAngle:I.getAngle,getSize:I.getSize,getFillColor:I.getBackgroundColor,getLineColor:I.getBorderColor,getLineWidth:I.getBorderWidth,getPixelOffset:I.getPixelOffset,getBoundingRect:{getText:I.getText,getTextAnchor:I.getTextAnchor,getAlignmentBaseline:I.getAlignmentBaseline,styleVersion:o}}}),{data:a.attributes&&a.attributes.background?{length:a.length,attributes:a.attributes.background}:a,_dataDiff:l,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new C({sdf:x.sdf,smoothing:Number.isFinite(x.smoothing)?x.smoothing:fv.smoothing,outlineWidth:b/(x.radius||fv.radius),outlineColor:w,iconAtlas:r,iconMapping:s,getPosition:c,getColor:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:T*n,sizeUnits:S,sizeMinPixels:E*n,sizeMaxPixels:A*n,transitions:M&&{getPosition:M.getPosition,getAngle:M.getAngle,getColor:M.getColor,getSize:M.getSize,getPixelOffset:M.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:I.getText,getPosition:I.getPosition,getAngle:I.getAngle,getColor:I.getColor,getSize:I.getSize,getPixelOffset:I.getPixelOffset,getIconOffsets:{getTextAnchor:I.getTextAnchor,getAlignmentBaseline:I.getAlignmentBaseline,styleVersion:o}}}),{data:a,_dataDiff:l,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(e){!function(e){Gn.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),mv=new pv(e)}(e)}}bt(Ev,"defaultProps",Sv),bt(Ev,"layerName","TextLayer");const Av={circle:{type:ny,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:Y_,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:Ev,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"}}},Mv={type:Cy,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Iv={type:Ky,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Cv({type:e,props:t}){const i={};for(const n in t)i[n]=e.defaultProps[t[n]];return i}function Pv(e,t){const{transitions:i,updateTriggers:n}=e.props,r={updateTriggers:{},transitions:i&&{getPosition:i.geometry}};for(const s in t){const o=t[s];let a=e.props[s];s.startsWith("get")&&(a=e.getSubLayerAccessor(a),r.updateTriggers[o]=n[s],i&&(r.transitions[o]=i[s])),r[o]=a}return r}function Lv(e,t,i={}){const n={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:r=0,endRow:s=e.length}=i;for(let i=r;i<s;i++){const r=e[i],{geometry:s}=r;if(s)if("GeometryCollection"===s.type){Gn.assert(Array.isArray(s.geometries),"GeoJSON does not have geometries array");const{geometries:e}=s;for(let s=0;s<e.length;s++){Rv(e[s],n,t,r,i)}}else Rv(s,n,t,r,i)}return n}function Rv(e,t,i,n,r){const{type:s,coordinates:o}=e,{pointFeatures:a,lineFeatures:l,polygonFeatures:c,polygonOutlineFeatures:u}=t;if(function(e,t){let i=Ov[e];Gn.assert(i,"Unknown GeoJSON type ".concat(e));for(;t&&--i>0;)t=t[0];return t&&Number.isFinite(t[0])}(s,o))switch(s){case"Point":a.push(i({geometry:e},n,r));break;case"MultiPoint":o.forEach(e=>{a.push(i({geometry:{type:"Point",coordinates:e}},n,r))});break;case"LineString":l.push(i({geometry:e},n,r));break;case"MultiLineString":o.forEach(e=>{l.push(i({geometry:{type:"LineString",coordinates:e}},n,r))});break;case"Polygon":c.push(i({geometry:e},n,r)),o.forEach(e=>{u.push(i({geometry:{type:"LineString",coordinates:e}},n,r))});break;case"MultiPolygon":o.forEach(e=>{c.push(i({geometry:{type:"Polygon",coordinates:e}},n,r)),e.forEach(e=>{u.push(i({geometry:{type:"LineString",coordinates:e}},n,r))})})}else Gn.warn("".concat(s," coordinates are malformed"))()}const Ov={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Dv(e){return e.geometry.coordinates}function Bv(e,t){const i={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:n,lines:r,polygons:s}=e,o=function(e,t){const i={points:null,lines:null,polygons:null};for(const n in i){const r=e[n].globalFeatureIds.value;i[n]=new Uint8ClampedArray(3*r.length);const s=[];for(let e=0;e<r.length;e++)t(r[e],s),i[n][3*e+0]=s[0],i[n][3*e+1]=s[1],i[n][3*e+2]=s[2]}return i}(e,t);return i.points.data={length:n.positions.value.length/n.positions.size,attributes:{...n.attributes,getPosition:n.positions,instancePickingColors:{size:3,value:o.points}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},i.lines.data={length:r.pathIndices.value.length-1,startIndices:r.pathIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:3,value:o.lines}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},i.lines._pathType="open",i.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},i.polygons._normalize=!1,s.triangles&&(i.polygons.data.attributes.indices=s.triangles.value),i.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},i.polygonsOutline._pathType="open",i}const Fv=["points","linestrings","polygons"],Nv={...Cv(Av.circle),...Cv(Av.icon),...Cv(Av.text),...Cv(Mv),...Cv(Iv),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:e=>e.properties.icon},getText:{type:"accessor",value:e=>e.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};let kv=class extends Nm{initializeState(){this.state={layerProps:{},features:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;const{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:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e}){const t=Bv(e.data,this.encodePickingColor);this.setState({layerProps:t})}_updateStateJSON({props:e,changeFlags:t}){const i=function(e){if(Array.isArray(e))return e;switch(Gn.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return Gn.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),n=this.getSubLayerRow.bind(this);let r={};const s={};if(Array.isArray(t.dataChanged)){const e=this.state.features;for(const t in e)r[t]=e[t].slice(),s[t]=[];for(const o of t.dataChanged){const t=Lv(i,n,o);for(const i in e)s[i].push(Qy({data:r[i],getIndex:e=>e.__source.index,dataRange:o,replace:t[i]}))}}else r=Lv(i,n);const o=function(e,t){const i={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:n,lineFeatures:r,polygonFeatures:s,polygonOutlineFeatures:o}=e;return i.points.data=n,i.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),i.points.getPosition=Dv,i.lines.data=r,i.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),i.lines.getPath=Dv,i.polygons.data=s,i.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),i.polygons.getPolygon=Dv,i.polygonsOutline.data=o,i.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),i.polygonsOutline.getPath=Dv,i}(r,s);this.setState({features:r,featuresDiff:s,layerProps:o})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i,sourceLayer:n}=t;return t.featureType=Fv.find(e=>n.id.startsWith("".concat(this.id,"-").concat(e,"-"))),i>=0&&n.id.startsWith("".concat(this.id,"-points-text"))&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[i]),t}_updateAutoHighlight(e){const t="".concat(this.id,"-points-"),i="points"===e.featureType;for(const n of this.getSubLayers())n.id.startsWith(t)===i&&n.updateAutoHighlight(e)}_renderPolygonLayer(){const{extruded:e,wireframe:t}=this.props,{layerProps:i}=this.state,n="polygons-fill",r=this.shouldRenderSubLayer(n,i.polygons.data)&&this.getSubLayerClass(n,Iv.type);if(r){const s=Pv(this,Iv.props),o=e&&t;return o||delete s.getLineColor,s.updateTriggers.lineColors=o,new r(s,this.getSubLayerProps({id:n,updateTriggers:s.updateTriggers}),i.polygons)}return null}_renderLineLayers(){const{extruded:e,stroked:t}=this.props,{layerProps:i}=this.state,n="polygons-stroke",r="linestrings",s=!e&&t&&this.shouldRenderSubLayer(n,i.polygonsOutline.data)&&this.getSubLayerClass(n,Mv.type),o=this.shouldRenderSubLayer(r,i.lines.data)&&this.getSubLayerClass(r,Mv.type);if(s||o){const e=Pv(this,Mv.props);return[s&&new s(e,this.getSubLayerProps({id:n,updateTriggers:e.updateTriggers}),i.polygonsOutline),o&&new o(e,this.getSubLayerProps({id:r,updateTriggers:e.updateTriggers}),i.lines)]}return null}_renderPointLayers(){const{pointType:e}=this.props,{layerProps:t,binary:i}=this.state;let{highlightedObjectIndex:n}=this.props;!i&&Number.isFinite(n)&&(n=t.points.data.findIndex(e=>e.__source.index===n));const r=new Set(e.split("+")),s=[];for(const e of r){const r="points-".concat(e),o=Av[e],a=o&&this.shouldRenderSubLayer(r,t.points.data)&&this.getSubLayerClass(r,o.type);if(a){const l=Pv(this,o.props);let c=t.points;if("text"===e&&i){const{instancePickingColors:e,...t}=c.data.attributes;c={...c,data:{...c.data,attributes:t}}}s.push(new a(l,this.getSubLayerProps({id:r,updateTriggers:l.updateTriggers,highlightedObjectIndex:n}),c))}}return s}renderLayers(){const{extruded:e}=this.props,t=this._renderPolygonLayer();return[!e&&t,this._renderLineLayers(),this._renderPointLayers(),e&&t]}getSubLayerAccessor(e){const{binary:t}=this.state;return t&&"function"==typeof e?(t,i)=>{const{data:n,index:r}=i,s=function(e,t){if(!e)return null;const i="startIndices"in e?e.startIndices[t]:t;return-1!==i?function(e,t,i){const n={properties:{...e.properties[t]}};for(const t in e.numericProps)n.properties[t]=e.numericProps[t].value[i];return n}(e,e.featureIds.value[i],i):null}(n,r);return e(s,i)}:super.getSubLayerAccessor(e)}};bt(kv,"layerName","GeoJsonLayer"),bt(kv,"defaultProps",Nv);const zv=512,Uv=Math.PI/180;function Vv({map:e,gl:t,deck:i}){if(e.__deck)return e.__deck;const n=null==i?void 0:i.props._customRender,r=null==i?void 0:i.props.onLoad,s=(o={...null==i?void 0:i.props,_customRender:()=>{e.triggerRepaint(),null==n||n("")}},{...o,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...o.parameters},views:o.views||[new Ep({id:"mapbox"})]});var o;let a;return i&&i.props.gl!==t||(Object.assign(s,{gl:t,width:null,height:null,touchAction:"unset",viewState:Gv(e)}),null!=i&&i.isInitialized?jv(i,e):s.onLoad=()=>{null==r||r(),jv(a,e)}),i?(a=i,i.setProps(s),i.userData.isExternal=!0):(a=new Cf(s),e.on("remove",()=>{!function(e){var t;null===(t=e.__deck)||void 0===t||t.finalize(),e.__deck=null}(e)})),a.userData.mapboxLayers=new Set,e.__deck=a,e.on("render",()=>{a.isInitialized&&function(e,t){const{mapboxLayers:i,isExternal:n}=e.userData;if(n){const n=Array.from(i,e=>e.id),r=Nd(e.props.layers,Boolean).some(e=>e&&!n.includes(e.id));let s=e.getViewports();const o=s.findIndex(e=>"mapbox"===e.id);(r||(s.length>1||o<0))&&(o>=0&&(s=s.slice(),s[o]=Hv(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:s,layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&("mapbox"!==t.viewport.id||!n.includes(t.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}(a,e)}),a}function jv(e,t){const i=()=>{e.isInitialized?function(e,t){e.setProps({viewState:Gv(t)}),e.needsRedraw({clearRedrawFlags:!0})}(e,t):t.off("move",i)};t.on("move",i)}function Gv(e){var t;const{lng:i,lat:n}=e.getCenter(),r={longitude:(i+540)%360-180,latitude:n,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return null!==(t=e.getTerrain)&&void 0!==t&&t.call(e)&&function(e,t){if(e.getFreeCameraOptions){const{position:i}=e.getFreeCameraOptions();if(!i||void 0===i.z)return;const n=e.transform.height,{longitude:r,latitude:s,pitch:o}=t,a=i.x*zv,l=(1-i.y)*zv,c=i.z*zv,u=Nh([r,s]),h=a-u[0],d=l-u[1],p=Math.sqrt(h*h+d*d),f=o*Uv,m=1.5*n,g=f<.001?m*Math.cos(f)/c:m*Math.sin(f)/p;t.zoom=Math.log2(g);const _=m*Math.cos(f)/g;t.position=[0,0,(c-_)/Uh(s)]}else"number"==typeof e.transform.elevation&&(t.position=[0,0,e.transform.elevation])}(e,r),r}function Hv(e,t,i=!0){return new _d({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...Gv(t),nearZMultiplier:i?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function Wv(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(e=>{const i=new(0,e.props.type)(e.props);t.push(i)}),e.setProps({layers:t})}class qv{constructor(e){if(bt(this,"id",void 0),bt(this,"type",void 0),bt(this,"renderingMode",void 0),bt(this,"map",void 0),bt(this,"deck",void 0),bt(this,"props",void 0),!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,t){var i;this.map=e,this.deck=Vv({map:e,gl:t,deck:this.props.deck}),(i=this.deck).userData.mapboxLayers.add(this),Wv(i)}onRemove(){var e;this.deck&&((e=this.deck).userData.mapboxLayers.delete(this),Wv(e))}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&Wv(this.deck)}render(){!function(e,t,i){let{currentViewport:n}=e.userData,r=!1;n||(n=Hv(e,t,!0),e.userData.currentViewport=n,r=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:({layer:e})=>i.id===e.id||e.props.operation.includes("terrain"),clearStack:r,clearCanvas:!1})}(this.deck,this.map,this)}}class Xv{constructor(e){this.implementation=e}onAdd(e,t){const i=this.implementation,n=i.id,r=Object.assign({},i,{type:kv}),s=e.map;this.map=e,delete r.minzoom,delete r.maxzoom,delete r.metadata,s.addLayer(new qv(r),t||"poi"),s.setLayerZoomRange(n,i.minzoom,i.maxzoom),s.style.getOwnLayer(n).metadata=i.metadata}}
/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const $v="183",Zv=1,Yv=3,Jv=0,Kv=1,Qv=2,ex=100,tx=101,ix=102,nx=200,rx=201,sx=202,ox=203,ax=204,lx=205,cx=206,ux=207,hx=208,dx=209,px=210,fx=211,mx=212,gx=213,_x=214,yx=0,vx=1,xx=2,bx=3,wx=4,Tx=5,Sx=6,Ex=7,Ax=0,Mx=1,Ix=2,Cx=1,Px=2,Lx=3,Rx=4,Ox=5,Dx=6,Bx=7,Fx="attached",Nx="detached",kx=300,zx=301,Ux=302,Vx=303,jx=304,Gx=306,Hx=1e3,Wx=1001,qx=1002,Xx=1003,$x=1004,Zx=1005,Yx=1006,Jx=1007,Kx=1008,Qx=1009,eb=1010,tb=1011,ib=1012,nb=1013,rb=1014,sb=1015,ob=1016,ab=1017,lb=1018,cb=1020,ub=35902,hb=35899,db=1021,pb=1022,fb=1023,mb=1026,gb=1027,_b=1028,yb=1029,vb=1030,xb=1031,bb=1033,wb=33776,Tb=33777,Sb=33778,Eb=33779,Ab=35840,Mb=35841,Ib=35842,Cb=35843,Pb=36196,Lb=37492,Rb=37496,Ob=37488,Db=37489,Bb=37490,Fb=37491,Nb=37808,kb=37809,zb=37810,Ub=37811,Vb=37812,jb=37813,Gb=37814,Hb=37815,Wb=37816,qb=37817,Xb=37818,$b=37819,Zb=37820,Yb=37821,Jb=36492,Kb=36494,Qb=36495,ew=36283,tw=36284,iw=36285,nw=36286,rw=2300,sw=2301,ow=2302,aw=2303,lw=2400,cw=2401,uw=2402,hw=2500,dw=2501,pw="",fw="srgb",mw="srgb-linear",gw="linear",_w="srgb",yw=7680,vw=512,xw=513,bw=514,ww=515,Tw=516,Sw=517,Ew=518,Aw=519,Mw=35044,Iw="300 es",Cw=2e3,Pw=2001;const Lw={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Rw(e,t){return new Lw[e](t)}function Ow(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Dw(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Bw(){const e=Dw("canvas");return e.style.display="block",e}const Fw={};let Nw=null;function kw(...e){const t="THREE."+e.shift();Nw&&Nw("log",t,...e)}function zw(e){const t=e[0];if("string"==typeof t&&t.startsWith("TSL:")){const t=e[1];t&&t.isStackTrace?e[0]+=" "+t.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Uw(...e){const t="THREE."+(e=zw(e)).shift();if(Nw)Nw("warn",t,...e);else{}}function Vw(...e){const t="THREE."+(e=zw(e)).shift();if(Nw)Nw("error",t,...e);else{}}function jw(...e){const t=e.join(" ");t in Fw||(Fw[t]=!0,Uw(...e))}const Gw={[yx]:1,[xx]:6,[wx]:7,[bx]:5,[vx]:0,[Sx]:2,[Ex]:4,[Tx]:3};class Hw{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return void 0!==i&&(void 0!==i[e]&&-1!==i[e].indexOf(t))}removeEventListener(e,t){const i=this._listeners;if(void 0===i)return;const n=i[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){const t=this._listeners;if(void 0===t)return;const i=t[e.type];if(void 0!==i){e.target=this;const t=i.slice(0);for(let i=0,n=t.length;i<n;i++)t[i].call(this,e);e.target=null}}}const Ww=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let qw=1234567;const Xw=Math.PI/180,$w=180/Math.PI;function Zw(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Ww[255&e]+Ww[e>>8&255]+Ww[e>>16&255]+Ww[e>>24&255]+"-"+Ww[255&t]+Ww[t>>8&255]+"-"+Ww[t>>16&15|64]+Ww[t>>24&255]+"-"+Ww[63&i|128]+Ww[i>>8&255]+"-"+Ww[i>>16&255]+Ww[i>>24&255]+Ww[255&n]+Ww[n>>8&255]+Ww[n>>16&255]+Ww[n>>24&255]).toLowerCase()}function Yw(e,t,i){return Math.max(t,Math.min(i,e))}function Jw(e,t){return(e%t+t)%t}function Kw(e,t,i){return(1-i)*e+i*t}function Qw(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function eT(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const tT={DEG2RAD:Xw,RAD2DEG:$w,generateUUID:Zw,clamp:Yw,euclideanModulo:Jw,mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:Kw,damp:function(e,t,i,n){return Kw(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(Jw(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(qw=e);let t=qw+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Xw},radToDeg:function(e){return e*$w},isPowerOfTwo:function(e){return!(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,i,n,r){const s=Math.cos,o=Math.sin,a=s(i/2),l=o(i/2),c=s((t+n)/2),u=o((t+n)/2),h=s((t-n)/2),d=o((t-n)/2),p=s((n-t)/2),f=o((n-t)/2);switch(r){case"XYX":e.set(a*u,l*h,l*d,a*c);break;case"YZY":e.set(l*d,a*u,l*h,a*c);break;case"ZXZ":e.set(l*h,l*d,a*u,a*c);break;case"XZX":e.set(a*u,l*f,l*p,a*c);break;case"YXY":e.set(l*p,a*u,l*f,a*c);break;case"ZYZ":e.set(l*f,l*p,a*u,a*c);break;default:Uw("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:eT,denormalize:Qw};class iT{constructor(e=0,t=0){iT.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Yw(this.x,e.x,t.x),this.y=Yw(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Yw(this.x,e,t),this.y=Yw(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yw(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Yw(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*n+e.x,this.y=r*n+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class nT{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,r,s,o){let a=i[n+0],l=i[n+1],c=i[n+2],u=i[n+3],h=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(u!==f||a!==h||l!==d||c!==p){let e=a*h+l*d+c*p+u*f;e<0&&(h=-h,d=-d,p=-p,f=-f,e=-e);let t=1-o;if(e<.9995){const i=Math.acos(e),n=Math.sin(i);t=Math.sin(t*i)/n,a=a*t+h*(o=Math.sin(o*i)/n),l=l*t+d*o,c=c*t+p*o,u=u*t+f*o}else{a=a*t+h*o,l=l*t+d*o,c=c*t+p*o,u=u*t+f*o;const e=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=e,l*=e,c*=e,u*=e}}e[t]=a,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,s){const o=i[n],a=i[n+1],l=i[n+2],c=i[n+3],u=r[s],h=r[s+1],d=r[s+2],p=r[s+3];return e[t]=o*p+c*u+a*d-l*h,e[t+1]=a*p+c*h+l*u-o*d,e[t+2]=l*p+c*d+o*h-a*u,e[t+3]=c*p-o*u-a*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,n=e._y,r=e._z,s=e._order,o=Math.cos,a=Math.sin,l=o(i/2),c=o(n/2),u=o(r/2),h=a(i/2),d=a(n/2),p=a(r/2);switch(s){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:Uw("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],s=t[1],o=t[5],a=t[9],l=t[2],c=t[6],u=t[10],h=i+o+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-a)*e,this._y=(r-l)*e,this._z=(s-n)*e}else if(i>o&&i>u){const e=2*Math.sqrt(1+i-o-u);this._w=(c-a)/e,this._x=.25*e,this._y=(n+s)/e,this._z=(r+l)/e}else if(o>u){const e=2*Math.sqrt(1+o-i-u);this._w=(r-l)/e,this._x=(n+s)/e,this._y=.25*e,this._z=(a+c)/e}else{const e=2*Math.sqrt(1+u-i-o);this._w=(s-n)/e,this._x=(r+l)/e,this._y=(a+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Yw(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,s=e._w,o=t._x,a=t._y,l=t._z,c=t._w;return this._x=i*c+s*o+n*l-r*a,this._y=n*c+s*a+r*o-i*l,this._z=r*c+s*l+i*a-n*o,this._w=s*c-i*o-n*a-r*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,r=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,s=-s,o=-o);let a=1-t;if(o<.9995){const e=Math.acos(o),l=Math.sin(e);a=Math.sin(a*e)/l,t=Math.sin(t*e)/l,this._x=this._x*a+i*t,this._y=this._y*a+n*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+i*t,this._y=this._y*a+n*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class rT{constructor(e=0,t=0,i=0){rT.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(oT.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(oT.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,s=e.y,o=e.z,a=e.w,l=2*(s*n-o*i),c=2*(o*t-r*n),u=2*(r*i-s*t);return this.x=t+a*l+s*u-o*c,this.y=i+a*c+o*l-r*u,this.z=n+a*u+r*c-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Yw(this.x,e.x,t.x),this.y=Yw(this.y,e.y,t.y),this.z=Yw(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Yw(this.x,e,t),this.y=Yw(this.y,e,t),this.z=Yw(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yw(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,s=t.x,o=t.y,a=t.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return sT.copy(this).projectOnVector(e),this.sub(sT)}reflect(e){return this.sub(sT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Yw(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const sT=new rT,oT=new nT;class aT{constructor(e,t,i,n,r,s,o,a,l){aT.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,s,o,a,l)}set(e,t,i,n,r,s,o,a,l){const c=this.elements;return c[0]=e,c[1]=n,c[2]=o,c[3]=t,c[4]=r,c[5]=a,c[6]=i,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],c=i[4],u=i[7],h=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],_=n[1],y=n[4],v=n[7],x=n[2],b=n[5],w=n[8];return r[0]=s*f+o*_+a*x,r[3]=s*m+o*y+a*b,r[6]=s*g+o*v+a*w,r[1]=l*f+c*_+u*x,r[4]=l*m+c*y+u*b,r[7]=l*g+c*v+u*w,r[2]=h*f+d*_+p*x,r[5]=h*m+d*y+p*b,r[8]=h*g+d*v+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],o=e[5],a=e[6],l=e[7],c=e[8];return t*s*c-t*o*l-i*r*c+i*o*a+n*r*l-n*s*a}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],o=e[5],a=e[6],l=e[7],c=e[8],u=c*s-o*l,h=o*a-c*r,d=l*r-s*a,p=t*u+i*h+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(n*l-c*i)*f,e[2]=(o*i-n*s)*f,e[3]=h*f,e[4]=(c*t-n*a)*f,e[5]=(n*r-o*t)*f,e[6]=d*f,e[7]=(i*a-l*t)*f,e[8]=(s*t-i*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,s,o){const a=Math.cos(r),l=Math.sin(r);return this.set(i*a,i*l,-i*(a*s+l*o)+s+e,-n*l,n*a,-n*(-l*s+a*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(lT.makeScale(e,t)),this}rotate(e){return this.premultiply(lT.makeRotation(-e)),this}translate(e,t){return this.premultiply(lT.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const lT=new aT,cT=(new aT).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),uT=(new aT).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function hT(){const e={enabled:!0,workingColorSpace:mw,spaces:{},convert:function(e,t,i){return!1!==this.enabled&&t!==i&&t&&i?(this.spaces[t].transfer===_w&&(e.r=pT(e.r),e.g=pT(e.g),e.b=pT(e.b)),this.spaces[t].primaries!==this.spaces[i].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===_w&&(e.r=fT(e.r),e.g=fT(e.g),e.b=fT(e.b)),e):e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===pw?gw:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,i){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,i){return jw("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,i)},toWorkingColorSpace:function(t,i){return jw("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,i)}},t=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],n=[.3127,.329];return e.define({[mw]:{primaries:t,whitePoint:n,transfer:gw,toXYZ:cT,fromXYZ:uT,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:fw},outputColorSpaceConfig:{drawingBufferColorSpace:fw}},[fw]:{primaries:t,whitePoint:n,transfer:_w,toXYZ:cT,fromXYZ:uT,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:fw}}}),e}const dT=hT();function pT(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function fT(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let mT;class gT{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{void 0===mT&&(mT=Dw("canvas")),mT.width=e.width,mT.height=e.height;const t=mT.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),i=mT}return i.toDataURL(t)}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Dw("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let e=0;e<r.length;e++)r[e]=255*pT(r[e]/255);return i.putImageData(n,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t[e]=t instanceof Uint8Array||t instanceof Uint8ClampedArray?Math.floor(255*pT(t[e]/255)):pT(t[e]);return{data:t,width:e.width,height:e.height}}return Uw("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let _T=0;class yT{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_T++}),this.uuid=Zw(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)e.push(vT(n[t].isDataTexture?n[t].image:n[t]))}else e=vT(n);i.url=e}return t||(e.images[this.uuid]=i),i}}function vT(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?gT.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Uw("Texture: Unable to serialize Texture."),{})}let xT=0;const bT=new rT;class wT extends Hw{constructor(e=wT.DEFAULT_IMAGE,t=wT.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,o=1023,a=Qx,l=wT.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xT++}),this.uuid=Zw(),this.name="",this.source=new yT(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=a,this.offset=new iT(0,0),this.repeat=new iT(1,1),this.center=new iT(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new aT,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(bT).x}get height(){return this.source.getSize(bT).y}get depth(){return this.source.getSize(bT).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(void 0===i){Uw(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];void 0!==n?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i:Uw(`Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==kx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Hx:e.x=e.x-Math.floor(e.x);break;case Wx:e.x=e.x<0?0:1;break;case qx:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Hx:e.y=e.y-Math.floor(e.y);break;case Wx:e.y=e.y<0?0:1;break;case qx:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}wT.DEFAULT_IMAGE=null,wT.DEFAULT_MAPPING=kx,wT.DEFAULT_ANISOTROPY=1;class TT{constructor(e=0,t=0,i=0,n=1){TT.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*n+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const s=.01,o=.1,a=e.elements,l=a[0],c=a[4],u=a[8],h=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(c-h)<s&&Math.abs(u-f)<s&&Math.abs(p-m)<s){if(Math.abs(c+h)<o&&Math.abs(u+f)<o&&Math.abs(p+m)<o&&Math.abs(l+d+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,a=(d+1)/2,_=(g+1)/2,y=(c+h)/4,v=(u+f)/4,x=(p+m)/4;return e>a&&e>_?e<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(e),n=y/i,r=v/i):a>_?a<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(a),i=y/n,r=x/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=v/r,n=x/r),this.set(i,n,r,t),this}let _=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(h-c)*(h-c));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(u-f)/_,this.z=(h-c)/_,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Yw(this.x,e.x,t.x),this.y=Yw(this.y,e.y,t.y),this.z=Yw(this.z,e.z,t.z),this.w=Yw(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Yw(this.x,e,t),this.y=Yw(this.y,e,t),this.z=Yw(this.z,e,t),this.w=Yw(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yw(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ST extends Hw{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yx,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new TT(0,0,e,t),this.scissorTest=!1,this.viewport=new TT(0,0,e,t),this.textures=[];const n=new wT({width:e,height:t,depth:i.depth}),r=i.count;for(let e=0;e<r;e++)this.textures[e]=n.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Yx,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){this.textures[e].setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=i,!0!==this.textures[n].isData3DTexture&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new yT(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ET extends ST{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class AT extends wT{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Xx,this.minFilter=Xx,this.wrapR=Wx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class MT extends wT{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Xx,this.minFilter=Xx,this.wrapR=Wx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class IT{constructor(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){IT.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m)}set(e,t,i,n,r,s,o,a,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new IT).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return 0===this.determinant()?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinant())return this.identity();const t=this.elements,i=e.elements,n=1/CT.setFromMatrixColumn(e,0).length(),r=1/CT.setFromMatrixColumn(e,1).length(),s=1/CT.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),l=Math.sin(n),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=s*c,i=s*u,n=o*c,r=o*u;t[0]=a*c,t[4]=-a*u,t[8]=l,t[1]=i+n*l,t[5]=e-r*l,t[9]=-o*a,t[2]=r-e*l,t[6]=n+i*l,t[10]=s*a}else if("YXZ"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e+r*o,t[4]=n*o-i,t[8]=s*l,t[1]=s*u,t[5]=s*c,t[9]=-o,t[2]=i*o-n,t[6]=r+e*o,t[10]=s*a}else if("ZXY"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e-r*o,t[4]=-s*u,t[8]=n+i*o,t[1]=i+n*o,t[5]=s*c,t[9]=r-e*o,t[2]=-s*l,t[6]=o,t[10]=s*a}else if("ZYX"===e.order){const e=s*c,i=s*u,n=o*c,r=o*u;t[0]=a*c,t[4]=n*l-i,t[8]=e*l+r,t[1]=a*u,t[5]=r*l+e,t[9]=i*l-n,t[2]=-l,t[6]=o*a,t[10]=s*a}else if("YZX"===e.order){const e=s*a,i=s*l,n=o*a,r=o*l;t[0]=a*c,t[4]=r-e*u,t[8]=n*u+i,t[1]=u,t[5]=s*c,t[9]=-o*c,t[2]=-l*c,t[6]=i*u+n,t[10]=e-r*u}else if("XZY"===e.order){const e=s*a,i=s*l,n=o*a,r=o*l;t[0]=a*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=s*c,t[9]=i*u-n,t[2]=n*u-i,t[6]=o*c,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(LT,e,RT)}lookAt(e,t,i){const n=this.elements;return BT.subVectors(e,t),0===BT.lengthSq()&&(BT.z=1),BT.normalize(),OT.crossVectors(i,BT),0===OT.lengthSq()&&(1===Math.abs(i.z)?BT.x+=1e-4:BT.z+=1e-4,BT.normalize(),OT.crossVectors(i,BT)),OT.normalize(),DT.crossVectors(BT,OT),n[0]=OT.x,n[4]=DT.x,n[8]=BT.x,n[1]=OT.y,n[5]=DT.y,n[9]=BT.y,n[2]=OT.z,n[6]=DT.z,n[10]=BT.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],o=i[4],a=i[8],l=i[12],c=i[1],u=i[5],h=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],_=i[3],y=i[7],v=i[11],x=i[15],b=n[0],w=n[4],T=n[8],S=n[12],E=n[1],A=n[5],M=n[9],I=n[13],C=n[2],P=n[6],L=n[10],R=n[14],O=n[3],D=n[7],B=n[11],F=n[15];return r[0]=s*b+o*E+a*C+l*O,r[4]=s*w+o*A+a*P+l*D,r[8]=s*T+o*M+a*L+l*B,r[12]=s*S+o*I+a*R+l*F,r[1]=c*b+u*E+h*C+d*O,r[5]=c*w+u*A+h*P+d*D,r[9]=c*T+u*M+h*L+d*B,r[13]=c*S+u*I+h*R+d*F,r[2]=p*b+f*E+m*C+g*O,r[6]=p*w+f*A+m*P+g*D,r[10]=p*T+f*M+m*L+g*B,r[14]=p*S+f*I+m*R+g*F,r[3]=_*b+y*E+v*C+x*O,r[7]=_*w+y*A+v*P+x*D,r[11]=_*T+y*M+v*L+x*B,r[15]=_*S+y*I+v*R+x*F,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[1],i=e[5],n=e[9],r=e[13],s=e[2],o=e[6],a=e[10],l=e[14],c=e[3],u=e[7],h=e[11],d=e[15],p=n*l-r*a,f=i*l-r*o,m=i*a-n*o,g=t*l-r*s,_=t*a-n*s,y=t*o-i*s;return e[0]*(u*p-h*f+d*m)-e[4]*(c*p-h*g+d*_)+e[8]*(c*f-u*g+d*y)-e[12]*(c*m-u*_+h*y)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],o=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],_=t*o-i*s,y=t*a-n*s,v=t*l-r*s,x=i*a-n*o,b=i*l-r*o,w=n*l-r*a,T=c*f-u*p,S=c*m-h*p,E=c*g-d*p,A=u*m-h*f,M=u*g-d*f,I=h*g-d*m,C=_*I-y*M+v*A+x*E-b*S+w*T;if(0===C)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/C;return e[0]=(o*I-a*M+l*A)*P,e[1]=(n*M-i*I-r*A)*P,e[2]=(f*w-m*b+g*x)*P,e[3]=(h*b-u*w-d*x)*P,e[4]=(a*E-s*I-l*S)*P,e[5]=(t*I-n*E+r*S)*P,e[6]=(m*v-p*w-g*y)*P,e[7]=(c*w-h*v+d*y)*P,e[8]=(s*M-o*E+l*T)*P,e[9]=(i*E-t*M-r*T)*P,e[10]=(p*b-f*v+g*_)*P,e[11]=(u*v-c*b-d*_)*P,e[12]=(o*S-s*A-a*T)*P,e[13]=(t*A-i*S+n*T)*P,e[14]=(f*y-p*x-m*_)*P,e[15]=(c*x-u*y+h*_)*P,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,s=e.x,o=e.y,a=e.z,l=r*s,c=r*o;return this.set(l*s+i,l*o-n*a,l*a+n*o,0,l*o+n*a,c*o+i,c*a-n*s,0,l*a-n*o,c*a+n*s,r*a*a+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,s){return this.set(1,i,r,0,e,1,s,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,s=t._y,o=t._z,a=t._w,l=r+r,c=s+s,u=o+o,h=r*l,d=r*c,p=r*u,f=s*c,m=s*u,g=o*u,_=a*l,y=a*c,v=a*u,x=i.x,b=i.y,w=i.z;return n[0]=(1-(f+g))*x,n[1]=(d+v)*x,n[2]=(p-y)*x,n[3]=0,n[4]=(d-v)*b,n[5]=(1-(h+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(p+y)*w,n[9]=(m-_)*w,n[10]=(1-(h+f))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const r=this.determinant();if(0===r)return i.set(1,1,1),t.identity(),this;let s=CT.set(n[0],n[1],n[2]).length();const o=CT.set(n[4],n[5],n[6]).length(),a=CT.set(n[8],n[9],n[10]).length();r<0&&(s=-s),PT.copy(this);const l=1/s,c=1/o,u=1/a;return PT.elements[0]*=l,PT.elements[1]*=l,PT.elements[2]*=l,PT.elements[4]*=c,PT.elements[5]*=c,PT.elements[6]*=c,PT.elements[8]*=u,PT.elements[9]*=u,PT.elements[10]*=u,t.setFromRotationMatrix(PT),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,n,r,s,o=2e3,a=!1){const l=this.elements,c=2*r/(t-e),u=2*r/(i-n),h=(t+e)/(t-e),d=(i+n)/(i-n);let p,f;if(a)p=r/(s-r),f=s*r/(s-r);else if(o===Cw)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(o!==Pw)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);p=-s/(s-r),f=-s*r/(s-r)}return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,r,s,o=2e3,a=!1){const l=this.elements,c=2/(t-e),u=2/(i-n),h=-(t+e)/(t-e),d=-(i+n)/(i-n);let p,f;if(a)p=1/(s-r),f=s/(s-r);else if(o===Cw)p=-2/(s-r),f=-(s+r)/(s-r);else{if(o!==Pw)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=-1/(s-r),f=-r/(s-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=u,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const CT=new rT,PT=new IT,LT=new rT(0,0,0),RT=new rT(1,1,1),OT=new rT,DT=new rT,BT=new rT,FT=new IT,NT=new nT;class kT{constructor(e=0,t=0,i=0,n=kT.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],s=n[4],o=n[8],a=n[1],l=n[5],c=n[9],u=n[2],h=n[6],d=n[10];switch(t){case"XYZ":this._y=Math.asin(Yw(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Yw(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Yw(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-Yw(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Yw(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Yw(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:Uw("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return FT.makeRotationFromQuaternion(e),this.setFromRotationMatrix(FT,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return NT.setFromEuler(this),this.setFromQuaternion(NT,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}kT.DEFAULT_ORDER="XYZ";class zT{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let UT=0;const VT=new rT,jT=new nT,GT=new IT,HT=new rT,WT=new rT,qT=new rT,XT=new nT,$T=new rT(1,0,0),ZT=new rT(0,1,0),YT=new rT(0,0,1),JT={type:"added"},KT={type:"removed"},QT={type:"childadded",child:null},eS={type:"childremoved",child:null};class tS extends Hw{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:UT++}),this.uuid=Zw(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tS.DEFAULT_UP.clone();const e=new rT,t=new kT,i=new nT,n=new rT(1,1,1);t._onChange(function(){i.setFromEuler(t,!1)}),i._onChange(function(){t.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new IT},normalMatrix:{value:new aT}}),this.matrix=new IT,this.matrixWorld=new IT,this.matrixAutoUpdate=tS.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=tS.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zT,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jT.setFromAxisAngle(e,t),this.quaternion.multiply(jT),this}rotateOnWorldAxis(e,t){return jT.setFromAxisAngle(e,t),this.quaternion.premultiply(jT),this}rotateX(e){return this.rotateOnAxis($T,e)}rotateY(e){return this.rotateOnAxis(ZT,e)}rotateZ(e){return this.rotateOnAxis(YT,e)}translateOnAxis(e,t){return VT.copy(e).applyQuaternion(this.quaternion),this.position.add(VT.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($T,e)}translateY(e){return this.translateOnAxis(ZT,e)}translateZ(e){return this.translateOnAxis(YT,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(GT.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?HT.copy(e):HT.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),WT.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?GT.lookAt(WT,HT,this.up):GT.lookAt(HT,WT,this.up),this.quaternion.setFromRotationMatrix(GT),n&&(GT.extractRotation(n.matrixWorld),jT.setFromRotationMatrix(GT),this.quaternion.premultiply(jT.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Vw("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(JT),QT.child=e,this.dispatchEvent(QT),QT.child=null):Vw("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(KT),eS.child=e,this.dispatchEvent(eS),eS.child=null),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),GT.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),GT.multiply(e.parent.matrixWorld)),e.applyMatrix4(GT),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(JT),QT.child=e,this.dispatchEvent(QT),QT.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let r=0,s=n.length;r<s;r++)n[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(WT,e,qT),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(WT,XT,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(null!==e){const t=e.x,i=e.y,n=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*i-r[8]*n,r[13]+=i-r[1]*t-r[5]*i-r[9]*n,r[14]+=n-r[2]*t-r[6]*i-r[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++){t[i].updateMatrixWorld(e)}}updateWorldMatrix(e,t){const i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++){e[t].updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};function r(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),!1!==this.static&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),null!==this.pivot&&(n.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(e=>({...e})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(n.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(n.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(n.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){r(e.shapes,i[t])}else r(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(r(e.materials,this.material[i]));n.material=t}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){n.animations.push(r(e.animations,this.animations[t]))}}if(t){const t=s(e.geometries),n=s(e.materials),r=s(e.textures),o=s(e.images),a=s(e.shapes),l=s(e.skeletons),c=s(e.animations),u=s(e.nodes);t.length>0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),o.length>0&&(i.images=o),a.length>0&&(i.shapes=a),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c),u.length>0&&(i.nodes=u)}return i.object=n,i;function s(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),null!==e.pivot&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){this.add(e.children[t].clone())}return this}}tS.DEFAULT_UP=new rT(0,1,0),tS.DEFAULT_MATRIX_AUTO_UPDATE=!0,tS.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class iS extends tS{constructor(){super(),this.isGroup=!0,this.type="Group"}}const nS={type:"move"};class rS{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new iS,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new iS,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new rT,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new rT),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new iS,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new rT,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new rT),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,s=null;const o=this._targetRay,a=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){s=!0;for(const n of e.hand.values()){const e=t.getJointPose(n,i),r=this._getHandJoint(l,n);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const n=l.joints["index-finger-tip"].position.distanceTo(l.joints["thumb-tip"].position),r=.02,o=.005;l.inputState.pinching&&n>r+o?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&n<=r-o&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1));null!==o&&(n=t.getPose(e.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(nS)))}return null!==o&&(o.visible=null!==n),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const i=new iS;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const sS={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},oS={h:0,s:0,l:0},aS={h:0,s:0,l:0};function lS(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}class cS{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(void 0===t&&void 0===i){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=fw){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,dT.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=dT.workingColorSpace){return this.r=e,this.g=t,this.b=i,dT.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=dT.workingColorSpace){if(e=Jw(e,1),t=Yw(t,0,1),i=Yw(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=lS(r,n,e+1/3),this.g=lS(r,n,e),this.b=lS(r,n,e-1/3)}return dT.colorSpaceToWorking(this,n),this}setStyle(e,t=fw){function i(t){void 0!==t&&parseFloat(t)<1&&Uw("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=n[2];switch(n[1]){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Uw("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(i,16),t);Uw("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=fw){const i=sS[e.toLowerCase()];return void 0!==i?this.setHex(i,t):Uw("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=pT(e.r),this.g=pT(e.g),this.b=pT(e.b),this}copyLinearToSRGB(e){return this.r=fT(e.r),this.g=fT(e.g),this.b=fT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=fw){return dT.workingToColorSpace(uS.copy(this),e),65536*Math.round(Yw(255*uS.r,0,255))+256*Math.round(Yw(255*uS.g,0,255))+Math.round(Yw(255*uS.b,0,255))}getHexString(e=fw){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dT.workingColorSpace){dT.workingToColorSpace(uS.copy(this),t);const i=uS.r,n=uS.g,r=uS.b,s=Math.max(i,n,r),o=Math.min(i,n,r);let a,l;const c=(o+s)/2;if(o===s)a=0,l=0;else{const e=s-o;switch(l=c<=.5?e/(s+o):e/(2-s-o),s){case i:a=(n-r)/e+(n<r?6:0);break;case n:a=(r-i)/e+2;break;case r:a=(i-n)/e+4}a/=6}return e.h=a,e.s=l,e.l=c,e}getRGB(e,t=dT.workingColorSpace){return dT.workingToColorSpace(uS.copy(this),t),e.r=uS.r,e.g=uS.g,e.b=uS.b,e}getStyle(e=fw){dT.workingToColorSpace(uS.copy(this),e);const t=uS.r,i=uS.g,n=uS.b;return e!==fw?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(e,t,i){return this.getHSL(oS),this.setHSL(oS.h+e,oS.s+t,oS.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(oS),e.getHSL(aS);const i=Kw(oS.h,aS.h,t),n=Kw(oS.s,aS.s,t),r=Kw(oS.l,aS.l,t);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const uS=new cS;cS.NAMES=sS;class hS{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new cS(e),this.density=t}clone(){return new hS(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class dS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new cS(e),this.near=t,this.far=i}clone(){return new dS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class pS extends tS{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new kT,this.environmentIntensity=1,this.environmentRotation=new kT,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const fS=new rT,mS=new rT,gS=new rT,_S=new rT,yS=new rT,vS=new rT,xS=new rT,bS=new rT,wS=new rT,TS=new rT,SS=new TT,ES=new TT,AS=new TT;class MS{constructor(e=new rT,t=new rT,i=new rT){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),fS.subVectors(e,t),n.cross(fS);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){fS.subVectors(n,t),mS.subVectors(i,t),gS.subVectors(e,t);const s=fS.dot(fS),o=fS.dot(mS),a=fS.dot(gS),l=mS.dot(mS),c=mS.dot(gS),u=s*l-o*o;if(0===u)return r.set(0,0,0),null;const h=1/u,d=(l*a-o*c)*h,p=(s*c-o*a)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,i,n){return null!==this.getBarycoord(e,t,i,n,_S)&&(_S.x>=0&&_S.y>=0&&_S.x+_S.y<=1)}static getInterpolation(e,t,i,n,r,s,o,a){return null===this.getBarycoord(e,t,i,n,_S)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,_S.x),a.addScaledVector(s,_S.y),a.addScaledVector(o,_S.z),a)}static getInterpolatedAttribute(e,t,i,n,r,s){return SS.setScalar(0),ES.setScalar(0),AS.setScalar(0),SS.fromBufferAttribute(e,t),ES.fromBufferAttribute(e,i),AS.fromBufferAttribute(e,n),s.setScalar(0),s.addScaledVector(SS,r.x),s.addScaledVector(ES,r.y),s.addScaledVector(AS,r.z),s}static isFrontFacing(e,t,i,n){return fS.subVectors(i,t),mS.subVectors(e,t),fS.cross(mS).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return fS.subVectors(this.c,this.b),mS.subVectors(this.a,this.b),.5*fS.cross(mS).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return MS.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return MS.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return MS.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return MS.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return MS.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let s,o;yS.subVectors(n,i),vS.subVectors(r,i),bS.subVectors(e,i);const a=yS.dot(bS),l=vS.dot(bS);if(a<=0&&l<=0)return t.copy(i);wS.subVectors(e,n);const c=yS.dot(wS),u=vS.dot(wS);if(c>=0&&u<=c)return t.copy(n);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return s=a/(a-c),t.copy(i).addScaledVector(yS,s);TS.subVectors(e,r);const d=yS.dot(TS),p=vS.dot(TS);if(p>=0&&d<=p)return t.copy(r);const f=d*l-a*p;if(f<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(i).addScaledVector(vS,o);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return xS.subVectors(r,n),o=(u-c)/(u-c+(d-p)),t.copy(n).addScaledVector(xS,o);const g=1/(m+f+h);return s=f*g,o=h*g,t.copy(i).addScaledVector(yS,s).addScaledVector(vS,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class IS{constructor(e=new rT(1/0,1/0,1/0),t=new rT(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(PS.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(PS.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=PS.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===t&&void 0!==n&&!0!==e.isInstancedMesh)for(let t=0,i=n.count;t<i;t++)!0===e.isMesh?e.getVertexPosition(t,PS):PS.fromBufferAttribute(n,t),PS.applyMatrix4(e.matrixWorld),this.expandByPoint(PS);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),LS.copy(e.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),LS.copy(i.boundingBox)),LS.applyMatrix4(e.matrixWorld),this.union(LS)}const n=e.children;for(let e=0,i=n.length;e<i;e++)this.expandByObject(n[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,PS),PS.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(kS),zS.subVectors(this.max,kS),RS.subVectors(e.a,kS),OS.subVectors(e.b,kS),DS.subVectors(e.c,kS),BS.subVectors(OS,RS),FS.subVectors(DS,OS),NS.subVectors(RS,DS);let t=[0,-BS.z,BS.y,0,-FS.z,FS.y,0,-NS.z,NS.y,BS.z,0,-BS.x,FS.z,0,-FS.x,NS.z,0,-NS.x,-BS.y,BS.x,0,-FS.y,FS.x,0,-NS.y,NS.x,0];return!!jS(t,RS,OS,DS,zS)&&(t=[1,0,0,0,1,0,0,0,1],!!jS(t,RS,OS,DS,zS)&&(US.crossVectors(BS,FS),t=[US.x,US.y,US.z],jS(t,RS,OS,DS,zS)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,PS).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(PS).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(CS[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),CS[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),CS[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),CS[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),CS[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),CS[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),CS[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),CS[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(CS)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const CS=[new rT,new rT,new rT,new rT,new rT,new rT,new rT,new rT],PS=new rT,LS=new IS,RS=new rT,OS=new rT,DS=new rT,BS=new rT,FS=new rT,NS=new rT,kS=new rT,zS=new rT,US=new rT,VS=new rT;function jS(e,t,i,n,r){for(let s=0,o=e.length-3;s<=o;s+=3){VS.fromArray(e,s);const o=r.x*Math.abs(VS.x)+r.y*Math.abs(VS.y)+r.z*Math.abs(VS.z),a=t.dot(VS),l=i.dot(VS),c=n.dot(VS);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>o)return!1}return!0}const GS=HS();function HS(){const e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),n=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(n[e]=0,n[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(n[e]=1024>>-t-14,n[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(n[e]=t+15<<10,n[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(n[e]=31744,n[256|e]=64512,r[e]=24,r[256|e]=24):(n[e]=31744,n[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;!(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,s[e]=t|i}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(a[e]=1024);return{floatView:t,uint32View:i,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function WS(e){Math.abs(e)>65504&&Uw("DataUtils.toHalfFloat(): Value out of range."),e=Yw(e,-65504,65504),GS.floatView[0]=e;const t=GS.uint32View[0],i=t>>23&511;return GS.baseTable[i]+((8388607&t)>>GS.shiftTable[i])}function qS(e){const t=e>>10;return GS.uint32View[0]=GS.mantissaTable[GS.offsetTable[t]+(1023&e)]+GS.exponentTable[t],GS.floatView[0]}const XS=new rT,$S=new iT;let ZS=0;class YS{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ZS++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=i,this.usage=Mw,this.updateRanges=[],this.gpuType=sb,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)$S.fromBufferAttribute(this,t),$S.applyMatrix3(e),this.setXY(t,$S.x,$S.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)XS.fromBufferAttribute(this,t),XS.applyMatrix3(e),this.setXYZ(t,XS.x,XS.y,XS.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)XS.fromBufferAttribute(this,t),XS.applyMatrix4(e),this.setXYZ(t,XS.x,XS.y,XS.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)XS.fromBufferAttribute(this,t),XS.applyNormalMatrix(e),this.setXYZ(t,XS.x,XS.y,XS.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)XS.fromBufferAttribute(this,t),XS.transformDirection(e),this.setXYZ(t,XS.x,XS.y,XS.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Qw(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=eT(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Qw(t,this.array)),t}setX(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Qw(t,this.array)),t}setY(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Qw(t,this.array)),t}setZ(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Qw(t,this.array)),t}setW(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array),r=eT(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Mw&&(e.usage=this.usage),e}}class JS extends YS{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class KS extends YS{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class QS extends YS{constructor(e,t,i){super(new Float32Array(e),t,i)}}const eE=new IS,tE=new rT,iE=new rT;class nE{constructor(e=new rT,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):eE.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;t<r;t++)n=Math.max(n,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;tE.subVectors(e,this.center);const t=tE.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(tE,i/e),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(iE.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(tE.copy(e.center).add(iE)),this.expandByPoint(tE.copy(e.center).sub(iE))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let rE=0;const sE=new IT,oE=new tS,aE=new rT,lE=new IS,cE=new IS,uE=new rT;class hE extends Hw{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:rE++}),this.uuid=Zw(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(function(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}(e)?KS:JS)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new aT).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return sE.makeRotationFromQuaternion(e),this.applyMatrix4(sE),this}rotateX(e){return sE.makeRotationX(e),this.applyMatrix4(sE),this}rotateY(e){return sE.makeRotationY(e),this.applyMatrix4(sE),this}rotateZ(e){return sE.makeRotationZ(e),this.applyMatrix4(sE),this}translate(e,t,i){return sE.makeTranslation(e,t,i),this.applyMatrix4(sE),this}scale(e,t,i){return sE.makeScale(e,t,i),this.applyMatrix4(sE),this}lookAt(e){return oE.lookAt(e),oE.updateMatrix(),this.applyMatrix4(oE.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(aE).negate(),this.translate(aE.x,aE.y,aE.z),this}setFromPoints(e){const t=this.getAttribute("position");if(void 0===t){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];t.push(n.x,n.y,n.z||0)}this.setAttribute("position",new QS(t,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const i=e[n];t.setXYZ(n,i.x,i.y,i.z||0)}e.length>t.count&&Uw("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new IS);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return Vw("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new rT(-1/0,-1/0,-1/0),new rT(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){lE.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(uE.addVectors(this.boundingBox.min,lE.min),this.boundingBox.expandByPoint(uE),uE.addVectors(this.boundingBox.max,lE.max),this.boundingBox.expandByPoint(uE)):(this.boundingBox.expandByPoint(lE.min),this.boundingBox.expandByPoint(lE.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vw('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nE);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return Vw("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new rT,1/0);if(e){const i=this.boundingSphere.center;if(lE.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){cE.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(uE.addVectors(lE.min,cE.min),lE.expandByPoint(uE),uE.addVectors(lE.max,cE.max),lE.expandByPoint(uE)):(lE.expandByPoint(cE.min),lE.expandByPoint(cE.max))}lE.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)uE.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared(uE));if(t)for(let r=0,s=t.length;r<s;r++){const s=t[r],o=this.morphTargetsRelative;for(let t=0,r=s.count;t<r;t++)uE.fromBufferAttribute(s,t),o&&(aE.fromBufferAttribute(e,t),uE.add(aE)),n=Math.max(n,i.distanceToSquared(uE))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Vw('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void Vw("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.position,n=t.normal,r=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new YS(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],a=[];for(let e=0;e<i.count;e++)o[e]=new rT,a[e]=new rT;const l=new rT,c=new rT,u=new rT,h=new iT,d=new iT,p=new iT,f=new rT,m=new rT;function g(e,t,n){l.fromBufferAttribute(i,e),c.fromBufferAttribute(i,t),u.fromBufferAttribute(i,n),h.fromBufferAttribute(r,e),d.fromBufferAttribute(r,t),p.fromBufferAttribute(r,n),c.sub(l),u.sub(l),d.sub(h),p.sub(h);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(c).multiplyScalar(p.y).addScaledVector(u,-d.y).multiplyScalar(s),m.copy(u).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(s),o[e].add(f),o[t].add(f),o[n].add(f),a[e].add(m),a[t].add(m),a[n].add(m))}let _=this.groups;0===_.length&&(_=[{start:0,count:e.count}]);for(let t=0,i=_.length;t<i;++t){const i=_[t],n=i.start;for(let t=n,r=n+i.count;t<r;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}const y=new rT,v=new rT,x=new rT,b=new rT;function w(e){x.fromBufferAttribute(n,e),b.copy(x);const t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),v.crossVectors(b,t);const i=v.dot(a[e]);s.setXYZW(e,y.x,y.y,y.z,i<0?-1:1)}for(let t=0,i=_.length;t<i;++t){const i=_[t],n=i.start;for(let t=n,r=n+i.count;t<r;t+=3)w(e.getX(t+0)),w(e.getX(t+1)),w(e.getX(t+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new YS(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);const n=new rT,r=new rT,s=new rT,o=new rT,a=new rT,l=new rT,c=new rT,u=new rT;if(e)for(let h=0,d=e.count;h<d;h+=3){const d=e.getX(h+0),p=e.getX(h+1),f=e.getX(h+2);n.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,f),c.subVectors(s,r),u.subVectors(n,r),c.cross(u),o.fromBufferAttribute(i,d),a.fromBufferAttribute(i,p),l.fromBufferAttribute(i,f),o.add(c),a.add(c),l.add(c),i.setXYZ(d,o.x,o.y,o.z),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,o=t.count;e<o;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),c.subVectors(s,r),u.subVectors(n,r),c.cross(u),i.setXYZ(e+0,c.x,c.y,c.z),i.setXYZ(e+1,c.x,c.y,c.z),i.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)uE.fromBufferAttribute(e,t),uE.normalize(),e.setXYZ(t,uE.x,uE.y,uE.z)}toNonIndexed(){function e(e,t){const i=e.array,n=e.itemSize,r=e.normalized,s=new i.constructor(t.length*n);let o=0,a=0;for(let r=0,l=t.length;r<l;r++){o=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*n;for(let e=0;e<n;e++)s[a++]=i[o++]}return new YS(s,n,r)}if(null===this.index)return Uw("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new hE,i=this.index.array,n=this.attributes;for(const r in n){const s=e(n[r],i);t.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],o=r[n];for(let t=0,n=o.length;t<n;t++){const n=e(o[t],i);s.push(n)}t.morphAttributes[n]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.addGroup(i.start,i.count,i.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){e.data.attributes[t]=i[t].toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],s=[];for(let t=0,n=i.length;t<n;t++){s.push(i[t].toJSON(e.data))}s.length>0&&(n[t]=s,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere=o.toJSON()),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone());const n=e.attributes;for(const e in n){this.setAttribute(e,n[e].clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e<r;e++)i.push(n[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const o=e.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=e.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class dE{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Mw,this.updateRanges=[],this.version=0,this.uuid=Zw()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Zw()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Zw()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const pE=new rT;class fE{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)pE.fromBufferAttribute(this,t),pE.applyMatrix4(e),this.setXYZ(t,pE.x,pE.y,pE.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)pE.fromBufferAttribute(this,t),pE.applyNormalMatrix(e),this.setXYZ(t,pE.x,pE.y,pE.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)pE.fromBufferAttribute(this,t),pE.transformDirection(e),this.setXYZ(t,pE.x,pE.y,pE.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Qw(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=eT(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=eT(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=eT(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=eT(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=eT(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Qw(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Qw(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Qw(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Qw(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array),r=eT(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(void 0===e){kw("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new YS(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new fE(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){kw("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let mE,gE=0;class _E extends Hw{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:gE++}),this.uuid=Zw(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ax,this.blendDst=lx,this.blendEquation=ex,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new cS(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yw,this.stencilZFail=yw,this.stencilZPass=yw,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){Uw(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:Uw(`Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function n(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),this.blendSrc!==ax&&(i.blendSrc=this.blendSrc),this.blendDst!==lx&&(i.blendDst=this.blendDst),this.blendEquation!==ex&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==yw&&(i.stencilFail=this.stencilFail),this.stencilZFail!==yw&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==yw&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class yE extends _E{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new cS(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const vE=new rT,xE=new rT,bE=new rT,wE=new iT,TE=new iT,SE=new IT,EE=new rT,AE=new rT,ME=new rT,IE=new iT,CE=new iT,PE=new iT;class LE extends tS{constructor(e=new yE){if(super(),this.isSprite=!0,this.type="Sprite",void 0===mE){mE=new hE;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new dE(e,5);mE.setIndex([0,1,2,0,2,3]),mE.setAttribute("position",new fE(t,3,0,!1)),mE.setAttribute("uv",new fE(t,2,3,!1))}this.geometry=mE,this.material=e,this.center=new iT(.5,.5),this.count=1}raycast(e,t){null===e.camera&&Vw('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xE.setFromMatrixScale(this.matrixWorld),SE.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),bE.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&xE.multiplyScalar(-bE.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;RE(EE.set(-.5,-.5,0),bE,s,xE,n,r),RE(AE.set(.5,-.5,0),bE,s,xE,n,r),RE(ME.set(.5,.5,0),bE,s,xE,n,r),IE.set(0,0),CE.set(1,0),PE.set(1,1);let o=e.ray.intersectTriangle(EE,AE,ME,!1,vE);if(null===o&&(RE(AE.set(-.5,.5,0),bE,s,xE,n,r),CE.set(0,1),o=e.ray.intersectTriangle(EE,ME,AE,!1,vE),null===o))return;const a=e.ray.origin.distanceTo(vE);a<e.near||a>e.far||t.push({distance:a,point:vE.clone(),uv:MS.getInterpolation(vE,EE,AE,ME,IE,CE,PE,new iT),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function RE(e,t,i,n,r,s){wE.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(TE.x=s*wE.x-r*wE.y,TE.y=r*wE.x+s*wE.y):TE.copy(wE),e.copy(t),e.x+=TE.x,e.y+=TE.y,e.applyMatrix4(SE)}const OE=new rT,DE=new rT;class BE extends tS{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,i=t.length;e<i;e++){const i=t[e];this.addLevel(i.object.clone(),i.distance,i.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const e=t.splice(i,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n;i++){let n=t[i].distance;if(t[i].object.visible&&(n-=n*t[i].hysteresis),e<n)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){OE.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(OE);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){OE.setFromMatrixPosition(e.matrixWorld),DE.setFromMatrixPosition(this.matrixWorld);const i=OE.distanceTo(DE)/e.zoom;let n,r;for(t[0].object.visible=!0,n=1,r=t.length;n<r;n++){let e=t[n].distance;if(t[n].object.visible&&(e-=e*t[n].hysteresis),!(i>=e))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;n<r;n++)t[n].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let e=0,n=i.length;e<n;e++){const n=i[e];t.object.levels.push({object:n.object.uuid,distance:n.distance,hysteresis:n.hysteresis})}return t}}const FE=new rT,NE=new rT,kE=new rT,zE=new rT,UE=new rT,VE=new rT,jE=new rT;class GE{constructor(e=new rT,t=new rT(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,FE)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=FE.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(FE.copy(this.origin).addScaledVector(this.direction,t),FE.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){NE.copy(e).add(t).multiplyScalar(.5),kE.copy(t).sub(e).normalize(),zE.copy(this.origin).sub(NE);const r=.5*e.distanceTo(t),s=-this.direction.dot(kE),o=zE.dot(this.direction),a=-zE.dot(kE),l=zE.lengthSq(),c=Math.abs(1-s*s);let u,h,d,p;if(c>0)if(u=s*a-o,h=s*o-a,p=r*c,u>=0)if(h>=-p)if(h<=p){const e=1/c;u*=e,h*=e,d=u*(u+s*h+2*o)+h*(s*u+h+2*a)+l}else h=r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+l;else h=-r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+l;else h<=-p?(u=Math.max(0,-(-s*r+o)),h=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+l):h<=p?(u=0,h=Math.min(Math.max(-r,-a),r),d=h*(h+2*a)+l):(u=Math.max(0,-(s*r+o)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+l);else h=s>0?-r:r,u=Math.max(0,-(s*h+o)),d=-u*u+h*(h+2*a)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(NE).addScaledVector(kE,h),d}intersectSphere(e,t){FE.subVectors(e.center,this.origin);const i=FE.dot(this.direction),n=FE.dot(FE)-i*i,r=e.radius*e.radius;if(n>r)return null;const s=Math.sqrt(r-n),o=i-s,a=i+s;return a<0?null:this.at(o<0?a:o,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,s,o,a;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,n=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,n=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,s=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,s=(e.min.y-h.y)*c),i>s||r>n?null:((r>i||isNaN(i))&&(i=r),(s<n||isNaN(n))&&(n=s),u>=0?(o=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,FE)}intersectTriangle(e,t,i,n,r){UE.subVectors(t,e),VE.subVectors(i,e),jE.crossVectors(UE,VE);let s,o=this.direction.dot(jE);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}zE.subVectors(this.origin,e);const a=s*this.direction.dot(VE.crossVectors(zE,VE));if(a<0)return null;const l=s*this.direction.dot(UE.cross(zE));if(l<0)return null;if(a+l>o)return null;const c=-s*zE.dot(jE);return c<0?null:this.at(c/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class HE extends _E{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cS(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kT,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const WE=new IT,qE=new GE,XE=new nE,$E=new rT,ZE=new rT,YE=new rT,JE=new rT,KE=new rT,QE=new rT,eA=new rT,tA=new rT;class iA extends tS{constructor(e=new hE,t=new HE){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const i=this.geometry,n=i.morphAttributes.position,r=i.morphTargetsRelative;t.fromBufferAttribute(i.attributes.position,e);const s=this.morphTargetInfluences;if(n&&s){QE.set(0,0,0);for(let i=0,o=n.length;i<o;i++){const o=s[i];0!==o&&(KE.fromBufferAttribute(n[i],e),QE.addScaledVector(r?KE:KE.sub(t),o))}t.add(QE)}return t}raycast(e,t){const i=this.geometry,n=this.matrixWorld;if(void 0!==this.material){if(null===i.boundingSphere&&i.computeBoundingSphere(),XE.copy(i.boundingSphere),XE.applyMatrix4(n),qE.copy(e.ray).recast(e.near),!1===XE.containsPoint(qE.origin)){if(null===qE.intersectSphere(XE,$E))return;if(qE.origin.distanceToSquared($E)>(e.far-e.near)**2)return}WE.copy(n).invert(),qE.copy(e.ray).applyMatrix4(WE),null!==i.boundingBox&&!1===qE.intersectsBox(i.boundingBox)||this._computeIntersections(e,t,qE)}}_computeIntersections(e,t,i){let n;const r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,u=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(s))for(let r=0,a=h.length;r<a;r++){const a=h[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){n=nA(this,p,e,i,l,c,u,o.getX(r),o.getX(r+1),o.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=a.materialIndex,t.push(n))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){n=nA(this,s,e,i,l,c,u,o.getX(r),o.getX(r+1),o.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),t.push(n))}}else if(void 0!==a)if(Array.isArray(s))for(let r=0,o=h.length;r<o;r++){const o=h[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){n=nA(this,p,e,i,l,c,u,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=o.materialIndex,t.push(n))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){n=nA(this,s,e,i,l,c,u,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),t.push(n))}}}}function nA(e,t,i,n,r,s,o,a,l,c){e.getVertexPosition(a,ZE),e.getVertexPosition(l,YE),e.getVertexPosition(c,JE);const u=function(e,t,i,n,r,s,o,a){let l;if(l=1===t.side?n.intersectTriangle(o,s,r,!0,a):n.intersectTriangle(r,s,o,0===t.side,a),null===l)return null;tA.copy(a),tA.applyMatrix4(e.matrixWorld);const c=i.ray.origin.distanceTo(tA);return c<i.near||c>i.far?null:{distance:c,point:tA.clone(),object:e}}(e,t,i,n,ZE,YE,JE,eA);if(u){const e=new rT;MS.getBarycoord(eA,ZE,YE,JE,e),r&&(u.uv=MS.getInterpolatedAttribute(r,a,l,c,e,new iT)),s&&(u.uv1=MS.getInterpolatedAttribute(s,a,l,c,e,new iT)),o&&(u.normal=MS.getInterpolatedAttribute(o,a,l,c,e,new rT),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const t={a:a,b:l,c:c,normal:new rT,materialIndex:0};MS.getNormal(ZE,YE,JE,t.normal),u.face=t,u.barycoord=e}return u}const rA=new rT,sA=new TT,oA=new TT,aA=new rT,lA=new IT,cA=new rT,uA=new nE,hA=new IT,dA=new GE;class pA extends iA{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Fx,this.bindMatrix=new IT,this.bindMatrixInverse=new IT,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new IS),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,cA),this.boundingBox.expandByPoint(cA)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new nE),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,cA),this.boundingSphere.expandByPoint(cA)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.matrixWorld;void 0!==this.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),uA.copy(this.boundingSphere),uA.applyMatrix4(i),!1!==e.ray.intersectsSphere(uA)&&(hA.copy(i).invert(),dA.copy(e.ray).applyMatrix4(hA),null!==this.boundingBox&&!1===dA.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,dA)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new TT,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Fx?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Nx?this.bindMatrixInverse.copy(this.bindMatrix).invert():Uw("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;sA.fromBufferAttribute(n.attributes.skinIndex,e),oA.fromBufferAttribute(n.attributes.skinWeight,e),rA.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const n=oA.getComponent(e);if(0!==n){const r=sA.getComponent(e);lA.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),t.addScaledVector(aA.copy(rA).applyMatrix4(lA),n)}}return t.applyMatrix4(this.bindMatrixInverse)}}class fA extends tS{constructor(){super(),this.isBone=!0,this.type="Bone"}}class mA extends wT{constructor(e=null,t=1,i=1,n,r,s,o,a,l=1003,c=1003,u,h){super(null,s,o,a,l,c,n,r,u,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const gA=new IT,_A=new IT;class yA{constructor(e=[],t=[]){this.uuid=Zw(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){Uw("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new IT)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new IT;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=e.length;n<r;n++){gA.multiplyMatrices(e[n]?e[n].matrixWorld:_A,t[n]),gA.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new yA(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new mA(t,e,e,fb,sb);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const n=e.bones[i];let r=t[n];void 0===r&&(Uw("Skeleton: No bone found with UUID:",n),r=new fA),this.bones.push(r),this.boneInverses.push((new IT).fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){e.bones.push(t[n].uuid);e.boneInverses.push(i[n].toArray())}return e}}class vA extends YS{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const xA=new IT,bA=new IT,wA=[],TA=new IS,SA=new IT,EA=new iA,AA=new nE;class MA extends iA{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new vA(new Float32Array(16*i),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<i;e++)this.setMatrixAt(e,SA)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new IS),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,xA),TA.copy(e.boundingBox).applyMatrix4(xA),this.boundingBox.union(TA)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new nE),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,xA),AA.copy(e.boundingSphere).applyMatrix4(xA),this.boundingSphere.union(AA)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.previousInstanceMatrix&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,r=e*(i.length+1)+1;for(let e=0;e<i.length;e++)i[e]=n[r+e]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(EA.geometry=this.geometry,EA.material=this.material,void 0!==EA.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),AA.copy(this.boundingSphere),AA.applyMatrix4(i),!1!==e.ray.intersectsSphere(AA)))for(let r=0;r<n;r++){this.getMatrixAt(r,xA),bA.multiplyMatrices(i,xA),EA.matrixWorld=bA,EA.raycast(e,wA);for(let e=0,i=wA.length;e<i;e++){const i=wA[e];i.instanceId=r,i.object=this,t.push(i)}wA.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new vA(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;null===this.morphTexture&&(this.morphTexture=new mA(new Float32Array(n*this.count),n,this.count,_b,sb));const r=this.morphTexture.source.data.data;let s=0;for(let e=0;e<i.length;e++)s+=i[e];const o=n*e;r[o]=this.geometry.morphTargetsRelative?1:1-s,r.set(i,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const IA=new rT,CA=new rT,PA=new aT;let LA=class{constructor(e=new rT(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=IA.subVectors(i,t).cross(CA.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(IA),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||PA.getNormalMatrix(e),n=this.coplanarPoint(IA).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}};const RA=new nE,OA=new iT(.5,.5),DA=new rT;class BA{constructor(e=new LA,t=new LA,i=new LA,n=new LA,r=new LA,s=new LA){this.planes=[e,t,i,n,r,s]}set(e,t,i,n,r,s){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=2e3,i=!1){const n=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],_=r[12],y=r[13],v=r[14],x=r[15];if(n[0].setComponents(l-s,d-c,g-p,x-_).normalize(),n[1].setComponents(l+s,d+c,g+p,x+_).normalize(),n[2].setComponents(l+o,d+u,g+f,x+y).normalize(),n[3].setComponents(l-o,d-u,g-f,x-y).normalize(),i)n[4].setComponents(a,h,m,v).normalize(),n[5].setComponents(l-a,d-h,g-m,x-v).normalize();else if(n[4].setComponents(l-a,d-h,g-m,x-v).normalize(),t===Cw)n[5].setComponents(l+a,d+h,g+m,x+v).normalize();else{if(t!==Pw)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,m,v).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),RA.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),RA.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(RA)}intersectsSprite(e){RA.center.set(0,0,0);const t=OA.distanceTo(e.center);return RA.radius=.7071067811865476+t,RA.applyMatrix4(e.matrixWorld),this.intersectsSphere(RA)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(i)<n)return!1}return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(DA.x=n.normal.x>0?e.max.x:e.min.x,DA.y=n.normal.y>0?e.max.y:e.min.y,DA.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(DA)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const FA=new IT,NA=new BA;class kA{constructor(){this.coordinateSystem=Cw}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),NA.setFromProjectionMatrix(FA,n.coordinateSystem,n.reversedDepth),NA.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),NA.setFromProjectionMatrix(FA,n.coordinateSystem,n.reversedDepth),NA.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),NA.setFromProjectionMatrix(FA,n.coordinateSystem,n.reversedDepth),NA.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),NA.setFromProjectionMatrix(FA,n.coordinateSystem,n.reversedDepth),NA.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),NA.setFromProjectionMatrix(FA,n.coordinateSystem,n.reversedDepth),NA.containsPoint(e))return!0}return!1}clone(){return new kA}}function zA(e,t){return e-t}function UA(e,t){return e.z-t.z}function VA(e,t){return t.z-e.z}class jA{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,n){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];s.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=n}reset(){this.list.length=0,this.index=0}}const GA=new IT,HA=new cS(1,1,1),WA=new BA,qA=new kA,XA=new IS,$A=new nE,ZA=new rT,YA=new rT,JA=new rT,KA=new jA,QA=new iA,eM=[];function tM(e,t,i=0){const n=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){const r=e.count;for(let s=0;s<r;s++)for(let r=0;r<n;r++)t.setComponent(s+i,r,e.getComponent(s,r))}else t.array.set(e.array,i*n);t.needsUpdate=!0}function iM(e,t){if(e.constructor!==t.constructor){const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)t[n]=e[n]}else{const i=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,i))}}class nM extends iA{constructor(e,t,i=2*t,n){super(new hE,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(4*this._maxInstanceCount);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new mA(t,e,e,fb,sb);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new mA(t,e,e,yb,rb);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new mA(t,e,e,fb,sb);i.colorSpace=dT.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,n=this._maxIndexCount;if(!1===this._geometryInitialized){for(const n in e.attributes){const r=e.getAttribute(n),{array:s,itemSize:o,normalized:a}=r,l=new s.constructor(i*o),c=new YS(l,o,a);t.setAttribute(n,c)}if(null!==e.getIndex()){const e=i>65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new YS(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=e.getAttribute(i),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||!1===t[e].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||!1===t[e].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new IS);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i<n;i++){if(!1===t[i].active)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,GA),this.getBoundingBoxAt(n,XA).applyMatrix4(GA),e.union(XA)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nE);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i<n;i++){if(!1===t[i].active)continue;const n=t[i].geometryIndex;this.getMatrixAt(i,GA),this.getBoundingSphereAt(n,$A).applyMatrix4(GA),e.union($A)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(zA),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=t):(i=this._instanceInfo.length,this._instanceInfo.push(t));const n=this._matricesTexture;GA.identity().toArray(n.image.data,16*i),n.needsUpdate=!0;const r=this._colorsTexture;return r&&(HA.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=-1===t?e.getAttribute("position").count:t;const s=e.getIndex();if(null!==s&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=-1===i?s.count:i),-1!==n.indexStart&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(zA),o=this._availableGeometryIds.shift(),r[o]=n):(o=this._geometryCount,this._geometryCount++,r.push(n)),this.setGeometryAt(o,e),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,n=null!==i.getIndex(),r=i.getIndex(),s=t.getIndex(),o=this._geometryInfo[e];if(n&&s.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const a=o.vertexStart,l=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const e in i.attributes){const n=t.getAttribute(e),r=i.getAttribute(e);tM(n,r,a);const s=n.itemSize;for(let e=n.count,t=l;e<t;e++){const t=a+e;for(let e=0;e<s;e++)r.setComponent(t,e,0)}r.needsUpdate=!0,r.addUpdateRange(a*s,l*s)}if(n){const e=o.indexStart,i=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let t=0;t<s.count;t++)r.setX(e+t,a+s.getX(t));for(let t=s.count,n=i;t<n;t++)r.setX(e+t,a);r.needsUpdate=!0,r.addUpdateRange(e,o.reservedIndexCount)}return o.start=n?o.indexStart:o.vertexStart,o.count=n?o.indexCount:o.vertexCount,o.boundingBox=null,null!==t.boundingBox&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,null!==t.boundingSphere&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||!1===t[e].active)return this;const i=this._instanceInfo;for(let t=0,n=i.length;t<n;t++)i[t].active&&i[t].geometryIndex===e&&this.deleteInstance(t);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const i=this._geometryInfo,n=i.map((e,t)=>t).sort((e,t)=>i[e].vertexStart-i[t].vertexStart),r=this.geometry;for(let s=0,o=i.length;s<o;s++){const o=i[n[s]];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==t){const{indexStart:i,vertexStart:n,reservedIndexCount:s}=o,a=r.index,l=a.array,c=e-n;for(let e=i;e<i+s;e++)l[e]=l[e]+c;a.array.copyWithin(t,i,i+s),a.addUpdateRange(t,s),a.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){const{vertexStart:t,reservedVertexCount:i}=o,n=r.attributes;for(const r in n){const s=n[r],{array:o,itemSize:a}=s;o.copyWithin(e*a,t*a,(t+i)*a),s.addUpdateRange(e*a,i*a),s.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(null===n.boundingBox){const e=new IS,t=i.index,r=i.attributes.position;for(let i=n.start,s=n.start+n.count;i<s;i++){let n=i;t&&(n=t.getX(n)),e.expandByPoint(ZA.fromBufferAttribute(r,n))}n.boundingBox=e}return t.copy(n.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(null===n.boundingSphere){const t=new nE;this.getBoundingBoxAt(e,XA),XA.getCenter(t.center);const r=i.index,s=i.attributes.position;let o=0;for(let e=n.start,i=n.start+n.count;e<i;e++){let i=e;r&&(i=r.getX(i)),ZA.fromBufferAttribute(s,i),o=Math.max(o,t.center.distanceToSquared(ZA))}t.radius=Math.sqrt(o),n.boundingSphere=t}return t.copy(n.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture;return t.toArray(this._matricesTexture.image.data,16*e),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,16*e)}setColorAt(e,t){return this.validateInstanceId(e),null===this._colorsTexture&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,4*e),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,4*e)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(this._instanceInfo[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(zA);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const n=new Int32Array(e),r=new Int32Array(e);iM(this._multiDrawCounts,n),iM(this._multiDrawStarts,r),this._multiDrawCounts=n,this._multiDrawStarts=r,this._maxInstanceCount=e;const s=this._indirectTexture,o=this._matricesTexture,a=this._colorsTexture;s.dispose(),this._initIndirectTexture(),iM(s.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),iM(o.image.data,this._matricesTexture.image.data),a&&(a.dispose(),this._initColorsTexture(),iM(a.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...i.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...i.map(e=>e.indexStart+e.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`)}const n=this.geometry;n.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new hE,this._initializeGeometry(n));const r=this.geometry;n.index&&iM(n.index.array,r.index.array);for(const e in n.attributes)iM(n.attributes[e].array,r.attributes[e].array)}raycast(e,t){const i=this._instanceInfo,n=this._geometryInfo,r=this.matrixWorld,s=this.geometry;QA.material=this.material,QA.geometry.index=s.index,QA.geometry.attributes=s.attributes,null===QA.geometry.boundingBox&&(QA.geometry.boundingBox=new IS),null===QA.geometry.boundingSphere&&(QA.geometry.boundingSphere=new nE);for(let s=0,o=i.length;s<o;s++){if(!i[s].visible||!i[s].active)continue;const o=i[s].geometryIndex,a=n[o];QA.geometry.setDrawRange(a.start,a.count),this.getMatrixAt(s,QA.matrixWorld).premultiply(r),this.getBoundingBoxAt(o,QA.geometry.boundingBox),this.getBoundingSphereAt(o,QA.geometry.boundingSphere),QA.raycast(e,eM);for(let e=0,i=eM.length;e<i;e++){const i=eM[e];i.object=this,i.batchId=s,t.push(i)}eM.length=0}QA.material=null,QA.geometry.index=null,QA.geometry.attributes={},QA.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=null!==e.boundingBox?e.boundingBox.clone():null,this.boundingSphere=null!==e.boundingSphere?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=n.getIndex();let o=null===s?1:s.array.BYTES_PER_ELEMENT,a=1;r.wireframe&&(a=2,o=n.attributes.position.count>65535?4:2);const l=this._instanceInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,p=this._indirectTexture,f=p.image.data,m=i.isArrayCamera?qA:WA;d&&!i.isArrayCamera&&(GA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),WA.setFromProjectionMatrix(GA,i.coordinateSystem,i.reversedDepth));let g=0;if(this.sortObjects){GA.copy(this.matrixWorld).invert(),ZA.setFromMatrixPosition(i.matrixWorld).applyMatrix4(GA),YA.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(GA);for(let e=0,t=l.length;e<t;e++)if(l[e].visible&&l[e].active){const t=l[e].geometryIndex;this.getMatrixAt(e,GA),this.getBoundingSphereAt(t,$A).applyMatrix4(GA);let n=!1;if(d&&(n=!m.intersectsSphere($A,i)),!n){const i=h[t],n=JA.subVectors($A.center,ZA).dot(YA);KA.push(i.start,i.count,n,e)}}const e=KA.list,t=this.customSort;null===t?e.sort(r.transparent?VA:UA):t.call(this,e,i);for(let t=0,i=e.length;t<i;t++){const i=e[t];c[g]=i.start*o*a,u[g]=i.count*a,f[g]=i.index,g++}KA.reset()}else for(let e=0,t=l.length;e<t;e++)if(l[e].visible&&l[e].active){const t=l[e].geometryIndex;let n=!1;if(d&&(this.getMatrixAt(e,GA),this.getBoundingSphereAt(t,$A).applyMatrix4(GA),n=!m.intersectsSphere($A,i)),!n){const i=h[t];c[g]=i.start*o*a,u[g]=i.count*a,f[g]=e,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,i,n,r,s){this.onBeforeRender(e,null,n,r,s)}}class rM extends _E{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new cS(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const sM=new rT,oM=new rT,aM=new IT,lM=new GE,cM=new nE,uM=new rT,hM=new rT;class dM extends tS{constructor(e=new hE,t=new rM){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;e<n;e++)sM.fromBufferAttribute(t,e-1),oM.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=sM.distanceTo(oM);e.setAttribute("lineDistance",new QS(i,1))}else Uw("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),cM.copy(i.boundingSphere),cM.applyMatrix4(n),cM.radius+=r,!1===e.ray.intersectsSphere(cM))return;aM.copy(n).invert(),lM.copy(e.ray).applyMatrix4(aM);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,l=this.isLineSegments?2:1,c=i.index,u=i.attributes.position;if(null!==c){const i=Math.max(0,s.start),n=Math.min(c.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=c.getX(r),n=c.getX(r+1),s=pM(this,e,lM,a,i,n,r);s&&t.push(s)}if(this.isLineLoop){const r=c.getX(n-1),s=c.getX(i),o=pM(this,e,lM,a,r,s,n-1);o&&t.push(o)}}else{const i=Math.max(0,s.start),n=Math.min(u.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=pM(this,e,lM,a,r,r+1,r);i&&t.push(i)}if(this.isLineLoop){const r=pM(this,e,lM,a,n-1,i,n-1);r&&t.push(r)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function pM(e,t,i,n,r,s,o){const a=e.geometry.attributes.position;sM.fromBufferAttribute(a,r),oM.fromBufferAttribute(a,s);if(i.distanceSqToSegment(sM,oM,uM,hM)>n)return;uM.applyMatrix4(e.matrixWorld);const l=t.ray.origin.distanceTo(uM);return l<t.near||l>t.far?void 0:{distance:l,point:hM.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}const fM=new rT,mM=new rT;class gM extends dM{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e<n;e+=2)fM.fromBufferAttribute(t,e),mM.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+fM.distanceTo(mM);e.setAttribute("lineDistance",new QS(i,1))}else Uw("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class _M extends dM{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class yM extends _E{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new cS(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const vM=new IT,xM=new GE,bM=new nE,wM=new rT;class TM extends tS{constructor(e=new hE,t=new yM){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),bM.copy(i.boundingSphere),bM.applyMatrix4(n),bM.radius+=r,!1===e.ray.intersectsSphere(bM))return;vM.copy(n).invert(),xM.copy(e.ray).applyMatrix4(vM);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,l=i.index,c=i.attributes.position;if(null!==l){for(let i=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);i<r;i++){const r=l.getX(i);wM.fromBufferAttribute(c,r),SM(wM,r,a,n,e,t,this)}}else{for(let i=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);i<r;i++)wM.fromBufferAttribute(c,i),SM(wM,i,a,n,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function SM(e,t,i,n,r,s,o){const a=xM.distanceSqToPoint(e);if(a<i){const i=new rT;xM.closestPointToPoint(e,i),i.applyMatrix4(n);const l=r.ray.origin.distanceTo(i);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:i,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class EM extends wT{constructor(e,t,i,n,r=1006,s=1006,o,a,l){super(e,t,i,n,r,s,o,a,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const c=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){c.needsUpdate=!0,c._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class AM extends wT{constructor(e,t,i,n,r,s,o,a,l,c,u,h){super(null,s,o,a,l,c,n,r,u,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class MM extends wT{constructor(e=[],t=301,i,n,r,s,o,a,l,c){super(e,t,i,n,r,s,o,a,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class IM extends wT{constructor(e,t,i=1014,n,r,s,o=1003,a=1003,l,c=1026,u=1){if(c!==mb&&c!==gb)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},n,r,s,o,a,c,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new yT(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class CM extends IM{constructor(e,t=1014,i=301,n,r,s=1003,o=1003,a,l=1026){const c={width:e,height:e,depth:1},u=[c,c,c,c,c,c];super(e,e,t,i,n,r,s,o,a,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class PM extends wT{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class LM extends hE{constructor(e=1,t=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const o=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const a=[],l=[],c=[],u=[];let h=0,d=0;function p(e,t,i,n,r,s,p,f,m,g,_){const y=s/m,v=p/g,x=s/2,b=p/2,w=f/2,T=m+1,S=g+1;let E=0,A=0;const M=new rT;for(let s=0;s<S;s++){const o=s*v-b;for(let a=0;a<T;a++){M[e]=(a*y-x)*n,M[t]=o*r,M[i]=w,l.push(M.x,M.y,M.z),M[e]=0,M[t]=0,M[i]=f>0?1:-1,c.push(M.x,M.y,M.z),u.push(a/m),u.push(1-s/g),E+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const i=h+t+T*(e+1),n=h+(t+1)+T*(e+1),r=h+(t+1)+T*e;a.push(h+t+T*e,i,r),a.push(i,n,r),A+=6}o.addGroup(d,A,_),d+=A,h+=E}p("z","y","x",-1,-1,i,t,e,s,r,0),p("z","y","x",1,-1,i,t,-e,s,r,1),p("x","z","y",1,1,e,i,t,n,s,2),p("x","z","y",1,-1,e,i,-t,n,s,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new QS(l,3)),this.setAttribute("normal",new QS(c,3)),this.setAttribute("uv",new QS(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new LM(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class RM extends hE{constructor(e=1,t=1,i=4,n=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:n,heightSegments:r},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),n=Math.max(3,Math.floor(n)),r=Math.max(1,Math.floor(r));const s=[],o=[],a=[],l=[],c=t/2,u=Math.PI/2*e,h=t,d=2*u+h,p=2*i+r,f=n+1,m=new rT,g=new rT;for(let _=0;_<=p;_++){let y=0,v=0,x=0,b=0;if(_<=i){const t=_/i,n=t*Math.PI/2;v=-c-e*Math.cos(n),x=e*Math.sin(n),b=-e*Math.cos(n),y=t*u}else if(_<=i+r){const n=(_-i)/r;v=n*t-c,x=e,b=0,y=u+n*h}else{const t=(_-i-r)/i,n=t*Math.PI/2;v=c+e*Math.sin(n),x=e*Math.cos(n),b=e*Math.sin(n),y=u+h+t*u}const w=Math.max(0,Math.min(1,y/d));let T=0;0===_?T=.5/n:_===p&&(T=-.5/n);for(let e=0;e<=n;e++){const t=e/n,i=t*Math.PI*2,r=Math.sin(i),s=Math.cos(i);g.x=-x*s,g.y=v,g.z=x*r,o.push(g.x,g.y,g.z),m.set(-x*s,b,x*r),m.normalize(),a.push(m.x,m.y,m.z),l.push(t+T,w)}if(_>0){const e=(_-1)*f;for(let t=0;t<n;t++){const i=e+t+1,n=_*f+t,r=_*f+t+1;s.push(e+t,i,n),s.push(i,r,n)}}}this.setIndex(s),this.setAttribute("position",new QS(o,3)),this.setAttribute("normal",new QS(a,3)),this.setAttribute("uv",new QS(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new RM(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class OM extends hE{constructor(e=1,t=32,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],s=[],o=[],a=[],l=new rT,c=new iT;s.push(0,0,0),o.push(0,0,1),a.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const h=i+r/t*n;l.x=e*Math.cos(h),l.y=e*Math.sin(h),s.push(l.x,l.y,l.z),o.push(0,0,1),c.x=(s[u]/e+1)/2,c.y=(s[u+1]/e+1)/2,a.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new QS(s,3)),this.setAttribute("normal",new QS(o,3)),this.setAttribute("uv",new QS(a,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new OM(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class DM extends hE{constructor(e=1,t=1,i=1,n=32,r=1,s=!1,o=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a};const l=this;n=Math.floor(n),r=Math.floor(r);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=i/2;let g=0;function _(i){const r=p,s=new iT,f=new rT;let _=0;const y=!0===i?e:t,v=!0===i?1:-1;for(let e=1;e<=n;e++)u.push(0,m*v,0),h.push(0,v,0),d.push(.5,.5),p++;const x=p;for(let e=0;e<=n;e++){const t=e/n*a+o,i=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*v,f.z=y*i,u.push(f.x,f.y,f.z),h.push(0,v,0),s.x=.5*i+.5,s.y=.5*r*v+.5,d.push(s.x,s.y),p++}for(let e=0;e<n;e++){const t=r+e,n=x+e;!0===i?c.push(n,n+1,t):c.push(n+1,n,t),_+=3}l.addGroup(g,_,!0===i?1:2),g+=_}!function(){const s=new rT,_=new rT;let y=0;const v=(t-e)/i;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=n;e++){const t=e/n,r=t*a+o,l=Math.sin(r),f=Math.cos(r);_.x=y*l,_.y=-g*i+m,_.z=y*f,u.push(_.x,_.y,_.z),s.set(l,v,f).normalize(),h.push(s.x,s.y,s.z),d.push(t,1-g),c.push(p++)}f.push(c)}for(let i=0;i<n;i++)for(let n=0;n<r;n++){const s=f[n+1][i],o=f[n+1][i+1],a=f[n][i+1];(e>0||0!==n)&&(c.push(f[n][i],s,a),y+=3),(t>0||n!==r-1)&&(c.push(s,o,a),y+=3)}l.addGroup(g,y,0),g+=y}(),!1===s&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new QS(u,3)),this.setAttribute("normal",new QS(h,3)),this.setAttribute("uv",new QS(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new DM(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class BM extends DM{constructor(e=1,t=1,i=32,n=1,r=!1,s=0,o=2*Math.PI){super(0,e,t,i,n,r,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:o}}static fromJSON(e){return new BM(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class FM extends hE{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],s=[];function o(e,t,i,n){const r=n+1,s=[];for(let n=0;n<=r;n++){s[n]=[];const o=e.clone().lerp(i,n/r),a=t.clone().lerp(i,n/r),l=r-n;for(let e=0;e<=l;e++)s[n][e]=0===e&&n===r?o:o.clone().lerp(a,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const i=Math.floor(t/2);t%2==0?(a(s[e][i+1]),a(s[e+1][i]),a(s[e][i])):(a(s[e][i+1]),a(s[e+1][i+1]),a(s[e+1][i]))}}function a(e){r.push(e.x,e.y,e.z)}function l(t,i){const n=3*t;i.x=e[n+0],i.y=e[n+1],i.z=e[n+2]}function c(e,t,i,n){n<0&&1===e.x&&(s[t]=e.x-1),0===i.x&&0===i.z&&(s[t]=n/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}function h(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}!function(e){const i=new rT,n=new rT,r=new rT;for(let s=0;s<t.length;s+=3)l(t[s+0],i),l(t[s+1],n),l(t[s+2],r),o(i,n,r,e)}(n),function(e){const t=new rT;for(let i=0;i<r.length;i+=3)t.x=r[i+0],t.y=r[i+1],t.z=r[i+2],t.normalize().multiplyScalar(e),r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z}(i),function(){const e=new rT;for(let t=0;t<r.length;t+=3){e.x=r[t+0],e.y=r[t+1],e.z=r[t+2];const i=u(e)/2/Math.PI+.5,n=h(e)/Math.PI+.5;s.push(i,1-n)}(function(){const e=new rT,t=new rT,i=new rT,n=new rT,o=new iT,a=new iT,l=new iT;for(let h=0,d=0;h<r.length;h+=9,d+=6){e.set(r[h+0],r[h+1],r[h+2]),t.set(r[h+3],r[h+4],r[h+5]),i.set(r[h+6],r[h+7],r[h+8]),o.set(s[d+0],s[d+1]),a.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),n.copy(e).add(t).add(i).divideScalar(3);const p=u(n);c(o,d+0,e,p),c(a,d+2,t,p),c(l,d+4,i,p)}})(),function(){for(let e=0;e<s.length;e+=6){const t=s[e+0],i=s[e+2],n=s[e+4],r=Math.max(t,i,n),o=Math.min(t,i,n);r>.9&&o<.1&&(t<.2&&(s[e+0]+=1),i<.2&&(s[e+2]+=1),n<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new QS(r,3)),this.setAttribute("normal",new QS(r.slice(),3)),this.setAttribute("uv",new QS(s,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new FM(e.vertices,e.indices,e.radius,e.detail)}}class NM extends FM{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new NM(e.radius,e.detail)}}const kM=new rT,zM=new rT,UM=new rT,VM=new MS;class jM extends hE{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const i=Math.pow(10,4),n=Math.cos(Xw*t),r=e.getIndex(),s=e.getAttribute("position"),o=r?r.count:s.count,a=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let e=0;e<o;e+=3){r?(a[0]=r.getX(e),a[1]=r.getX(e+1),a[2]=r.getX(e+2)):(a[0]=e,a[1]=e+1,a[2]=e+2);const{a:t,b:o,c:d}=VM;if(t.fromBufferAttribute(s,a[0]),o.fromBufferAttribute(s,a[1]),d.fromBufferAttribute(s,a[2]),VM.getNormal(UM),c[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,c[1]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,c[2]=`${Math.round(d.x*i)},${Math.round(d.y*i)},${Math.round(d.z*i)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let e=0;e<3;e++){const t=(e+1)%3,i=c[e],r=c[t],s=VM[l[e]],o=VM[l[t]],d=`${i}_${r}`,p=`${r}_${i}`;p in u&&u[p]?(UM.dot(u[p].normal)<=n&&(h.push(s.x,s.y,s.z),h.push(o.x,o.y,o.z)),u[p]=null):d in u||(u[d]={index0:a[e],index1:a[t],normal:UM.clone()})}}for(const e in u)if(u[e]){const{index0:t,index1:i}=u[e];kM.fromBufferAttribute(s,t),zM.fromBufferAttribute(s,i),h.push(kM.x,kM.y,kM.z),h.push(zM.x,zM.y,zM.z)}this.setAttribute("position",new QS(h,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class GM{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Uw("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let n=0;const r=i.length;let s;s=t||e*i[r-1];let o,a=0,l=r-1;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),o=i[n]-s,o<0)a=n+1;else{if(!(o>0)){l=n;break}l=n-1}if(n=l,i[n]===s)return n/(r-1);const c=i[n];return(n+(s-c)/(i[n+1]-c))/(r-1)}getTangent(e,t){const i=1e-4;let n=e-i,r=e+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),o=this.getPoint(r),a=t||(s.isVector2?new iT:new rT);return a.copy(o).sub(s).normalize(),a}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new rT,n=[],r=[],s=[],o=new rT,a=new IT;for(let t=0;t<=e;t++){n[t]=this.getTangentAt(t/e,new rT)}r[0]=new rT,s[0]=new rT;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),u=Math.abs(n[0].y),h=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),h<=l&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],o),s[0].crossVectors(n[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),o.crossVectors(n[t-1],n[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(Yw(n[t-1].dot(n[t]),-1,1));r[t].applyMatrix4(a.makeRotationAxis(o,e))}s[t].crossVectors(n[t],r[t])}if(!0===t){let t=Math.acos(Yw(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],t*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class HM extends GM{constructor(e=0,t=0,i=1,n=1,r=0,s=2*Math.PI,o=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=o,this.aRotation=a}getPoint(e,t=new iT){const i=t,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const o=this.aStartAngle+e*r;let a=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),i=a-this.aX,n=l-this.aY;a=i*e-n*t+this.aX,l=i*t+n*e+this.aY}return i.set(a,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class WM extends HM{constructor(e,t,i,n,r,s){super(e,t,i,i,n,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function qM(){let e=0,t=0,i=0,n=0;function r(r,s,o,a){e=r,t=o,i=-3*r+3*s-2*o-a,n=2*r-2*s+o+a}return{initCatmullRom:function(e,t,i,n,s){r(t,i,s*(i-e),s*(n-t))},initNonuniformCatmullRom:function(e,t,i,n,s,o,a){let l=(t-e)/s-(i-e)/(s+o)+(i-t)/o,c=(i-t)/o-(n-t)/(o+a)+(n-i)/a;l*=o,c*=o,r(t,i,l,c)},calc:function(r){const s=r*r;return e+t*r+i*s+n*(s*r)}}}const XM=new rT,$M=new qM,ZM=new qM,YM=new qM;class JM extends GM{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new rT){const i=t,n=this.points,r=n.length,s=(r-(this.closed?0:1))*e;let o,a,l=Math.floor(s),c=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?o=n[(l-1)%r]:(XM.subVectors(n[0],n[1]).add(n[0]),o=XM);const u=n[l%r],h=n[(l+1)%r];if(this.closed||l+2<r?a=n[(l+2)%r]:(XM.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=XM),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(o.distanceToSquared(u),e),i=Math.pow(u.distanceToSquared(h),e),n=Math.pow(h.distanceToSquared(a),e);i<1e-4&&(i=1),t<1e-4&&(t=i),n<1e-4&&(n=i),$M.initNonuniformCatmullRom(o.x,u.x,h.x,a.x,t,i,n),ZM.initNonuniformCatmullRom(o.y,u.y,h.y,a.y,t,i,n),YM.initNonuniformCatmullRom(o.z,u.z,h.z,a.z,t,i,n)}else"catmullrom"===this.curveType&&($M.initCatmullRom(o.x,u.x,h.x,a.x,this.tension),ZM.initCatmullRom(o.y,u.y,h.y,a.y,this.tension),YM.initCatmullRom(o.z,u.z,h.z,a.z,this.tension));return i.set($M.calc(c),ZM.calc(c),YM.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){this.points.push(e.points[t].clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){e.points.push(this.points[t].toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new rT).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function KM(e,t,i,n,r){const s=.5*(n-t),o=.5*(r-i),a=e*e;return(2*i-2*n+s+o)*(e*a)+(-3*i+3*n-2*s-o)*a+s*e+i}function QM(e,t,i,n){return function(e,t){const i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,i)+function(e,t){return e*e*t}(e,n)}function eI(e,t,i,n,r){return function(e,t){const i=1-e;return i*i*i*t}(e,t)+function(e,t){const i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*t}(e,n)+function(e,t){return e*e*e*t}(e,r)}class tI extends GM{constructor(e=new iT,t=new iT,i=new iT,n=new iT){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new iT){const i=t,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(eI(e,n.x,r.x,s.x,o.x),eI(e,n.y,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class iI extends GM{constructor(e=new rT,t=new rT,i=new rT,n=new rT){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new rT){const i=t,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(eI(e,n.x,r.x,s.x,o.x),eI(e,n.y,r.y,s.y,o.y),eI(e,n.z,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class nI extends GM{constructor(e=new iT,t=new iT){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new iT){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new iT){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class rI extends GM{constructor(e=new rT,t=new rT){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new rT){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new rT){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class sI extends GM{constructor(e=new iT,t=new iT,i=new iT){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new iT){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(QM(e,n.x,r.x,s.x),QM(e,n.y,r.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class oI extends GM{constructor(e=new rT,t=new rT,i=new rT){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new rT){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(QM(e,n.x,r.x,s.x),QM(e,n.y,r.y,s.y),QM(e,n.z,r.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class aI extends GM{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new iT){const i=t,n=this.points,r=(n.length-1)*e,s=Math.floor(r),o=r-s,a=n[0===s?s:s-1],l=n[s],c=n[s>n.length-2?n.length-1:s+1],u=n[s>n.length-3?n.length-1:s+2];return i.set(KM(o,a.x,l.x,c.x,u.x),KM(o,a.y,l.y,c.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){this.points.push(e.points[t].clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){e.points.push(this.points[t].toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new iT).fromArray(i))}return this}}var lI=Object.freeze({__proto__:null,ArcCurve:WM,CatmullRomCurve3:JM,CubicBezierCurve:tI,CubicBezierCurve3:iI,EllipseCurve:HM,LineCurve:nI,LineCurve3:rI,QuadraticBezierCurve:sI,QuadraticBezierCurve3:oI,SplineCurve:aI});class cI extends GM{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){this.curves.push(new lI[!0===e.isVector2?"LineCurve":"LineCurve3"](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const e=n[r]-i,s=this.curves[r],o=s.getLength();return s.getPointAt(0===o?0:1-e/o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],o=s.getPoints(s.isEllipseCurve?2*e:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e);for(let e=0;e<o.length;e++){const n=o[e];i&&i.equals(n)||(t.push(n),i=n)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){this.curves.push(e.curves[t].clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){e.curves.push(this.curves[t].toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push((new lI[i.type]).fromJSON(i))}return this}}class uI extends cI{constructor(e){super(),this.type="Path",this.currentPoint=new iT,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new nI(this.currentPoint.clone(),new iT(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new sI(this.currentPoint.clone(),new iT(e,t),new iT(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,s){const o=new tI(this.currentPoint.clone(),new iT(e,t),new iT(i,n),new iT(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new aI(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,s){return this.absarc(e+this.currentPoint.x,t+this.currentPoint.y,i,n,r,s),this}absarc(e,t,i,n,r,s){return this.absellipse(e,t,i,i,n,r,s),this}ellipse(e,t,i,n,r,s,o,a){return this.absellipse(e+this.currentPoint.x,t+this.currentPoint.y,i,n,r,s,o,a),this}absellipse(e,t,i,n,r,s,o,a){const l=new HM(e,t,i,n,r,s,o,a);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class hI extends uI{constructor(e){super(e),this.uuid=Zw(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){this.holes.push(e.holes[t].clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){e.holes.push(this.holes[t].toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push((new uI).fromJSON(i))}return this}}function dI(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let s=pI(e,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(n&&(s=function(e,t,i,n){const r=[];for(let i=0,s=t.length;i<s;i++){const o=pI(e,t[i]*n,i<s-1?t[i+1]*n:e.length,n,!1);o===o.next&&(o.steiner=!0),r.push(SI(o))}r.sort(xI);for(let e=0;e<r.length;e++)i=bI(r[e],i);return i}(e,t,s,i)),e.length>80*i){a=e[0],l=e[1];let t=a,n=l;for(let s=i;s<r;s+=i){const i=e[s],r=e[s+1];i<a&&(a=i),r<l&&(l=r),i>t&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return mI(s,o,i,a,l,c,0),o}function pI(e,t,i,n,r){let s;if(r===function(e,t,i,n){let r=0;for(let s=t,o=i-n;s<i;s+=n)r+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return r}(e,t,i,n)>0)for(let r=t;r<i;r+=n)s=BI(r/n|0,e[r],e[r+1],s);else for(let r=i-n;r>=t;r-=n)s=BI(r/n|0,e[r],e[r+1],s);return s&&CI(s,s.next)&&(FI(s),s=s.next),s}function fI(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!CI(n,n.next)&&0!==II(n.prev,n,n.next))n=n.next;else{if(FI(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function mI(e,t,i,n,r,s,o){if(!e)return;!o&&s&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=TI(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let e=0;e<i&&(a++,o=o.nextZ,o);e++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;r=o}s.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,s);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(s?_I(e,n,r,s):gI(e))t.push(l.i,e.i,c.i),FI(e),e=c.next,a=c.next;else if((e=c)===a){o?1===o?mI(e=yI(fI(e),t),t,i,n,r,s,2):2===o&&vI(e,t,i,n,r,s):mI(fI(e),t,i,n,r,s,1);break}}}function gI(e){const t=e.prev,i=e,n=e.next;if(II(t,i,n)>=0)return!1;const r=t.x,s=i.x,o=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,s,o),h=Math.min(a,l,c),d=Math.max(r,s,o),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&AI(r,a,s,l,o,c,f.x,f.y)&&II(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function _I(e,t,i,n){const r=e.prev,s=e,o=e.next;if(II(r,s,o)>=0)return!1;const a=r.x,l=s.x,c=o.x,u=r.y,h=s.y,d=o.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=TI(p,f,t,i,n),y=TI(m,g,t,i,n);let v=e.prevZ,x=e.nextZ;for(;v&&v.z>=_&&x&&x.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==o&&AI(a,u,l,h,c,d,v.x,v.y)&&II(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&AI(a,u,l,h,c,d,x.x,x.y)&&II(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==o&&AI(a,u,l,h,c,d,v.x,v.y)&&II(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==o&&AI(a,u,l,h,c,d,x.x,x.y)&&II(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function yI(e,t){let i=e;do{const n=i.prev,r=i.next.next;!CI(n,r)&&PI(n,i,i.next,r)&&OI(n,r)&&OI(r,n)&&(t.push(n.i,i.i,r.i),FI(i),FI(i.next),i=e=r),i=i.next}while(i!==e);return fI(i)}function vI(e,t,i,n,r,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&MI(o,e)){let a=DI(o,e);return o=fI(o,o.next),a=fI(a,a.next),mI(o,t,i,n,r,s,0),void mI(a,t,i,n,r,s,0)}e=e.next}o=o.next}while(o!==e)}function xI(e,t){let i=e.x-t.x;if(0===i&&(i=e.y-t.y,0===i)){i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return i}function bI(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let s,o=-1/0;if(CI(e,i))return i;do{if(CI(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>o&&(o=e,s=i.x<i.next.x?i:i.next,e===n))return s}i=i.next}while(i!==t);if(!s)return null;const a=s,l=s.x,c=s.y;let u=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&EI(r<c?n:o,r,l,c,r<c?o:n,r,i.x,i.y)){const t=Math.abs(r-i.y)/(n-i.x);OI(i,e)&&(t<u||t===u&&(i.x>s.x||i.x===s.x&&wI(s,i)))&&(s=i,u=t)}i=i.next}while(i!==a);return s}(e,t);if(!i)return t;const n=DI(i,e);return fI(n,n.next),fI(i,i.next)}function wI(e,t){return II(e.prev,e,t.prev)<0&&II(t.next,e,e.next)<0}function TI(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function SI(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function EI(e,t,i,n,r,s,o,a){return(r-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(n-a)>=(i-o)*(t-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function AI(e,t,i,n,r,s,o,a){return!(e===o&&t===a)&&EI(e,t,i,n,r,s,o,a)}function MI(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&PI(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(OI(e,t)&&OI(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(II(e.prev,e,t.prev)||II(e,t.prev,t))||CI(e,t)&&II(e.prev,e,e.next)>0&&II(t.prev,t,t.next)>0)}function II(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function CI(e,t){return e.x===t.x&&e.y===t.y}function PI(e,t,i,n){const r=RI(II(e,t,i)),s=RI(II(e,t,n)),o=RI(II(i,n,e)),a=RI(II(i,n,t));return r!==s&&o!==a||(!(0!==r||!LI(e,i,t))||(!(0!==s||!LI(e,n,t))||(!(0!==o||!LI(i,e,n))||!(0!==a||!LI(i,t,n)))))}function LI(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function RI(e){return e>0?1:e<0?-1:0}function OI(e,t){return II(e.prev,e,e.next)<0?II(e,t,e.next)>=0&&II(e,e.prev,t)>=0:II(e,t,e.prev)<0||II(e,e.next,t)<0}function DI(e,t){const i=NI(e.i,e.x,e.y),n=NI(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function BI(e,t,i,n){const r=NI(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function FI(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function NI(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class kI{static triangulate(e,t,i=2){return dI(e,t,i)}}class zI{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return.5*i}static isClockWise(e){return zI.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];UI(e),VI(i,e);let s=e.length;t.forEach(UI);for(let e=0;e<t.length;e++)n.push(s),s+=t[e].length,VI(i,t[e]);const o=kI.triangulate(i,n);for(let e=0;e<o.length;e+=3)r.push(o.slice(e,e+3));return r}}function UI(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function VI(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class jI extends hE{constructor(e=new hI([new iT(.5,.5),new iT(-.5,.5),new iT(-.5,-.5),new iT(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let t=0,i=e.length;t<i;t++){s(e[t])}function s(e){const s=[],o=void 0!==t.curveSegments?t.curveSegments:12,a=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,h=void 0!==t.bevelSize?t.bevelSize:u-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:GI;let g,_,y,v,x,b=!1;if(f){g=f.getSpacedPoints(a),b=!0,c=!1;_=f.computeFrenetFrames(a,!!f.isCatmullRomCurve3&&f.closed),y=new rT,v=new rT,x=new rT}c||(p=0,u=0,h=0,d=0);const w=e.extractPoints(o);let T=w.shape;const S=w.holes;if(!zI.isClockWise(T)){T=T.reverse();for(let e=0,t=S.length;e<t;e++){const t=S[e];zI.isClockWise(t)&&(S[e]=t.reverse())}}function E(e){const t=1e-10*1e-10;let i=e[0];for(let n=1;n<=e.length;n++){const r=n%e.length,s=e[r],o=s.x-i.x,a=s.y-i.y,l=o*o+a*a,c=Math.max(Math.abs(s.x),Math.abs(s.y),Math.abs(i.x),Math.abs(i.y));l<=t*c*c?(e.splice(r,1),n--):i=s}}E(T),S.forEach(E);const A=S.length,M=T;for(let e=0;e<A;e++){T=T.concat(S[e])}function I(e,t,i){return t||Vw("ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,i)}const C=T.length;function P(e,t,i){let n,r,s;const o=e.x-t.x,a=e.y-t.y,l=i.x-e.x,c=i.y-e.y,u=o*o+a*a;if(Math.abs(o*c-a*l)>Number.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=t.x-a/h,f=t.y+o/h,m=((i.x-c/d-p)*c-(i.y+l/d-f)*l)/(o*c-a*l);n=p+o*m-e.x,r=f+a*m-e.y;const g=n*n+r*r;if(g<=2)return new iT(n,r);s=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?l>Number.EPSILON&&(e=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(c)&&(e=!0),e?(n=-a,r=o,s=Math.sqrt(u)):(n=o,r=a,s=Math.sqrt(u/2))}return new iT(n/s,r/s)}const L=[];for(let e=0,t=M.length,i=t-1,n=e+1;e<t;e++,i++,n++)i===t&&(i=0),n===t&&(n=0),L[e]=P(M[e],M[i],M[n]);const R=[];let O,D,B=L.concat();for(let e=0,t=A;e<t;e++){const t=S[e];O=[];for(let e=0,i=t.length,n=i-1,r=e+1;e<i;e++,n++,r++)n===i&&(n=0),r===i&&(r=0),O[e]=P(t[e],t[n],t[r]);R.push(O),B=B.concat(O)}if(0===p)D=zI.triangulateShape(M,S);else{const e=[],t=[];for(let i=0;i<p;i++){const n=i/p,r=u*Math.cos(n*Math.PI/2),s=h*Math.sin(n*Math.PI/2)+d;for(let t=0,i=M.length;t<i;t++){const i=I(M[t],L[t],s);z(i.x,i.y,-r),0===n&&e.push(i)}for(let e=0,i=A;e<i;e++){const i=S[e];O=R[e];const o=[];for(let e=0,t=i.length;e<t;e++){const t=I(i[e],O[e],s);z(t.x,t.y,-r),0===n&&o.push(t)}0===n&&t.push(o)}}D=zI.triangulateShape(e,t)}const F=D.length,N=h+d;for(let e=0;e<C;e++){const t=c?I(T[e],B[e],N):T[e];b?(v.copy(_.normals[0]).multiplyScalar(t.x),y.copy(_.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(v).add(y),z(x.x,x.y,x.z)):z(t.x,t.y,0)}for(let e=1;e<=a;e++)for(let t=0;t<C;t++){const i=c?I(T[t],B[t],N):T[t];b?(v.copy(_.normals[e]).multiplyScalar(i.x),y.copy(_.binormals[e]).multiplyScalar(i.y),x.copy(g[e]).add(v).add(y),z(x.x,x.y,x.z)):z(i.x,i.y,l/a*e)}for(let e=p-1;e>=0;e--){const t=e/p,i=u*Math.cos(t*Math.PI/2),n=h*Math.sin(t*Math.PI/2)+d;for(let e=0,t=M.length;e<t;e++){const t=I(M[e],L[e],n);z(t.x,t.y,l+i)}for(let e=0,t=S.length;e<t;e++){const t=S[e];O=R[e];for(let e=0,r=t.length;e<r;e++){const r=I(t[e],O[e],n);b?z(r.x,r.y+g[a-1].y,g[a-1].x+i):z(r.x,r.y,l+i)}}}function k(e,t){let i=e.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=e.length-1);for(let e=0,i=a+2*p;e<i;e++){const i=C*e,s=C*(e+1);V(t+n+i,t+r+i,t+r+s,t+n+s)}}}function z(e,t,i){s.push(e),s.push(t),s.push(i)}function U(e,t,r){j(e),j(t),j(r);const s=n.length/3,o=m.generateTopUV(i,n,s-3,s-2,s-1);G(o[0]),G(o[1]),G(o[2])}function V(e,t,r,s){j(e),j(t),j(s),j(t),j(r),j(s);const o=n.length/3,a=m.generateSideWallUV(i,n,o-6,o-3,o-2,o-1);G(a[0]),G(a[1]),G(a[3]),G(a[1]),G(a[2]),G(a[3])}function j(e){n.push(s[3*e+0]),n.push(s[3*e+1]),n.push(s[3*e+2])}function G(e){r.push(e.x),r.push(e.y)}!function(){const e=n.length/3;if(c){let e=0,t=C*e;for(let e=0;e<F;e++){const i=D[e];U(i[2]+t,i[1]+t,i[0]+t)}e=a+2*p,t=C*e;for(let e=0;e<F;e++){const i=D[e];U(i[0]+t,i[1]+t,i[2]+t)}}else{for(let e=0;e<F;e++){const t=D[e];U(t[2],t[1],t[0])}for(let e=0;e<F;e++){const t=D[e];U(t[0]+C*a,t[1]+C*a,t[2]+C*a)}}i.addGroup(e,n.length/3-e,0)}(),function(){const e=n.length/3;let t=0;k(M,t),t+=M.length;for(let e=0,i=S.length;e<i;e++){const i=S[e];k(i,t),t+=i.length}i.addGroup(e,n.length/3-e,1)}()}this.setAttribute("position",new QS(n,3)),this.setAttribute("uv",new QS(r,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t,i){if(i.shapes=[],Array.isArray(e))for(let t=0,n=e.length;t<n;t++){i.shapes.push(e[t].uuid)}else i.shapes.push(e.uuid);i.options=Object.assign({},t),void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){i.push(t[e.shapes[n]])}const n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new lI[n.type]).fromJSON(n)),new jI(i,e.options)}}const GI={generateTopUV:function(e,t,i,n,r){const s=t[3*n],o=t[3*n+1],a=t[3*r],l=t[3*r+1];return[new iT(t[3*i],t[3*i+1]),new iT(s,o),new iT(a,l)]},generateSideWallUV:function(e,t,i,n,r,s){const o=t[3*i],a=t[3*i+1],l=t[3*i+2],c=t[3*n],u=t[3*n+1],h=t[3*n+2],d=t[3*r],p=t[3*r+1],f=t[3*r+2],m=t[3*s],g=t[3*s+1],_=t[3*s+2];return Math.abs(a-u)<Math.abs(o-c)?[new iT(o,1-l),new iT(c,1-h),new iT(d,1-f),new iT(m,1-_)]:[new iT(a,1-l),new iT(u,1-h),new iT(p,1-f),new iT(g,1-_)]}};class HI extends FM{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new HI(e.radius,e.detail)}}class WI extends hE{constructor(e=[new iT(0,-.5),new iT(.5,0),new iT(0,.5)],t=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=Yw(n,0,2*Math.PI);const r=[],s=[],o=[],a=[],l=[],c=1/t,u=new rT,h=new iT,d=new rT,p=new rT,f=new rT;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),a.push(d.x,d.y,d.z);break;case e.length-1:a.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),a.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=t;r++){const d=i+r*c*n,p=Math.sin(d),f=Math.cos(d);for(let i=0;i<=e.length-1;i++){u.x=e[i].x*p,u.y=e[i].y,u.z=e[i].x*f,s.push(u.x,u.y,u.z),h.x=r/t,h.y=i/(e.length-1),o.push(h.x,h.y);l.push(a[3*i+0]*p,a[3*i+1],a[3*i+0]*f)}}for(let i=0;i<t;i++)for(let t=0;t<e.length-1;t++){const n=t+i*e.length,s=n+e.length,o=n+e.length+1,a=n+1;r.push(n,s,a),r.push(o,a,s)}this.setIndex(r),this.setAttribute("position",new QS(s,3)),this.setAttribute("uv",new QS(o,2)),this.setAttribute("normal",new QS(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new WI(e.points,e.segments,e.phiStart,e.phiLength)}}class qI extends FM{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new qI(e.radius,e.detail)}}class XI extends hE{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,s=t/2,o=Math.floor(i),a=Math.floor(n),l=o+1,c=a+1,u=e/o,h=t/a,d=[],p=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*h-s;for(let i=0;i<l;i++){p.push(i*u-r,-t,0),f.push(0,0,1),m.push(i/o),m.push(1-e/a)}}for(let e=0;e<a;e++)for(let t=0;t<o;t++){const i=t+l*(e+1),n=t+1+l*(e+1),r=t+1+l*e;d.push(t+l*e,i,r),d.push(i,n,r)}this.setIndex(d),this.setAttribute("position",new QS(p,3)),this.setAttribute("normal",new QS(f,3)),this.setAttribute("uv",new QS(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new XI(e.width,e.height,e.widthSegments,e.heightSegments)}}class $I extends hE{constructor(e=.5,t=1,i=32,n=1,r=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:s},i=Math.max(3,i);const o=[],a=[],l=[],c=[];let u=e;const h=(t-e)/(n=Math.max(1,n)),d=new rT,p=new iT;for(let e=0;e<=n;e++){for(let e=0;e<=i;e++){const n=r+e/i*s;d.x=u*Math.cos(n),d.y=u*Math.sin(n),a.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,c.push(p.x,p.y)}u+=h}for(let e=0;e<n;e++){const t=e*(i+1);for(let e=0;e<i;e++){const n=e+t,r=n+i+1,s=n+i+2,a=n+1;o.push(n,r,a),o.push(r,s,a)}}this.setIndex(o),this.setAttribute("position",new QS(a,3)),this.setAttribute("normal",new QS(l,3)),this.setAttribute("uv",new QS(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $I(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ZI extends hE{constructor(e=new hI([new iT(0,.5),new iT(-.5,-.5),new iT(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],s=[];let o=0,a=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(o,a,t),o+=a,a=0;function l(e){const o=n.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===zI.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===zI.isClockWise(t)&&(u[e]=t.reverse())}const h=zI.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){c=c.concat(u[e])}for(let e=0,t=c.length;e<t;e++){const t=c[e];n.push(t.x,t.y,0),r.push(0,0,1),s.push(t.x,t.y)}for(let e=0,t=h.length;e<t;e++){const t=h[e];i.push(t[0]+o,t[1]+o,t[2]+o),a+=3}}this.setIndex(i),this.setAttribute("position",new QS(n,3)),this.setAttribute("normal",new QS(r,3)),this.setAttribute("uv",new QS(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){t.shapes.push(e[i].uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){i.push(t[e.shapes[n]])}return new ZI(i,e.curveSegments)}}class YI extends hE{constructor(e=1,t=32,i=16,n=0,r=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const a=Math.min(s+o,Math.PI);let l=0;const c=[],u=new rT,h=new rT,d=[],p=[],f=[],m=[];for(let d=0;d<=i;d++){const g=[],_=d/i;let y=0;0===d&&0===s?y=.5/t:d===i&&a===Math.PI&&(y=-.5/t);for(let i=0;i<=t;i++){const a=i/t;u.x=-e*Math.cos(n+a*r)*Math.sin(s+_*o),u.y=e*Math.cos(s+_*o),u.z=e*Math.sin(n+a*r)*Math.sin(s+_*o),p.push(u.x,u.y,u.z),h.copy(u).normalize(),f.push(h.x,h.y,h.z),m.push(a+y,1-_),g.push(l++)}c.push(g)}for(let e=0;e<i;e++)for(let n=0;n<t;n++){const t=c[e][n],r=c[e+1][n],o=c[e+1][n+1];(0!==e||s>0)&&d.push(c[e][n+1],t,o),(e!==i-1||a<Math.PI)&&d.push(t,r,o)}this.setIndex(d),this.setAttribute("position",new QS(p,3)),this.setAttribute("normal",new QS(f,3)),this.setAttribute("uv",new QS(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new YI(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class JI extends FM{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new JI(e.radius,e.detail)}}class KI extends hE{constructor(e=1,t=.4,i=12,n=48,r=2*Math.PI,s=0,o=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r,thetaStart:s,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const a=[],l=[],c=[],u=[],h=new rT,d=new rT,p=new rT;for(let a=0;a<=i;a++){const f=s+a/i*o;for(let s=0;s<=n;s++){const o=s/n*r;d.x=(e+t*Math.cos(f))*Math.cos(o),d.y=(e+t*Math.cos(f))*Math.sin(o),d.z=t*Math.sin(f),l.push(d.x,d.y,d.z),h.x=e*Math.cos(o),h.y=e*Math.sin(o),p.subVectors(d,h).normalize(),c.push(p.x,p.y,p.z),u.push(s/n),u.push(a/i)}}for(let e=1;e<=i;e++)for(let t=1;t<=n;t++){const i=(n+1)*(e-1)+t-1,r=(n+1)*(e-1)+t,s=(n+1)*e+t;a.push((n+1)*e+t-1,i,s),a.push(i,r,s)}this.setIndex(a),this.setAttribute("position",new QS(l,3)),this.setAttribute("normal",new QS(c,3)),this.setAttribute("uv",new QS(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new KI(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class QI extends hE{constructor(e=1,t=.4,i=64,n=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:s},i=Math.floor(i),n=Math.floor(n);const o=[],a=[],l=[],c=[],u=new rT,h=new rT,d=new rT,p=new rT,f=new rT,m=new rT,g=new rT;for(let o=0;o<=i;++o){const y=o/i*r*Math.PI*2;_(y,r,s,e,d),_(y+.01,r,s,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=n;++e){const r=e/n*Math.PI*2,s=-t*Math.cos(r),p=t*Math.sin(r);u.x=d.x+(s*g.x+p*f.x),u.y=d.y+(s*g.y+p*f.y),u.z=d.z+(s*g.z+p*f.z),a.push(u.x,u.y,u.z),h.subVectors(u,d).normalize(),l.push(h.x,h.y,h.z),c.push(o/i),c.push(e/n)}}for(let e=1;e<=i;e++)for(let t=1;t<=n;t++){const i=(n+1)*e+(t-1),r=(n+1)*e+t,s=(n+1)*(e-1)+t;o.push((n+1)*(e-1)+(t-1),i,s),o.push(i,r,s)}function _(e,t,i,n,r){const s=Math.cos(e),o=Math.sin(e),a=i/t*e,l=Math.cos(a);r.x=n*(2+l)*.5*s,r.y=n*(2+l)*o*.5,r.z=n*Math.sin(a)*.5}this.setIndex(o),this.setAttribute("position",new QS(a,3)),this.setAttribute("normal",new QS(l,3)),this.setAttribute("uv",new QS(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new QI(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class eC extends hE{constructor(e=new oI(new rT(-1,-1,0),new rT(-1,1,0),new rT(1,1,0)),t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};const s=e.computeFrenetFrames(t,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const o=new rT,a=new rT,l=new iT;let c=new rT;const u=[],h=[],d=[],p=[];function f(r){c=e.getPointAt(r/t,c);const l=s.normals[r],d=s.binormals[r];for(let e=0;e<=n;e++){const t=e/n*Math.PI*2,r=Math.sin(t),s=-Math.cos(t);a.x=s*l.x+r*d.x,a.y=s*l.y+r*d.y,a.z=s*l.z+r*d.z,a.normalize(),h.push(a.x,a.y,a.z),o.x=c.x+i*a.x,o.y=c.y+i*a.y,o.z=c.z+i*a.z,u.push(o.x,o.y,o.z)}}!function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let i=0;i<=n;i++)l.x=e/t,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=n;t++){const i=(n+1)*e+(t-1),r=(n+1)*e+t,s=(n+1)*(e-1)+t;p.push((n+1)*(e-1)+(t-1),i,s),p.push(i,r,s)}}()}(),this.setIndex(p),this.setAttribute("position",new QS(u,3)),this.setAttribute("normal",new QS(h,3)),this.setAttribute("uv",new QS(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new eC((new lI[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class tC extends hE{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],i=new Set,n=new rT,r=new rT;if(null!==e.index){const s=e.attributes.position,o=e.index;let a=e.groups;0===a.length&&(a=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,l=a.length;e<l;++e){const l=a[e],c=l.start;for(let e=c,a=c+l.count;e<a;e+=3)for(let a=0;a<3;a++){const l=o.getX(e+a),c=o.getX(e+(a+1)%3);n.fromBufferAttribute(s,l),r.fromBufferAttribute(s,c),!0===iC(n,r,i)&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}}else{const s=e.attributes.position;for(let e=0,o=s.count/3;e<o;e++)for(let o=0;o<3;o++){const a=3*e+(o+1)%3;n.fromBufferAttribute(s,3*e+o),r.fromBufferAttribute(s,a),!0===iC(n,r,i)&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new QS(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function iC(e,t,i){const n=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==i.has(n)&&!0!==i.has(r)&&(i.add(n),i.add(r),!0)}var nC=Object.freeze({__proto__:null,BoxGeometry:LM,CapsuleGeometry:RM,CircleGeometry:OM,ConeGeometry:BM,CylinderGeometry:DM,DodecahedronGeometry:NM,EdgesGeometry:jM,ExtrudeGeometry:jI,IcosahedronGeometry:HI,LatheGeometry:WI,OctahedronGeometry:qI,PlaneGeometry:XI,PolyhedronGeometry:FM,RingGeometry:$I,ShapeGeometry:ZI,SphereGeometry:YI,TetrahedronGeometry:JI,TorusGeometry:KI,TorusKnotGeometry:QI,TubeGeometry:eC,WireframeGeometry:tC});class rC extends _E{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new cS(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}function sC(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Uw("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[i][n]=null):t[i][n]=r.clone():t[i][n]=Array.isArray(r)?r.slice():r}}return t}function oC(e){const t={};for(let i=0;i<e.length;i++){const n=sC(e[i]);for(const e in n)t[e]=n[e]}return t}function aC(e){const t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:dT.workingColorSpace}const lC={clone:sC,merge:oC};class cC extends _E{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=sC(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;t.uniforms[i]=n&&n.isTexture?{type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?{type:"c",value:n.getHex()}:n&&n.isVector2?{type:"v2",value:n.toArray()}:n&&n.isVector3?{type:"v3",value:n.toArray()}:n&&n.isVector4?{type:"v4",value:n.toArray()}:n&&n.isMatrix3?{type:"m3",value:n.toArray()}:n&&n.isMatrix4?{type:"m4",value:n.toArray()}:{value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class uC extends cC{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class hC extends _E{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new cS(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cS(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kT,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dC extends hC{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new iT(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Yw(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new cS(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new cS(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new cS(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class pC extends _E{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cS(16777215),this.specular=new cS(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cS(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kT,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class fC extends _E{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cS(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cS(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class mC extends _E{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class gC extends _E{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cS(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cS(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kT,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class _C extends _E{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class yC extends _E{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class vC extends _E{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cS(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new iT(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xC extends rM{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function bC(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function wC(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort(function(t,i){return e[t]-e[i]}),i}function TC(e,t,i){const n=e.length,r=new e.constructor(n);for(let s=0,o=0;o!==n;++s){const n=i[s]*t;for(let i=0;i!==t;++i)r[o++]=e[n+i]}return r}function SC(e,t,i,n){let r=1,s=e[0];for(;void 0!==s&&void 0===s[n];)s=e[r++];if(void 0===s)return;let o=s[n];if(void 0!==o)if(Array.isArray(o))do{o=s[n],void 0!==o&&(t.push(s.time),i.push(...o)),s=e[r++]}while(void 0!==s);else if(void 0!==o.toArray)do{o=s[n],void 0!==o&&(t.push(s.time),o.toArray(i,i.length)),s=e[r++]}while(void 0!==s);else do{o=s[n],void 0!==o&&(t.push(s.time),i.push(o)),s=e[r++]}while(void 0!==s)}class EC{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let s;i:{n:if(!(e<n)){for(let s=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===s)break;if(r=n,n=t[++i],e<n)break t}s=t.length;break i}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(i===s)break;if(n=r,r=t[--i-1],e>=r)break t}s=i,i=0;break i}break e}for(;i<s;){const n=i+s>>>1;e<t[n]?s=n:i=n+1}if(n=t[i],r=t[i-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let e=0;e!==n;++e)t[e]=i[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class AC extends EC{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:lw,endingEnd:lw}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,s=e+1,o=n[r],a=n[s];if(void 0===o)switch(this.getSettings_().endingStart){case cw:r=e,o=2*t-i;break;case uw:r=n.length-2,o=t+n[r]-n[r+1];break;default:r=e,o=i}if(void 0===a)switch(this.getSettings_().endingEnd){case cw:s=e,a=2*i-t;break;case uw:s=1,a=i+n[1]-n[0];break;default:s=e-1,a=t}const l=.5*(i-t),c=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(a-i),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,l=a-o,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(i-t)/(n-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,_=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,v=d*m-d*f;for(let e=0;e!==o;++e)r[e]=g*s[c+e]+_*s[l+e]+y*s[a+e]+v*s[u+e];return r}}class MC extends EC{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,l=a-o,c=(i-t)/(n-t),u=1-c;for(let e=0;e!==o;++e)r[e]=s[l+e]*u+s[a+e]*c;return r}}class IC extends EC{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class CC extends EC{interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,l=a-o,c=this.settings||this.DefaultSettings_,u=c.inTangents,h=c.outTangents;if(!u||!h){const e=(i-t)/(n-t),c=1-e;for(let t=0;t!==o;++t)r[t]=s[l+t]*c+s[a+t]*e;return r}const d=2*o,p=e-1;for(let c=0;c!==o;++c){const o=s[l+c],f=s[a+c],m=p*d+2*c,g=h[m],_=h[m+1],y=e*d+2*c,v=u[y],x=u[y+1];let b,w,T,S,E,A=(i-t)/(n-t);for(let e=0;e<8;e++){b=A*A,w=b*A,T=1-A,S=T*T,E=S*T;const e=E*t+3*S*A*g+3*T*b*v+w*n-i;if(Math.abs(e)<1e-10)break;const r=3*S*(g-t)+6*T*A*(v-g)+3*b*(n-v);if(Math.abs(r)<1e-10)break;A-=e/r,A=Math.max(0,Math.min(1,A))}r[c]=E*o+3*S*A*_+3*T*b*x+w*f}return r}}class PC{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=bC(t,this.TimeBufferType),this.values=bC(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:bC(e.times,Array),values:bC(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(i.interpolation=t)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new IC(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new MC(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new AC(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new CC(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case rw:t=this.InterpolantFactoryMethodDiscrete;break;case sw:t=this.InterpolantFactoryMethodLinear;break;case ow:t=this.InterpolantFactoryMethodSmooth;break;case aw:t=this.InterpolantFactoryMethodBezier}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return Uw("KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return rw;case this.InterpolantFactoryMethodLinear:return sw;case this.InterpolantFactoryMethodSmooth:return ow;case this.InterpolantFactoryMethodBezier:return aw}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==s&&i[s]>t;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=i.slice(r,s),this.values=this.values.slice(r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Vw("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(Vw("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){Vw("KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==s&&s>n){Vw("KeyframeTrack: Out of order keys.",this,t,n,s),e=!1;break}s=n}if(void 0!==n&&Ow(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){Vw("KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===ow,r=e.length-1;let s=1;for(let o=1;o<r;++o){let r=!1;const a=e[o];if(a!==e[o+1]&&(1!==o||a!==e[0]))if(n)r=!0;else{const e=o*i,n=e-i,s=e+i;for(let o=0;o!==i;++o){const i=t[e+o];if(i!==t[n+o]||i!==t[s+o]){r=!0;break}}}if(r){if(o!==s){e[s]=e[o];const n=o*i,r=s*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++s}}if(r>0){e[s]=e[r];for(let e=r*i,n=s*i,o=0;o!==i;++o)t[n+o]=t[e+o];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}PC.prototype.ValueTypeName="",PC.prototype.TimeBufferType=Float32Array,PC.prototype.ValueBufferType=Float32Array,PC.prototype.DefaultInterpolation=sw;class LC extends PC{constructor(e,t,i){super(e,t,i)}}LC.prototype.ValueTypeName="bool",LC.prototype.ValueBufferType=Array,LC.prototype.DefaultInterpolation=rw,LC.prototype.InterpolantFactoryMethodLinear=void 0,LC.prototype.InterpolantFactoryMethodSmooth=void 0;class RC extends PC{constructor(e,t,i,n){super(e,t,i,n)}}RC.prototype.ValueTypeName="color";class OC extends PC{constructor(e,t,i,n){super(e,t,i,n)}}OC.prototype.ValueTypeName="number";class DC extends EC{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(i-t)/(n-t);let l=e*o;for(let e=l+o;l!==e;l+=4)nT.slerpFlat(r,0,s,l-o,s,l,a);return r}}class BC extends PC{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new DC(this.times,this.values,this.getValueSize(),e)}}BC.prototype.ValueTypeName="quaternion",BC.prototype.InterpolantFactoryMethodSmooth=void 0;class FC extends PC{constructor(e,t,i){super(e,t,i)}}FC.prototype.ValueTypeName="string",FC.prototype.ValueBufferType=Array,FC.prototype.DefaultInterpolation=rw,FC.prototype.InterpolantFactoryMethodLinear=void 0,FC.prototype.InterpolantFactoryMethodSmooth=void 0;class NC extends PC{constructor(e,t,i,n){super(e,t,i,n)}}NC.prototype.ValueTypeName="vector";class kC{constructor(e="",t=-1,i=[],n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Zw(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(zC(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,n=i.length;e!==n;++e)t.push(PC.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,s=[];for(let e=0;e<r;e++){let o=[],a=[];o.push((e+r-1)%r,e,(e+1)%r),a.push(0,1,0);const l=wC(o);o=TC(o,1,l),a=TC(a,1,l),n||0!==o[0]||(o.push(r),a.push(a[0])),s.push(new OC(".morphTargetInfluences["+t[e].name+"]",o,a).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){i=e.geometry&&e.geometry.animations||e.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){const i=e[t],s=i.name.match(r);if(s&&s.length>1){const e=s[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const s=[];for(const e in n)s.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return s}static parseAnimation(e,t){if(Uw("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Vw("AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,i,n,r){if(0!==i.length){const s=[],o=[];SC(i,s,o,n),0!==s.length&&r.push(new e(t,s,o))}},n=[],r=e.name||"default",s=e.fps||30,o=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let i=0;i<r[t].morphTargets.length;i++)e[r[t].morphTargets[i]]=-1;for(const i in e){const e=[],s=[];for(let n=0;n!==r[t].morphTargets.length;++n){const n=r[t];e.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new OC(".morphTargetInfluence["+i+"]",e,s))}a=e.length*s}else{const s=".bones["+t[e].name+"]";i(NC,s+".position",r,"pos",n),i(BC,s+".quaternion",r,"rot",n),i(NC,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,a,n,o)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){const i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function zC(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return OC;case"vector":case"vector2":case"vector3":case"vector4":return NC;case"color":return RC;case"quaternion":return BC;case"bool":case"boolean":return LC;case"string":return FC}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],i=[];SC(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const UC={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(VC(e)||(this.files[e]=t))},get:function(e){if(!1!==this.enabled&&!VC(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function VC(e){try{const t=e.slice(e.indexOf(":")+1);return"blob:"===new URL(t).protocol}catch(e){return!1}}class jC{constructor(e,t,i){const n=this;let r,s=!1,o=0,a=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(e){a++,!1===s&&void 0!==n.onStart&&n.onStart(e,o,a),s=!0},this.itemEnd=function(e){o++,void 0!==n.onProgress&&n.onProgress(e,o,a),o===a&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=l.length;t<i;t+=2){const i=l[t],n=l[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const GC=new jC;class HC{constructor(e){this.manager=void 0!==e?e:GC,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}HC.DEFAULT_MATERIAL_NAME="__DEFAULT";const WC={};class qC extends Error{constructor(e,t){super(e),this.response=t}}class XC extends HC{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=UC.get(`file:${e}`);if(void 0!==r)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(void 0!==WC[e])return void WC[e].push({onLoad:t,onProgress:i,onError:n});WC[e]=[],WC[e].push({onLoad:t,onProgress:i,onError:n});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&Uw("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const i=WC[e],n=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),s=r?parseInt(r):0,o=0!==s;let a=0;const l=new ReadableStream({start(e){!function t(){n.read().then(({done:n,value:r})=>{if(n)e.close();else{a+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:o,loaded:a,total:s});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(n)}e.enqueue(r),t()}},t=>{e.error(t)})}()}});return new Response(l)}throw new qC(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>(new DOMParser).parseFromString(e,o));case"json":return e.json();default:if(""===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),i=t&&t[1]?t[1].toLowerCase():void 0,n=new TextDecoder(i);return e.arrayBuffer().then(e=>n.decode(e))}}}).then(t=>{UC.add(`file:${e}`,t);const i=WC[e];delete WC[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onLoad&&n.onLoad(t)}}).catch(t=>{const i=WC[e];if(void 0===i)throw this.manager.itemError(e),t;delete WC[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const $C=new WeakMap;class ZC extends HC{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=UC.get(`image:${e}`);if(void 0!==s){if(!0===s.complete)r.manager.itemStart(e),setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0);else{let e=$C.get(s);void 0===e&&(e=[],$C.set(s,e)),e.push({onLoad:t,onError:n})}return s}const o=Dw("img");function a(){c(),t&&t(this);const i=$C.get(this)||[];for(let e=0;e<i.length;e++){const t=i[e];t.onLoad&&t.onLoad(this)}$C.delete(this),r.manager.itemEnd(e)}function l(t){c(),n&&n(t),UC.remove(`image:${e}`);const i=$C.get(this)||[];for(let e=0;e<i.length;e++){const n=i[e];n.onError&&n.onError(t)}$C.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){o.removeEventListener("load",a,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",a,!1),o.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),UC.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class YC extends HC{constructor(e){super(e)}load(e,t,i,n){const r=new wT,s=new ZC(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)},i,n),r}}class JC extends tS{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new cS(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class KC extends JC{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(tS.DEFAULT_UP),this.updateMatrix(),this.groundColor=new cS(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const QC=new IT,eP=new rT,tP=new rT;class iP{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new iT(512,512),this.mapType=Qx,this.map=null,this.mapPass=null,this.matrix=new IT,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new BA,this._frameExtents=new iT(1,1),this._viewportCount=1,this._viewports=[new TT(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;eP.setFromMatrixPosition(e.matrixWorld),t.position.copy(eP),tP.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tP),t.updateMatrixWorld(),QC.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(QC,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Pw||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(QC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const nP=new rT,rP=new nT,sP=new rT;class oP extends tS{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new IT,this.projectionMatrix=new IT,this.projectionMatrixInverse=new IT,this.coordinateSystem=Cw,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(nP,rP,sP),1===sP.x&&1===sP.y&&1===sP.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(nP,rP,sP.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(nP,rP,sP),1===sP.x&&1===sP.y&&1===sP.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(nP,rP,sP.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const aP=new rT,lP=new iT,cP=new iT;class uP extends oP{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*$w*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Xw*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*$w*Math.atan(Math.tan(.5*Xw*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){aP.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(aP.x,aP.y).multiplyScalar(-e/aP.z),aP.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(aP.x,aP.y).multiplyScalar(-e/aP.z)}getViewSize(e,t){return this.getViewBounds(e,lP,cP),t.subVectors(cP,lP)}setViewOffset(e,t,i,n,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Xw*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,o=s.fullHeight;r+=s.offsetX*n/e,t-=s.offsetY*i/o,n*=s.width/e,i*=s.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class hP extends iP{constructor(){super(new uP(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=2*$w*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class dP extends JC{constructor(e,t,i=0,n=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(tS.DEFAULT_UP),this.updateMatrix(),this.target=new tS,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new hP}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class pP extends iP{constructor(){super(new uP(90,1,.5,500)),this.isPointLightShadow=!0}}class fP extends JC{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new pP}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class mP extends oP{constructor(e=-1,t=1,i=1,n=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,s=i+e,o=n+t,a=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,o-=t*this.view.offsetY,a=o-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class gP extends iP{constructor(){super(new mP(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class _P extends JC{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(tS.DEFAULT_UP),this.updateMatrix(),this.target=new tS,this.shadow=new gP}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class yP extends JC{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class vP extends JC{constructor(e,t,i=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class xP{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new rT)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*n),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],i*n*1.092548),t.addScaledVector(s[5],n*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],i*r*1.092548),t.addScaledVector(s[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*n),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*i),t.addScaledVector(s[4],.858086*i*n),t.addScaledVector(s[5],.858086*n*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*i*r),t.addScaledVector(s[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}class bP extends JC{constructor(e=new xP,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class wP extends HC{constructor(e){super(e),this.textures={}}load(e,t,i,n){const r=this,s=new XC(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):Vw(t),r.manager.itemError(e)}},i,n)}parse(e){const t=this.textures;function i(e){return void 0===t[e]&&Uw("MaterialLoader: Undefined texture",e),t[e]}const n=this.createMaterialFromType(e.type);if(void 0!==e.uuid&&(n.uuid=e.uuid),void 0!==e.name&&(n.name=e.name),void 0!==e.color&&void 0!==n.color&&n.color.setHex(e.color),void 0!==e.roughness&&(n.roughness=e.roughness),void 0!==e.metalness&&(n.metalness=e.metalness),void 0!==e.sheen&&(n.sheen=e.sheen),void 0!==e.sheenColor&&(n.sheenColor=(new cS).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(n.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==n.emissive&&n.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==n.specular&&n.specular.setHex(e.specular),void 0!==e.specularIntensity&&(n.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(n.shininess=e.shininess),void 0!==e.clearcoat&&(n.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(n.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(n.dispersion=e.dispersion),void 0!==e.iridescence&&(n.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(n.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(n.transmission=e.transmission),void 0!==e.thickness&&(n.thickness=e.thickness),void 0!==e.attenuationDistance&&(n.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(n.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(n.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(n.fog=e.fog),void 0!==e.flatShading&&(n.flatShading=e.flatShading),void 0!==e.blending&&(n.blending=e.blending),void 0!==e.combine&&(n.combine=e.combine),void 0!==e.side&&(n.side=e.side),void 0!==e.shadowSide&&(n.shadowSide=e.shadowSide),void 0!==e.opacity&&(n.opacity=e.opacity),void 0!==e.transparent&&(n.transparent=e.transparent),void 0!==e.alphaTest&&(n.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(n.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(n.depthFunc=e.depthFunc),void 0!==e.depthTest&&(n.depthTest=e.depthTest),void 0!==e.depthWrite&&(n.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(n.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(n.blendSrc=e.blendSrc),void 0!==e.blendDst&&(n.blendDst=e.blendDst),void 0!==e.blendEquation&&(n.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(n.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(n.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(n.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==n.blendColor&&n.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(n.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(n.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(n.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(n.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(n.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(n.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(n.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(n.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(n.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(n.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(n.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(n.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(n.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(n.rotation=e.rotation),void 0!==e.linewidth&&(n.linewidth=e.linewidth),void 0!==e.dashSize&&(n.dashSize=e.dashSize),void 0!==e.gapSize&&(n.gapSize=e.gapSize),void 0!==e.scale&&(n.scale=e.scale),void 0!==e.polygonOffset&&(n.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(n.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(n.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(n.dithering=e.dithering),void 0!==e.alphaToCoverage&&(n.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(n.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(n.forceSinglePass=e.forceSinglePass),void 0!==e.allowOverride&&(n.allowOverride=e.allowOverride),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.toneMapped&&(n.toneMapped=e.toneMapped),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.vertexColors&&(n.vertexColors="number"==typeof e.vertexColors?e.vertexColors>0:e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(n.uniforms[t]={},r.type){case"t":n.uniforms[t].value=i(r.value);break;case"c":n.uniforms[t].value=(new cS).setHex(r.value);break;case"v2":n.uniforms[t].value=(new iT).fromArray(r.value);break;case"v3":n.uniforms[t].value=(new rT).fromArray(r.value);break;case"v4":n.uniforms[t].value=(new TT).fromArray(r.value);break;case"m3":n.uniforms[t].value=(new aT).fromArray(r.value);break;case"m4":n.uniforms[t].value=(new IT).fromArray(r.value);break;default:n.uniforms[t].value=r.value}}if(void 0!==e.defines&&(n.defines=e.defines),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(n.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)n.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(n.lights=e.lights),void 0!==e.clipping&&(n.clipping=e.clipping),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=i(e.map)),void 0!==e.matcap&&(n.matcap=i(e.matcap)),void 0!==e.alphaMap&&(n.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(n.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(n.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),n.normalScale=(new iT).fromArray(t)}return void 0!==e.displacementMap&&(n.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=i(e.specularMap)),void 0!==e.specularIntensityMap&&(n.specularIntensityMap=i(e.specularIntensityMap)),void 0!==e.specularColorMap&&(n.specularColorMap=i(e.specularColorMap)),void 0!==e.envMap&&(n.envMap=i(e.envMap)),void 0!==e.envMapRotation&&n.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(n.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(n.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(n.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(n.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(n.clearcoatNormalScale=(new iT).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(n.iridescenceMap=i(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(n.transmissionMap=i(e.transmissionMap)),void 0!==e.thicknessMap&&(n.thicknessMap=i(e.thicknessMap)),void 0!==e.anisotropyMap&&(n.anisotropyMap=i(e.anisotropyMap)),void 0!==e.sheenColorMap&&(n.sheenColorMap=i(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return wP.createMaterialFromType(e)}static createMaterialFromType(e){return new{ShadowMaterial:rC,SpriteMaterial:yE,RawShaderMaterial:uC,ShaderMaterial:cC,PointsMaterial:yM,MeshPhysicalMaterial:dC,MeshStandardMaterial:hC,MeshPhongMaterial:pC,MeshToonMaterial:fC,MeshNormalMaterial:mC,MeshLambertMaterial:gC,MeshDepthMaterial:_C,MeshDistanceMaterial:yC,MeshBasicMaterial:HE,MeshMatcapMaterial:vC,LineDashedMaterial:xC,LineBasicMaterial:rM,Material:_E}[e]}}class TP{static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class SP extends hE{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class EP extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new XC(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):Vw(t),r.manager.itemError(e)}},i,n)}parse(e){const t={},i={};function n(e,n){if(void 0!==t[n])return t[n];const r=e.interleavedBuffers[n],s=function(e,t){if(void 0!==i[t])return i[t];const n=e.arrayBuffers,r=n[t],s=new Uint32Array(r).buffer;return i[t]=s,s}(e,r.buffer),o=Rw(r.type,s),a=new dE(o,r.stride);return a.uuid=r.uuid,t[n]=a,a}const r=e.isInstancedBufferGeometry?new SP:new hE,s=e.data.index;if(void 0!==s){const e=Rw(s.type,s.array);r.setIndex(new YS(e,1))}const o=e.data.attributes;for(const t in o){const i=o[t];let s;if(i.isInterleavedBufferAttribute){const t=n(e.data,i.data);s=new fE(t,i.itemSize,i.offset,i.normalized)}else{const e=Rw(i.type,i.array);s=new(i.isInstancedBufferAttribute?vA:YS)(e,i.itemSize,i.normalized)}void 0!==i.name&&(s.name=i.name),void 0!==i.usage&&s.setUsage(i.usage),r.setAttribute(t,s)}const a=e.data.morphAttributes;if(a)for(const t in a){const i=a[t],s=[];for(let t=0,r=i.length;t<r;t++){const r=i[t];let o;if(r.isInterleavedBufferAttribute){const t=n(e.data,r.data);o=new fE(t,r.itemSize,r.offset,r.normalized)}else{const e=Rw(r.type,r.array);o=new YS(e,r.itemSize,r.normalized)}void 0!==r.name&&(o.name=r.name),s.push(o)}r.morphAttributes[t]=s}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];r.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;return void 0!==c&&(r.boundingSphere=(new nE).fromJSON(c)),e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}const AP={UVMapping:kx,CubeReflectionMapping:zx,CubeRefractionMapping:Ux,EquirectangularReflectionMapping:Vx,EquirectangularRefractionMapping:jx,CubeUVReflectionMapping:Gx},MP={RepeatWrapping:Hx,ClampToEdgeWrapping:Wx,MirroredRepeatWrapping:qx},IP={NearestFilter:Xx,NearestMipmapNearestFilter:$x,NearestMipmapLinearFilter:Zx,LinearFilter:Yx,LinearMipmapNearestFilter:Jx,LinearMipmapLinearFilter:Kx},CP=new WeakMap;class PP extends HC{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&Uw("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&Uw("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=UC.get(`image-bitmap:${e}`);if(void 0!==s)return r.manager.itemStart(e),s.then?void s.then(i=>{if(!0!==CP.has(s))return t&&t(i),r.manager.itemEnd(e),i;n&&n(CP.get(s)),r.manager.itemError(e),r.manager.itemEnd(e)}):(setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0),s);const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader,o.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const a=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){return UC.add(`image-bitmap:${e}`,i),t&&t(i),r.manager.itemEnd(e),i}).catch(function(t){n&&n(t),CP.set(a,t),UC.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});UC.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let LP;class RP{static getContext(){return void 0===LP&&(LP=new(window.AudioContext||window.webkitAudioContext)),LP}static setContext(e){LP=e}}const OP=new IT,DP=new IT,BP=new IT;const FP=-90;class NP extends tS{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new uP(FP,1,e,t);n.layers=this.layers,this.add(n);const r=new uP(FP,1,e,t);r.layers=this.layers,this.add(r);const s=new uP(FP,1,e,t);s.layers=this.layers,this.add(s);const o=new uP(FP,1,e,t);o.layers=this.layers,this.add(o);const a=new uP(FP,1,e,t);a.layers=this.layers,this.add(a);const l=new uP(FP,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,s,o,a]=t;for(const e of t)this.remove(e);if(e===Cw)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else{if(e!==Pw)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,s,o,a,l,c]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;m=!0===e.isWebGLRenderer?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(i,0,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,4,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=f,e.setRenderTarget(i,5,n),m&&!1===e.autoClear&&e.clearDepth(),e.render(t,c),e.setRenderTarget(u,h,d),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class kP extends uP{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class zP{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,void 0!==e.hidden&&(this._pageVisibilityHandler=UP.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==e?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function UP(){!1===this._document.hidden&&this.reset()}const VP=new rT,jP=new nT,GP=new rT,HP=new rT,WP=new rT;class qP extends tS{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void Uw("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void Uw("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;Uw("Audio: this Audio has no playback control.")}stop(e=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this;Uw("Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;Uw("Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(Uw("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;Uw("Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),"buffer"!==e.sourceType?(Uw("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const XP=new rT,$P=new nT,ZP=new rT,YP=new rT;class JP{constructor(e,t,i){let n,r,s;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==n;++e)i[r+e]=i[e];s=t}else{s+=t;this._mixBufferRegion(i,r,0,t/s,n)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){this._mixBufferRegion(i,n,t*this._origIndex,1-r,t)}s>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){o.setValue(i,n);break}}saveOriginalState(){const e=this.buffer,t=this.valueSize,i=t*this._origIndex;this.binding.getValue(e,i);for(let n=t,r=i;n!==r;++n)e[n]=e[i+n%t];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){this.binding.setValue(this.buffer,3*this.valueSize)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){nT.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const s=this._workIndex*r;nT.multiplyQuaternionsFlat(e,s,e,t,e,i),nT.slerpFlat(e,t,e,t,e,s,n)}_lerp(e,t,i,n,r){const s=1-n;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*s+e[i+o]*n}}_lerpAdditive(e,t,i,n,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[i+s]*n}}}const KP="\\[\\]\\.:\\/",QP=new RegExp("["+KP+"]","g"),eL="[^"+KP+"]",tL="[^"+KP.replace("\\.","")+"]",iL=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",eL)+/(WCOD+)?/.source.replace("WCOD",tL)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eL)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eL)+"$"),nL=["material","materials","bones","map"];class rL{constructor(e,t,i){this.path=t,this.parsedPath=i||rL.parseTrackName(t),this.node=rL.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new rL.Composite(e,t,i):new rL(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(QP,"")}static parseTrackName(e){const t=iL.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==nL.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const i=function(e){for(let n=0;n<e.length;n++){const r=e[n];if(r.name===t||r.uuid===t)return r;const s=i(r.children);if(s)return s}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=rL.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void Uw("PropertyBinding: No target node found for track: "+this.path+".");if(i){let n=t.objectIndex;switch(i){case"materials":if(!e.material)return void Vw("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void Vw("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void Vw("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===n){n=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void Vw("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void Vw("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[i])return void Vw("PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void Vw("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}const s=e[n];if(void 0===s){return void Vw("PropertyBinding: Trying to update property for track: "+t.nodeName+"."+n+" but it wasn't found.",e)}let o=this.Versioning.None;this.targetObject=e,!0===e.isMaterial?o=this.Versioning.NeedsUpdate:!0===e.isObject3D&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!e.geometry)return void Vw("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void Vw("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}rL.Composite=class{constructor(e,t,i){const n=i||rL.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._bindings[this._targetGroup.nCachedObjects_];void 0!==i&&i.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},rL.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},rL.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},rL.prototype.GetterByBindingType=[rL.prototype._getValue_direct,rL.prototype._getValue_array,rL.prototype._getValue_arrayElement,rL.prototype._getValue_toArray],rL.prototype.SetterByBindingTypeAndVersioning=[[rL.prototype._setValue_direct,rL.prototype._setValue_direct_setNeedsUpdate,rL.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[rL.prototype._setValue_array,rL.prototype._setValue_array_setNeedsUpdate,rL.prototype._setValue_array_setMatrixWorldNeedsUpdate],[rL.prototype._setValue_arrayElement,rL.prototype._setValue_arrayElement_setNeedsUpdate,rL.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[rL.prototype._setValue_fromArray,rL.prototype._setValue_fromArray_setNeedsUpdate,rL.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class sL{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,s=r.length,o=new Array(s),a={endingStart:lw,endingEnd:lw};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);o[e]=t,t.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),!0===i){const i=this._clip.duration,n=e._clip.duration,r=i/n;e.warp(1,n/i,t),this.warp(r,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,s=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,a[1]=r+i,l[0]=e/s,l[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;n<0||0===i?t=0:(this._startTime=null,t=i*n)}t*=this._updateTimeScale(e);const s=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===dw)for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(s),t[i].accumulateAdditive(o);else for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(s),t[i].accumulate(n,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const s=2202===i;if(0===e)return-1===r||!s||1&~r?n:t-n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&!(1&~r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=cw,n.endingEnd=cw):(n.endingStart=e?this.zeroSlopeAtStart?cw:lw:uw,n.endingEnd=t?this.zeroSlopeAtEnd?cw:lw:uw)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=i,this}}const oL=new Float32Array(1);class aL{constructor(e){this.value=e}clone(){return new aL(void 0===this.value.clone?this.value:this.value.clone())}}let lL=0;const cL=new IT;function uL(e,t){return e.distance-t.distance}function hL(e,t,i,n){let r=!0;if(e.layers.test(t.layers)){!1===e.raycast(t,i)&&(r=!1)}if(!0===r&&!0===n){const n=e.children;for(let e=0,r=n.length;e<r;e++)hL(n[e],t,i,!0)}}class dL{constructor(e,t,i,n){dL.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=n,this}}const pL=new iT;const fL=new rT,mL=new rT,gL=new rT,_L=new rT,yL=new rT,vL=new rT,xL=new rT;const bL=new rT;const wL=new rT,TL=new IT,SL=new IT;function EL(e){const t=[];!0===e.isBone&&t.push(e);for(let i=0;i<e.children.length;i++)t.push(...EL(e.children[i]));return t}const AL=new rT,ML=new cS,IL=new cS;const CL=new rT,PL=new rT,LL=new rT;const RL=new rT,OL=new oP;function DL(e,t,i,n,r,s,o){RL.set(r,s,o).unproject(n);const a=t[e];if(void 0!==a){const e=i.getAttribute("position");for(let t=0,i=a.length;t<i;t++)e.setXYZ(a[t],RL.x,RL.y,RL.z)}}const BL=new IS;const FL=new rT;let NL,kL;function zL(e,t,i,n){const r=function(e){switch(e){case Qx:case eb:return{byteLength:1,components:1};case ib:case tb:case ob:return{byteLength:2,components:1};case ab:case lb:return{byteLength:2,components:4};case rb:case nb:case sb:return{byteLength:4,components:1};case ub:case hb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${e}.`)}(n);switch(i){case db:return e*t;case _b:case yb:return e*t/r.components*r.byteLength;case vb:case xb:return e*t*2/r.components*r.byteLength;case pb:return e*t*3/r.components*r.byteLength;case fb:case bb:return e*t*4/r.components*r.byteLength;case wb:case Tb:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Sb:case Eb:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Mb:case Cb:return Math.max(e,16)*Math.max(t,8)/4;case Ab:case Ib:return Math.max(e,8)*Math.max(t,8)/2;case Pb:case Lb:case Ob:case Db:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Rb:case Bb:case Fb:case Nb:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case kb:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case zb:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case Ub:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Vb:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case jb:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Gb:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case Hb:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Wb:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case qb:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case Xb:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case $b:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case Zb:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case Yb:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Jb:case Kb:case Qb:return Math.ceil(e/4)*Math.ceil(t/4)*16;case ew:case tw:return Math.ceil(e/4)*Math.ceil(t/4)*8;case iw:case nw:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${i} format.`)}
/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
function UL(){let e=null,t=!1,i=null,n=null;function r(t,s){i(t,s),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function VL(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=t.get(i);n&&(e.deleteBuffer(n.buffer),t.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const e=t.get(i);return void((!e||e.version<i.version)&&t.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=t.get(i);if(void 0===r)t.set(i,function(t,i){const n=t.array,r=t.usage,s=n.byteLength,o=e.createBuffer();let a;if(e.bindBuffer(i,o),e.bufferData(i,n,r),t.onUploadCallback(),n instanceof Float32Array)a=e.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)a=e.HALF_FLOAT;else if(n instanceof Uint16Array)a=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(n instanceof Int16Array)a=e.SHORT;else if(n instanceof Uint32Array)a=e.UNSIGNED_INT;else if(n instanceof Int32Array)a=e.INT;else if(n instanceof Int8Array)a=e.BYTE;else if(n instanceof Uint8Array)a=e.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);a=e.UNSIGNED_BYTE}return{buffer:o,type:a,bytesPerElement:n.BYTES_PER_ELEMENT,version:t.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,i,n){const r=i.array,s=i.updateRanges;if(e.bindBuffer(n,t),0===s.length)e.bufferSubData(n,0,r);else{s.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<s.length;e++){const i=s[t],n=s[e];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++t,s[t]=n)}s.length=t+1;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$v}})),"undefined"!=typeof window&&(window.__THREE__?Uw("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$v);const jL={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660,  0.0556434,\n\t\t-1.5371385,  1.8760108, -0.2040259,\n\t\t-0.4985314,  0.0415560,  1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n    float x2 = x * x;\n    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3(             0, 1,             0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(  1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,  1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,  1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},HL={common:{diffuse:{value:new cS(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new aT},alphaMap:{value:null},alphaMapTransform:{value:new aT},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new aT}},envmap:{envMap:{value:null},envMapRotation:{value:new aT},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new aT}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new aT}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new aT},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new aT},normalScale:{value:new iT(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new aT},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new aT}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new aT}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new aT}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cS(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new cS(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new aT},alphaTest:{value:0},uvTransform:{value:new aT}},sprite:{diffuse:{value:new cS(16777215)},opacity:{value:1},center:{value:new iT(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new aT},alphaMap:{value:null},alphaMapTransform:{value:new aT},alphaTest:{value:0}}},WL={basic:{uniforms:oC([HL.common,HL.specularmap,HL.envmap,HL.aomap,HL.lightmap,HL.fog]),vertexShader:jL.meshbasic_vert,fragmentShader:jL.meshbasic_frag},lambert:{uniforms:oC([HL.common,HL.specularmap,HL.envmap,HL.aomap,HL.lightmap,HL.emissivemap,HL.bumpmap,HL.normalmap,HL.displacementmap,HL.fog,HL.lights,{emissive:{value:new cS(0)},envMapIntensity:{value:1}}]),vertexShader:jL.meshlambert_vert,fragmentShader:jL.meshlambert_frag},phong:{uniforms:oC([HL.common,HL.specularmap,HL.envmap,HL.aomap,HL.lightmap,HL.emissivemap,HL.bumpmap,HL.normalmap,HL.displacementmap,HL.fog,HL.lights,{emissive:{value:new cS(0)},specular:{value:new cS(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jL.meshphong_vert,fragmentShader:jL.meshphong_frag},standard:{uniforms:oC([HL.common,HL.envmap,HL.aomap,HL.lightmap,HL.emissivemap,HL.bumpmap,HL.normalmap,HL.displacementmap,HL.roughnessmap,HL.metalnessmap,HL.fog,HL.lights,{emissive:{value:new cS(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jL.meshphysical_vert,fragmentShader:jL.meshphysical_frag},toon:{uniforms:oC([HL.common,HL.aomap,HL.lightmap,HL.emissivemap,HL.bumpmap,HL.normalmap,HL.displacementmap,HL.gradientmap,HL.fog,HL.lights,{emissive:{value:new cS(0)}}]),vertexShader:jL.meshtoon_vert,fragmentShader:jL.meshtoon_frag},matcap:{uniforms:oC([HL.common,HL.bumpmap,HL.normalmap,HL.displacementmap,HL.fog,{matcap:{value:null}}]),vertexShader:jL.meshmatcap_vert,fragmentShader:jL.meshmatcap_frag},points:{uniforms:oC([HL.points,HL.fog]),vertexShader:jL.points_vert,fragmentShader:jL.points_frag},dashed:{uniforms:oC([HL.common,HL.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jL.linedashed_vert,fragmentShader:jL.linedashed_frag},depth:{uniforms:oC([HL.common,HL.displacementmap]),vertexShader:jL.depth_vert,fragmentShader:jL.depth_frag},normal:{uniforms:oC([HL.common,HL.bumpmap,HL.normalmap,HL.displacementmap,{opacity:{value:1}}]),vertexShader:jL.meshnormal_vert,fragmentShader:jL.meshnormal_frag},sprite:{uniforms:oC([HL.sprite,HL.fog]),vertexShader:jL.sprite_vert,fragmentShader:jL.sprite_frag},background:{uniforms:{uvTransform:{value:new aT},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jL.background_vert,fragmentShader:jL.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new aT}},vertexShader:jL.backgroundCube_vert,fragmentShader:jL.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jL.cube_vert,fragmentShader:jL.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jL.equirect_vert,fragmentShader:jL.equirect_frag},distance:{uniforms:oC([HL.common,HL.displacementmap,{referencePosition:{value:new rT},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jL.distance_vert,fragmentShader:jL.distance_frag},shadow:{uniforms:oC([HL.lights,HL.fog,{color:{value:new cS(0)},opacity:{value:1}}]),vertexShader:jL.shadow_vert,fragmentShader:jL.shadow_frag}};WL.physical={uniforms:oC([WL.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new aT},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new aT},clearcoatNormalScale:{value:new iT(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new aT},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new aT},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new aT},sheen:{value:0},sheenColor:{value:new cS(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new aT},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new aT},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new aT},transmissionSamplerSize:{value:new iT},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new aT},attenuationDistance:{value:0},attenuationColor:{value:new cS(0)},specularColor:{value:new cS(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new aT},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new aT},anisotropyVector:{value:new iT},anisotropyMap:{value:null},anisotropyMapTransform:{value:new aT}}]),vertexShader:jL.meshphysical_vert,fragmentShader:jL.meshphysical_frag};const qL={r:0,b:0,g:0},XL=new kT,$L=new IT;function ZL(e,t,i,n,r,s){const o=new cS(0);let a,l,c=!0===r?0:1,u=null,h=0,d=null;function p(e){let i=!0===e.isScene?e.background:null;if(i&&i.isTexture){i=t.get(i,e.backgroundBlurriness>0)}return i}function f(t,n){t.getRGB(qL,aC(e)),i.buffers.color.setClear(qL.r,qL.g,qL.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),c=t,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(o,c)},render:function(t){let n=!1;const r=p(t);null===r?f(o,c):r&&r.isColor&&(f(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,i){const r=p(i);r&&(r.isCubeTexture||r.mapping===Gx)?(void 0===l&&(l=new iA(new LM(1,1,1),new cC({name:"BackgroundCubeMaterial",uniforms:sC(WL.backgroundCube.uniforms),vertexShader:WL.backgroundCube.vertexShader,fragmentShader:WL.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),XL.copy(i.backgroundRotation),XL.x*=-1,XL.y*=-1,XL.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(XL.y*=-1,XL.z*=-1),l.material.uniforms.envMap.value=r,l.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4($L.makeRotationFromEuler(XL)),l.material.toneMapped=dT.getTransfer(r.colorSpace)!==_w,u===r&&h===r.version&&d===e.toneMapping||(l.material.needsUpdate=!0,u=r,h=r.version,d=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===a&&(a=new iA(new XI(2,2),new cC({name:"BackgroundMaterial",uniforms:sC(WL.background.uniforms),vertexShader:WL.background.vertexShader,fragmentShader:WL.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=r,a.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,a.material.toneMapped=dT.getTransfer(r.colorSpace)!==_w,!0===r.matrixAutoUpdate&&r.updateMatrix(),a.material.uniforms.uvTransform.value.copy(r.matrix),u===r&&h===r.version&&d===e.toneMapping||(a.material.needsUpdate=!0,u=r,h=r.version,d=e.toneMapping),a.layers.enableAll(),t.unshift(a,a.geometry,a.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==a&&(a.geometry.dispose(),a.material.dispose(),a=void 0)}}}function YL(e,t){const i=e.getParameter(e.MAX_VERTEX_ATTRIBS),n={},r=c(null);let s=r,o=!1;function a(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){const e=s.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function h(e){d(e,0)}function d(t,i){const n=s.enabledAttributes,r=s.attributeDivisors;s.newAttributes[t]=1,0===n[t]&&(e.enableVertexAttribArray(t),n[t]=1),r[t]!==i&&(e.vertexAttribDivisor(t,i),r[t]=i)}function p(){const t=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function f(t,i,n,r,s,o,a){!0===a?e.vertexAttribIPointer(t,i,n,s,o):e.vertexAttribPointer(t,i,n,r,s,o)}function m(){g(),o=!0,s!==r&&(s=r,a(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,l,m,g){let _=!1;const y=function(t,i,r,s){const o=!0===s.wireframe;let a=n[i.id];void 0===a&&(a={},n[i.id]=a);const l=!0===t.isInstancedMesh?t.id:0;let u=a[l];void 0===u&&(u={},a[l]=u);let h=u[r.id];void 0===h&&(h={},u[r.id]=h);let d=h[o];void 0===d&&(d=c(e.createVertexArray()),h[o]=d);return d}(i,m,l,r);s!==y&&(s=y,a(s.object)),_=function(e,t,i,n){const r=s.attributes,o=t.attributes;let a=0;const l=i.getAttributes();for(const t in l){if(l[t].location>=0){const i=r[t];let n=o[t];if(void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;a++}}return s.attributesNum!==a||s.index!==n}(i,m,l,g),_&&function(e,t,i,n){const r={},o=t.attributes;let a=0;const l=i.getAttributes();for(const t in l){if(l[t].location>=0){let i=o[t];void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[t]=n,a++}}s.attributes=r,s.attributesNum=a,s.index=n}(i,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(_||o)&&(o=!1,function(i,n,r,s){u();const o=s.attributes,a=r.getAttributes(),l=n.defaultAttributeValues;for(const n in a){const r=a[n];if(r.location>=0){let a=o[n];if(void 0===a&&("instanceMatrix"===n&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const n=a.normalized,o=a.itemSize,l=t.get(a);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement,m=u===e.INT||u===e.UNSIGNED_INT||a.gpuType===nb;if(a.isInterleavedBufferAttribute){const t=a.data,l=t.stride,g=a.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)d(r.location+e,t.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,o/r.locationSize,u,n,l*p,(g+o/r.locationSize*e)*p,m)}else{if(a.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)d(r.location+e,a.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,o/r.locationSize,u,n,o*p,o/r.locationSize*e*p,m)}}else if(void 0!==l){const t=l[n];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(i,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in n){const t=n[e];for(const e in t){const i=t[e];for(const e in i){const t=i[e];for(const e in t)l(t[e].object),delete t[e];delete i[e]}}delete n[e]}},releaseStatesOfGeometry:function(e){if(void 0===n[e.id])return;const t=n[e.id];for(const e in t){const i=t[e];for(const e in i){const t=i[e];for(const e in t)l(t[e].object),delete t[e];delete i[e]}}delete n[e.id]},releaseStatesOfObject:function(e){for(const t in n){const i=n[t],r=!0===e.isInstancedMesh?e.id:0,s=i[r];if(void 0!==s){for(const e in s){const t=s[e];for(const e in t)l(t[e].object),delete t[e];delete s[e]}delete i[r],0===Object.keys(i).length&&delete n[t]}}},releaseStatesOfProgram:function(e){for(const t in n){const i=n[t];for(const t in i){const n=i[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)l(r[e].object),delete r[e];delete n[e.id]}}},initAttributes:u,enableAttribute:h,disableUnusedAttributes:p}}function JL(e,t,i){let n;function r(t,r,s){0!==s&&(e.drawArraysInstanced(n,t,r,s),i.update(r,n,s))}this.setMode=function(e){n=e},this.render=function(t,r){e.drawArrays(n,t,r),i.update(r,n,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,e,0,r,0,s);let o=0;for(let e=0;e<s;e++)o+=r[e];i.update(o,n,1)},this.renderMultiDrawInstances=function(e,s,o,a){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],s[t],a[t]);else{l.multiDrawArraysInstancedWEBGL(n,e,0,s,0,a,0,o);let t=0;for(let e=0;e<o;e++)t+=s[e]*a[e];i.update(t,n,1)}}}function KL(e,t,i,n){let r;function s(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==i.precision?i.precision:"highp";const a=s(o);a!==o&&(Uw("WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(t){return t===fb||n.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===ob&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(i!==Qx&&n.convert(i)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==sb&&!r)},precision:o,logarithmicDepthBuffer:!0===i.logarithmicDepthBuffer,reversedDepthBuffer:!0===i.reversedDepthBuffer&&t.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function QL(e){const t=this;let i=null,n=0,r=!1,s=!1;const o=new LA,a=new aT,l={value:null,needsUpdate:!1};function c(e,i,n,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=n+4*s,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,i=n;t!==s;++t,i+=4)o.copy(e[t]).applyMatrix4(r,a),o.normal.toArray(c,i),c[i+3]=o.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const i=0!==e.length||t||0!==n||r;return r=t,n=e.length,i},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(e,t){i=c(e,t,0)},this.setState=function(o,a,u){const h=o.clippingPlanes,d=o.clipIntersection,p=o.clipShadows,f=e.get(o);if(!r||null===h||0===h.length||s&&!p)s?c(null):function(){l.value!==i&&(l.value=i,l.needsUpdate=n>0);t.numPlanes=n,t.numIntersection=0}();else{const e=s?0:n,t=4*e;let r=f.clippingState||null;l.value=r,r=c(h,a,t,u);for(let e=0;e!==t;++e)r[e]=i[e];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}const eR=[.125,.215,.35,.446,.526,.582],tR=20,iR=new mP,nR=new cS;let rR=null,sR=0,oR=0,aR=!1;const lR=new rT;class cR{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,r={}){const{size:s=256,position:o=lR}=r;rR=this._renderer.getRenderTarget(),sR=this._renderer.getActiveCubeFace(),oR=this._renderer.getActiveMipmapLevel(),aR=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,n,a,o),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=pR(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=dR(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(rR,sR,oR),this._renderer.xr.enabled=aR,e.scissorTest=!1,hR(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSize(e.mapping===zx||e.mapping===Ux?0===e.image.length?16:e.image[0].width||e.image[0].image.width:e.image.width/4),rR=this._renderer.getRenderTarget(),sR=this._renderer.getActiveCubeFace(),oR=this._renderer.getActiveMipmapLevel(),aR=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Yx,minFilter:Yx,generateMipmaps:!1,type:ob,format:fb,colorSpace:mw,depthBuffer:!1},n=uR(e,t,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=uR(e,t,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){const t=[],i=[],n=[];let r=e;const s=e-4+1+eR.length;for(let o=0;o<s;o++){const s=Math.pow(2,r);t.push(s);let a=1/s;o>e-4?a=eR[o-e+4-1]:0===o&&(a=0),i.push(a);const l=1/(s-2),c=-l,u=1+l,h=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*d),y=new Float32Array(m*p*d),v=new Float32Array(g*p*d);for(let e=0;e<d;e++){const t=e%3*2/3-1,i=e>2?0:-1;_.set([t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0],f*p*e),y.set(h,m*p*e);v.set([e,e,e,e,e,e],g*p*e)}const x=new hE;x.setAttribute("position",new YS(_,f)),x.setAttribute("uv",new YS(y,m)),x.setAttribute("faceIndex",new YS(v,g)),n.push(new iA(x,null)),r>4&&r--}return{lodMeshes:n,sizeLods:t,sigmas:i}}(n)),this._blurMaterial=function(e,t,i){const n=new Float32Array(tR),r=new rT(0,1,0),s=new cC({name:"SphericalGaussianBlur",defines:{n:tR,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:fR(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(n,e,t),this._ggxMaterial=function(e,t,i){const n=new cC({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:fR(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return n}(n,e,t)}return n}_compileMaterial(e){const t=new iA(new hE,e);this._renderer.compile(t,iR)}_sceneToCubeUV(e,t,i,n,r){const s=new uP(90,1,t,i),o=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(nR),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(n),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new iA(new LM,new HE({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const h=this._backgroundBox,d=h.material;let p=!1;const f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(nR),p=!0);for(let t=0;t<6;t++){const i=t%3;0===i?(s.up.set(0,o[t],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+a[t],r.y,r.z)):1===i?(s.up.set(0,0,o[t]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+a[t],r.z)):(s.up.set(0,o[t],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+a[t]));const c=this._cubeSize;hR(n,i*c,t>2?c:0,c,c),l.setRenderTarget(n),p&&l.render(h,s),l.render(e,s)}l.toneMapping=u,l.autoClear=c,e.background=f}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===zx||e.mapping===Ux;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=pR()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=dR());const r=n?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;r.uniforms.envMap.value=e;const o=this._cubeSize;hR(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(s,iR)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let t=1;t<n;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;const a=s.uniforms,l=i/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:h}=this,d=this._sizeLods[i],p=3*d*(i>h-4?i-h+4:0),f=4*(this._cubeSize-d);a.envMap.value=e.texture,a.roughness.value=u,a.mipInt.value=h-t,hR(r,p,f,3*d,2*d),n.setRenderTarget(r),n.render(o,iR),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=h-i,hR(e,p,f,3*d,2*d),n.setRenderTarget(e),n.render(o,iR)}_blur(e,t,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,n,"latitudinal",r),this._halfBlur(s,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,s,o){const a=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&Vw("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[n];c.material=l;const u=l.uniforms,h=this._sizeLods[i]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):tR;f>tR&&Uw(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<tR;++e){const t=e/p,i=Math.exp(-t*t/2);m.push(i),0===e?g+=i:e<f&&(g+=2*i)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===s,o&&(u.poleAxis.value=o);const{_lodMax:_}=this;u.dTheta.value=d,u.mipInt.value=_-i;const y=this._sizeLods[n];hR(t,3*y*(n>_-4?n-_+4:0),4*(this._cubeSize-y),3*y,2*y),a.setRenderTarget(t),a.render(c,iR)}}function uR(e,t,i){const n=new ET(e,t,i);return n.texture.mapping=Gx,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function hR(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function dR(){return new cC({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:fR(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function pR(){return new cC({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fR(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function fR(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}class mR extends ET{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1};this.texture=new MM([i,i,i,i,i,i]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new LM(5,5,5),r=new cC({name:"CubemapFromEquirect",uniforms:sC(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const s=new iA(n,r),o=t.minFilter;t.minFilter===Kx&&(t.minFilter=Yx);return new NP(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}function gR(e){let t=new WeakMap,i=new WeakMap,n=null;function r(e,t){return t===Vx?e.mapping=zx:t===jx&&(e.mapping=Ux),e}function s(e){const i=e.target;i.removeEventListener("dispose",s);const n=t.get(i);void 0!==n&&(t.delete(i),n.dispose())}function o(e){const t=e.target;t.removeEventListener("dispose",o);const n=i.get(t);void 0!==n&&(i.delete(t),n.dispose())}return{get:function(a,l=!1){return null==a?null:l?function(t){if(t&&t.isTexture){const r=t.mapping,s=r===Vx||r===jx,a=r===zx||r===Ux;if(s||a){let r=i.get(t);if(t.isRenderTargetTexture&&t.pmremVersion!==(void 0!==r?r.texture.pmremVersion:0))return null===n&&(n=new cR(e)),r=s?n.fromEquirectangular(t,r):n.fromCubemap(t,r),r.texture.pmremVersion=t.pmremVersion,i.set(t,r),r.texture;if(void 0!==r)return r.texture;{const l=t.image;return s&&l&&l.height>0||a&&l&&function(e){let t=0;const i=6;for(let n=0;n<i;n++)void 0!==e[n]&&t++;return t===i}(l)?(null===n&&(n=new cR(e)),r=s?n.fromEquirectangular(t):n.fromCubemap(t),r.texture.pmremVersion=t.pmremVersion,i.set(t,r),t.addEventListener("dispose",o),r.texture):null}}}return t}(a):function(i){if(i&&i.isTexture){const n=i.mapping;if(n===Vx||n===jx){if(t.has(i)){return r(t.get(i).texture,i.mapping)}{const n=i.image;if(n&&n.height>0){const o=new mR(n.height);return o.fromEquirectangularTexture(e,i),t.set(i,o),i.addEventListener("dispose",s),r(o.texture,i.mapping)}return null}}}return i}(a)},dispose:function(){t=new WeakMap,i=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function _R(e){const t={};function i(i){if(void 0!==t[i])return t[i];const n=e.getExtension(i);return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(e){const t=i(e);return null===t&&jw("WebGLRenderer: "+e+" extension not supported."),t}}}function yR(e,t,i,n){const r={},s=new WeakMap;function o(e){const a=e.target;null!==a.index&&t.remove(a.index);for(const e in a.attributes)t.remove(a.attributes[e]);a.removeEventListener("dispose",o),delete r[a.id];const l=s.get(a);l&&(t.remove(l),s.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(e){const i=[],n=e.index,r=e.attributes.position;let o=0;if(void 0===r)return;if(null!==n){const e=n.array;o=n.version;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+0],r=e[t+1],s=e[t+2];i.push(n,r,r,s,s,n)}}else{o=r.version;for(let e=0,t=r.array.length/3-1;e<t;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const a=new(r.count>=65535?KS:JS)(i,1);a.version=o;const l=s.get(e);l&&t.remove(l),s.set(e,a)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",o),r[t.id]=!0,i.memory.geometries++),t},update:function(i){const n=i.attributes;for(const i in n)t.update(n[i],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=s.get(e);if(t){const i=e.index;null!==i&&t.version<i.version&&a(e)}else a(e);return s.get(e)}}}function vR(e,t,i){let n,r,s;function o(t,o,a){0!==a&&(e.drawElementsInstanced(n,o,r,t*s,a),i.update(o,n,a))}this.setMode=function(e){n=e},this.setIndex=function(e){r=e.type,s=e.bytesPerElement},this.render=function(t,o){e.drawElements(n,o,r,t*s),i.update(o,n,1)},this.renderInstances=o,this.renderMultiDraw=function(e,s,o){if(0===o)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,e,0,o);let a=0;for(let e=0;e<o;e++)a+=s[e];i.update(a,n,1)},this.renderMultiDrawInstances=function(e,a,l,c){if(0===l)return;const u=t.get("WEBGL_multi_draw");if(null===u)for(let t=0;t<e.length;t++)o(e[t]/s,a[t],c[t]);else{u.multiDrawElementsInstancedWEBGL(n,a,0,r,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=a[e]*c[e];i.update(t,n,1)}}}function xR(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(i,n,r){switch(t.calls++,n){case e.TRIANGLES:t.triangles+=r*(i/3);break;case e.LINES:t.lines+=r*(i/2);break;case e.LINE_STRIP:t.lines+=r*(i-1);break;case e.LINE_LOOP:t.lines+=r*i;break;case e.POINTS:t.points+=r*i;break;default:Vw("WebGLInfo: Unknown draw mode:",n)}}}}function bR(e,t,i){const n=new WeakMap,r=new TT;return{update:function(s,o,a){const l=s.morphTargetInfluences,c=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=void 0!==c?c.length:0;let h=n.get(o);if(void 0===h||h.count!==u){void 0!==h&&h.texture.dispose();const d=void 0!==o.morphAttributes.position,p=void 0!==o.morphAttributes.normal,f=void 0!==o.morphAttributes.color,m=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let y=0;!0===d&&(y=1),!0===p&&(y=2),!0===f&&(y=3);let v=o.attributes.position.count*y,x=1;v>t.maxTextureSize&&(x=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);const b=new Float32Array(v*x*4*u),w=new AT(b,v,x,u);w.type=sb,w.needsUpdate=!0;const T=4*y;for(let E=0;E<u;E++){const A=m[E],M=g[E],I=_[E],C=v*x*4*E;for(let P=0;P<A.count;P++){const L=P*T;!0===d&&(r.fromBufferAttribute(A,P),b[C+L+0]=r.x,b[C+L+1]=r.y,b[C+L+2]=r.z,b[C+L+3]=0),!0===p&&(r.fromBufferAttribute(M,P),b[C+L+4]=r.x,b[C+L+5]=r.y,b[C+L+6]=r.z,b[C+L+7]=0),!0===f&&(r.fromBufferAttribute(I,P),b[C+L+8]=r.x,b[C+L+9]=r.y,b[C+L+10]=r.z,b[C+L+11]=4===I.itemSize?r.w:1)}}function S(){w.dispose(),n.delete(o),o.removeEventListener("dispose",S)}h={count:u,texture:w,size:new iT(v,x)},n.set(o,h),o.addEventListener("dispose",S)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)a.getUniforms().setValue(e,"morphTexture",s.morphTexture,i);else{let R=0;for(let D=0;D<l.length;D++)R+=l[D];const O=o.morphTargetsRelative?1:1-R;a.getUniforms().setValue(e,"morphTargetBaseInfluence",O),a.getUniforms().setValue(e,"morphTargetInfluences",l)}a.getUniforms().setValue(e,"morphTargetsTexture",h.texture,i),a.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}}}function wR(e,t,i,n,r){let s=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.releaseStatesOfObject(t),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(n){const a=r.render.frame,l=t.get(n,n.geometry);if(s.get(l)!==a&&(t.update(l),s.set(l,a)),n.isInstancedMesh&&(!1===n.hasEventListener("dispose",o)&&n.addEventListener("dispose",o),s.get(n)!==a&&(i.update(n.instanceMatrix,e.ARRAY_BUFFER),null!==n.instanceColor&&i.update(n.instanceColor,e.ARRAY_BUFFER),s.set(n,a))),n.isSkinnedMesh){const e=n.skeleton;s.get(e)!==a&&(e.update(),s.set(e,a))}return l},dispose:function(){s=new WeakMap}}}const TR={[Cx]:"LINEAR_TONE_MAPPING",[Px]:"REINHARD_TONE_MAPPING",[Lx]:"CINEON_TONE_MAPPING",[Rx]:"ACES_FILMIC_TONE_MAPPING",[Dx]:"AGX_TONE_MAPPING",[Bx]:"NEUTRAL_TONE_MAPPING",[Ox]:"CUSTOM_TONE_MAPPING"};function SR(e,t,i,n,r){const s=new ET(t,i,{type:e,depthBuffer:n,stencilBuffer:r}),o=new ET(t,i,{type:ob,depthBuffer:!1,stencilBuffer:!1}),a=new hE;a.setAttribute("position",new QS([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new QS([0,2,0,0,2,0],2));const l=new uC({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),c=new iA(a,l),u=new mP(-1,1,1,-1,0,1);let h,d=null,p=null,f=!1,m=null,g=[],_=!1;this.setSize=function(e,t){s.setSize(e,t),o.setSize(e,t);for(let i=0;i<g.length;i++){const n=g[i];n.setSize&&n.setSize(e,t)}},this.setEffects=function(e){g=e,_=g.length>0&&!0===g[0].isRenderPass;const t=s.width,i=s.height;for(let e=0;e<g.length;e++){const n=g[e];n.setSize&&n.setSize(t,i)}},this.begin=function(e,t){if(f)return!1;if(0===e.toneMapping&&0===g.length)return!1;if(m=t,null!==t){const e=t.width,i=t.height;s.width===e&&s.height===i||this.setSize(e,i)}return!1===_&&e.setRenderTarget(s),h=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return _},this.end=function(e,t){e.toneMapping=h,f=!0;let i=s,n=o;for(let r=0;r<g.length;r++){const s=g[r];if(!1!==s.enabled&&(s.render(e,n,i,t),!1!==s.needsSwap)){const e=i;i=n,n=e}}if(d!==e.outputColorSpace||p!==e.toneMapping){d=e.outputColorSpace,p=e.toneMapping,l.defines={},dT.getTransfer(d)===_w&&(l.defines.SRGB_TRANSFER="");const t=TR[p];t&&(l.defines[t]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=i.texture,e.setRenderTarget(m),e.render(c,u),m=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){s.dispose(),o.dispose(),a.dispose(),l.dispose()}}const ER=new wT,AR=new IM(1,1),MR=new AT,IR=new MT,CR=new MM,PR=[],LR=[],RR=new Float32Array(16),OR=new Float32Array(9),DR=new Float32Array(4);function BR(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let s=PR[r];if(void 0===s&&(s=new Float32Array(r),PR[r]=s),0!==t){n.toArray(s,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(s,r)}return s}function FR(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function NR(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function kR(e,t){let i=LR[t];void 0===i&&(i=new Int32Array(t),LR[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function zR(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function UR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(FR(i,t))return;e.uniform2fv(this.addr,t),NR(i,t)}}function VR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(FR(i,t))return;e.uniform3fv(this.addr,t),NR(i,t)}}function jR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(FR(i,t))return;e.uniform4fv(this.addr,t),NR(i,t)}}function GR(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(FR(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),NR(i,t)}else{if(FR(i,n))return;DR.set(n),e.uniformMatrix2fv(this.addr,!1,DR),NR(i,n)}}function HR(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(FR(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),NR(i,t)}else{if(FR(i,n))return;OR.set(n),e.uniformMatrix3fv(this.addr,!1,OR),NR(i,n)}}function WR(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(FR(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),NR(i,t)}else{if(FR(i,n))return;RR.set(n),e.uniformMatrix4fv(this.addr,!1,RR),NR(i,n)}}function qR(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function XR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(FR(i,t))return;e.uniform2iv(this.addr,t),NR(i,t)}}function $R(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(FR(i,t))return;e.uniform3iv(this.addr,t),NR(i,t)}}function ZR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(FR(i,t))return;e.uniform4iv(this.addr,t),NR(i,t)}}function YR(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function JR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(FR(i,t))return;e.uniform2uiv(this.addr,t),NR(i,t)}}function KR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(FR(i,t))return;e.uniform3uiv(this.addr,t),NR(i,t)}}function QR(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(FR(i,t))return;e.uniform4uiv(this.addr,t),NR(i,t)}}function eO(e,t,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),this.type===e.SAMPLER_2D_SHADOW?(AR.compareFunction=i.isReversedDepthBuffer()?Ew:ww,s=AR):s=ER,i.setTexture2D(t||s,r)}function tO(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||IR,r)}function iO(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(t||CR,r)}function nO(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||MR,r)}function rO(e,t){e.uniform1fv(this.addr,t)}function sO(e,t){const i=BR(t,this.size,2);e.uniform2fv(this.addr,i)}function oO(e,t){const i=BR(t,this.size,3);e.uniform3fv(this.addr,i)}function aO(e,t){const i=BR(t,this.size,4);e.uniform4fv(this.addr,i)}function lO(e,t){const i=BR(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function cO(e,t){const i=BR(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function uO(e,t){const i=BR(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function hO(e,t){e.uniform1iv(this.addr,t)}function dO(e,t){e.uniform2iv(this.addr,t)}function pO(e,t){e.uniform3iv(this.addr,t)}function fO(e,t){e.uniform4iv(this.addr,t)}function mO(e,t){e.uniform1uiv(this.addr,t)}function gO(e,t){e.uniform2uiv(this.addr,t)}function _O(e,t){e.uniform3uiv(this.addr,t)}function yO(e,t){e.uniform4uiv(this.addr,t)}function vO(e,t,i){const n=this.cache,r=t.length,s=kR(i,r);let o;FR(n,s)||(e.uniform1iv(this.addr,s),NR(n,s)),o=this.type===e.SAMPLER_2D_SHADOW?AR:ER;for(let e=0;e!==r;++e)i.setTexture2D(t[e]||o,s[e])}function xO(e,t,i){const n=this.cache,r=t.length,s=kR(i,r);FR(n,s)||(e.uniform1iv(this.addr,s),NR(n,s));for(let e=0;e!==r;++e)i.setTexture3D(t[e]||IR,s[e])}function bO(e,t,i){const n=this.cache,r=t.length,s=kR(i,r);FR(n,s)||(e.uniform1iv(this.addr,s),NR(n,s));for(let e=0;e!==r;++e)i.setTextureCube(t[e]||CR,s[e])}function wO(e,t,i){const n=this.cache,r=t.length,s=kR(i,r);FR(n,s)||(e.uniform1iv(this.addr,s),NR(n,s));for(let e=0;e!==r;++e)i.setTexture2DArray(t[e]||MR,s[e])}class TO{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return zR;case 35664:return UR;case 35665:return VR;case 35666:return jR;case 35674:return GR;case 35675:return HR;case 35676:return WR;case 5124:case 35670:return qR;case 35667:case 35671:return XR;case 35668:case 35672:return $R;case 35669:case 35673:return ZR;case 5125:return YR;case 36294:return JR;case 36295:return KR;case 36296:return QR;case 35678:case 36198:case 36298:case 36306:case 35682:return eO;case 35679:case 36299:case 36307:return tO;case 35680:case 36300:case 36308:case 36293:return iO;case 36289:case 36303:case 36311:case 36292:return nO}}(t.type)}}class SO{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return rO;case 35664:return sO;case 35665:return oO;case 35666:return aO;case 35674:return lO;case 35675:return cO;case 35676:return uO;case 5124:case 35670:return hO;case 35667:case 35671:return dO;case 35668:case 35672:return pO;case 35669:case 35673:return fO;case 5125:return mO;case 36294:return gO;case 36295:return _O;case 36296:return yO;case 35678:case 36198:case 36298:case 36306:case 35682:return vO;case 35679:case 36299:case 36307:return xO;case 35680:case 36300:case 36308:case 36293:return bO;case 36289:case 36303:case 36311:case 36292:return wO}}(t.type)}}class EO{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(e,t[s.id],i)}}}const AO=/(\w+)(\])?(\[|\.)?/g;function MO(e,t){e.seq.push(t),e.map[t.id]=t}function IO(e,t,i){const n=e.name,r=n.length;for(AO.lastIndex=0;;){const s=AO.exec(n);let o=s[1];const a=s[3];if("]"===s[2]&&(o|=0),void 0===a||"["===a&&AO.lastIndex+2===r){MO(i,void 0===a?new TO(o,e,t):new SO(o,e,t));break}{let e=i.map[o];void 0===e&&(e=new EO(o),MO(i,e)),i=e}}}class CO{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=e.getActiveUniform(t,n);IO(i,e.getUniformLocation(t,i.name),this)}const n=[],r=[];for(const t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?n.push(t):r.push(t);n.length>0&&(this.seq=n.concat(r))}setValue(e,t,i,n){const r=this.map[t];void 0!==r&&r.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];void 0!==n&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,s=t.length;r!==s;++r){const s=t[r],o=i[s.id];!1!==o.needsUpdate&&s.setValue(e,o.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const r=e[n];r.id in t&&i.push(r)}return i}}function PO(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}let LO=0;const RO=new aT;function OO(e,t,i){const n=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const i=e.split("\n"),n=[],r=Math.max(t-6,0),s=Math.min(t+6,i.length);for(let e=r;e<s;e++){const r=e+1;n.push(`${r===t?">":" "} ${r}: ${i[e]}`)}return n.join("\n")}(e.getShaderSource(t),n)}return r}function DO(e,t){const i=function(e){dT._getMatrix(RO,dT.workingColorSpace,e);const t=`mat3( ${RO.elements.map(e=>e.toFixed(4))} )`;switch(dT.getTransfer(e)){case gw:return[t,"LinearTransferOETF"];case _w:return[t,"sRGBTransferOETF"];default:return Uw("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}const BO={[Cx]:"Linear",[Px]:"Reinhard",[Lx]:"Cineon",[Rx]:"ACESFilmic",[Dx]:"AgX",[Bx]:"Neutral",[Ox]:"Custom"};function FO(e,t){const i=BO[t];return void 0===i?(Uw("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const NO=new rT;function kO(){dT.getLuminanceCoefficients(NO);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${NO.x.toFixed(4)}, ${NO.y.toFixed(4)}, ${NO.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function zO(e){return""!==e}function UO(e,t){const i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function VO(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const jO=/^[ \t]*#include +<([\w\d./]+)>/gm;function GO(e){return e.replace(jO,WO)}const HO=new Map;function WO(e,t){let i=jL[t];if(void 0===i){const e=HO.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");i=jL[e],Uw('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return GO(i)}const qO=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function XO(e){return e.replace(qO,$O)}function $O(e,t,i,n){let r="";for(let e=parseInt(t);e<parseInt(i);e++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function ZO(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}const YO={[Zv]:"SHADOWMAP_TYPE_PCF",[Yv]:"SHADOWMAP_TYPE_VSM"};const JO={[zx]:"ENVMAP_TYPE_CUBE",[Ux]:"ENVMAP_TYPE_CUBE",[Gx]:"ENVMAP_TYPE_CUBE_UV"};const KO={[Ux]:"ENVMAP_MODE_REFRACTION"};const QO={[Ax]:"ENVMAP_BLENDING_MULTIPLY",[Mx]:"ENVMAP_BLENDING_MIX",[Ix]:"ENVMAP_BLENDING_ADD"};function eD(e,t,i,n){const r=e.getContext(),s=i.defines;let o=i.vertexShader,a=i.fragmentShader;const l=function(e){return YO[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(i),c=function(e){return!1===e.envMap?"ENVMAP_TYPE_CUBE":JO[e.envMapMode]||"ENVMAP_TYPE_CUBE"}(i),u=function(e){return!1===e.envMap?"ENVMAP_MODE_REFLECTION":KO[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}(i),h=function(e){return!1===e.envMap?"ENVMAP_BLENDING_NONE":QO[e.combine]||"ENVMAP_BLENDING_NONE"}(i),d=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const i=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zO).join("\n")}(i),f=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(s),m=r.createProgram();let g,_,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(zO).join("\n"),g.length>0&&(g+="\n"),_=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(zO).join("\n"),_.length>0&&(_+="\n")):(g=[ZO(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(zO).join("\n"),_=[ZO(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+u:"",i.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas||i.batchingColor?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?jL.tonemapping_pars_fragment:"",0!==i.toneMapping?FO("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",jL.colorspace_pars_fragment,DO("linearToOutputTexel",i.outputColorSpace),kO(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(zO).join("\n")),o=GO(o),o=UO(o,i),o=VO(o,i),a=GO(a),a=UO(a,i),a=VO(a,i),o=XO(o),a=XO(a),!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Iw?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Iw?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const v=y+_+a,x=PO(r,r.VERTEX_SHADER,y+g+o),b=PO(r,r.FRAGMENT_SHADER,v);function w(t){if(e.debug.checkShaderErrors){const i=r.getProgramInfoLog(m)||"",n=r.getShaderInfoLog(x)||"",s=r.getShaderInfoLog(b)||"",o=i.trim(),a=n.trim(),l=s.trim();let c=!0,u=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,x,b);else{const e=OO(r,x,"vertex"),i=OO(r,b,"fragment");Vw("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+o+"\n"+e+"\n"+i)}else""!==o?Uw("WebGLProgram: Program Info Log:",o):""!==a&&""!==l||(u=!1);u&&(t.diagnostics={runnable:c,programLog:o,vertexShader:{log:a,prefix:g},fragmentShader:{log:l,prefix:_}})}r.deleteShader(x),r.deleteShader(b),T=new CO(r,m),S=function(e,t){const i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=e.getActiveAttrib(t,r),s=n.name;let o=1;n.type===e.FLOAT_MAT2&&(o=2),n.type===e.FLOAT_MAT3&&(o=3),n.type===e.FLOAT_MAT4&&(o=4),i[s]={type:n.type,location:e.getAttribLocation(t,s),locationSize:o}}return i}(r,m)}let T,S;r.attachShader(m,x),r.attachShader(m,b),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===T&&w(this),T},this.getAttributes=function(){return void 0===S&&w(this),S};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=r.getProgramParameter(m,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=LO++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=x,this.fragmentShader=b,this}let tD=0;class iD{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.fragmentShader,i=this._getShaderStage(e.vertexShader),n=this._getShaderStage(t),r=this._getShaderCacheForMaterial(e);return!1===r.has(i)&&(r.add(i),i.usedTimes++),!1===r.has(n)&&(r.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return void 0===i&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return void 0===i&&(i=new nD(e),t.set(e,i)),i}}class nD{constructor(e){this.id=tD++,this.code=e,this.usedTimes=0}}function rD(e,t,i,n,r,s){const o=new zT,a=new iD,l=new Set,c=[],u=new Map,h=n.logarithmicDepthBuffer;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(e){return l.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(r,o,c,u,m){const g=u.fog,_=m.geometry,y=t.get(r.envMap||(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?u.environment:null),r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap),v=y&&y.mapping===Gx?y.image.height:null,x=p[r.type];null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&Uw("WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead."));const b=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=void 0!==b?b.length:0;let T,S,E,A,M=0;if(void 0!==_.morphAttributes.position&&(M=1),void 0!==_.morphAttributes.normal&&(M=2),void 0!==_.morphAttributes.color&&(M=3),x){const e=WL[x];T=e.vertexShader,S=e.fragmentShader}else T=r.vertexShader,S=r.fragmentShader,a.update(r),E=a.getVertexShaderID(r),A=a.getFragmentShaderID(r);const I=e.getRenderTarget(),C=e.state.buffers.depth.getReversed(),P=!0===m.isInstancedMesh,L=!0===m.isBatchedMesh,R=!!r.map,O=!!y,D=!!r.aoMap,B=!!r.lightMap,F=!!r.bumpMap,N=!!r.normalMap,k=!!r.displacementMap,z=!!r.emissiveMap,U=!!r.metalnessMap,V=!!r.roughnessMap,j=r.anisotropy>0,G=r.clearcoat>0,H=r.iridescence>0,W=r.sheen>0,q=r.transmission>0,X=j&&!!r.anisotropyMap,$=G&&!!r.clearcoatMap,Z=G&&!!r.clearcoatNormalMap,Y=G&&!!r.clearcoatRoughnessMap,J=H&&!!r.iridescenceMap,K=H&&!!r.iridescenceThicknessMap,Q=W&&!!r.sheenColorMap,ee=W&&!!r.sheenRoughnessMap,te=!!r.specularMap,ie=!!r.specularColorMap,ne=!!r.specularIntensityMap,re=q&&!!r.transmissionMap,se=q&&!!r.thicknessMap,oe=!!r.alphaMap,ae=!!r.extensions;let le=0;r.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(le=e.toneMapping));const ce={shaderID:x,shaderType:r.type,shaderName:r.name,vertexShader:T,fragmentShader:S,defines:r.defines,customVertexShaderID:E,customFragmentShaderID:A,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,batching:L,batchingColor:L&&null!==m._colorsTexture,instancing:P,instancingColor:P&&null!==m.instanceColor,instancingMorph:P&&null!==m.morphTexture,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:mw,alphaToCoverage:!!r.alphaToCoverage,map:R,matcap:!!r.matcap,envMap:O,envMapMode:O&&y.mapping,envMapCubeUVHeight:v,aoMap:D,lightMap:B,bumpMap:F,normalMap:N,displacementMap:k,emissiveMap:z,normalMapObjectSpace:N&&1===r.normalMapType,normalMapTangentSpace:N&&0===r.normalMapType,metalnessMap:U,roughnessMap:V,anisotropy:j,anisotropyMap:X,clearcoat:G,clearcoatMap:$,clearcoatNormalMap:Z,clearcoatRoughnessMap:Y,dispersion:r.dispersion>0,iridescence:H,iridescenceMap:J,iridescenceThicknessMap:K,sheen:W,sheenColorMap:Q,sheenRoughnessMap:ee,specularMap:te,specularColorMap:ie,specularIntensityMap:ne,transmission:q,transmissionMap:re,thicknessMap:se,gradientMap:!!r.gradientMap,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:oe,alphaTest:r.alphaTest>0,alphaHash:!!r.alphaHash,combine:r.combine,mapUv:R&&f(r.map.channel),aoMapUv:D&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:F&&f(r.bumpMap.channel),normalMapUv:N&&f(r.normalMap.channel),displacementMapUv:k&&f(r.displacementMap.channel),emissiveMapUv:z&&f(r.emissiveMap.channel),metalnessMapUv:U&&f(r.metalnessMap.channel),roughnessMapUv:V&&f(r.roughnessMap.channel),anisotropyMapUv:X&&f(r.anisotropyMap.channel),clearcoatMapUv:$&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:Z&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:K&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:Q&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:ee&&f(r.sheenRoughnessMap.channel),specularMapUv:te&&f(r.specularMap.channel),specularColorMapUv:ie&&f(r.specularColorMap.channel),specularIntensityMapUv:ne&&f(r.specularIntensityMap.channel),transmissionMapUv:re&&f(r.transmissionMap.channel),thicknessMapUv:se&&f(r.thicknessMap.channel),alphaMapUv:oe&&f(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(N||j),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!_.attributes.uv&&(R||oe),fog:!!g,useFog:!0===r.fog,fogExp2:!!g&&g.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===_.attributes.normal&&!1===N&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:h,reversedDepthBuffer:C,skinning:!0===m.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:w,morphTextureStride:M,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:le,decodeVideoTexture:R&&!0===r.map.isVideoTexture&&dT.getTransfer(r.map.colorSpace)===_w,decodeVideoTextureEmissive:z&&!0===r.emissiveMap.isVideoTexture&&dT.getTransfer(r.emissiveMap.colorSpace)===_w,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:ae&&!0===r.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ae&&!0===r.extensions.multiDraw||L)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return ce.vertexUv1s=l.has(1),ce.vertexUv2s=l.has(2),ce.vertexUv3s=l.has(3),l.clear(),ce},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.customVertexShaderID),i.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(i,t),function(e,t){o.disableAll(),t.instancing&&o.enable(0);t.instancingColor&&o.enable(1);t.instancingMorph&&o.enable(2);t.matcap&&o.enable(3);t.envMap&&o.enable(4);t.normalMapObjectSpace&&o.enable(5);t.normalMapTangentSpace&&o.enable(6);t.clearcoat&&o.enable(7);t.iridescence&&o.enable(8);t.alphaTest&&o.enable(9);t.vertexColors&&o.enable(10);t.vertexAlphas&&o.enable(11);t.vertexUv1s&&o.enable(12);t.vertexUv2s&&o.enable(13);t.vertexUv3s&&o.enable(14);t.vertexTangents&&o.enable(15);t.anisotropy&&o.enable(16);t.alphaHash&&o.enable(17);t.batching&&o.enable(18);t.dispersion&&o.enable(19);t.batchingColor&&o.enable(20);t.gradientMap&&o.enable(21);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reversedDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);e.push(o.mask)}(i,t),i.push(e.outputColorSpace)),i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){const t=p[e.type];let i;if(t){i=lC.clone(WL[t].uniforms)}else i=e.uniforms;return i},acquireProgram:function(t,i){let n=u.get(i);return void 0!==n?++n.usedTimes:(n=new eD(e,i,t,r),c.push(n),u.set(i,n)),n},releaseProgram:function(e){if(0===--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),u.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){a.remove(e)},programs:c,dispose:function(){a.dispose()}}}function sD(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,n){e.get(t)[i]=n},dispose:function(){e=new WeakMap}}}function oD(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function aD(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function lD(){const e=[];let t=0;const i=[],n=[],r=[];function s(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(i,n,r,o,a,l){let c=e[t];return void 0===c?(c={id:i.id,object:i,geometry:n,material:r,materialVariant:s(i),groupOrder:o,renderOrder:i.renderOrder,z:a,group:l},e[t]=c):(c.id=i.id,c.object=i,c.geometry=n,c.material=r,c.materialVariant=s(i),c.groupOrder=o,c.renderOrder=i.renderOrder,c.z=a,c.group=l),t++,c}return{opaque:i,transmissive:n,transparent:r,init:function(){t=0,i.length=0,n.length=0,r.length=0},push:function(e,t,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?n.push(u):!0===s.transparent?r.push(u):i.push(u)},unshift:function(e,t,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?n.unshift(u):!0===s.transparent?r.unshift(u):i.unshift(u)},finish:function(){for(let i=t,n=e.length;i<n;i++){const t=e[i];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){i.length>1&&i.sort(e||oD),n.length>1&&n.sort(t||aD),r.length>1&&r.sort(t||aD)}}}function cD(){let e=new WeakMap;return{get:function(t,i){const n=e.get(t);let r;return void 0===n?(r=new lD,e.set(t,[r])):i>=n.length?(r=new lD,n.push(r)):r=n[i],r},dispose:function(){e=new WeakMap}}}function uD(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new rT,color:new cS};break;case"SpotLight":i={position:new rT,direction:new rT,color:new cS,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new rT,color:new cS,distance:0,decay:0};break;case"HemisphereLight":i={direction:new rT,skyColor:new cS,groundColor:new cS};break;case"RectAreaLight":i={color:new cS,position:new rT,halfWidth:new rT,halfHeight:new rT}}return e[t.id]=i,i}}}let hD=0;function dD(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function pD(e){const t=new uD,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new iT};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new iT,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)n.probe.push(new rT);const r=new rT,s=new IT,o=new IT;return{setup:function(r){let s=0,o=0,a=0;for(let e=0;e<9;e++)n.probe[e].set(0,0,0);let l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0,_=0,y=0;r.sort(dD);for(let e=0,v=r.length;e<v;e++){const v=r[e],x=v.color,b=v.intensity,w=v.distance;let T=null;if(v.shadow&&v.shadow.map&&(T=v.shadow.map.texture.format===vb?v.shadow.map.texture:v.shadow.map.depthTexture||v.shadow.map.texture),v.isAmbientLight)s+=x.r*b,o+=x.g*b,a+=x.b*b;else if(v.isLightProbe){for(let e=0;e<9;e++)n.probe[e].addScaledVector(v.sh.coefficients[e],b);y++}else if(v.isDirectionalLight){const e=t.get(v);if(e.color.copy(v.color).multiplyScalar(v.intensity),v.castShadow){const e=v.shadow,t=i.get(v);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,n.directionalShadow[l]=t,n.directionalShadowMap[l]=T,n.directionalShadowMatrix[l]=v.shadow.matrix,p++}n.directional[l]=e,l++}else if(v.isSpotLight){const e=t.get(v);e.position.setFromMatrixPosition(v.matrixWorld),e.color.copy(x).multiplyScalar(b),e.distance=w,e.coneCos=Math.cos(v.angle),e.penumbraCos=Math.cos(v.angle*(1-v.penumbra)),e.decay=v.decay,n.spot[u]=e;const r=v.shadow;if(v.map&&(n.spotLightMap[g]=v.map,g++,r.updateMatrices(v),v.castShadow&&_++),n.spotLightMatrix[u]=r.matrix,v.castShadow){const e=i.get(v);e.shadowIntensity=r.intensity,e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,n.spotShadow[u]=e,n.spotShadowMap[u]=T,m++}u++}else if(v.isRectAreaLight){const e=t.get(v);e.color.copy(x).multiplyScalar(b),e.halfWidth.set(.5*v.width,0,0),e.halfHeight.set(0,.5*v.height,0),n.rectArea[h]=e,h++}else if(v.isPointLight){const e=t.get(v);if(e.color.copy(v.color).multiplyScalar(v.intensity),e.distance=v.distance,e.decay=v.decay,v.castShadow){const e=v.shadow,t=i.get(v);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,n.pointShadow[c]=t,n.pointShadowMap[c]=T,n.pointShadowMatrix[c]=v.shadow.matrix,f++}n.point[c]=e,c++}else if(v.isHemisphereLight){const e=t.get(v);e.skyColor.copy(v.color).multiplyScalar(b),e.groundColor.copy(v.groundColor).multiplyScalar(b),n.hemi[d]=e,d++}}h>0&&(!0===e.has("OES_texture_float_linear")?(n.rectAreaLTC1=HL.LTC_FLOAT_1,n.rectAreaLTC2=HL.LTC_FLOAT_2):(n.rectAreaLTC1=HL.LTC_HALF_1,n.rectAreaLTC2=HL.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=o,n.ambient[2]=a;const v=n.hash;v.directionalLength===l&&v.pointLength===c&&v.spotLength===u&&v.rectAreaLength===h&&v.hemiLength===d&&v.numDirectionalShadows===p&&v.numPointShadows===f&&v.numSpotShadows===m&&v.numSpotMaps===g&&v.numLightProbes===y||(n.directional.length=l,n.spot.length=u,n.rectArea.length=h,n.point.length=c,n.hemi.length=d,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=f,n.pointShadowMap.length=f,n.spotShadow.length=m,n.spotShadowMap.length=m,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=f,n.spotLightMatrix.length=m+g-_,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=_,n.numLightProbes=y,v.directionalLength=l,v.pointLength=c,v.spotLength=u,v.rectAreaLength=h,v.hemiLength=d,v.numDirectionalShadows=p,v.numPointShadows=f,v.numSpotShadows=m,v.numSpotMaps=g,v.numLightProbes=y,n.version=hD++)},setupView:function(e,t){let i=0,a=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=n.directional[i];e.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),i++}else if(d.isSpotLight){const e=n.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),l++}else if(d.isRectAreaLight){const e=n.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),o.identity(),s.copy(d.matrixWorld),s.premultiply(h),o.extractRotation(s),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const e=n.point[a];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),a++}else if(d.isHemisphereLight){const e=n.hemi[u];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(h),u++}}},state:n}}function fD(e){const t=new pD(e),i=[],n=[];const r={lightsArray:i,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,i.length=0,n.length=0},state:r,setupLights:function(){t.setup(i)},setupLightsView:function(e){t.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){n.push(e)}}}function mD(e){let t=new WeakMap;return{get:function(i,n=0){const r=t.get(i);let s;return void 0===r?(s=new fD(e),t.set(i,[s])):n>=r.length?(s=new fD(e),r.push(s)):s=r[n],s},dispose:function(){t=new WeakMap}}}const gD=[new rT(1,0,0),new rT(-1,0,0),new rT(0,1,0),new rT(0,-1,0),new rT(0,0,1),new rT(0,0,-1)],_D=[new rT(0,-1,0),new rT(0,-1,0),new rT(0,0,1),new rT(0,0,-1),new rT(0,-1,0),new rT(0,-1,0)],yD=new IT,vD=new rT,xD=new rT;function bD(e,t,i){let n=new BA;const r=new iT,s=new iT,o=new TT,a=new _C,l=new yC,c={},u=i.maxTextureSize,h={[Jv]:1,[Kv]:0,[Qv]:2},d=new cC({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new iT},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new hE;f.setAttribute("position",new YS(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new iA(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;function y(i,n){const s=t.update(m);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new ET(r.x,r.y,{format:vb,type:ob})),d.uniforms.shadow_pass.value=i.map.depthTexture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,s,d,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,s,p,m,null)}function v(t,i,n,r){let s=null;const o=!0===n.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===n.isPointLight?l:a,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const e=s.uuid,t=i.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let r=n[t];void 0===r&&(r=s.clone(),n[t]=r,i.addEventListener("dispose",b)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:h[i.side],s.alphaMap=i.alphaMap,s.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=n}return s}function x(i,r,s,o,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=t.update(i),l=i.material;if(Array.isArray(l)){const t=n.groups;for(let c=0,u=t.length;c<u;c++){const u=t[c],h=l[u.materialIndex];if(h&&h.visible){const t=v(i,h,o,a);i.onBeforeShadow(e,i,r,s,n,t,u),e.renderBufferDirect(s,null,n,t,i,u),i.onAfterShadow(e,i,r,s,n,t,u)}}}else if(l.visible){const t=v(i,l,o,a);i.onBeforeShadow(e,i,r,s,n,t,null),e.renderBufferDirect(s,null,n,t,i,null),i.onAfterShadow(e,i,r,s,n,t,null)}}const l=i.children;for(let e=0,t=l.length;e<t;e++)x(l[e],r,s,o,a)}function b(e){e.target.removeEventListener("dispose",b);for(const t in c){const i=c[t],n=e.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(t,i,a){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;2===this.type&&(Uw("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const l=e.getRenderTarget(),c=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),!0===d.buffers.depth.getReversed()?d.buffers.color.setClear(0,0,0,0):d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=_!==this.type;p&&i.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let l=0,c=t.length;l<c;l++){const c=t[l],h=c.shadow;if(void 0===h){Uw("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);const f=h.getFrameExtents();r.multiply(f),s.copy(h.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/f.x),r.x=s.x*f.x,h.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/f.y),r.y=s.y*f.y,h.mapSize.y=s.y));const m=e.state.buffers.depth.getReversed();if(h.camera._reversedDepth=m,null===h.map||!0===p){if(null!==h.map&&(null!==h.map.depthTexture&&(h.map.depthTexture.dispose(),h.map.depthTexture=null),h.map.dispose()),3===this.type){if(c.isPointLight){Uw("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}h.map=new ET(r.x,r.y,{format:vb,type:ob,minFilter:Yx,magFilter:Yx,generateMipmaps:!1}),h.map.texture.name=c.name+".shadowMap",h.map.depthTexture=new IM(r.x,r.y,sb),h.map.depthTexture.name=c.name+".shadowMapDepth",h.map.depthTexture.format=mb,h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=Xx,h.map.depthTexture.magFilter=Xx}else c.isPointLight?(h.map=new mR(r.x),h.map.depthTexture=new CM(r.x,rb)):(h.map=new ET(r.x,r.y),h.map.depthTexture=new IM(r.x,r.y,rb)),h.map.depthTexture.name=c.name+".shadowMap",h.map.depthTexture.format=mb,1===this.type?(h.map.depthTexture.compareFunction=m?Ew:ww,h.map.depthTexture.minFilter=Yx,h.map.depthTexture.magFilter=Yx):(h.map.depthTexture.compareFunction=null,h.map.depthTexture.minFilter=Xx,h.map.depthTexture.magFilter=Xx);h.camera.updateProjectionMatrix()}const g=h.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<g;t++){if(h.map.isWebGLCubeRenderTarget)e.setRenderTarget(h.map,t),e.clear();else{0===t&&(e.setRenderTarget(h.map),e.clear());const i=h.getViewport(t);o.set(s.x*i.x,s.y*i.y,s.x*i.z,s.y*i.w),d.viewport(o)}if(c.isPointLight){const e=h.camera,i=h.matrix,n=c.distance||e.far;n!==e.far&&(e.far=n,e.updateProjectionMatrix()),vD.setFromMatrixPosition(c.matrixWorld),e.position.copy(vD),xD.copy(e.position),xD.add(gD[t]),e.up.copy(_D[t]),e.lookAt(xD),e.updateMatrixWorld(),i.makeTranslation(-vD.x,-vD.y,-vD.z),yD.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),h._frustum.setFromProjectionMatrix(yD,e.coordinateSystem,e.reversedDepth)}else h.updateMatrices(c);n=h.getFrustum(),x(i,a,h.camera,c,this.type)}!0!==h.isPointLightShadow&&3===this.type&&y(h,a),h.needsUpdate=!1}_=this.type,g.needsUpdate=!1,e.setRenderTarget(l,c,h)}}function wD(e,t){const i=new function(){let t=!1;const i=new TT;let n=null;const r=new TT(0,0,0,0);return{setMask:function(i){n===i||t||(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,s,o,a){!0===a&&(t*=o,n*=o,s*=o),i.set(t,n,s,o),!1===r.equals(i)&&(e.clearColor(t,n,s,o),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,o=null;return{setReversed:function(e){if(n!==e){const i=t.get("EXT_clip_control");i.clipControlEXT(i.LOWER_LEFT_EXT,e?i.ZERO_TO_ONE_EXT:i.NEGATIVE_ONE_TO_ONE_EXT),n=e;const r=o;o=null,this.setClear(r)}},getReversed:function(){return n},setTest:function(t){t?U(e.DEPTH_TEST):V(e.DEPTH_TEST)},setMask:function(t){r===t||i||(e.depthMask(t),r=t)},setFunc:function(t){if(n&&(t=Gw[t]),s!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}s=t}},setLocked:function(e){i=e},setClear:function(t){o!==t&&(o=t,n&&(t=1-t),e.clearDepth(t))},reset:function(){i=!1,r=null,s=null,o=null,n=!1}}},r=new function(){let t=!1,i=null,n=null,r=null,s=null,o=null,a=null,l=null,c=null;return{setTest:function(i){t||(i?U(e.STENCIL_TEST):V(e.STENCIL_TEST))},setMask:function(n){i===n||t||(e.stencilMask(n),i=n)},setFunc:function(t,i,o){n===t&&r===i&&s===o||(e.stencilFunc(t,i,o),n=t,r=i,s=o)},setOp:function(t,i,n){o===t&&a===i&&l===n||(e.stencilOp(t,i,n),o=t,a=i,l=n)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,i=null,n=null,r=null,s=null,o=null,a=null,l=null,c=null}}},s=new WeakMap,o=new WeakMap;let a={},l={},c=new WeakMap,u=[],h=null,d=!1,p=null,f=null,m=null,g=null,_=null,y=null,v=null,x=new cS(0,0,0),b=0,w=!1,T=null,S=null,E=null,A=null,M=null;const I=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let C=!1,P=0;const L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),C=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),C=P>=2);let R=null,O={};const D=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),F=(new TT).fromArray(D),N=(new TT).fromArray(B);function k(t,i,n,r){const s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<n;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(i,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage2D(i+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s);return o}const z={};function U(t){!0!==a[t]&&(e.enable(t),a[t]=!0)}function V(t){!1!==a[t]&&(e.disable(t),a[t]=!1)}z[e.TEXTURE_2D]=k(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=k(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=k(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=k(e.TEXTURE_3D,e.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),U(e.DEPTH_TEST),n.setFunc(3),W(!1),q(1),U(e.CULL_FACE),H(0);const j={[ex]:e.FUNC_ADD,[tx]:e.FUNC_SUBTRACT,[ix]:e.FUNC_REVERSE_SUBTRACT};j[103]=e.MIN,j[104]=e.MAX;const G={[nx]:e.ZERO,[rx]:e.ONE,[sx]:e.SRC_COLOR,[ax]:e.SRC_ALPHA,[px]:e.SRC_ALPHA_SATURATE,[hx]:e.DST_COLOR,[cx]:e.DST_ALPHA,[ox]:e.ONE_MINUS_SRC_COLOR,[lx]:e.ONE_MINUS_SRC_ALPHA,[dx]:e.ONE_MINUS_DST_COLOR,[ux]:e.ONE_MINUS_DST_ALPHA,[fx]:e.CONSTANT_COLOR,[mx]:e.ONE_MINUS_CONSTANT_COLOR,[gx]:e.CONSTANT_ALPHA,[_x]:e.ONE_MINUS_CONSTANT_ALPHA};function H(t,i,n,r,s,o,a,l,c,u){if(0!==t){if(!1===d&&(U(e.BLEND),d=!0),5===t)s=s||i,o=o||n,a=a||r,i===f&&s===_||(e.blendEquationSeparate(j[i],j[s]),f=i,_=s),n===m&&r===g&&o===y&&a===v||(e.blendFuncSeparate(G[n],G[r],G[o],G[a]),m=n,g=r,y=o,v=a),!1!==l.equals(x)&&c===b||(e.blendColor(l.r,l.g,l.b,c),x.copy(l),b=c),p=t,w=!1;else if(t!==p||u!==w){if(f===ex&&_===ex||(e.blendEquation(e.FUNC_ADD),f=ex,_=ex),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Vw("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:Vw("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Vw("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Vw("WebGLState: Invalid blending: ",t)}m=null,g=null,y=null,v=null,x.set(0,0,0),b=0,p=t,w=u}}else!0===d&&(V(e.BLEND),d=!1)}function W(t){T!==t&&(e.frontFace(t?e.CW:e.CCW),T=t)}function q(t){0!==t?(U(e.CULL_FACE),t!==S&&e.cullFace(1===t?e.BACK:2===t?e.FRONT:e.FRONT_AND_BACK)):V(e.CULL_FACE),S=t}function X(t,i,r){t?(U(e.POLYGON_OFFSET_FILL),A===i&&M===r||(A=i,M=r,n.getReversed()&&(i=-i),e.polygonOffset(i,r))):V(e.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:U,disable:V,bindFramebuffer:function(t,i){return l[t]!==i&&(e.bindFramebuffer(t,i),l[t]=i,t===e.DRAW_FRAMEBUFFER&&(l[e.FRAMEBUFFER]=i),t===e.FRAMEBUFFER&&(l[e.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(t,i){let n=u,r=!1;if(t){n=c.get(i),void 0===n&&(n=[],c.set(i,n));const s=t.textures;if(n.length!==s.length||n[0]!==e.COLOR_ATTACHMENT0){for(let t=0,i=s.length;t<i;t++)n[t]=e.COLOR_ATTACHMENT0+t;n.length=s.length,r=!0}}else n[0]!==e.BACK&&(n[0]=e.BACK,r=!0);r&&e.drawBuffers(n)},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:H,setMaterial:function(t,s){2===t.side?V(e.CULL_FACE):U(e.CULL_FACE);let o=1===t.side;s&&(o=!o),W(o),1===t.blending&&!1===t.transparent?H(0):H(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),n.setFunc(t.depthFunc),n.setTest(t.depthTest),n.setMask(t.depthWrite),i.setMask(t.colorWrite);const a=t.stencilWrite;r.setTest(a),a&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),X(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?U(e.SAMPLE_ALPHA_TO_COVERAGE):V(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:W,setCullFace:q,setLineWidth:function(t){t!==E&&(C&&e.lineWidth(t),E=t)},setPolygonOffset:X,setScissorTest:function(t){t?U(e.SCISSOR_TEST):V(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+I-1),R!==t&&(e.activeTexture(t),R=t)},bindTexture:function(t,i,n){void 0===n&&(n=null===R?e.TEXTURE0+I-1:R);let r=O[n];void 0===r&&(r={type:void 0,texture:void 0},O[n]=r),r.type===t&&r.texture===i||(R!==n&&(e.activeTexture(n),R=n),e.bindTexture(t,i||z[t]),r.type=t,r.texture=i)},unbindTexture:function(){const t=O[R];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){Vw("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){Vw("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){Vw("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){Vw("WebGLState:",e)}},updateUBOMapping:function(t,i){let n=o.get(i);void 0===n&&(n=new WeakMap,o.set(i,n));let r=n.get(t);void 0===r&&(r=e.getUniformBlockIndex(i,t.name),n.set(t,r))},uniformBlockBinding:function(t,i){const n=o.get(i).get(t);s.get(i)!==n&&(e.uniformBlockBinding(i,n,t.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){Vw("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){Vw("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){Vw("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){Vw("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){Vw("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){Vw("WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===N.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),N.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),n.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),a={},R=null,O={},l={},c=new WeakMap,u=[],h=null,d=!1,p=null,f=null,m=null,g=null,_=null,y=null,v=null,x=new cS(0,0,0),b=0,w=!1,T=null,S=null,E=null,A=null,M=null,F.set(0,0,e.canvas.width,e.canvas.height),N.set(0,0,e.canvas.width,e.canvas.height),i.reset(),n.reset(),r.reset()}}}function TD(e,t,i,n,r,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new iT,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return p?new OffscreenCanvas(e,t):Dw("canvas")}function m(e,t,i){let n=1;const r=G(e);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===h&&(h=f(i,s));const o=t?f(i,s):h;o.width=i,o.height=s;return o.getContext("2d").drawImage(e,0,0,i,s),Uw("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),o}return"data"in e&&Uw("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function g(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function v(i,n,r,s,o=!1){if(null!==i){if(void 0!==e[i])return e[i];Uw("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let a=n;if(n===e.RED&&(r===e.FLOAT&&(a=e.R32F),r===e.HALF_FLOAT&&(a=e.R16F),r===e.UNSIGNED_BYTE&&(a=e.R8)),n===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(a=e.R8UI),r===e.UNSIGNED_SHORT&&(a=e.R16UI),r===e.UNSIGNED_INT&&(a=e.R32UI),r===e.BYTE&&(a=e.R8I),r===e.SHORT&&(a=e.R16I),r===e.INT&&(a=e.R32I)),n===e.RG&&(r===e.FLOAT&&(a=e.RG32F),r===e.HALF_FLOAT&&(a=e.RG16F),r===e.UNSIGNED_BYTE&&(a=e.RG8)),n===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(a=e.RG8UI),r===e.UNSIGNED_SHORT&&(a=e.RG16UI),r===e.UNSIGNED_INT&&(a=e.RG32UI),r===e.BYTE&&(a=e.RG8I),r===e.SHORT&&(a=e.RG16I),r===e.INT&&(a=e.RG32I)),n===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(a=e.RGB8UI),r===e.UNSIGNED_SHORT&&(a=e.RGB16UI),r===e.UNSIGNED_INT&&(a=e.RGB32UI),r===e.BYTE&&(a=e.RGB8I),r===e.SHORT&&(a=e.RGB16I),r===e.INT&&(a=e.RGB32I)),n===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(a=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(a=e.RGBA16UI),r===e.UNSIGNED_INT&&(a=e.RGBA32UI),r===e.BYTE&&(a=e.RGBA8I),r===e.SHORT&&(a=e.RGBA16I),r===e.INT&&(a=e.RGBA32I)),n===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(a=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(a=e.R11F_G11F_B10F)),n===e.RGBA){const t=o?gw:dT.getTransfer(s);r===e.FLOAT&&(a=e.RGBA32F),r===e.HALF_FLOAT&&(a=e.RGBA16F),r===e.UNSIGNED_BYTE&&(a=t===_w?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(a=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(a=e.RGB5_A1)}return a!==e.R16F&&a!==e.R32F&&a!==e.RG16F&&a!==e.RG32F&&a!==e.RGBA16F&&a!==e.RGBA32F||t.get("EXT_color_buffer_float"),a}function x(t,i){let n;return t?null===i||i===rb||i===cb?n=e.DEPTH24_STENCIL8:i===sb?n=e.DEPTH32F_STENCIL8:i===ib&&(n=e.DEPTH24_STENCIL8,Uw("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===rb||i===cb?n=e.DEPTH_COMPONENT24:i===sb?n=e.DEPTH_COMPONENT32F:i===ib&&(n=e.DEPTH_COMPONENT16),n}function b(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==Xx&&e.minFilter!==Yx?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){const t=e.target;t.removeEventListener("dispose",w),function(e){const t=n.get(e);if(void 0===t.__webglInit)return;const i=e.source,r=d.get(i);if(r){const n=r[t.__cacheKey];n.usedTimes--,0===n.usedTimes&&S(e),0===Object.keys(r).length&&d.delete(i)}n.remove(e)}(t),t.isVideoTexture&&u.delete(t)}function T(t){const i=t.target;i.removeEventListener("dispose",T),function(t){const i=n.get(t);t.depthTexture&&(t.depthTexture.dispose(),n.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(i.__webglFramebuffer[t]))for(let n=0;n<i.__webglFramebuffer[t].length;n++)e.deleteFramebuffer(i.__webglFramebuffer[t][n]);else e.deleteFramebuffer(i.__webglFramebuffer[t]);i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t])}else{if(Array.isArray(i.__webglFramebuffer))for(let t=0;t<i.__webglFramebuffer.length;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]);else e.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let t=0;t<i.__webglColorRenderbuffer.length;t++)i.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(i.__webglColorRenderbuffer[t]);i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,i=r.length;t<i;t++){const i=n.get(r[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),o.memory.textures--),n.remove(r[t])}n.remove(t)}(i)}function S(t){const i=n.get(t);e.deleteTexture(i.__webglTexture);delete d.get(t.source)[i.__cacheKey],o.memory.textures--}let E=0;function A(t,r){const s=n.get(t);if(t.isVideoTexture&&function(e){const t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&s.__version!==t.version){const e=t.image;if(null===e)Uw("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void O(s,t,r);Uw("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(s.__webglTexture=t.sourceTexture?t.sourceTexture:null);i.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const M={[Hx]:e.REPEAT,[Wx]:e.CLAMP_TO_EDGE,[qx]:e.MIRRORED_REPEAT},I={[Xx]:e.NEAREST,[$x]:e.NEAREST_MIPMAP_NEAREST,[Zx]:e.NEAREST_MIPMAP_LINEAR,[Yx]:e.LINEAR,[Jx]:e.LINEAR_MIPMAP_NEAREST,[Kx]:e.LINEAR_MIPMAP_LINEAR},C={[vw]:e.NEVER,[Aw]:e.ALWAYS,[xw]:e.LESS,[ww]:e.LEQUAL,[bw]:e.EQUAL,[Ew]:e.GEQUAL,[Tw]:e.GREATER,[Sw]:e.NOTEQUAL};function P(i,s){if(s.type!==sb||!1!==t.has("OES_texture_float_linear")||s.magFilter!==Yx&&s.magFilter!==Jx&&s.magFilter!==Zx&&s.magFilter!==Kx&&s.minFilter!==Yx&&s.minFilter!==Jx&&s.minFilter!==Zx&&s.minFilter!==Kx||Uw("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(i,e.TEXTURE_WRAP_S,M[s.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,M[s.wrapT]),i!==e.TEXTURE_3D&&i!==e.TEXTURE_2D_ARRAY||e.texParameteri(i,e.TEXTURE_WRAP_R,M[s.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,I[s.minFilter]),s.compareFunction&&(e.texParameteri(i,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(i,e.TEXTURE_COMPARE_FUNC,C[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Xx)return;if(s.minFilter!==Zx&&s.minFilter!==Kx)return;if(s.type===sb&&!1===t.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const o=t.get("EXT_texture_filter_anisotropic");e.texParameterf(i,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function L(t,i){let n=!1;void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",w));const r=i.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const a=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(i);if(a!==t.__cacheKey){void 0===s[a]&&(s[a]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,n=!0),s[a].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&S(i)),t.__cacheKey=a,t.__webglTexture=s[a].texture}return n}function R(e,t,i){return Math.floor(Math.floor(e/i)/t)}function O(t,o,a){let l=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(l=e.TEXTURE_3D);const c=L(t,o),u=o.source;i.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const h=n.get(u);if(u.version!==h.__version||!0===c){i.activeTexture(e.TEXTURE0+a);const t=dT.getPrimaries(dT.workingColorSpace),n=o.colorSpace===pw?null:dT.getPrimaries(o.colorSpace),d=o.colorSpace===pw||t===n?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(o.image,!1,r.maxTextureSize);p=j(o,p);const f=s.convert(o.format,o.colorSpace),y=s.convert(o.type);let w,T=v(o.internalFormat,f,y,o.colorSpace,o.isVideoTexture);P(l,o);const S=o.mipmaps,E=!0!==o.isVideoTexture,A=void 0===h.__version||!0===c,M=u.dataReady,I=b(o,p);if(o.isDepthTexture)T=x(o.format===gb,o.type),A&&(E?i.texStorage2D(e.TEXTURE_2D,1,T,p.width,p.height):i.texImage2D(e.TEXTURE_2D,0,T,p.width,p.height,0,f,y,null));else if(o.isDataTexture)if(S.length>0){E&&A&&i.texStorage2D(e.TEXTURE_2D,I,T,S[0].width,S[0].height);for(let t=0,n=S.length;t<n;t++)w=S[t],E?M&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,w.width,w.height,f,y,w.data):i.texImage2D(e.TEXTURE_2D,t,T,w.width,w.height,0,f,y,w.data);o.generateMipmaps=!1}else E?(A&&i.texStorage2D(e.TEXTURE_2D,I,T,p.width,p.height),M&&function(t,n,r,s){const o=t.updateRanges;if(0===o.length)i.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,r,s,n.data);else{o.sort((e,t)=>e.start-t.start);let a=0;for(let e=1;e<o.length;e++){const t=o[a],i=o[e],r=t.start+t.count,s=R(i.start,n.width,4),l=R(t.start,n.width,4);i.start<=r+1&&s===l&&R(i.start+i.count-1,n.width,4)===s?t.count=Math.max(t.count,i.start+i.count-t.start):(++a,o[a]=i)}o.length=a+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),u=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,n.width);for(let t=0,a=o.length;t<a;t++){const a=o[t],l=Math.floor(a.start/4),c=Math.ceil(a.count/4),u=l%n.width,h=Math.floor(l/n.width),d=c,p=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,u),e.pixelStorei(e.UNPACK_SKIP_ROWS,h),i.texSubImage2D(e.TEXTURE_2D,0,u,h,d,p,r,s,n.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}(o,p,f,y)):i.texImage2D(e.TEXTURE_2D,0,T,p.width,p.height,0,f,y,p.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){E&&A&&i.texStorage3D(e.TEXTURE_2D_ARRAY,I,T,S[0].width,S[0].height,p.depth);for(let t=0,n=S.length;t<n;t++)if(w=S[t],o.format!==fb)if(null!==f)if(E){if(M)if(o.layerUpdates.size>0){const n=zL(w.width,w.height,o.format,o.type);for(const r of o.layerUpdates){const s=w.data.subarray(r*n/w.data.BYTES_PER_ELEMENT,(r+1)*n/w.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,w.width,w.height,1,f,s)}o.clearLayerUpdates()}else i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,w.data)}else i.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,T,w.width,w.height,p.depth,0,w.data,0,0);else Uw("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?M&&i.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,y,w.data):i.texImage3D(e.TEXTURE_2D_ARRAY,t,T,w.width,w.height,p.depth,0,f,y,w.data)}else{E&&A&&i.texStorage2D(e.TEXTURE_2D,I,T,S[0].width,S[0].height);for(let t=0,n=S.length;t<n;t++)w=S[t],o.format!==fb?null!==f?E?M&&i.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,w.width,w.height,f,w.data):i.compressedTexImage2D(e.TEXTURE_2D,t,T,w.width,w.height,0,w.data):Uw("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?M&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,w.width,w.height,f,y,w.data):i.texImage2D(e.TEXTURE_2D,t,T,w.width,w.height,0,f,y,w.data)}else if(o.isDataArrayTexture)if(E){if(A&&i.texStorage3D(e.TEXTURE_2D_ARRAY,I,T,p.width,p.height,p.depth),M)if(o.layerUpdates.size>0){const t=zL(p.width,p.height,o.format,o.type);for(const n of o.layerUpdates){const r=p.data.subarray(n*t/p.data.BYTES_PER_ELEMENT,(n+1)*t/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,f,y,r)}o.clearLayerUpdates()}else i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,y,p.data)}else i.texImage3D(e.TEXTURE_2D_ARRAY,0,T,p.width,p.height,p.depth,0,f,y,p.data);else if(o.isData3DTexture)E?(A&&i.texStorage3D(e.TEXTURE_3D,I,T,p.width,p.height,p.depth),M&&i.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,y,p.data)):i.texImage3D(e.TEXTURE_3D,0,T,p.width,p.height,p.depth,0,f,y,p.data);else if(o.isFramebufferTexture){if(A)if(E)i.texStorage2D(e.TEXTURE_2D,I,T,p.width,p.height);else{let t=p.width,n=p.height;for(let r=0;r<I;r++)i.texImage2D(e.TEXTURE_2D,r,T,t,n,0,f,y,null),t>>=1,n>>=1}}else if(S.length>0){if(E&&A){const t=G(S[0]);i.texStorage2D(e.TEXTURE_2D,I,T,t.width,t.height)}for(let t=0,n=S.length;t<n;t++)w=S[t],E?M&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,f,y,w):i.texImage2D(e.TEXTURE_2D,t,T,f,y,w);o.generateMipmaps=!1}else if(E){if(A){const t=G(p);i.texStorage2D(e.TEXTURE_2D,I,T,t.width,t.height)}M&&i.texSubImage2D(e.TEXTURE_2D,0,0,0,f,y,p)}else i.texImage2D(e.TEXTURE_2D,0,T,f,y,p);g(o)&&_(l),h.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function D(t,r,o,l,c,u){const h=s.convert(o.format,o.colorSpace),d=s.convert(o.type),p=v(o.internalFormat,h,d,o.colorSpace),f=n.get(r),m=n.get(o);if(m.__renderTarget=r,!f.__hasExternalTextures){const t=Math.max(1,r.width>>u),n=Math.max(1,r.height>>u);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?i.texImage3D(c,u,p,t,n,r.depth,0,h,d,null):i.texImage2D(c,u,p,t,n,0,h,d,null)}i.bindFramebuffer(e.FRAMEBUFFER,t),V(r)?a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,c,m.__webglTexture,0,U(r)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,c,m.__webglTexture,u),i.bindFramebuffer(e.FRAMEBUFFER,null)}function B(t,i,n){if(e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer){const r=i.depthTexture,s=x(i.stencilBuffer,r&&r.isDepthTexture?r.type:null),o=i.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;V(i)?a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,U(i),s,i.width,i.height):n?e.renderbufferStorageMultisample(e.RENDERBUFFER,U(i),s,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,s,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,o,e.RENDERBUFFER,t)}else{const t=i.textures;for(let r=0;r<t.length;r++){const o=t[r],l=s.convert(o.format,o.colorSpace),c=s.convert(o.type),u=v(o.internalFormat,l,c,o.colorSpace);V(i)?a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,U(i),u,i.width,i.height):n?e.renderbufferStorageMultisample(e.RENDERBUFFER,U(i),u,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,u,i.width,i.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function F(t,r,o){const l=!0===r.isWebGLCubeRenderTarget;if(i.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const c=n.get(r.depthTexture);if(c.__renderTarget=r,c.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===c.__webglInit&&(c.__webglInit=!0,r.depthTexture.addEventListener("dispose",w)),void 0===c.__webglTexture){c.__webglTexture=e.createTexture(),i.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),P(e.TEXTURE_CUBE_MAP,r.depthTexture);const t=s.convert(r.depthTexture.format),n=s.convert(r.depthTexture.type);let o;r.depthTexture.format===mb?o=e.DEPTH_COMPONENT24:r.depthTexture.format===gb&&(o=e.DEPTH24_STENCIL8);for(let i=0;i<6;i++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,o,r.width,r.height,0,t,n,null)}}else A(r.depthTexture,0);const u=c.__webglTexture,h=U(r),d=l?e.TEXTURE_CUBE_MAP_POSITIVE_X+o:e.TEXTURE_2D,p=r.depthTexture.format===gb?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(r.depthTexture.format===mb)V(r)?a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,d,u,0,h):e.framebufferTexture2D(e.FRAMEBUFFER,p,d,u,0);else{if(r.depthTexture.format!==gb)throw new Error("Unknown depthTexture format");V(r)?a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,d,u,0,h):e.framebufferTexture2D(e.FRAMEBUFFER,p,d,u,0)}}function N(t){const r=n.get(t),s=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){const t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer)if(s)for(let e=0;e<6;e++)F(r.__webglFramebuffer[e],t,e);else{const e=t.texture.mipmaps;F(e&&e.length>0?r.__webglFramebuffer[0]:r.__webglFramebuffer,t,0)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=e.createRenderbuffer(),B(r.__webglDepthbuffer[n],t,!1);else{const i=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,s)}}else{const n=t.texture.mipmaps;if(i.bindFramebuffer(e.FRAMEBUFFER,n&&n.length>0?r.__webglFramebuffer[0]:r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),B(r.__webglDepthbuffer,t,!1);else{const i=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,n),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,n)}}i.bindFramebuffer(e.FRAMEBUFFER,null)}const k=[],z=[];function U(e){return Math.min(r.maxSamples,e.samples)}function V(e){const i=n.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function j(e,t){const i=e.colorSpace,n=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||i!==mw&&i!==pw&&(dT.getTransfer(i)===_w?n===fb&&r===Qx||Uw("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Vw("WebGLTextures: Unsupported texture color space:",i)),t}function G(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){const e=E;return e>=r.maxTextures&&Uw("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),E+=1,e},this.resetTextureUnits=function(){E=0},this.setTexture2D=A,this.setTexture2DArray=function(t,r){const s=n.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?O(s,t,r):(t.isExternalTexture&&(s.__webglTexture=t.sourceTexture?t.sourceTexture:null),i.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r))},this.setTexture3D=function(t,r){const s=n.get(t);!1===t.isRenderTargetTexture&&t.version>0&&s.__version!==t.version?O(s,t,r):i.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,o){const a=n.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&a.__version!==t.version?function(t,o,a){if(6!==o.image.length)return;const l=L(t,o),c=o.source;i.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=n.get(c);if(c.version!==u.__version||!0===l){i.activeTexture(e.TEXTURE0+a);const t=dT.getPrimaries(dT.workingColorSpace),n=o.colorSpace===pw?null:dT.getPrimaries(o.colorSpace),h=o.colorSpace===pw||t===n?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);const d=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=d||p?p?o.image[e].image:o.image[e]:m(o.image[e],!0,r.maxCubemapSize),f[e]=j(o,f[e]);const y=f[0],x=s.convert(o.format,o.colorSpace),w=s.convert(o.type),T=v(o.internalFormat,x,w,o.colorSpace),S=!0!==o.isVideoTexture,E=void 0===u.__version||!0===l,A=c.dataReady;let M,I=b(o,y);if(P(e.TEXTURE_CUBE_MAP,o),d){S&&E&&i.texStorage2D(e.TEXTURE_CUBE_MAP,I,T,y.width,y.height);for(let t=0;t<6;t++){M=f[t].mipmaps;for(let n=0;n<M.length;n++){const r=M[n];o.format!==fb?null!==x?S?A&&i.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,T,r.width,r.height,0,r.data):Uw("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?A&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,r.width,r.height,x,w,r.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,T,r.width,r.height,0,x,w,r.data)}}}else{if(M=o.mipmaps,S&&E){M.length>0&&I++;const t=G(f[0]);i.texStorage2D(e.TEXTURE_CUBE_MAP,I,T,t.width,t.height)}for(let t=0;t<6;t++)if(p){S?A&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,x,w,f[t].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,f[t].width,f[t].height,0,x,w,f[t].data);for(let n=0;n<M.length;n++){const r=M[n].image[t].image;S?A&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,r.width,r.height,x,w,r.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,r.width,r.height,0,x,w,r.data)}}else{S?A&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,x,w,f[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,x,w,f[t]);for(let n=0;n<M.length;n++){const r=M[n];S?A&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,x,w,r.image[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,x,w,r.image[t])}}}g(o)&&_(e.TEXTURE_CUBE_MAP),u.__version=c.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}(a,t,o):i.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+o)},this.rebindTextures=function(t,i,r){const s=n.get(t);void 0!==i&&D(s.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&N(t)},this.setupRenderTarget=function(t){const r=t.texture,a=n.get(t),l=n.get(r);t.addEventListener("dispose",T);const c=t.textures,u=!0===t.isWebGLCubeRenderTarget,h=c.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,o.memory.textures++),u){a.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){a.__webglFramebuffer[t]=[];for(let i=0;i<r.mipmaps.length;i++)a.__webglFramebuffer[t][i]=e.createFramebuffer()}else a.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){a.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)a.__webglFramebuffer[t]=e.createFramebuffer()}else a.__webglFramebuffer=e.createFramebuffer();if(h)for(let t=0,i=c.length;t<i;t++){const i=n.get(c[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&!1===V(t)){a.__webglMultisampledFramebuffer=e.createFramebuffer(),a.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,a.__webglMultisampledFramebuffer);for(let i=0;i<c.length;i++){const n=c[i];a.__webglColorRenderbuffer[i]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,a.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),o=s.convert(n.type),l=v(n.internalFormat,r,o,n.colorSpace,!0===t.isXRRenderTarget),u=U(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,a.__webglColorRenderbuffer[i])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(a.__webglDepthRenderbuffer=e.createRenderbuffer(),B(a.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){i.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),P(e.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)D(a.__webglFramebuffer[i][n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else D(a.__webglFramebuffer[i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(r)&&_(e.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(h){for(let r=0,s=c.length;r<s;r++){const s=c[r],o=n.get(s);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),i.bindTexture(l,o.__webglTexture),P(l,s),D(a.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+r,l,0),g(s)&&_(l)}i.unbindTexture()}else{let n=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(n=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),i.bindTexture(n,l.__webglTexture),P(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)D(a.__webglFramebuffer[i],t,r,e.COLOR_ATTACHMENT0,n,i);else D(a.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,n,0);g(r)&&_(n),i.unbindTexture()}t.depthBuffer&&N(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let r=0,s=t.length;r<s;r++){const s=t[r];if(g(s)){const t=y(e),r=n.get(s).__webglTexture;i.bindTexture(t,r),_(t),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===V(t)){const r=t.textures,s=t.width,o=t.height;let a=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=n.get(t),h=r.length>1;if(h)for(let t=0;t<r.length;t++)i.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),i.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);i.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);const d=t.texture.mipmaps;i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d&&d.length>0?u.__webglFramebuffer[0]:u.__webglFramebuffer);for(let i=0;i<r.length;i++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(a|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(a|=e.STENCIL_BUFFER_BIT)),h){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[i]);const t=n.get(r[i]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,s,o,0,0,s,o,a,e.NEAREST),!0===l&&(k.length=0,z.length=0,k.push(e.COLOR_ATTACHMENT0+i),t.depthBuffer&&!1===t.resolveDepthBuffer&&(k.push(c),z.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,z)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,k))}if(i.bindFramebuffer(e.READ_FRAMEBUFFER,null),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),h)for(let t=0;t<r.length;t++){i.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const s=n.get(r[t]).__webglTexture;i.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,s,0)}i.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT])}},this.setupDepthRenderbuffer=N,this.setupFrameBufferTexture=D,this.useMultisampledRTT=V,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function SD(e,t){return{convert:function(i,n=""){let r;const s=dT.getTransfer(n);if(i===Qx)return e.UNSIGNED_BYTE;if(i===ab)return e.UNSIGNED_SHORT_4_4_4_4;if(i===lb)return e.UNSIGNED_SHORT_5_5_5_1;if(i===ub)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===hb)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===eb)return e.BYTE;if(i===tb)return e.SHORT;if(i===ib)return e.UNSIGNED_SHORT;if(i===nb)return e.INT;if(i===rb)return e.UNSIGNED_INT;if(i===sb)return e.FLOAT;if(i===ob)return e.HALF_FLOAT;if(i===db)return e.ALPHA;if(i===pb)return e.RGB;if(i===fb)return e.RGBA;if(i===mb)return e.DEPTH_COMPONENT;if(i===gb)return e.DEPTH_STENCIL;if(i===_b)return e.RED;if(i===yb)return e.RED_INTEGER;if(i===vb)return e.RG;if(i===xb)return e.RG_INTEGER;if(i===bb)return e.RGBA_INTEGER;if(i===wb||i===Tb||i===Sb||i===Eb)if(s===_w){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===wb)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Tb)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Sb)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Eb)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===wb)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Tb)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Sb)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Eb)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Ab||i===Mb||i===Ib||i===Cb){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Ab)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Mb)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ib)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Cb)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Pb||i===Lb||i===Rb||i===Ob||i===Db||i===Bb||i===Fb){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===Pb||i===Lb)return s===_w?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Rb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ob)return r.COMPRESSED_R11_EAC;if(i===Db)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Bb)return r.COMPRESSED_RG11_EAC;if(i===Fb)return r.COMPRESSED_SIGNED_RG11_EAC}if(i===Nb||i===kb||i===zb||i===Ub||i===Vb||i===jb||i===Gb||i===Hb||i===Wb||i===qb||i===Xb||i===$b||i===Zb||i===Yb){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===Nb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===zb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ub)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Vb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Gb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Hb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Wb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===qb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Xb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===$b)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Zb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Yb)return s===_w?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===Jb||i===Kb||i===Qb){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(i===Jb)return s===_w?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Kb)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Qb)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===ew||i===tw||i===iw||i===nw){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===ew)return r.COMPRESSED_RED_RGTC1_EXT;if(i===tw)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===iw)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===nw)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===cb?e.UNSIGNED_INT_24_8:void 0!==e[i]?e[i]:null}}}class ED{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const i=new PM(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,i=new cC({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new iA(new XI(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class AD extends Hw{constructor(e,t){super();const i=this;let n=null,r=1,s=null,o="local-floor",a=1,l=null,c=null,u=null,h=null,d=null,p=null;const f="undefined"!=typeof XRWebGLBinding,m=new ED,g={},_=t.getContextAttributes();let y=null,v=null;const x=[],b=[],w=new iT;let T=null;const S=new uP;S.viewport=new TT;const E=new uP;E.viewport=new TT;const A=[S,E],M=new kP;let I=null,C=null;function P(e){const t=b.indexOf(e.inputSource);if(-1===t)return;const i=x[t];void 0!==i&&(i.update(e.inputSource,e.frame,l||s),i.dispatchEvent({type:e.type,data:e.inputSource}))}function L(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",L),n.removeEventListener("inputsourceschange",R);for(let e=0;e<x.length;e++){const t=b[e];null!==t&&(b[e]=null,x[e].disconnect(t))}I=null,C=null,m.reset();for(const e in g)delete g[e];e.setRenderTarget(y),d=null,h=null,u=null,n=null,v=null,N.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(w.width,w.height,!1),i.dispatchEvent({type:"sessionend"})}function R(e){for(let t=0;t<e.removed.length;t++){const i=e.removed[t],n=b.indexOf(i);n>=0&&(b[n]=null,x[n].disconnect(i))}for(let t=0;t<e.added.length;t++){const i=e.added[t];let n=b.indexOf(i);if(-1===n){for(let e=0;e<x.length;e++){if(e>=b.length){b.push(i),n=e;break}if(null===b[e]){b[e]=i,n=e;break}}if(-1===n)break}const r=x[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=x[e];return void 0===t&&(t=new rS,x[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=x[e];return void 0===t&&(t=new rS,x[e]=t),t.getGripSpace()},this.getHand=function(e){let t=x[e];return void 0===t&&(t=new rS,x[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===i.isPresenting&&Uw("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&Uw("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return null===u&&f&&(u=new XRWebGLBinding(n,t)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(c){if(n=c,null!==n){y=e.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",L),n.addEventListener("inputsourceschange",R),!0!==_.xrCompatible&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(w);if(f&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,i=_.stencil?gb:mb,s=_.stencil?cb:rb);const a={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:r};u=this.getBinding(),h=u.createProjectionLayer(a),n.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),v=new ET(h.textureWidth,h.textureHeight,{format:fb,type:Qx,depthTexture:new IM(h.textureWidth,h.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:!1===h.ignoreDepthValues,resolveStencilBuffer:!1===h.ignoreDepthValues})}else{d=new XRWebGLLayer(n,t,{antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:r}),n.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new ET(d.framebufferWidth,d.framebufferHeight,{format:fb,type:Qx,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}v.isXRRenderTarget=!0,this.setFoveation(a),l=null,s=await n.requestReferenceSpace(o),N.setContext(n),N.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const O=new rT,D=new rT;function B(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===n)return;let t=e.near,i=e.far;null!==m.texture&&(m.depthNear>0&&(t=m.depthNear),m.depthFar>0&&(i=m.depthFar)),M.near=E.near=S.near=t,M.far=E.far=S.far=i,I===M.near&&C===M.far||(n.updateRenderState({depthNear:M.near,depthFar:M.far}),I=M.near,C=M.far),M.layers.mask=6|e.layers.mask,S.layers.mask=-5&M.layers.mask,E.layers.mask=-3&M.layers.mask;const r=e.parent,s=M.cameras;B(M,r);for(let e=0;e<s.length;e++)B(s[e],r);2===s.length?function(e,t,i){O.setFromMatrixPosition(t.matrixWorld),D.setFromMatrixPosition(i.matrixWorld);const n=O.distanceTo(D),r=t.projectionMatrix.elements,s=i.projectionMatrix.elements,o=r[14]/(r[10]-1),a=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],h=(s[8]+1)/s[0],d=o*u,p=o*h,f=n/(-u+h),m=f*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=o+f,i=a+f;e.projectionMatrix.makePerspective(d-m,p+(n-m),l*a/i*t,c*a/i*t,t,i),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(M,S,E):M.projectionMatrix.copy(S.projectionMatrix),function(e,t,i){null===i?e.matrix.copy(t.matrixWorld):(e.matrix.copy(i.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*$w*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,M,r)},this.getCamera=function(){return M},this.getFoveation=function(){if(null!==h||null!==d)return a},this.setFoveation=function(e){a=e,null!==h&&(h.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(M)},this.getCameraTexture=function(e){return g[e]};let F=null;const N=new UL;N.setAnimationLoop(function(t,r){if(c=r.getViewerPose(l||s),p=r,null!==c){const t=c.views;null!==d&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let r=!1;t.length!==M.cameras.length&&(M.cameras.length=0,r=!0);for(let i=0;i<t.length;i++){const n=t[i];let s=null;if(null!==d)s=d.getViewport(n);else{const t=u.getViewSubImage(h,n);s=t.viewport,0===i&&(e.setRenderTargetTextures(v,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(v))}let o=A[i];void 0===o&&(o=new uP,o.layers.enable(i),o.viewport=new TT,A[i]=o),o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(n.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(s.x,s.y,s.width,s.height),0===i&&(M.matrix.copy(o.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),!0===r&&M.cameras.push(o)}const s=n.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&f){u=i.getBinding();const e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&m.init(e,n.renderState)}if(s&&s.includes("camera-access")&&f){e.state.unbindTexture(),u=i.getBinding();for(let e=0;e<t.length;e++){const i=t[e].camera;if(i){let e=g[i];e||(e=new PM,g[i]=e);const t=u.getCameraImage(i);e.sourceTexture=t}}}}for(let e=0;e<x.length;e++){const t=b[e],i=x[e];null!==t&&void 0!==i&&i.update(t,r,l||s)}F&&F(t,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(e){F=e},this.dispose=function(){}}}const MD=new kT,ID=new IT;function CD(e,t){function i(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function n(e,n){e.opacity.value=n.opacity,n.color&&e.diffuse.value.copy(n.color),n.emissive&&e.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(e.map.value=n.map,i(n.map,e.mapTransform)),n.alphaMap&&(e.alphaMap.value=n.alphaMap,i(n.alphaMap,e.alphaMapTransform)),n.bumpMap&&(e.bumpMap.value=n.bumpMap,i(n.bumpMap,e.bumpMapTransform),e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,i(n.normalMap,e.normalMapTransform),e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,i(n.displacementMap,e.displacementMapTransform),e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,e.emissiveMapTransform)),n.specularMap&&(e.specularMap.value=n.specularMap,i(n.specularMap,e.specularMapTransform)),n.alphaTest>0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n),s=r.envMap,o=r.envMapRotation;s&&(e.envMap.value=s,MD.copy(o),MD.x*=-1,MD.y*=-1,MD.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(MD.y*=-1,MD.z*=-1),e.envMapRotation.value.setFromMatrix4(ID.makeRotationFromEuler(MD)),e.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.ior.value=n.ior,e.refractionRatio.value=n.refractionRatio),n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,e.lightMapTransform)),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,i){i.color.getRGB(t.fogColor.value,aC(e)),i.isFog?(t.fogNear.value=i.near,t.fogFar.value=i.far):i.isFogExp2&&(t.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,r,s,o,a){r.isMeshBasicMaterial?n(e,r):r.isMeshLambertMaterial?(n(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(n(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(n(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(n(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,i(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,i(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,n){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,i(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,i(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,i(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,i(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,i(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,i(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,i(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,i(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,i(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,i(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,i(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,i(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,a)):r.isMeshMatcapMaterial?(n(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?n(e,r):r.isMeshDistanceMaterial?(n(e,r),function(e,i){const n=t.get(i).light;e.referencePosition.value.setFromMatrixPosition(n.matrixWorld),e.nearDistance.value=n.shadow.camera.near,e.farDistance.value=n.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?n(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,i(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map,i(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,i(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,o):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,i(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,i(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function PD(e,t,i,n){let r={},s={},o=[];const a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,i,n){const r=e.value,s=t+"_"+i;if(void 0===n[s])return n[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=n[s];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return n[s]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?Uw("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Uw("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const i=t.target;i.removeEventListener("dispose",u);const n=o.indexOf(i.__bindingPointIndex);o.splice(n,1),e.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(e,t){n.uniformBlockBinding(e,t.program)},update:function(i,h){let d=r[i.id];void 0===d&&(!function(e){const t=e.uniforms;let i=0;const n=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],s=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=s.length;e<r;e++){const r=c(s[e]),o=i%n,a=o%r.boundary,l=o+a;i+=a,0!==l&&n-l<r.storage&&(i+=n-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);e.__size=i,e.__cache={}}(i),d=function(t){const i=function(){for(let e=0;e<a;e++)if(-1===o.indexOf(e))return o.push(e),e;return Vw("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=i;const n=e.createBuffer(),r=t.__size,s=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,s),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=d,i.addEventListener("dispose",u)),n.updateUBOMapping(i,h.program);const p=t.render.frame;s[i.id]!==p&&(!function(t){const i=r[t.id],n=t.uniforms,s=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,i);for(let t=0,i=n.length;t<i;t++){const i=Array.isArray(n[t])?n[t]:[n[t]];for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!0===l(r,t,n,s)){const t=r.__offset,i=Array.isArray(r.value)?r.value:[r.value];let n=0;for(let s=0;s<i.length;s++){const o=i[s],a=c(o);"number"==typeof o||"boolean"==typeof o?(r.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+n,r.__data)):o.isMatrix3?(r.__data[0]=o.elements[0],r.__data[1]=o.elements[1],r.__data[2]=o.elements[2],r.__data[3]=0,r.__data[4]=o.elements[3],r.__data[5]=o.elements[4],r.__data[6]=o.elements[5],r.__data[7]=0,r.__data[8]=o.elements[6],r.__data[9]=o.elements[7],r.__data[10]=o.elements[8],r.__data[11]=0):(o.toArray(r.__data,n),n+=a.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(i),s[i.id]=p)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);o=[],r={},s={}}}}const LD=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let RD=null;class OD{constructor(e={}){const{canvas:t=Bw(),context:i=null,depth:n=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:h=!1,outputBufferType:d=Qx}=e;let p;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=s;const f=d,m=new Set([bb,xb,yb]),g=new Set([Qx,rb,ib,cb,ab,lb]),_=new Uint32Array(4),y=new Int32Array(4);let v=null,x=null;const b=[],w=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let E=!1;this._outputColorSpace=fw;let A=0,M=0,I=null,C=-1,P=null;const L=new TT,R=new TT;let O=null;const D=new cS(0);let B=0,F=t.width,N=t.height,k=1,z=null,U=null;const V=new TT(0,0,F,N),j=new TT(0,0,F,N);let G=!1;const H=new BA;let W=!1,q=!1;const X=new IT,$=new rT,Z=new TT,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let J=!1;function K(){return null===I?k:1}let Q,ee,te,ie,ne,re,se,oe,ae,le,ce,ue,he,de,pe,fe,me,ge,_e,ye,ve,xe,be,we=i;function Te(e,i){return t.getContext(e,i)}try{const e={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$v}`),t.addEventListener("webglcontextlost",Ae,!1),t.addEventListener("webglcontextrestored",Me,!1),t.addEventListener("webglcontextcreationerror",Ie,!1),null===we){const t="webgl2";if(we=Te(t,e),null===we)throw Te(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw Vw("WebGLRenderer: "+e.message),e}function Se(){Q=new _R(we),Q.init(),ve=new SD(we,Q),ee=new KL(we,Q,e,ve),te=new wD(we,Q),ee.reversedDepthBuffer&&h&&te.buffers.depth.setReversed(!0),ie=new xR(we),ne=new sD,re=new TD(we,Q,te,ne,ee,ve,ie),se=new gR(S),oe=new VL(we),xe=new YL(we,oe),ae=new yR(we,oe,ie,xe),le=new wR(we,ae,oe,xe,ie),ge=new bR(we,ee,re),pe=new QL(ne),ce=new rD(S,se,Q,ee,xe,pe),ue=new CD(S,ne),he=new cD,de=new mD(Q),me=new ZL(S,se,te,le,p,a),fe=new bD(S,le,ee),be=new PD(we,ie,ee,te),_e=new JL(we,Q,ie),ye=new vR(we,Q,ie),ie.programs=ce.programs,S.capabilities=ee,S.extensions=Q,S.properties=ne,S.renderLists=he,S.shadowMap=fe,S.state=te,S.info=ie}Se(),f!==Qx&&(T=new SR(f,t.width,t.height,n,r));const Ee=new AD(S,we);function Ae(e){e.preventDefault(),kw("WebGLRenderer: Context Lost."),E=!0}function Me(){kw("WebGLRenderer: Context Restored."),E=!1;const e=ie.autoReset,t=fe.enabled,i=fe.autoUpdate,n=fe.needsUpdate,r=fe.type;Se(),ie.autoReset=e,fe.enabled=t,fe.autoUpdate=i,fe.needsUpdate=n,fe.type=r}function Ie(e){Vw("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ce(e){const t=e.target;t.removeEventListener("dispose",Ce),function(e){(function(e){const t=ne.get(e).programs;void 0!==t&&(t.forEach(function(e){ce.releaseProgram(e)}),e.isShaderMaterial&&ce.releaseShaderCache(e))})(e),ne.remove(e)}(t)}function Pe(e,t,i){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Ue(e,t,i),e.side=0,e.needsUpdate=!0,Ue(e,t,i),e.side=2):Ue(e,t,i)}this.xr=Ee,this.getContext=function(){return we},this.getContextAttributes=function(){return we.getContextAttributes()},this.forceContextLoss=function(){const e=Q.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Q.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(e){void 0!==e&&(k=e,this.setSize(F,N,!1))},this.getSize=function(e){return e.set(F,N)},this.setSize=function(e,i,n=!0){Ee.isPresenting?Uw("WebGLRenderer: Can't change size while VR device is presenting."):(F=e,N=i,t.width=Math.floor(e*k),t.height=Math.floor(i*k),!0===n&&(t.style.width=e+"px",t.style.height=i+"px"),null!==T&&T.setSize(t.width,t.height),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return e.set(F*k,N*k).floor()},this.setDrawingBufferSize=function(e,i,n){F=e,N=i,k=n,t.width=Math.floor(e*n),t.height=Math.floor(i*n),this.setViewport(0,0,e,i)},this.setEffects=function(e){if(f!==Qx){if(e)for(let t=0;t<e.length&&!0!==e[t].isOutputPass;t++);T.setEffects(e||[])}},this.getCurrentViewport=function(e){return e.copy(L)},this.getViewport=function(e){return e.copy(V)},this.setViewport=function(e,t,i,n){e.isVector4?V.set(e.x,e.y,e.z,e.w):V.set(e,t,i,n),te.viewport(L.copy(V).multiplyScalar(k).round())},this.getScissor=function(e){return e.copy(j)},this.setScissor=function(e,t,i,n){e.isVector4?j.set(e.x,e.y,e.z,e.w):j.set(e,t,i,n),te.scissor(R.copy(j).multiplyScalar(k).round())},this.getScissorTest=function(){return G},this.setScissorTest=function(e){te.setScissorTest(G=e)},this.setOpaqueSort=function(e){z=e},this.setTransparentSort=function(e){U=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,i=!0){let n=0;if(e){let e=!1;if(null!==I){e=m.has(I.texture.format)}if(e){const e=g.has(I.texture.type),t=me.getClearColor(),i=me.getClearAlpha(),n=t.r,r=t.g,s=t.b;e?(_[0]=n,_[1]=r,_[2]=s,_[3]=i,we.clearBufferuiv(we.COLOR,0,_)):(y[0]=n,y[1]=r,y[2]=s,y[3]=i,we.clearBufferiv(we.COLOR,0,y))}else n|=we.COLOR_BUFFER_BIT}t&&(n|=we.DEPTH_BUFFER_BIT),i&&(n|=we.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==n&&we.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ae,!1),t.removeEventListener("webglcontextrestored",Me,!1),t.removeEventListener("webglcontextcreationerror",Ie,!1),me.dispose(),he.dispose(),de.dispose(),ne.dispose(),se.dispose(),le.dispose(),xe.dispose(),be.dispose(),ce.dispose(),Ee.dispose(),Ee.removeEventListener("sessionstart",Re),Ee.removeEventListener("sessionend",Oe),De.stop()},this.renderBufferDirect=function(e,t,i,n,r,s){null===t&&(t=Y);const o=r.isMesh&&r.matrixWorld.determinant()<0,a=function(e,t,i,n,r){!0!==t.isScene&&(t=Y);re.resetTextureUnits();const s=t.fog,o=n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial?t.environment:null,a=null===I?S.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:mw,l=n.isMeshStandardMaterial||n.isMeshLambertMaterial&&!n.envMap||n.isMeshPhongMaterial&&!n.envMap,c=se.get(n.envMap||o,l),u=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,h=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,f=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(m=S.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,_=void 0!==g?g.length:0,y=ne.get(n),v=x.state.lights;if(!0===W&&(!0===q||e!==P)){pe.setState(n,e,e===P&&n.id===C)}let b=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==v.state.version||y.outputColorSpace!==a||r.isBatchedMesh&&!1===y.batching?b=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?b=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?b=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==c||!0===n.fog&&y.fog!==s?b=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===pe.numPlanes&&y.numIntersection===pe.numIntersection?(y.vertexAlphas!==u||y.vertexTangents!==h||y.morphTargets!==d||y.morphNormals!==p||y.morphColors!==f||y.toneMapping!==m||y.morphTargetsCount!==_)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,y.__version=n.version);let w=y.currentProgram;!0===b&&(w=Ue(n,t,r));let T=!1,E=!1,A=!1;const M=w.getUniforms(),L=y.uniforms;te.useProgram(w.program)&&(T=!0,E=!0,A=!0);n.id!==C&&(C=n.id,E=!0);if(T||P!==e){te.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),M.setValue(we,"projectionMatrix",e.projectionMatrix),M.setValue(we,"viewMatrix",e.matrixWorldInverse);const t=M.map.cameraPosition;void 0!==t&&t.setValue(we,$.setFromMatrixPosition(e.matrixWorld)),ee.logarithmicDepthBuffer&&M.setValue(we,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&M.setValue(we,"isOrthographic",!0===e.isOrthographicCamera),P!==e&&(P=e,E=!0,A=!0)}y.needsLights&&(v.state.directionalShadowMap.length>0&&M.setValue(we,"directionalShadowMap",v.state.directionalShadowMap,re),v.state.spotShadowMap.length>0&&M.setValue(we,"spotShadowMap",v.state.spotShadowMap,re),v.state.pointShadowMap.length>0&&M.setValue(we,"pointShadowMap",v.state.pointShadowMap,re));if(r.isSkinnedMesh){M.setOptional(we,r,"bindMatrix"),M.setOptional(we,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),M.setValue(we,"boneTexture",e.boneTexture,re))}r.isBatchedMesh&&(M.setOptional(we,r,"batchingTexture"),M.setValue(we,"batchingTexture",r._matricesTexture,re),M.setOptional(we,r,"batchingIdTexture"),M.setValue(we,"batchingIdTexture",r._indirectTexture,re),M.setOptional(we,r,"batchingColorTexture"),null!==r._colorsTexture&&M.setValue(we,"batchingColorTexture",r._colorsTexture,re));const R=i.morphAttributes;void 0===R.position&&void 0===R.normal&&void 0===R.color||ge.update(r,i,w);(E||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,M.setValue(we,"receiveShadow",r.receiveShadow));(n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial)&&null===n.envMap&&null!==t.environment&&(L.envMapIntensity.value=t.environmentIntensity);void 0!==L.dfgLUT&&(L.dfgLUT.value=(null===RD&&(RD=new mA(LD,16,16,vb,ob),RD.name="DFG_LUT",RD.minFilter=Yx,RD.magFilter=Yx,RD.wrapS=Wx,RD.wrapT=Wx,RD.generateMipmaps=!1,RD.needsUpdate=!0),RD));E&&(M.setValue(we,"toneMappingExposure",S.toneMappingExposure),y.needsLights&&((O=L).ambientLightColor.needsUpdate=D=A,O.lightProbe.needsUpdate=D,O.directionalLights.needsUpdate=D,O.directionalLightShadows.needsUpdate=D,O.pointLights.needsUpdate=D,O.pointLightShadows.needsUpdate=D,O.spotLights.needsUpdate=D,O.spotLightShadows.needsUpdate=D,O.rectAreaLights.needsUpdate=D,O.hemisphereLights.needsUpdate=D),s&&!0===n.fog&&ue.refreshFogUniforms(L,s),ue.refreshMaterialUniforms(L,n,k,N,x.state.transmissionRenderTarget[e.id]),CO.upload(we,Ve(y),L,re));var O,D;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(CO.upload(we,Ve(y),L,re),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&M.setValue(we,"center",r.center);if(M.setValue(we,"modelViewMatrix",r.modelViewMatrix),M.setValue(we,"normalMatrix",r.normalMatrix),M.setValue(we,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const e=n.uniformsGroups;for(let t=0,i=e.length;t<i;t++){const i=e[t];be.update(i,w),be.bind(i,w)}}return w}(e,t,i,n,r);te.setMaterial(n,o);let l=i.index,c=1;if(!0===n.wireframe){if(l=ae.getWireframeAttribute(i),void 0===l)return;c=2}const u=i.drawRange,h=i.attributes.position;let d=u.start*c,p=(u.start+u.count)*c;null!==s&&(d=Math.max(d,s.start*c),p=Math.min(p,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=h&&(d=Math.max(d,0),p=Math.min(p,h.count));const f=p-d;if(f<0||f===1/0)return;let m;xe.setup(r,n,a,i,l);let g=_e;if(null!==l&&(m=oe.get(l),g=ye,g.setIndex(m)),r.isMesh)!0===n.wireframe?(te.setLineWidth(n.wireframeLinewidth*K()),g.setMode(we.LINES)):g.setMode(we.TRIANGLES);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),te.setLineWidth(e*K()),g.setMode(r.isLineSegments?we.LINES:r.isLineLoop?we.LINE_LOOP:we.LINE_STRIP)}else r.isPoints?g.setMode(we.POINTS):r.isSprite&&g.setMode(we.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)jw("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,i=r._multiDrawCount,s=l?oe.get(l).bytesPerElement:1,o=ne.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)o.setValue(we,"_gl_DrawID",n),g.render(e[n]/s,t[n])}else if(r.isInstancedMesh)g.renderInstances(d,f,r.count);else if(i.isInstancedBufferGeometry){const e=Math.min(i.instanceCount,void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0);g.renderInstances(d,f,e)}else g.render(d,f)},this.compile=function(e,t,i=null){null===i&&(i=e),x=de.get(i),x.init(t),w.push(x),i.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==i&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights();const n=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const s=t[r];Pe(s,i,e),n.add(s)}else Pe(t,i,e),n.add(t)}),x=w.pop(),n},this.compileAsync=function(e,t,i=null){const n=this.compile(e,t,i);return new Promise(t=>{function i(){n.forEach(function(e){ne.get(e).currentProgram.isReady()&&n.delete(e)}),0!==n.size?setTimeout(i,10):t(e)}null!==Q.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let Le=null;function Re(){De.stop()}function Oe(){De.start()}const De=new UL;function Be(e,t,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||H.intersectsSprite(e)){n&&Z.setFromMatrixPosition(e.matrixWorld).applyMatrix4(X);const t=le.update(e),r=e.material;r.visible&&v.push(e,t,r,i,Z.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||H.intersectsObject(e))){const t=le.update(e),r=e.material;if(n&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),Z.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),Z.copy(t.boundingSphere.center)),Z.applyMatrix4(e.matrixWorld).applyMatrix4(X)),Array.isArray(r)){const n=t.groups;for(let s=0,o=n.length;s<o;s++){const o=n[s],a=r[o.materialIndex];a&&a.visible&&v.push(e,t,a,i,Z.z,o)}}else r.visible&&v.push(e,t,r,i,Z.z,null)}const r=e.children;for(let e=0,s=r.length;e<s;e++)Be(r[e],t,i,n)}function Fe(e,t,i,n){const{opaque:r,transmissive:s,transparent:o}=e;x.setupLightsView(i),!0===W&&pe.setGlobalState(S.clippingPlanes,i),n&&te.viewport(L.copy(n)),r.length>0&&ke(r,t,i),s.length>0&&ke(s,t,i),o.length>0&&ke(o,t,i),te.buffers.depth.setTest(!0),te.buffers.depth.setMask(!0),te.buffers.color.setMask(!0),te.setPolygonOffset(!1)}function Ne(e,t,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;if(void 0===x.state.transmissionRenderTarget[n.id]){const e=Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float");x.state.transmissionRenderTarget[n.id]=new ET(1,1,{generateMipmaps:!0,type:e?ob:Qx,minFilter:Kx,samples:Math.max(4,ee.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:dT.workingColorSpace})}const s=x.state.transmissionRenderTarget[n.id],o=n.viewport||L;s.setSize(o.z*S.transmissionResolutionScale,o.w*S.transmissionResolutionScale);const a=S.getRenderTarget(),l=S.getActiveCubeFace(),c=S.getActiveMipmapLevel();S.setRenderTarget(s),S.getClearColor(D),B=S.getClearAlpha(),B<1&&S.setClearColor(16777215,.5),S.clear(),J&&me.render(i);const u=S.toneMapping;S.toneMapping=0;const h=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),x.setupLightsView(n),!0===W&&pe.setGlobalState(S.clippingPlanes,n),ke(e,i,n),re.updateMultisampleRenderTarget(s),re.updateRenderTargetMipmap(s),!1===Q.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,s=t.length;r<s;r++){const s=t[r],{object:o,geometry:a,material:l,group:c}=s;if(2===l.side&&o.layers.test(n.layers)){const t=l.side;l.side=1,l.needsUpdate=!0,ze(o,i,n,a,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(re.updateMultisampleRenderTarget(s),re.updateRenderTargetMipmap(s))}S.setRenderTarget(a,l,c),S.setClearColor(D,B),void 0!==h&&(n.viewport=h),S.toneMapping=u}function ke(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r<s;r++){const s=e[r],{object:o,geometry:a,group:l}=s;let c=s.material;!0===c.allowOverride&&null!==n&&(c=n),o.layers.test(i.layers)&&ze(o,t,i,a,c,l)}}function ze(e,t,i,n,r,s){e.onBeforeRender(S,t,i,n,r,s),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(S,t,i,n,e,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,S.renderBufferDirect(i,t,n,r,e,s),r.side=0,r.needsUpdate=!0,S.renderBufferDirect(i,t,n,r,e,s),r.side=2):S.renderBufferDirect(i,t,n,r,e,s),e.onAfterRender(S,t,i,n,r,s)}function Ue(e,t,i){!0!==t.isScene&&(t=Y);const n=ne.get(e),r=x.state.lights,s=r.state.version,o=ce.getParameters(e,r.state,x.state.shadowsArray,t,i),a=ce.getProgramCacheKey(o);let l=n.programs;n.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,n.fog=t.fog;n.envMap=se.get(e.envMap||n.environment,e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap),n.envMapRotation=null!==n.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===l&&(e.addEventListener("dispose",Ce),l=new Map,n.programs=l);let c=l.get(a);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===s)return je(e,o),c}else o.uniforms=ce.getUniforms(e),e.onBeforeCompile(o,S),c=ce.acquireProgram(o,a),l.set(a,c),n.uniforms=o.uniforms;const u=n.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=pe.uniform),je(e,o),n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=s,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function Ve(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=CO.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function je(e,t){const i=ne.get(e);i.outputColorSpace=t.outputColorSpace,i.batching=t.batching,i.batchingColor=t.batchingColor,i.instancing=t.instancing,i.instancingColor=t.instancingColor,i.instancingMorph=t.instancingMorph,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.morphColors=t.morphColors,i.morphTargetsCount=t.morphTargetsCount,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents,i.toneMapping=t.toneMapping}De.setAnimationLoop(function(e){Le&&Le(e)}),"undefined"!=typeof self&&De.setContext(self),this.setAnimationLoop=function(e){Le=e,Ee.setAnimationLoop(e),null===e?De.stop():De.start()},Ee.addEventListener("sessionstart",Re),Ee.addEventListener("sessionend",Oe),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void Vw("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===E)return;const i=null!==T&&(null===I||!0===Ee.enabled&&!0===Ee.isPresenting)&&T.begin(S,I);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0!==Ee.enabled||!0!==Ee.isPresenting||null!==T&&!1!==T.isCompositing()||(!0===Ee.cameraAutoUpdate&&Ee.updateCamera(t),t=Ee.getCamera()),!0===e.isScene&&e.onBeforeRender(S,e,t,I),x=de.get(e,w.length),x.init(t),w.push(x),X.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),H.setFromProjectionMatrix(X,Cw,t.reversedDepth),q=this.localClippingEnabled,W=pe.init(this.clippingPlanes,q),v=he.get(e,b.length),v.init(),b.push(v),!0===Ee.enabled&&!0===Ee.isPresenting){const e=S.xr.getDepthSensingMesh();null!==e&&Be(e,t,-1/0,S.sortObjects)}Be(e,t,0,S.sortObjects),v.finish(),!0===S.sortObjects&&v.sort(z,U),J=!1===Ee.enabled||!1===Ee.isPresenting||!1===Ee.hasDepthSensing(),J&&me.addToRenderList(v,e),this.info.render.frame++,!0===W&&pe.beginShadows();fe.render(x.state.shadowsArray,e,t),!0===W&&pe.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(i&&T.hasRenderPass())){const i=v.opaque,n=v.transmissive;if(x.setupLights(),t.isArrayCamera){const r=t.cameras;if(n.length>0)for(let t=0,s=r.length;t<s;t++){Ne(i,n,e,r[t])}J&&me.render(e);for(let t=0,i=r.length;t<i;t++){const i=r[t];Fe(v,e,i,i.viewport)}}else n.length>0&&Ne(i,n,e,t),J&&me.render(e),Fe(v,e,t)}null!==I&&0===M&&(re.updateMultisampleRenderTarget(I),re.updateRenderTargetMipmap(I)),i&&T.end(S),!0===e.isScene&&e.onAfterRender(S,e,t),xe.resetDefaultState(),C=-1,P=null,w.pop(),w.length>0?(x=w[w.length-1],!0===W&&pe.setGlobalState(S.clippingPlanes,x.state.camera)):x=null,b.pop(),v=b.length>0?b[b.length-1]:null},this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(e,t,i){const n=ne.get(e);n.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const i=ne.get(e);i.__webglFramebuffer=t,i.__useDefaultFramebuffer=void 0===t};const Ge=we.createFramebuffer();this.setRenderTarget=function(e,t=0,i=0){I=e,A=t,M=i;let n=null,r=!1,s=!1;if(e){const o=ne.get(e);if(void 0!==o.__useDefaultFramebuffer)return te.bindFramebuffer(we.FRAMEBUFFER,o.__webglFramebuffer),L.copy(e.viewport),R.copy(e.scissor),O=e.scissorTest,te.viewport(L),te.scissor(R),te.setScissorTest(O),void(C=-1);if(void 0===o.__webglFramebuffer)re.setupRenderTarget(e);else if(o.__hasExternalTextures)re.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&ne.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");re.setupDepthRenderbuffer(e)}}const a=e.texture;(a.isData3DTexture||a.isDataArrayTexture||a.isCompressedArrayTexture)&&(s=!0);const l=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=Array.isArray(l[t])?l[t][i]:l[t],r=!0):n=e.samples>0&&!1===re.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,L.copy(e.viewport),R.copy(e.scissor),O=e.scissorTest}else L.copy(V).multiplyScalar(k).floor(),R.copy(j).multiplyScalar(k).floor(),O=G;0!==i&&(n=Ge);if(te.bindFramebuffer(we.FRAMEBUFFER,n)&&te.drawBuffers(e,n),te.viewport(L),te.scissor(R),te.setScissorTest(O),r){const n=ne.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_CUBE_MAP_POSITIVE_X+t,n.__webglTexture,i)}else if(s){const n=t;for(let t=0;t<e.textures.length;t++){const r=ne.get(e.textures[t]);we.framebufferTextureLayer(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0+t,r.__webglTexture,i,n)}}else if(null!==e&&0!==i){const t=ne.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,t.__webglTexture,i)}C=-1},this.readRenderTargetPixels=function(e,t,i,n,r,s,o,a=0){if(!e||!e.isWebGLRenderTarget)return void Vw("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){te.bindFramebuffer(we.FRAMEBUFFER,l);try{const o=e.textures[a],l=o.format,c=o.type;if(e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+a),!ee.textureFormatReadable(l))return void Vw("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(c))return void Vw("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&we.readPixels(t,i,n,r,ve.convert(l),ve.convert(c),s)}finally{const e=null!==I?ne.get(I).__webglFramebuffer:null;te.bindFramebuffer(we.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,i,n,r,s,o,a=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){if(t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r){te.bindFramebuffer(we.FRAMEBUFFER,l);const o=e.textures[a],c=o.format,u=o.type;if(e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+a),!ee.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const h=we.createBuffer();we.bindBuffer(we.PIXEL_PACK_BUFFER,h),we.bufferData(we.PIXEL_PACK_BUFFER,s.byteLength,we.STREAM_READ),we.readPixels(t,i,n,r,ve.convert(c),ve.convert(u),0);const d=null!==I?ne.get(I).__webglFramebuffer:null;te.bindFramebuffer(we.FRAMEBUFFER,d);const p=we.fenceSync(we.SYNC_GPU_COMMANDS_COMPLETE,0);return we.flush(),await function(e,t,i){return new Promise(function(n,r){setTimeout(function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}},i)})}(we,p,4),we.bindBuffer(we.PIXEL_PACK_BUFFER,h),we.getBufferSubData(we.PIXEL_PACK_BUFFER,0,s),we.deleteBuffer(h),we.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),s=Math.floor(e.image.height*n),o=null!==t?t.x:0,a=null!==t?t.y:0;re.setTexture2D(e,0),we.copyTexSubImage2D(we.TEXTURE_2D,i,0,0,o,a,r,s),te.unbindTexture()};const He=we.createFramebuffer(),We=we.createFramebuffer();this.copyTextureToTexture=function(e,t,i=null,n=null,r=0,s=0){let o,a,l,c,u,h,d,p,f;const m=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==i)o=i.max.x-i.min.x,a=i.max.y-i.min.y,l=i.isBox3?i.max.z-i.min.z:1,c=i.min.x,u=i.min.y,h=i.isBox3?i.min.z:0;else{const t=Math.pow(2,-r);o=Math.floor(m.width*t),a=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,u=0,h=0}null!==n?(d=n.x,p=n.y,f=n.z):(d=0,p=0,f=0);const g=ve.convert(t.format),_=ve.convert(t.type);let y;t.isData3DTexture?(re.setTexture3D(t,0),y=we.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(re.setTexture2DArray(t,0),y=we.TEXTURE_2D_ARRAY):(re.setTexture2D(t,0),y=we.TEXTURE_2D),we.pixelStorei(we.UNPACK_FLIP_Y_WEBGL,t.flipY),we.pixelStorei(we.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),we.pixelStorei(we.UNPACK_ALIGNMENT,t.unpackAlignment);const v=we.getParameter(we.UNPACK_ROW_LENGTH),x=we.getParameter(we.UNPACK_IMAGE_HEIGHT),b=we.getParameter(we.UNPACK_SKIP_PIXELS),w=we.getParameter(we.UNPACK_SKIP_ROWS),T=we.getParameter(we.UNPACK_SKIP_IMAGES);we.pixelStorei(we.UNPACK_ROW_LENGTH,m.width),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,m.height),we.pixelStorei(we.UNPACK_SKIP_PIXELS,c),we.pixelStorei(we.UNPACK_SKIP_ROWS,u),we.pixelStorei(we.UNPACK_SKIP_IMAGES,h);const S=e.isDataArrayTexture||e.isData3DTexture,E=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const i=ne.get(e),n=ne.get(t),m=ne.get(i.__renderTarget),g=ne.get(n.__renderTarget);te.bindFramebuffer(we.READ_FRAMEBUFFER,m.__webglFramebuffer),te.bindFramebuffer(we.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<l;i++)S&&(we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,ne.get(e).__webglTexture,r,h+i),we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,ne.get(t).__webglTexture,s,f+i)),we.blitFramebuffer(c,u,o,a,d,p,o,a,we.DEPTH_BUFFER_BIT,we.NEAREST);te.bindFramebuffer(we.READ_FRAMEBUFFER,null),te.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||ne.has(e)){const i=ne.get(e),n=ne.get(t);te.bindFramebuffer(we.READ_FRAMEBUFFER,He),te.bindFramebuffer(we.DRAW_FRAMEBUFFER,We);for(let e=0;e<l;e++)S?we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,i.__webglTexture,r,h+e):we.framebufferTexture2D(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,i.__webglTexture,r),E?we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,n.__webglTexture,s,f+e):we.framebufferTexture2D(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,n.__webglTexture,s),0!==r?we.blitFramebuffer(c,u,o,a,d,p,o,a,we.COLOR_BUFFER_BIT,we.NEAREST):E?we.copyTexSubImage3D(y,s,d,p,f+e,c,u,o,a):we.copyTexSubImage2D(y,s,d,p,c,u,o,a);te.bindFramebuffer(we.READ_FRAMEBUFFER,null),te.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else E?e.isDataTexture||e.isData3DTexture?we.texSubImage3D(y,s,d,p,f,o,a,l,g,_,m.data):t.isCompressedArrayTexture?we.compressedTexSubImage3D(y,s,d,p,f,o,a,l,g,m.data):we.texSubImage3D(y,s,d,p,f,o,a,l,g,_,m):e.isDataTexture?we.texSubImage2D(we.TEXTURE_2D,s,d,p,o,a,g,_,m.data):e.isCompressedTexture?we.compressedTexSubImage2D(we.TEXTURE_2D,s,d,p,m.width,m.height,g,m.data):we.texSubImage2D(we.TEXTURE_2D,s,d,p,o,a,g,_,m);we.pixelStorei(we.UNPACK_ROW_LENGTH,v),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,x),we.pixelStorei(we.UNPACK_SKIP_PIXELS,b),we.pixelStorei(we.UNPACK_SKIP_ROWS,w),we.pixelStorei(we.UNPACK_SKIP_IMAGES,T),0===s&&t.generateMipmaps&&we.generateMipmap(y),te.unbindTexture()},this.initRenderTarget=function(e){void 0===ne.get(e).__webglFramebuffer&&re.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?re.setTextureCube(e,0):e.isData3DTexture?re.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?re.setTexture2DArray(e,0):re.setTexture2D(e,0),te.unbindTexture()},this.resetState=function(){A=0,M=0,I=null,te.reset(),xe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cw}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=dT._getDrawingBufferColorSpace(e),t.unpackColorSpace=dT._getUnpackColorSpace()}}var DD=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:ex,AddOperation:2,AdditiveAnimationBlendMode:dw,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:db,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:yP,AnimationAction:sL,AnimationClip:kC,AnimationLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new XC(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):Vw(t),r.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=kC.parse(e[i]);t.push(n)}return t}},AnimationMixer:class extends Hw{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,s=e._propertyBindings,o=e._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=c);for(let e=0;e!==r;++e){const r=n[e],l=r.name;let u=c[l];if(void 0!==u)++u.referenceCount,s[e]=u;else{if(u=s[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,l));continue}u=new JP(rL.create(i,l,t&&t._propertyBindings[e].binding.parsedPath),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,l),s[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let s=r[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=n.length,n.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,l=a[a.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,a[c]=l,a.pop(),e._byClipCacheIndex=null;delete o.actionByRoot[(e._localRoot||this._root).uuid],0===a.length&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[t];void 0===s&&(s={},n[t]=s),s[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[n],a=t[t.length-1],l=e._cacheIndex;a._cacheIndex=l,t[l]=a,t.pop(),delete o[r],0===Object.keys(o).length&&delete s[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&(i=new MC(new Float32Array(2),new Float32Array(2),1,oL),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let s="string"==typeof e?kC.findByName(n,e):e;const o=null!==s?s.uuid:e,a=this._actionsByClip[o];let l=null;if(void 0===i&&(i=null!==s?s.blendMode:hw),void 0!==a){const e=a.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;l=a.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const c=new sL(this,s,t,i);return this._bindAction(c,l),this._addInactiveAction(c,o,r),c}existingAction(e,t){const i=t||this._root,n=i.uuid,r="string"==typeof e?kC.findByName(i,e):e,s=this._actionsByClip[r?r.uuid:e];return void 0!==s&&s.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){const t=this._actions,i=this._nActiveActions,n=this.time+=e*=this.timeScale,r=Math.sign(e),s=this._accuIndex^=1;for(let o=0;o!==i;++o){t[o]._update(n,e,r,s)}const o=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)o[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){const n=e[i];this._deactivateAction(n);const r=n._cacheIndex,s=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,t[r]=s,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const e in i){const n=i[e].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){const t=n[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Zw(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let o,a=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],h=u.uuid;let d=t[h];if(void 0===d){d=a++,t[h]=d,e.push(u);for(let e=0,t=s;e!==t;++e)r[e].push(new rL(u,i[e],n[e]))}else if(d<l){o=e[d];const a=--l,c=e[a];t[c.uuid]=d,e[d]=c,t[h]=a,e[a]=u;for(let e=0,t=s;e!==t;++e){const t=r[e];let s=t[d];t[d]=t[a],void 0===s&&(s=new rL(u,i[e],n[e])),t[a]=s}}else e[d]!==o&&Vw("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s],a=o.uuid,l=t[a];if(void 0!==l&&l>=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[a]=s,e[s]=o;for(let e=0,t=n;e!==t;++e){const t=i[e],n=t[l];t[l]=t[s],t[s]=n}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=e.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,l=t[a];if(void 0!==l)if(delete t[a],l<r){const o=--r,a=e[o],c=--s,u=e[c];t[a.uuid]=l,e[l]=a,t[u.uuid]=o,e[o]=u,e.pop();for(let e=0,t=n;e!==t;++e){const t=i[e],n=t[c];t[l]=t[o],t[o]=n,t.pop()}}else{const r=--s,o=e[r];r>0&&(t[o.uuid]=l),e[l]=o,e.pop();for(let e=0,t=n;e!==t;++e){const t=i[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,o=this._parsedPaths,a=this._objects,l=this.nCachedObjects_,c=new Array(a.length);n=r.length,i[e]=n,s.push(e),o.push(t),r.push(c);for(let i=l,n=a.length;i!==n;++i){c[i]=new rL(a[i],e,t)}return c}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o];t[e[o]]=i,s[i]=a,s.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}},AnimationUtils:class{static convertArray(e,t){return bC(e,t)}static isTypedArray(e){return Ow(e)}static getKeyframeOrder(e){return wC(e)}static sortedArray(e,t,i){return TC(e,t,i)}static flattenJSON(e,t,i,n){SC(e,t,i,n)}static subclip(e,t,i,n,r=30){return function(e,t,i,n,r=30){const s=e.clone();s.name=t;const o=[];for(let e=0;e<s.tracks.length;++e){const t=s.tracks[e],a=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const s=t.times[e]*r;if(!(s<i||s>=n)){l.push(t.times[e]);for(let i=0;i<a;++i)c.push(t.values[e*a+i])}}0!==l.length&&(t.times=bC(l,t.times.constructor),t.values=bC(c,t.values.constructor),o.push(t))}s.tracks=o;let a=1/0;for(let e=0;e<s.tracks.length;++e)a>s.tracks[e].times[0]&&(a=s.tracks[e].times[0]);for(let e=0;e<s.tracks.length;++e)s.tracks[e].shift(-1*a);return s.resetDuration(),s}(e,t,i,n,r)}static makeClipAdditive(e,t=0,i=e,n=30){return function(e,t=0,i=e,n=30){n<=0&&(n=30);const r=i.tracks.length,s=t/n;for(let t=0;t<r;++t){const n=i.tracks[t],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const o=e.tracks.find(function(e){return e.name===n.name&&e.ValueTypeName===r});if(void 0===o)continue;let a=0;const l=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=l/3);let c=0;const u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const h=n.times.length-1;let d;if(s<=n.times[0])d=n.values.slice(a,l-a);else if(s>=n.times[h]){const e=h*l+a;d=n.values.slice(e,e+l-a)}else{const e=n.createInterpolant(),t=a,i=l-a;e.evaluate(s),d=e.resultBuffer.slice(t,i)}"quaternion"===r&&(new nT).fromArray(d).normalize().conjugate().toArray(d);const p=o.times.length;for(let e=0;e<p;++e){const t=e*u+c;if("quaternion"===r)nT.multiplyQuaternionsFlat(o.values,t,d,0,o.values,t);else{const e=u-2*c;for(let i=0;i<e;++i)o.values[t+i]-=d[i]}}}return e.blendMode=dw,e}(e,t,i,n)}},ArcCurve:WM,ArrayCamera:kP,ArrowHelper:class extends tS{constructor(e=new rT(0,0,1),t=new rT(0,0,0),i=1,n=16776960,r=.2*i,s=.2*r){super(),this.type="ArrowHelper",void 0===NL&&(NL=new hE,NL.setAttribute("position",new QS([0,0,0,0,1,0],3)),kL=new BM(.5,1,5,1),kL.translate(0,-.5,0)),this.position.copy(t),this.line=new dM(NL,new rM({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new iA(kL,new HE({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,s)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{FL.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(FL,t)}}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:Fx,Audio:qP,AudioAnalyser:class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},AudioContext:RP,AudioListener:class extends tS{constructor(){super(),this.type="AudioListener",this.context=RP.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new zP}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(VP,jP,GP),HP.set(0,0,-1).applyQuaternion(jP),WP.set(0,1,0).applyQuaternion(jP),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(VP.x,e),t.positionY.linearRampToValueAtTime(VP.y,e),t.positionZ.linearRampToValueAtTime(VP.z,e),t.forwardX.linearRampToValueAtTime(HP.x,e),t.forwardY.linearRampToValueAtTime(HP.y,e),t.forwardZ.linearRampToValueAtTime(HP.z,e),t.upX.linearRampToValueAtTime(WP.x,e),t.upY.linearRampToValueAtTime(WP.y,e),t.upZ.linearRampToValueAtTime(WP.z,e)}else t.setPosition(VP.x,VP.y,VP.z),t.setOrientation(HP.x,HP.y,HP.z,WP.x,WP.y,WP.z)}},AudioLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new XC(this.manager);function o(t){n?n(t):Vw(t),r.manager.itemError(e)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(e){try{const i=e.slice(0);RP.getContext().decodeAudioData(i,function(e){t(e)}).catch(o)}catch(e){o(e)}},i,n)}},AxesHelper:class extends gM{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new hE;i.setAttribute("position",new QS(t,3)),i.setAttribute("color",new QS([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new rM({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){const n=new cS,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:nM,BezierInterpolant:CC,Bone:fA,BooleanKeyframeTrack:LC,Box2:class{constructor(e=new iT(1/0,1/0),t=new iT(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=pL.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,pL).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Box3:IS,Box3Helper:class extends gM{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new hE;n.setIndex(new YS(i,1)),n.setAttribute("position",new QS([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new rM({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:LM,BoxHelper:class extends gM{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new hE;r.setIndex(new YS(i,1)),r.setAttribute("position",new YS(n,3)),super(r,new rM({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&BL.setFromObject(this.object),BL.isEmpty())return;const e=BL.min,t=BL.max,i=this.geometry.attributes.position,n=i.array;n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=e.x,n[4]=t.y,n[5]=t.z,n[6]=e.x,n[7]=e.y,n[8]=t.z,n[9]=t.x,n[10]=e.y,n[11]=t.z,n[12]=t.x,n[13]=t.y,n[14]=e.z,n[15]=e.x,n[16]=t.y,n[17]=e.z,n[18]=e.x,n[19]=e.y,n[20]=e.z,n[21]=t.x,n[22]=e.y,n[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:YS,BufferGeometry:hE,BufferGeometryLoader:EP,ByteType:eb,Cache:UC,Camera:oP,CameraHelper:class extends gM{constructor(e){const t=new hE,i=new rM({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],s={};function o(e,t){a(e),a(t)}function a(e){n.push(0,0,0),r.push(0,0,0),void 0===s[e]&&(s[e]=[]),s[e].push(n.length/3-1)}o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4"),t.setAttribute("position",new QS(n,3)),t.setAttribute("color",new QS(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new cS(16755200),c=new cS(16711680),u=new cS(43775),h=new cS(16777215),d=new cS(3355443);this.setColors(l,c,u,h,d)}setColors(e,t,i,n,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,n.r,n.g,n.b),s.setXYZ(39,n.r,n.g,n.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap;let i,n;if(OL.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===Cw)i=-1,n=1;else{if(this.camera.coordinateSystem!==Pw)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}DL("c",t,e,OL,0,0,i),DL("t",t,e,OL,0,0,n),DL("n1",t,e,OL,-1,-1,i),DL("n2",t,e,OL,1,-1,i),DL("n3",t,e,OL,-1,1,i),DL("n4",t,e,OL,1,1,i),DL("f1",t,e,OL,-1,-1,n),DL("f2",t,e,OL,1,-1,n),DL("f3",t,e,OL,-1,1,n),DL("f4",t,e,OL,1,1,n),DL("u1",t,e,OL,.7,1.1,i),DL("u2",t,e,OL,-.7,1.1,i),DL("u3",t,e,OL,0,2,i),DL("cf1",t,e,OL,-1,0,n),DL("cf2",t,e,OL,1,0,n),DL("cf3",t,e,OL,0,-1,n),DL("cf4",t,e,OL,0,1,n),DL("cn1",t,e,OL,-1,0,i),DL("cn2",t,e,OL,1,0,i),DL("cn3",t,e,OL,0,-1,i),DL("cn4",t,e,OL,0,1,i),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends wT{constructor(e,t,i,n,r,s,o,a,l){super(e,t,i,n,r,s,o,a,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:RM,CatmullRomCurve3:JM,CineonToneMapping:3,CircleGeometry:OM,ClampToEdgeWrapping:Wx,Clock:class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Uw("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},Color:cS,ColorKeyframeTrack:RC,ColorManagement:dT,Compatibility:{TEXTURE_COMPARE:"depthTextureCompare"},CompressedArrayTexture:class extends AM{constructor(e,t,i,n,r,s){super(e,t,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=Wx,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends AM{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,zx),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},CompressedTexture:AM,CompressedTextureLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=[],o=new AM,a=new XC(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function c(c){a.load(e[c],function(e){const i=r.parse(e,!0);s[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(o.minFilter=Yx),o.image=s,o.format=i.format,o.needsUpdate=!0,t&&t(o))},i,n)}if(Array.isArray(e))for(let t=0,i=e.length;t<i;++t)c(t);else a.load(e,function(e){const i=r.parse(e,!0);if(i.isCubemap){const e=i.mipmaps.length/i.mipmapCount;for(let t=0;t<e;t++){s[t]={mipmaps:[]};for(let e=0;e<i.mipmapCount;e++)s[t].mipmaps.push(i.mipmaps[t*i.mipmapCount+e]),s[t].format=i.format,s[t].width=i.width,s[t].height=i.height}o.image=s}else o.image.width=i.width,o.image.height=i.height,o.mipmaps=i.mipmaps;1===i.mipmapCount&&(o.minFilter=Yx),o.format=i.format,o.needsUpdate=!0,t&&t(o)},i,n);return o}},ConeGeometry:BM,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:class extends Hw{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){void 0!==e?(null!==this.domElement&&this.disconnect(),this.domElement=e):Uw("Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}},CubeCamera:NP,CubeDepthTexture:CM,CubeReflectionMapping:zx,CubeRefractionMapping:Ux,CubeTexture:MM,CubeTextureLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=new MM;r.colorSpace=fw;const s=new ZC(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function a(i){s.load(e[i],function(e){r.images[i]=e,o++,6===o&&(r.needsUpdate=!0,t&&t(r))},void 0,n)}for(let t=0;t<e.length;++t)a(t);return r}},CubeUVReflectionMapping:Gx,CubicBezierCurve:tI,CubicBezierCurve3:iI,CubicInterpolant:AC,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:GM,CurvePath:cI,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:DM,Cylindrical:class{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:MT,DataArrayTexture:AT,DataTexture:mA,DataTextureLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new mA,o=new XC(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(e){let i;try{i=r.parse(e)}catch(e){if(void 0===n)return void e(e);n(e)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:Wx,s.wrapT=void 0!==i.wrapT?i.wrapT:Wx,s.magFilter=void 0!==i.magFilter?i.magFilter:Yx,s.minFilter=void 0!==i.minFilter?i.minFilter:Yx,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(s.colorSpace=i.colorSpace),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=Kx),1===i.mipmapCount&&(s.minFilter=Yx),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,t&&t(s,i)},i,n),s}},DataUtils:class{static toHalfFloat(e){return WS(e)}static fromHalfFloat(e){return qS(e)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:GC,DepthFormat:mb,DepthStencilFormat:gb,DepthTexture:IM,DetachedBindMode:Nx,DirectionalLight:_P,DirectionalLightHelper:class extends tS{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===t&&(t=1);let n=new hE;n.setAttribute("position",new QS([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new rM({fog:!1,toneMapped:!1});this.lightPlane=new dM(n,r),this.add(this.lightPlane),n=new hE,n.setAttribute("position",new QS([0,0,0,0,0,1],3)),this.targetLine=new dM(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),CL.setFromMatrixPosition(this.light.matrixWorld),PL.setFromMatrixPosition(this.light.target.matrixWorld),LL.subVectors(PL,CL),this.lightPlane.lookAt(PL),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(PL),this.targetLine.scale.z=LL.length()}},DiscreteInterpolant:IC,DodecahedronGeometry:NM,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:jM,EllipseCurve:HM,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:Vx,EquirectangularRefractionMapping:jx,Euler:kT,EventDispatcher:Hw,ExternalTexture:PM,ExtrudeGeometry:jI,FileLoader:XC,Float16BufferAttribute:class extends YS{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=qS(this.array[e*this.itemSize]);return this.normalized&&(t=Qw(t,this.array)),t}setX(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize]=WS(t),this}getY(e){let t=qS(this.array[e*this.itemSize+1]);return this.normalized&&(t=Qw(t,this.array)),t}setY(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+1]=WS(t),this}getZ(e){let t=qS(this.array[e*this.itemSize+2]);return this.normalized&&(t=Qw(t,this.array)),t}setZ(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+2]=WS(t),this}getW(e){let t=qS(this.array[e*this.itemSize+3]);return this.normalized&&(t=Qw(t,this.array)),t}setW(e,t){return this.normalized&&(t=eT(t,this.array)),this.array[e*this.itemSize+3]=WS(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array)),this.array[e+0]=WS(t),this.array[e+1]=WS(i),this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array)),this.array[e+0]=WS(t),this.array[e+1]=WS(i),this.array[e+2]=WS(n),this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=eT(t,this.array),i=eT(i,this.array),n=eT(n,this.array),r=eT(r,this.array)),this.array[e+0]=WS(t),this.array[e+1]=WS(i),this.array[e+2]=WS(n),this.array[e+3]=WS(r),this}},Float32BufferAttribute:QS,FloatType:sb,Fog:dS,FogExp2:hS,FramebufferTexture:class extends wT{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Xx,this.minFilter=Xx,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:BA,FrustumArray:kA,GLBufferAttribute:class{constructor(e,t,i,n,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,this.normalized=s,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},GLSL1:"100",GLSL3:Iw,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Ew,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends gM{constructor(e=10,t=10,i=4473924,n=8947848){i=new cS(i),n=new cS(n);const r=t/2,s=e/t,o=e/2,a=[],l=[];for(let e=0,c=0,u=-o;e<=t;e++,u+=s){a.push(-o,0,u,o,0,u),a.push(u,0,-o,u,0,o);const t=e===r?i:n;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new hE;c.setAttribute("position",new QS(a,3)),c.setAttribute("color",new QS(l,3));super(c,new rM({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:iS,HalfFloatType:ob,HemisphereLight:KC,HemisphereLightHelper:class extends tS{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new qI(t);n.rotateY(.5*Math.PI),this.material=new HE({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new YS(s,3)),this.add(new iA(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");ML.copy(this.light.color),IL.copy(this.light.groundColor);for(let e=0,i=t.count;e<i;e++){const n=e<i/2?ML:IL;t.setXYZ(e,n.r,n.g,n.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(AL.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:HI,ImageBitmapLoader:PP,ImageLoader:ZC,ImageUtils:gT,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:vA,InstancedBufferGeometry:SP,InstancedInterleavedBuffer:class extends dE{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},InstancedMesh:MA,Int16BufferAttribute:class extends YS{constructor(e,t,i){super(new Int16Array(e),t,i)}},Int32BufferAttribute:class extends YS{constructor(e,t,i){super(new Int32Array(e),t,i)}},Int8BufferAttribute:class extends YS{constructor(e,t,i){super(new Int8Array(e),t,i)}},IntType:nb,InterleavedBuffer:dE,InterleavedBufferAttribute:fE,Interpolant:EC,InterpolateBezier:aw,InterpolateDiscrete:rw,InterpolateLinear:sw,InterpolateSmooth:ow,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:yw,KeyframeTrack:PC,LOD:BE,LatheGeometry:WI,Layers:zT,LessCompare:513,LessDepth:2,LessEqualCompare:ww,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:JC,LightProbe:bP,Line:dM,Line3:class{constructor(e=new rT,t=new rT){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){fL.subVectors(e,this.start),mL.subVectors(this.end,this.start);const i=mL.dot(mL);let n=mL.dot(fL)/i;return t&&(n=Yw(n,0,1)),n}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}distanceSqToLine3(e,t=vL,i=xL){const n=1e-8*1e-8;let r,s;const o=this.start,a=e.start,l=e.end;gL.subVectors(this.end,o),_L.subVectors(l,a),yL.subVectors(o,a);const c=gL.dot(gL),u=_L.dot(_L),h=_L.dot(yL);if(c<=n&&u<=n)return t.copy(o),i.copy(a),t.sub(i),t.dot(t);if(c<=n)r=0,s=h/u,s=Yw(s,0,1);else{const e=gL.dot(yL);if(u<=n)s=0,r=Yw(-e/c,0,1);else{const t=gL.dot(_L),i=c*u-t*t;r=0!==i?Yw((t*h-e*u)/i,0,1):0,s=(t*r+h)/u,s<0?(s=0,r=Yw(-e/c,0,1)):s>1&&(s=1,r=Yw((t-e)/c,0,1))}}return t.copy(o).addScaledVector(gL,r),i.copy(a).addScaledVector(_L,s),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:rM,LineCurve:nI,LineCurve3:rI,LineDashedMaterial:xC,LineLoop:_M,LineSegments:gM,LinearFilter:Yx,LinearInterpolant:MC,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:Kx,LinearMipmapNearestFilter:Jx,LinearSRGBColorSpace:mw,LinearToneMapping:1,LinearTransfer:gw,Loader:HC,LoaderUtils:TP,LoadingManager:jC,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:_E,MaterialBlending:6,MaterialLoader:wP,MathUtils:tT,Matrix2:dL,Matrix3:aT,Matrix4:IT,MaxEquation:104,Mesh:iA,MeshBasicMaterial:HE,MeshDepthMaterial:_C,MeshDistanceMaterial:yC,MeshLambertMaterial:gC,MeshMatcapMaterial:vC,MeshNormalMaterial:mC,MeshPhongMaterial:pC,MeshPhysicalMaterial:dC,MeshStandardMaterial:hC,MeshToonMaterial:fC,MinEquation:103,MirroredRepeatWrapping:qx,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:Xx,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:Zx,NearestMipmapNearestFilter:$x,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:pw,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:hw,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:OC,Object3D:tS,ObjectLoader:class extends HC{constructor(e){super(e)}load(e,t,i,n){const r=this,s=""===this.path?TP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new XC(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(i){let s=null;try{s=JSON.parse(i)}catch(t){return void 0!==n&&n(t),void t("ObjectLoader: Can't parse "+e+".",t.message)}const o=s.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+e)),void Vw("ObjectLoader: Can't load "+e);r.parse(s,t)},i,n)}async loadAsync(e,t){const i=""===this.path?TP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const n=new XC(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(e,t);let s;try{s=JSON.parse(r)}catch(t){throw new Error("ObjectLoader: Can't parse "+e+". "+t.message)}const o=s.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(s)}parse(e,t){const i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=this.parseImages(e.images,function(){void 0!==t&&t(l)}),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,r,a,o,i),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==t){let e=!1;for(const t in s)if(s[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,s),a=this.parseObject(e.object,n,o,s,t),l=this.parseSkeletons(e.skeletons,a);return this.bindSkeletons(a,l),this.bindLightTargets(a),a}parseShapes(e){const t={};if(void 0!==e)for(let i=0,n=e.length;i<n;i++){const n=(new hI).fromJSON(e[i]);t[n.uuid]=n}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse(function(e){e.isBone&&(n[e.uuid]=e)}),void 0!==e)for(let t=0,r=e.length;t<r;t++){const r=(new yA).fromJSON(e[t],n);i[r.uuid]=r}return i}parseGeometries(e,t){const i={};if(void 0!==e){const n=new EP;for(let r=0,s=e.length;r<s;r++){let s;const o=e[r];switch(o.type){case"BufferGeometry":case"InstancedBufferGeometry":s=n.parse(o);break;default:o.type in nC?s=nC[o.type].fromJSON(o,t):Uw(`ObjectLoader: Unsupported geometry type "${o.type}"`)}s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.userData&&(s.userData=o.userData),i[o.uuid]=s}}return i}parseMaterials(e,t){const i={},n={};if(void 0!==e){const r=new wP;r.setTextures(t);for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0===i[s.uuid]&&(i[s.uuid]=r.parse(s)),n[s.uuid]=i[s.uuid]}}return n}parseAnimations(e){const t={};if(void 0!==e)for(let i=0;i<e.length;i++){const n=kC.parse(e[i]);t[n.uuid]=n}return t}parseImages(e,t){const i=this,n={};let r;function s(e){if("string"==typeof e){const t=e;return function(e){return i.manager.itemStart(e),r.load(e,function(){i.manager.itemEnd(e)},void 0,function(){i.manager.itemError(e),i.manager.itemEnd(e)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:i.resourcePath+t)}return e.data?{data:Rw(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const i=new jC(t);r=new ZC(i),r.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const i=e[t],r=i.url;if(Array.isArray(r)){const e=[];for(let t=0,i=r.length;t<i;t++){const i=s(r[t]);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new mA(i.data,i.width,i.height)))}n[i.uuid]=new yT(e)}else{const e=s(i.url);n[i.uuid]=new yT(e)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function r(e){if("string"==typeof e){const i=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:t.resourcePath+i;return await n.loadAsync(r)}return e.data?{data:Rw(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){n=new ZC(this.manager),n.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],s=n.url;if(Array.isArray(s)){const e=[];for(let t=0,i=s.length;t<i;t++){const i=s[t],n=await r(i);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new mA(n.data,n.width,n.height)))}i[n.uuid]=new yT(e)}else{const e=await r(n.url);i[n.uuid]=new yT(e)}}}return i}parseTextures(e,t){function i(e,t){return"number"==typeof e?e:(Uw("ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const n={};if(void 0!==e)for(let r=0,s=e.length;r<s;r++){const s=e[r];void 0===s.image&&Uw('ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&Uw("ObjectLoader: Undefined image",s.image);const o=t[s.image],a=o.data;let l;Array.isArray(a)?(l=new MM,6===a.length&&(l.needsUpdate=!0)):(l=a&&a.data?new mA:new wT,a&&(l.needsUpdate=!0)),l.source=o,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=i(s.mapping,AP)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=i(s.wrap[0],MP),l.wrapT=i(s.wrap[1],MP)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.minFilter&&(l.minFilter=i(s.minFilter,IP)),void 0!==s.magFilter&&(l.magFilter=i(s.magFilter,IP)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.userData&&(l.userData=s.userData),n[s.uuid]=l}return n}parseObject(e,t,i,n,r){let s,o,a;function l(e){return void 0===t[e]&&Uw("ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];void 0===i[r]&&Uw("ObjectLoader: Undefined material",r),t.push(i[r])}return t}return void 0===i[e]&&Uw("ObjectLoader: Undefined material",e),i[e]}}function u(e){return void 0===n[e]&&Uw("ObjectLoader: Undefined texture",e),n[e]}switch(e.type){case"Scene":s=new pS,void 0!==e.background&&(s.background=Number.isInteger(e.background)?new cS(e.background):u(e.background)),void 0!==e.environment&&(s.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?s.fog=new dS(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(s.fog=new hS(e.fog.color,e.fog.density)),""!==e.fog.name&&(s.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(s.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(s.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&s.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(s.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&s.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":s=new uP(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(s.focus=e.focus),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.filmGauge&&(s.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(s.filmOffset=e.filmOffset),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new mP(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(s.zoom=e.zoom),void 0!==e.view&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new yP(e.color,e.intensity);break;case"DirectionalLight":s=new _P(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new fP(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new vP(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new dP(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new KC(e.color,e.groundColor,e.intensity);break;case"LightProbe":const t=(new xP).fromArray(e.sh);s=new bP(t,e.intensity);break;case"SkinnedMesh":o=l(e.geometry),a=c(e.material),s=new pA(o,a),void 0!==e.bindMode&&(s.bindMode=e.bindMode),void 0!==e.bindMatrix&&s.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(s.skeleton=e.skeleton);break;case"Mesh":o=l(e.geometry),a=c(e.material),s=new iA(o,a);break;case"InstancedMesh":o=l(e.geometry),a=c(e.material);const i=e.instanceMatrix,n=e.instanceColor;s=new MA(o,a,e.count),s.instanceMatrix=new vA(new Float32Array(i.array),16),void 0!==n&&(s.instanceColor=new vA(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":o=l(e.geometry),a=c(e.material),s=new nM(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,a),s.geometry=o,s.perObjectFrustumCulled=e.perObjectFrustumCulled,s.sortObjects=e.sortObjects,s._drawRanges=e.drawRanges,s._reservedRanges=e.reservedRanges,s._geometryInfo=e.geometryInfo.map(e=>{let t=null,i=null;return void 0!==e.boundingBox&&(t=(new IS).fromJSON(e.boundingBox)),void 0!==e.boundingSphere&&(i=(new nE).fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:i}}),s._instanceInfo=e.instanceInfo,s._availableInstanceIds=e._availableInstanceIds,s._availableGeometryIds=e._availableGeometryIds,s._nextIndexStart=e.nextIndexStart,s._nextVertexStart=e.nextVertexStart,s._geometryCount=e.geometryCount,s._maxInstanceCount=e.maxInstanceCount,s._maxVertexCount=e.maxVertexCount,s._maxIndexCount=e.maxIndexCount,s._geometryInitialized=e.geometryInitialized,s._matricesTexture=u(e.matricesTexture.uuid),s._indirectTexture=u(e.indirectTexture.uuid),void 0!==e.colorsTexture&&(s._colorsTexture=u(e.colorsTexture.uuid)),void 0!==e.boundingSphere&&(s.boundingSphere=(new nE).fromJSON(e.boundingSphere)),void 0!==e.boundingBox&&(s.boundingBox=(new IS).fromJSON(e.boundingBox));break;case"LOD":s=new BE;break;case"Line":s=new dM(l(e.geometry),c(e.material));break;case"LineLoop":s=new _M(l(e.geometry),c(e.material));break;case"LineSegments":s=new gM(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":s=new TM(l(e.geometry),c(e.material));break;case"Sprite":s=new LE(c(e.material));break;case"Group":s=new iS;break;case"Bone":s=new fA;break;default:s=new tS}if(s.uuid=e.uuid,void 0!==e.name&&(s.name=e.name),void 0!==e.matrix?(s.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==e.position&&s.position.fromArray(e.position),void 0!==e.rotation&&s.rotation.fromArray(e.rotation),void 0!==e.quaternion&&s.quaternion.fromArray(e.quaternion),void 0!==e.scale&&s.scale.fromArray(e.scale)),void 0!==e.up&&s.up.fromArray(e.up),void 0!==e.pivot&&(s.pivot=(new rT).fromArray(e.pivot)),void 0!==e.morphTargetDictionary&&(s.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),void 0!==e.morphTargetInfluences&&(s.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.castShadow&&(s.castShadow=e.castShadow),void 0!==e.receiveShadow&&(s.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(s.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(s.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(s.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(s.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&s.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(s.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.frustumCulled&&(s.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(s.renderOrder=e.renderOrder),void 0!==e.static&&(s.static=e.static),void 0!==e.userData&&(s.userData=e.userData),void 0!==e.layers&&(s.layers.mask=e.layers),void 0!==e.children){const o=e.children;for(let e=0;e<o.length;e++)s.add(this.parseObject(o[e],t,i,n,r))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){s.animations.push(r[t[e]])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(s.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const i=t[e],n=s.getObjectByProperty("uuid",i.object);void 0!==n&&s.addLevel(n,i.distance,i.hysteresis)}}return s}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse(function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const i=t[e.skeleton];void 0===i?Uw("ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(i,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=e.getObjectByProperty("uuid",t.target);t.target=void 0!==i?i:new tS}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:qI,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:lx,OneMinusSrcColorFactor:203,OrthographicCamera:mP,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:cR,Path:uI,PerspectiveCamera:uP,Plane:LA,PlaneGeometry:XI,PlaneHelper:class extends dM{constructor(e,t=1,i=16776960){const n=i,r=new hE;r.setAttribute("position",new QS([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new rM({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const s=new hE;s.setAttribute("position",new QS([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new iA(s,new HE({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:fP,PointLightHelper:class extends iA{constructor(e,t,i){super(new YI(t,4,2),new HE({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:TM,PointsMaterial:yM,PolarGridHelper:class extends gM{constructor(e=10,t=16,i=8,n=64,r=4473924,s=8947848){r=new cS(r),s=new cS(s);const o=[],a=[];if(t>1)for(let i=0;i<t;i++){const n=i/t*(2*Math.PI),l=Math.sin(n)*e,c=Math.cos(n)*e;o.push(0,0,0),o.push(l,0,c);const u=1&i?r:s;a.push(u.r,u.g,u.b),a.push(u.r,u.g,u.b)}for(let t=0;t<i;t++){const l=1&t?r:s,c=e-e/i*t;for(let e=0;e<n;e++){let t=e/n*(2*Math.PI),i=Math.sin(t)*c,r=Math.cos(t)*c;o.push(i,0,r),a.push(l.r,l.g,l.b),t=(e+1)/n*(2*Math.PI),i=Math.sin(t)*c,r=Math.cos(t)*c,o.push(i,0,r),a.push(l.r,l.g,l.b)}}const l=new hE;l.setAttribute("position",new QS(o,3)),l.setAttribute("color",new QS(a,3));super(l,new rM({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:FM,PositionalAudio:class extends qP{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(XP,$P,ZP),YP.set(0,0,1).applyQuaternion($P);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(XP.x,e),t.positionY.linearRampToValueAtTime(XP.y,e),t.positionZ.linearRampToValueAtTime(XP.z,e),t.orientationX.linearRampToValueAtTime(YP.x,e),t.orientationY.linearRampToValueAtTime(YP.y,e),t.orientationZ.linearRampToValueAtTime(YP.z,e)}else t.setPosition(XP.x,XP.y,XP.z),t.setOrientation(YP.x,YP.y,YP.z)}},PropertyBinding:rL,PropertyMixer:JP,QuadraticBezierCurve:sI,QuadraticBezierCurve3:oI,Quaternion:nT,QuaternionKeyframeTrack:BC,QuaternionLinearInterpolant:DC,R11_EAC_Format:Ob,RED_GREEN_RGTC2_Format:iw,RED_RGTC1_Format:ew,REVISION:$v,RG11_EAC_Format:Bb,RGBADepthPacking:3201,RGBAFormat:fb,RGBAIntegerFormat:bb,RGBA_ASTC_10x10_Format:$b,RGBA_ASTC_10x5_Format:Wb,RGBA_ASTC_10x6_Format:qb,RGBA_ASTC_10x8_Format:Xb,RGBA_ASTC_12x10_Format:Zb,RGBA_ASTC_12x12_Format:Yb,RGBA_ASTC_4x4_Format:Nb,RGBA_ASTC_5x4_Format:kb,RGBA_ASTC_5x5_Format:zb,RGBA_ASTC_6x5_Format:Ub,RGBA_ASTC_6x6_Format:Vb,RGBA_ASTC_8x5_Format:jb,RGBA_ASTC_8x6_Format:Gb,RGBA_ASTC_8x8_Format:Hb,RGBA_BPTC_Format:Jb,RGBA_ETC2_EAC_Format:Rb,RGBA_PVRTC_2BPPV1_Format:Cb,RGBA_PVRTC_4BPPV1_Format:Ib,RGBA_S3TC_DXT1_Format:Tb,RGBA_S3TC_DXT3_Format:Sb,RGBA_S3TC_DXT5_Format:Eb,RGBDepthPacking:3202,RGBFormat:pb,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:Kb,RGB_BPTC_UNSIGNED_Format:Qb,RGB_ETC1_Format:Pb,RGB_ETC2_Format:Lb,RGB_PVRTC_2BPPV1_Format:Mb,RGB_PVRTC_4BPPV1_Format:Ab,RGB_S3TC_DXT1_Format:wb,RGDepthPacking:3203,RGFormat:vb,RGIntegerFormat:xb,RawShaderMaterial:uC,Ray:GE,Raycaster:class{constructor(e,t,i=0,n=1/0){this.ray=new GE(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new zT,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Vw("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return cL.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cL),this}intersectObject(e,t=!0,i=[]){return hL(e,this,i,t),i.sort(uL),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)hL(e[n],this,i,t);return i.sort(uL),i}},RectAreaLight:vP,RedFormat:_b,RedIntegerFormat:yb,ReinhardToneMapping:2,RenderTarget:ST,RenderTarget3D:class extends ST{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new MT(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:Hx,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:$I,SIGNED_R11_EAC_Format:Db,SIGNED_RED_GREEN_RGTC2_Format:nw,SIGNED_RED_RGTC1_Format:tw,SIGNED_RG11_EAC_Format:Fb,SRGBColorSpace:fw,SRGBTransfer:_w,Scene:pS,ShaderChunk:jL,ShaderLib:WL,ShaderMaterial:cC,ShadowMaterial:rC,Shape:hI,ShapeGeometry:ZI,ShapePath:class{constructor(){this.type="ShapePath",this.color=new cS,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new uI,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,s){return this.currentPath.bezierCurveTo(e,t,i,n,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const i=t.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=t[r],o=t[s],a=o.x-i.x,l=o.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=t[s],a=-a,o=t[r],l=-l),e.y<i.y||e.y>o.y)continue;if(e.y===i.y){if(e.x===i.x)return!0}else{const t=l*(e.x-i.x)-a*(e.y-i.y);if(0===t)return!0;if(t<0)continue;n=!n}}else{if(e.y!==i.y)continue;if(o.x<=e.x&&e.x<=i.x||i.x<=e.x&&e.x<=o.x)return!0}}return n}const i=zI.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,s,o;const a=[];if(1===n.length)return s=n[0],o=new hI,o.curves=s.curves,a.push(o),a;let l=!i(n[0].getPoints());l=e?!l:l;const c=[],u=[];let h,d,p=[],f=0;u[f]=void 0,p[f]=[];for(let t=0,o=n.length;t<o;t++)s=n[t],h=s.getPoints(),r=i(h),r=e?!r:r,r?(!l&&u[f]&&f++,u[f]={s:new hI,p:h},u[f].s.curves=s.curves,l&&f++,p[f]=[]):p[f].push({h:s,p:h[0]});if(!u[0])return function(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=new hI;r.curves=n.curves,t.push(r)}return t}(n);if(u.length>1){let e=!1,i=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let n=0,r=u.length;n<r;n++){const r=p[n];for(let s=0;s<r.length;s++){const o=r[s];let a=!0;for(let r=0;r<u.length;r++)t(o.p,u[r].p)&&(n!==r&&i++,a?(a=!1,c[r].push(o)):e=!0);a&&c[n].push(o)}}i>0&&!1===e&&(p=c)}for(let e=0,t=u.length;e<t;e++){o=u[e].s,a.push(o),d=p[e];for(let e=0,t=d.length;e<t;e++)o.holes.push(d[e].h)}return a}},ShapeUtils:zI,ShortType:tb,Skeleton:yA,SkeletonHelper:class extends gM{constructor(e){const t=EL(e),i=new hE,n=[],r=[];for(let e=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new QS(n,3)),i.setAttribute("color",new QS(r,3));super(i,new rM({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const s=new cS(255),o=new cS(65280);this.setColors(s,o)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");SL.copy(this.root.matrixWorld).invert();for(let e=0,i=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(TL.multiplyMatrices(SL,r.matrixWorld),wL.setFromMatrixPosition(TL),n.setXYZ(i,wL.x,wL.y,wL.z),TL.multiplyMatrices(SL,r.parent.matrixWorld),wL.setFromMatrixPosition(TL),n.setXYZ(i+1,wL.x,wL.y,wL.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,e.r,e.g,e.b),i.setXYZ(n+1,t.r,t.g,t.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:pA,Source:yT,Sphere:nE,SphereGeometry:YI,Spherical:class{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Yw(this.phi,e,Math.PI-e),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Yw(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:xP,SplineCurve:aI,SpotLight:dP,SpotLightHelper:class extends tS{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new hE,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,i=32;e<i;e++,t++){const r=e/i*Math.PI*2,s=t/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new QS(n,3));const r=new rM({fog:!1,toneMapped:!1});this.cone=new gM(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),bL.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(bL),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:LE,SpriteMaterial:yE,SrcAlphaFactor:ax,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Mw,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new uP,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new uP,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,BP.copy(e.projectionMatrix);const i=t.eyeSep/2,n=i*t.near/t.focus,r=t.near*Math.tan(Xw*t.fov*.5)/t.zoom;let s,o;DP.elements[12]=-i,OP.elements[12]=i,s=-r*t.aspect+n,o=r*t.aspect+n,BP.elements[0]=2*t.near/(o-s),BP.elements[8]=(o+s)/(o-s),this.cameraL.projectionMatrix.copy(BP),s=-r*t.aspect-n,o=r*t.aspect-n,BP.elements[0]=2*t.near/(o-s),BP.elements[8]=(o+s)/(o-s),this.cameraR.projectionMatrix.copy(BP)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(DP),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(OP)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:FC,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:JI,Texture:wT,TextureLoader:YC,TextureUtils:class{static contain(e,t){return function(e,t){const i=e.image&&e.image.width?e.image.width/e.image.height:1;return i>t?(e.repeat.x=1,e.repeat.y=i/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/i,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}(e,t)}static cover(e,t){return function(e,t){const i=e.image&&e.image.width?e.image.width/e.image.height:1;return i>t?(e.repeat.x=t/i,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=i/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}(e,t)}static fill(e){return function(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}(e)}static getByteLength(e,t,i,n){return zL(e,t,i,n)}},Timer:zP,TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:KI,TorusKnotGeometry:QI,Triangle:MS,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:eC,UVMapping:kx,Uint16BufferAttribute:JS,Uint32BufferAttribute:KS,Uint8BufferAttribute:class extends YS{constructor(e,t,i){super(new Uint8Array(e),t,i)}},Uint8ClampedBufferAttribute:class extends YS{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},Uniform:aL,UniformsGroup:class extends Hw{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:lL++}),this.name="",this.usage=Mw,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let e=0,i=t.length;e<i;e++){const i=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<i.length;e++)this.uniforms.push(i[e].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:HL,UniformsUtils:lC,UnsignedByteType:Qx,UnsignedInt101111Type:hb,UnsignedInt248Type:cb,UnsignedInt5999Type:ub,UnsignedIntType:rb,UnsignedShort4444Type:ab,UnsignedShort5551Type:lb,UnsignedShortType:ib,VSMShadowMap:3,Vector2:iT,Vector3:rT,Vector4:TT,VectorKeyframeTrack:NC,VideoFrameTexture:class extends EM{constructor(e,t,i,n,r,s,o,a){super({},e,t,i,n,r,s,o,a),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},VideoTexture:EM,WebGL3DRenderTarget:class extends ET{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new MT(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends ET{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new AT(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:Cw,WebGLCubeRenderTarget:mR,WebGLRenderTarget:ET,WebGLRenderer:OD,WebGLUtils:SD,WebGPUCoordinateSystem:Pw,WebXRController:rS,WireframeGeometry:tC,WrapAroundEnding:uw,ZeroCurvatureEnding:lw,ZeroFactor:200,ZeroSlopeEnding:cw,ZeroStencilOp:0,createCanvasElement:Bw,error:Vw,getConsoleFunction:function(){return Nw},log:kw,setConsoleFunction:function(e){Nw=e},warn:Uw,warnOnce:jw});const BD=Math.sqrt(3);function FD(e,[t,i,n]){e.setRGB(t/255,i/255,n/255,fw)}class ND{constructor(e){const t=this;t.implementation=e,t._onResize=t._onResize.bind(t),t._updateLights=t._updateLights.bind(t)}onAdd(e,t){const i=this,n=i.implementation,r=n.id,s=e.map;i.map=e,i.modelOrigin=e.getModelOrigin(),s.addLayer({id:r,type:"custom",renderingMode:"3d",onAdd:(t,r)=>{i._onAdd(t,r),n.onAdd&&n.onAdd(e,{renderer:i.renderer,scene:i.scene,camera:i.camera})},onRemove:(t,r)=>{i._onRemove(t,r),n.onRemove&&n.onRemove(e,{renderer:i.renderer,scene:i.scene,camera:i.camera})},prerender:()=>{n.prerender&&n.prerender(e,{renderer:i.renderer,scene:i.scene,camera:i.camera})},render:i._render.bind(i)},t||"poi"),s.setLayerZoomRange(r,n.minzoom,n.maxzoom)}_onAdd(e,t){const i=this,{_fov:n,width:r,height:s}=e.transform,o=i.renderer=new OD({canvas:e.getCanvas(),context:t}),a=i.scene=new pS,l=i.implementation.lightColor,c=i.light=new _P(l,3.8),u=i.ambientLight=new yP(l,.4);o.autoClear=!1,a.add(c),a.add(u),a.fog=new dS(0),a.add(new iA),i.mbox=e,i.camera=new uP(tT.radToDeg(n),r/s),i.camera.matrixWorldAutoUpdate=!1,e.on("resize",i._onResize),void 0===l&&(i.map.on("light",i._updateLights),i._updateLights({directional:O_(e),ambient:D_(e)}))}_onRemove(e){const t=this;e.off("resize",t._onResize),void 0===t.implementation.lightColor&&t.map.off("light",t._updateLights),delete t.mbox}_render(e,t){const i=this,{modelOrigin:n,mbox:r,renderer:s,camera:o,light:a,scene:l}=i,{_fov:c,_camera:u,_horizonShift:h,pixelsPerMeter:d,worldSize:p,_pitch:f,width:m,height:g}=r.transform,_=c/2,y=u.position[2]*p/Math.cos(f),v=y/h,x=1e3*d/Math.cos(f),b=o.far=Math.max(v,y+x),w=o.near=g/50,T=Math.tan(_)*w,S=T*m/g,E=(new IT).fromArray(t),A=(new IT).makeTranslation(n.x,n.y,0).scale(new rT(1,-1,1));o.projectionMatrix.makePerspective(-S,S,T,-T,w,b),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.matrixWorldInverse.copy(o.projectionMatrixInverse).multiply(E).multiply(A),o.matrixWorld.copy(o.matrixWorldInverse).invert();const M=tT.degToRad(r.getBearing()+30);a.position.set(-Math.sin(M),-Math.cos(M),BD).normalize(),FD(l.fog.color,F_(r)),[l.fog.near,l.fog.far]=N_(y,b),s.resetState();const I=i.implementation;I.render?I.render(i.map,{renderer:s,scene:l,camera:o}):s.render(l,o)}_updateLights({directional:e,ambient:t}){const{light:i,ambientLight:n}=this;FD(i.color,e.color),i.intensity=3.8*e.intensity,FD(n.color,t.color),n.intensity=.4*t.intensity}_onResize(e){const t=this.camera,i=e.target.transform;t.aspect=i.width/i.height,t.updateProjectionMatrix()}}const kD=-1,zD=0,UD=1;new gc,new gc;const VD=new gc,jD=new gc;class GD{constructor(e=[0,0,0],t=0){bt(this,"center",void 0),bt(this,"radius",void 0),this.radius=-0,this.center=new gc,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=VD.from(t),this.center=(new gc).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new GD(this.center,this.radius)}union(e){const t=this.center,i=this.radius,n=e.radius,r=VD.copy(e.center).subtract(t),s=r.magnitude();if(i>=s+n)return this.clone();if(n>=s+i)return e.clone();const o=.5*(i+s+n);return jD.copy(r).scale((-i+o)/s).add(t),this.center.copy(jD),this.radius=o,this}expand(e){const t=VD.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=function(e,t){var i=t[0],n=t[1],r=t[2],s=t[4],o=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(i*i+n*n+r*r),e[1]=Math.sqrt(s*s+o*o+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}(VD,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=VD.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.radius,i=e.normal.dot(this.center)+e.distance;return i<-t?kD:i<t?zD:UD}}const HD=new gc,WD=new gc,qD=new gc,XD=new gc,$D=new gc,ZD=new gc,YD=new gc,JD=0,KD=1,QD=2,eB=3,tB=4,iB=5,nB=6,rB=7,sB=8;class oB{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){bt(this,"center",void 0),bt(this,"halfAxes",void 0),this.center=(new gc).from(e),this.halfAxes=new Ec(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2);return[new gc(e).len(),new gc(t).len(),new gc(i).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),n=new gc(e).normalize(),r=new gc(t).normalize(),s=new gc(i).normalize();return(new uu).fromMatrix3(new Ec([...n,...r,...s]))}fromCenterHalfSizeQuaternion(e,t,i){const n=new uu(i),r=(new Ec).fromQuaternion(n);return r[0]=r[0]*t[0],r[1]=r[1]*t[0],r[2]=r[2]*t[0],r[3]=r[3]*t[1],r[4]=r[4]*t[1],r[5]=r[5]*t[1],r[6]=r[6]*t[2],r[7]=r[7]*t[2],r[8]=r[8]*t[2],this.center=(new gc).from(e),this.halfAxes=r,this}clone(){return new oB(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new GD){const t=this.halfAxes,i=t.getColumn(0,qD),n=t.getColumn(1,XD),r=t.getColumn(2,$D),s=HD.copy(i).add(n).add(r);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){const t=this.center,i=e.normal,n=this.halfAxes,r=i.x,s=i.y,o=i.z,a=Math.abs(r*n[JD]+s*n[KD]+o*n[QD])+Math.abs(r*n[eB]+s*n[tB]+o*n[iB])+Math.abs(r*n[nB]+s*n[rB]+o*n[sB]),l=i.dot(t)+e.distance;return l<=-a?kD:l>=a?UD:zD}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=WD.from(e).subtract(this.center),i=this.halfAxes,n=i.getColumn(0,qD),r=i.getColumn(1,XD),s=i.getColumn(2,$D),o=n.magnitude(),a=r.magnitude(),l=s.magnitude();n.normalize(),r.normalize(),s.normalize();let c,u=0;return c=Math.abs(t.dot(n))-o,c>0&&(u+=c*c),c=Math.abs(t.dot(r))-a,c>0&&(u+=c*c),c=Math.abs(t.dot(s))-l,c>0&&(u+=c*c),u}computePlaneDistances(e,t,i=[-0,-0]){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const s=this.center,o=this.halfAxes,a=o.getColumn(0,qD),l=o.getColumn(1,XD),c=o.getColumn(2,$D),u=ZD.copy(a).add(l).add(c).add(s),h=YD.copy(u).subtract(e);let d=t.dot(h);return n=Math.min(d,n),r=Math.max(d,r),u.copy(s).add(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),u.copy(s).add(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),u.copy(s).add(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),s.copy(u).subtract(a).add(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),s.copy(u).subtract(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),s.copy(u).subtract(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),s.copy(u).subtract(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),i[0]=n,i[1]=r,i}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,qD);t.transformAsPoint(e);const i=this.halfAxes.getColumn(1,XD);i.transformAsPoint(e);const n=this.halfAxes.getColumn(2,$D);return n.transformAsPoint(e),this.halfAxes=new Ec([...t,...i,...n]),this}getTransform(){throw new Error("not implemented")}}const aB=new gc,lB=new gc;class cB{constructor(e=[0,0,1],t=0){bt(this,"normal",void 0),bt(this,"distance",void 0),this.normal=new gc,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Pl(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=aB.from(e),this.normal.from(t).normalize();const i=-this.normal.dot(e);return this.distance=i,this}fromCoefficients(e,t,i,n){return this.normal.set(e,t,i),Pl(Vl(this.normal.len(),1)),this.distance=n,this}clone(){return new cB(this.normal,this.distance)}equals(e){return Vl(this.distance,e.distance)&&Vl(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=lB.copy(this.normal).transformAsVector(e).normalize(),i=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(i,t)}projectPointOntoPlane(e,t=[0,0,0]){e=aB.from(e);const i=this.getPointDistance(e),n=lB.copy(this.normal).scale(i);return e.subtract(n).to(t)}}const uB=[new gc([1,0,0]),new gc([0,1,0]),new gc([0,0,1])],hB=new gc,dB=new gc;new cB(new gc(1,0,0),0);class pB{constructor(e=[]){bt(this,"planes",void 0),this.planes=e}fromBoundingSphere(e){this.planes.length=2*uB.length;const t=e.center,i=e.radius;let n=0;for(const e of uB){let r=this.planes[n],s=this.planes[n+1];r||(r=this.planes[n]=new cB),s||(s=this.planes[n+1]=new cB);const o=hB.copy(e).scale(-i).add(t);e.dot(o),r.fromPointNormal(o,e);const a=hB.copy(e).scale(i).add(t),l=dB.copy(e).negate();l.dot(a),s.fromPointNormal(a,l),n+=2}return this}computeVisibility(e){let t=UD;for(const i of this.planes){switch(e.intersectPlane(i)){case kD:return kD;case zD:t=zD}}return t}computeVisibilityWithPlaneMask(e,t){if(Pl(Number.isFinite(t),"parentPlaneMask is required."),t===pB.MASK_OUTSIDE||t===pB.MASK_INSIDE)return t;let i=pB.MASK_INSIDE;const n=this.planes;for(let r=0;r<this.planes.length;++r){const s=r<31?1<<r:0;if(r<31&&0===(t&s))continue;const o=e.intersectPlane(n[r]);if(o===kD)return pB.MASK_OUTSIDE;o===zD&&(i|=s)}return i}}bt(pB,"MASK_OUTSIDE",4294967295),bt(pB,"MASK_INSIDE",0),bt(pB,"MASK_INDETERMINATE",2147483647),new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc,new gc;const fB=new Ec,mB=new Ec,gB=new Ec,_B=new Ec,yB=new Ec;function vB(e,t={}){const i=fu;let n=0,r=0;const s=mB,o=gB;s.identity(),o.copy(e);const a=i*function(e){let t=0;for(let i=0;i<9;++i){const n=e[i];t+=n*n}return Math.sqrt(t)}(o);for(;r<10&&wB(o)>a;)TB(o,_B),yB.copy(_B).transpose(),o.multiplyRight(_B),o.multiplyLeft(yB),s.multiplyRight(_B),++n>2&&(++r,n=0);return t.unitary=s.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const xB=[1,0,0],bB=[2,2,1];function wB(e){let t=0;for(let i=0;i<3;++i){const n=e[fB.getElementIndex(bB[i],xB[i])];t+=2*n*n}return Math.sqrt(t)}function TB(e,t){const i=pu;let n=0,r=1;for(let t=0;t<3;++t){const i=Math.abs(e[fB.getElementIndex(bB[t],xB[t])]);i>n&&(r=t,n=i)}const s=xB[r],o=bB[r];let a=1,l=0;if(Math.abs(e[fB.getElementIndex(o,s)])>i){const t=(e[fB.getElementIndex(o,o)]-e[fB.getElementIndex(s,s)])/2/e[fB.getElementIndex(o,s)];let i;i=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),a=1/Math.sqrt(1+i*i),l=i*a}return Ec.IDENTITY.to(t),t[fB.getElementIndex(s,s)]=t[fB.getElementIndex(o,o)]=a,t[fB.getElementIndex(o,s)]=l,t[fB.getElementIndex(s,o)]=-l,t}const SB=new gc,EB=new gc,AB=new gc,MB=new gc,IB=new gc,CB=new Ec,PB={diagonal:new Ec,unitary:new Ec};const LB=Math.PI/180,RB=new Float32Array(16),OB=new Float32Array(12);function DB(e,t,i){const n=t[0]*LB,r=t[1]*LB,s=t[2]*LB,o=Math.sin(s),a=Math.sin(n),l=Math.sin(r),c=Math.cos(s),u=Math.cos(n),h=Math.cos(r),d=i[0],p=i[1],f=i[2];e[0]=d*h*u,e[1]=d*l*u,e[2]=d*-a,e[3]=p*(-l*c+h*a*o),e[4]=p*(h*c+l*a*o),e[5]=p*u*o,e[6]=f*(l*o+h*a*c),e[7]=f*(-h*o+l*a*c),e[8]=f*u*c}function BB(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}const FB={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrix__LOCATION_0:{size:3,elementOffset:0},instanceModelMatrix__LOCATION_1:{size:3,elementOffset:3},instanceModelMatrix__LOCATION_2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(e,{startRow:t,endRow:i}){const{data:n,getOrientation:r,getScale:s,getTranslation:o,getTransformMatrix:a}=this.props,l=Array.isArray(a),c=l&&16===a.length,u=Array.isArray(s),h=Array.isArray(r),d=Array.isArray(o),p=c||!l&&Boolean(a(n[0]));e.constant=p?c:h&&u&&d;const f=e.value;if(e.constant){let t;if(p)RB.set(a),t=BB(RB);else{t=OB;DB(t,r,s),t.set(o,9)}e.value=new Float32Array(t)}else{let l=t*e.size;const{iterable:m,objectInfo:g}=Ff(n,t,i);for(const e of m){let t;if(g.index++,p)RB.set(c?a:a(e,g)),t=BB(RB);else{t=OB;DB(t,h?r:r(e,g),u?s:s(e,g)),t.set(d?o:o(e,g),9)}f[l++]=t[0],f[l++]=t[1],f[l++]=t[2],f[l++]=t[3],f[l++]=t[4],f[l++]=t[5],f[l++]=t[6],f[l++]=t[7],f[l++]=t[8],f[l++]=t[9],f[l++]=t[10],f[l++]=t[11]}}}};function NB(e,t){return t===Zn.CARTESIAN||t===Zn.METER_OFFSETS||t===Zn.DEFAULT&&!e.isGeospatial}function kB(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;e<l;e+=3){const l=a[e],c=a[e+1],u=a[e+2];t=l<t?l:t,i=c<i?c:i,n=u<n?u:n,r=l>r?l:r,s=c>s?c:s,o=u>o?u:o}return[[t,i,n],[r,s,o]]}class zB{constructor(e,t){bt(this,"fields",void 0),bt(this,"metadata",void 0),function(e){if(!e)throw new Error("loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const i of e)t[i.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(){const e=Object.create(null);for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];for(const t of i)e[t]=!0;const r=this.fields.filter(t=>e[t.name]);return new zB(r,this.metadata)}selectAt(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=t.map(e=>this.fields[e]).filter(Boolean);return new zB(n,this.metadata)}assign(e){let t,i=this.metadata;if(e instanceof zB){const n=e;t=n.fields,i=UB(UB(new Map,this.metadata),n.metadata)}else t=e;const n=Object.create(null);for(const e of this.fields)n[e.name]=e;for(const e of t)n[e.name]=e;const r=Object.values(n);return new zB(r,i)}}function UB(e,t){return new Map([...e||new Map,...t||new Map])}class VB{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;bt(this,"name",void 0),bt(this,"type",void 0),bt(this,"nullable",void 0),bt(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=i,this.metadata=n}get typeId(){return this.type&&this.type.typeId}clone(){return new VB(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let jB,GB,HB,WB=function(e){return e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e}({});class qB{static isNull(e){return e&&e.typeId===WB.Null}static isInt(e){return e&&e.typeId===WB.Int}static isFloat(e){return e&&e.typeId===WB.Float}static isBinary(e){return e&&e.typeId===WB.Binary}static isUtf8(e){return e&&e.typeId===WB.Utf8}static isBool(e){return e&&e.typeId===WB.Bool}static isDecimal(e){return e&&e.typeId===WB.Decimal}static isDate(e){return e&&e.typeId===WB.Date}static isTime(e){return e&&e.typeId===WB.Time}static isTimestamp(e){return e&&e.typeId===WB.Timestamp}static isInterval(e){return e&&e.typeId===WB.Interval}static isList(e){return e&&e.typeId===WB.List}static isStruct(e){return e&&e.typeId===WB.Struct}static isUnion(e){return e&&e.typeId===WB.Union}static isFixedSizeBinary(e){return e&&e.typeId===WB.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===WB.FixedSizeList}static isMap(e){return e&&e.typeId===WB.Map}static isDictionary(e){return e&&e.typeId===WB.Dictionary}get typeId(){return WB.NONE}compareTo(e){return this===e}}jB=Symbol.toStringTag;class XB extends qB{constructor(e,t){super(),bt(this,"isSigned",void 0),bt(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return WB.Int}get[jB](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class $B extends XB{constructor(){super(!0,8)}}class ZB extends XB{constructor(){super(!0,16)}}class YB extends XB{constructor(){super(!0,32)}}class JB extends XB{constructor(){super(!1,8)}}class KB extends XB{constructor(){super(!1,16)}}class QB extends XB{constructor(){super(!1,32)}}const eF=32,tF=64;GB=Symbol.toStringTag;class iF extends qB{constructor(e){super(),bt(this,"precision",void 0),this.precision=e}get typeId(){return WB.Float}get[GB](){return"Float"}toString(){return"Float".concat(this.precision)}}class nF extends iF{constructor(){super(eF)}}class rF extends iF{constructor(){super(tF)}}HB=Symbol.toStringTag;class sF extends qB{constructor(e,t){super(),bt(this,"listSize",void 0),bt(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return WB.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[HB](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function oF(e,t,i){const n=function(e){switch(e.constructor){case Int8Array:return new $B;case Uint8Array:return new JB;case Int16Array:return new ZB;case Uint16Array:return new KB;case Int32Array:return new YB;case Uint32Array:return new QB;case Float32Array:return new nF;case Float64Array:return new rF;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new VB(e,new sF(t.size,new VB("value",n)),!1,r)}function aF(e,t){(e.COLOR_0||e.colors)&&t||(e.colors={constant:!0,value:new Float32Array([1,1,1])}),Gn.assert(e.positions||e.POSITION,'no "postions" or "POSITION" attribute in mesh')}function lF(e,t){if(e.attributes)return aF(e.attributes,t),e instanceof Hu?e:new Hu(e);if(e.positions||e.POSITION)return aF(e,t),new Hu({attributes:e});throw Error("Invalid mesh")}const cF={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_useMeshColors:{type:"boolean",value:!1},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:[0,0,0,255]},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}};class uF extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){const e=!ir(this.context.gl),t={};return fo(this.context.gl,uo)&&(t.DERIVATIVES_AVAILABLE=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin mat3 instanceModelMatrix;\nin vec3 instanceTranslation;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\n\nvoid main(void) {\n  geometry.worldPosition = instancePositions;\n  geometry.uv = texCoords;\n  geometry.pickingColor = instancePickingColors;\n\n  vTexCoord = texCoords;\n  cameraPosition = project_uCameraPosition;\n  vColor = vec4(colors * instanceColors.rgb, instanceColors.a);\n\n  vec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation;\n\n  if (composeModelMatrix) {\n    DECKGL_FILTER_SIZE(pos, geometry);\n    normals_commonspace = project_normal(instanceModelMatrix * normals);\n    geometry.worldPosition += pos;\n    gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);\n    geometry.position = position_commonspace;\n  }\n  else {\n    pos = project_size(pos);\n    DECKGL_FILTER_SIZE(pos, geometry);\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);\n    geometry.position = position_commonspace;\n    normals_commonspace = project_normal(instanceModelMatrix * normals);\n  }\n\n  geometry.normal = normals_commonspace;\n  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\n\nprecision highp float;\n\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n  geometry.uv = vTexCoord;\n\n  vec3 normal;\n  if (flatShading) {\n#ifdef DERIVATIVES_AVAILABLE\n    normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n#else\n    normal = vec3(0.0, 0.0, 1.0);\n#endif\n  } else {\n    normal = normals_commonspace;\n  }\n\n  vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\n  DECKGL_FILTER_COLOR(color, geometry);\n\n  vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n  fragColor = vec4(lightColor, color.a * opacity);\n}\n",modules:[jd,Eu,Gd],transpileToGLSL100:e,defines:t})}getBounds(){var e;if(this.props._instanced)return super.getBounds();let t=this.state.positionBounds;if(t)return t;const{mesh:i}=this.props;if(!i)return null;if(t=null===(e=i.header)||void 0===e?void 0:e.boundingBox,!t){const{attributes:e}=lF(i,this.props._useMeshColors);e.POSITION=e.POSITION||e.positions,t=kB(e)}return this.state.positionBounds=t,t}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:5130,fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:5121,transition:!0,size:this.props.colorFormat.length,normalized:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:FB}),this.setState({emptyTexture:new Ls(this.context.gl,{data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:n}=e;if(t.mesh!==i.mesh||n.extensionsChanged){var r;if(this.state.positionBounds=null,null===(r=this.state.model)||void 0===r||r.delete(),t.mesh){this.state.model=this.getModel(t.mesh);const e=t.mesh.attributes||t.mesh;this.setState({hasNormals:Boolean(e.NORMAL||e.normals)})}this.getAttributeManager().invalidateAll()}t.texture!==i.texture&&this.setTexture(t.texture),this.state.model&&this.state.model.setDrawMode(this.props.wireframe?3:4)}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){if(!this.state.model)return;const{viewport:t}=this.context,{sizeScale:i,coordinateSystem:n,_instanced:r}=this.props;this.state.model.setUniforms(e).setUniforms({sizeScale:i,composeModelMatrix:!r||NB(t,n),flatShading:!this.state.hasNormals}).draw()}get isLoaded(){var e;return(null===(e=this.state)||void 0===e?void 0:e.model)&&super.isLoaded}getModel(e){const t=new Du(this.context.gl,{...this.getShaders(),id:this.props.id,geometry:lF(e,this.props._useMeshColors),isInstanced:!0}),{texture:i}=this.props,{emptyTexture:n}=this.state;return t.setUniforms({sampler:i||n,hasTexture:Boolean(i)}),t}setTexture(e){const{emptyTexture:t,model:i}=this.state;i&&i.setUniforms({sampler:e||t,hasTexture:Boolean(e)})}}bt(uF,"defaultProps",cF),bt(uF,"layerName","SimpleMeshLayer");class hF{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t}=e;this.id=t||ls(this.constructor.name),this.display=!0,this.position=new gc,this.rotation=new gc,this.scale=new gc(1,1,1),this.matrix=new Hc,this.userData={},this.props={},this._setScenegraphNodeProps(e)}delete(){}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return"{type: ScenegraphNode, id: ".concat(this.id,")}")}getBounds(){return null}setPosition(e){return rs(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return rs(3===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return rs(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e){!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:t,rotation:i,scale:n,update:r=!0}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),r&&this.updateMatrix(),this}updateMatrix(){const e=this.position,t=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(i),this}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{position:t,rotation:i,scale:n}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){rs(e),t=t||this.matrix;const i=new Hc(e).multiplyRight(t),n=i.invert(),r=n.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:i,worldInverseMatrix:n,worldInverseTransposeMatrix:r}}_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)}}class dF extends hF{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;Qn.assert(t.every(e=>e instanceof hF),"every child must an instance of ScenegraphNode"),super(e),this.children=t}add(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(const e of t)Array.isArray(e)?this.add(...e):this.children.push(e);return this}remove(e){const t=this.children,i=t.indexOf(e);return i>-1&&t.splice(i,1),this}removeAll(){return this.children=[],this}delete(){this.children.forEach(e=>e.delete()),this.removeAll(),super.delete()}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,i)=>{let{worldMatrix:n}=i;const r=t.getBounds();if(!r)return;const[s,o]=r,a=new gc(s).add(o).divide([2,2,2]);n.transformAsPoint(a,a);const l=new gc(o).subtract(s).divide([2,2,2]);n.transformAsVector(l,l);for(let t=0;t<8;t++){const i=new gc(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(l).add(a);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],i[t]),e[1][t]=Math.max(e[1][t],i[t])}}),Number.isFinite(e[0][0])?e:null}traverse(e){let{worldMatrix:t=new Hc}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new Hc(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof dF?t.traverse(e,{worldMatrix:i}):e(t,{worldMatrix:i})}}const pF={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fF={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function mF(e){if(!e._animation){const t=fF[e.componentType],i=pF[e.type],n=i*e.count,{buffer:r,byteOffset:s}=e.bufferView.data,o=new t(r,s+(e.byteOffset||0),n);if(1===i)e._animation=Array.from(o);else{const t=[];for(let e=0;e<o.length;e+=i)t.push(Array.from(o.slice(e,e+i)));e._animation=t}}return e._animation}const gF=new Hc;const _F=new uu;function yF(e,t,i,n){let{input:r,interpolation:s,output:o}=t;const a=e%r[r.length-1],l=r.findIndex(e=>e>=a),c=Math.max(0,l-1);if(!Array.isArray(i[n]))switch(n){case"translation":i[n]=[0,0,0];break;case"rotation":i[n]=[0,0,0,1];break;case"scale":i[n]=[1,1,1];break;default:Qn.warn("Bad animation path ".concat(n))()}rs(i[n].length===o[c].length);const u=r[c],h=r[l];switch(s){case"STEP":!function(e,t,i){for(let n=0;n<i.length;n++)e[t][n]=i[n]}(i,n,o[c]);break;case"LINEAR":if(h>u){!function(e,t,i,n,r){if("rotation"===t){_F.slerp({start:i,target:n,ratio:r});for(let i=0;i<_F.length;i++)e[t][i]=_F[i]}else for(let s=0;s<i.length;s++)e[t][s]=r*n[s]+(1-r)*i[s]}(i,n,o[c],o[l],(a-u)/(h-u))}break;case"CUBICSPLINE":if(h>u){!function(e,t,i){let{p0:n,outTangent0:r,inTangent1:s,p1:o,tDiff:a,ratio:l}=i;for(let i=0;i<e[t].length;i++){const c=r[i]*a,u=s[i]*a;e[t][i]=(2*Math.pow(l,3)-3*Math.pow(l,2)+1)*n[i]+(Math.pow(l,3)-2*Math.pow(l,2)+l)*c+(-2*Math.pow(l,3)+3*Math.pow(l,2))*o[i]+(Math.pow(l,3)-Math.pow(l,2))*u}}(i,n,{p0:o[3*c+1],outTangent0:o[3*c+2],inTangent1:o[3*l+0],p1:o[3*l+1],tDiff:h-u,ratio:(a-u)/(h-u)})}break;default:Qn.warn("Interpolation ".concat(s," not supported"))()}}class vF{constructor(e){this.startTime=0,this.playing=!0,this.speed=1,this.channels=[],Object.assign(this,e)}animate(e){if(!this.playing)return;const t=(e/1e3-this.startTime)*this.speed;this.channels.forEach(e=>{let{sampler:i,target:n,path:r}=e;yF(t,i,n,r),function(e,t){if(t.matrix.identity(),e.translation&&t.matrix.translate(e.translation),e.rotation){const i=gF.fromQuaternion(e.rotation);t.matrix.multiplyRight(i)}e.scale&&t.matrix.scale(e.scale)}(n,n._node)})}}class xF{constructor(e){this.animations=e.animations.map((t,i)=>{const n=t.name||"Animation-".concat(i),r=t.samplers.map(t=>{let{input:i,interpolation:n="LINEAR",output:r}=t;return{input:mF(e.accessors[i]),interpolation:n,output:mF(e.accessors[r])}}),s=t.channels.map(t=>{let{sampler:i,target:n}=t;return{sampler:r[i],target:e.nodes[n.node],path:n.path}});return new vF({name:n,channels:s})})}animate(e){this.setTime(e)}setTime(e){this.animations.forEach(t=>t.animate(e))}getAnimations(){return this.animations}}class bF extends hF{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),this.onBeforeRender=null,this.AfterRender=null,e instanceof Du?(this.model=e,this._setModelNodeProps(t)):this.model=new Du(e,t),this.bounds=null,this.managedResources=t.managedResources||[]}setProps(e){return super.setProps(e),this._setModelNodeProps(e),this}getBounds(){return this.bounds}delete(){this.model&&(this.model.delete(),this.model=null),this.managedResources.forEach(e=>e.delete()),this.managedResources=[]}draw(){return this.model.draw(...arguments)}setUniforms(){return this.model.setUniforms(...arguments),this}setAttributes(){return this.model.setAttributes(...arguments),this}updateModuleSettings(){return this.model.updateModuleSettings(...arguments),this}_setModelNodeProps(e){this.model.setProps(e)}}class wF{constructor(e,t){let{attributes:i,material:n,pbrDebug:r,imageBasedLightingEnvironment:s,lights:o,useTangents:a}=t;this.gl=e,this.defines={MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},fo(e,ho)&&(this.defines.USE_TEX_LOD=1),this.uniforms={u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},this.parameters={},this.generatedTextures=[],s&&(this.uniforms.u_DiffuseEnvSampler=s.getDiffuseEnvSampler(),this.uniforms.u_SpecularEnvSampler=s.getSpecularEnvSampler(),this.uniforms.u_brdfLUT=s.getBrdfTexture(),this.uniforms.u_ScaleIBLAmbient=[1,1]),r&&(this.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],this.uniforms.u_ScaleFGDSpec=[0,0,0,0]),this.defineIfPresent(i.NORMAL,"HAS_NORMALS"),this.defineIfPresent(i.TANGENT&&a,"HAS_TANGENTS"),this.defineIfPresent(i.TEXCOORD_0,"HAS_UV"),this.defineIfPresent(s,"USE_IBL"),this.defineIfPresent(o,"USE_LIGHTS"),this.defineIfPresent(r,"PBR_DEBUG"),n&&this.parseMaterial(n)}defineIfPresent(e,t){e&&(this.defines[t]=1)}parseTexture(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const n=e.texture&&e.texture.sampler&&e.texture.sampler.parameters||{},r=e.texture.source.image;let s,o={};r.compressed?(s=r,o={[this.gl.TEXTURE_MIN_FILTER]:r.data.length>1?this.gl.LINEAR_MIPMAP_NEAREST:this.gl.LINEAR}):s={data:r};const a=new Ls(this.gl,{id:e.name||e.id,parameters:{...n,...o},pixelStore:{[this.gl.UNPACK_FLIP_Y_WEBGL]:!1},...s});this.uniforms[t]=a,this.defineIfPresent(i,i),this.generatedTextures.push(a)}parsePbrMetallicRoughness(e){e.baseColorTexture&&this.parseTexture(e.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP"),this.uniforms.u_BaseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&this.parseTexture(e.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP");const{metallicFactor:t=1,roughnessFactor:i=1}=e;this.uniforms.u_MetallicRoughnessValues=[t,i]}parseMaterial(e){if(this.uniforms.pbr_uUnlit=Boolean(e.unlit),e.pbrMetallicRoughness&&this.parsePbrMetallicRoughness(e.pbrMetallicRoughness),e.normalTexture){this.parseTexture(e.normalTexture,"u_NormalSampler","HAS_NORMALMAP");const{scale:t=1}=e.normalTexture;this.uniforms.u_NormalScale=t}if(e.occlusionTexture){this.parseTexture(e.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP");const{strength:t=1}=e.occlusionTexture;this.uniforms.u_OcclusionStrength=t}if(e.emissiveTexture&&(this.parseTexture(e.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP"),this.uniforms.u_EmissiveFactor=e.emissiveFactor||[0,0,0]),"MASK"===e.alphaMode){const{alphaCutoff:t=.5}=e;this.defines.ALPHA_CUTOFF=1,this.uniforms.u_AlphaCutoff=t}else"BLEND"===e.alphaMode&&(Qn.warn("BLEND alphaMode might not work well because it requires mesh sorting")(),Object.assign(this.parameters,{blend:!0,blendEquation:this.gl.FUNC_ADD,blendFunc:[this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA]}))}delete(){this.generatedTextures.forEach(e=>e.delete())}}function TF(e,t){return ir(e)?"#version 300 es\n".concat(t):t}const SF={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},EF={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1};class AF{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=e,this.options=Object.assign({},EF,t)}instantiate(e){this.gltf=e;return(e.scenes||[]).map(e=>this.createScene(e))}createAnimator(){return Array.isArray(this.gltf.animations)?new xF(this.gltf):null}createScene(e){const t=(e.nodes||[]).map(e=>this.createNode(e));return new dF({id:e.name||e.id,children:t})}createNode(e){if(!e._node){const t=(e.children||[]).map(e=>this.createNode(e));e.mesh&&t.push(this.createMesh(e.mesh));const i=new dF({id:e.name||e.id,children:t});if(e.matrix)i.setMatrix(e.matrix);else{if(i.matrix.identity(),e.translation&&i.matrix.translate(e.translation),e.rotation){const t=(new Hc).fromQuaternion(e.rotation);i.matrix.multiplyRight(t)}e.scale&&i.matrix.scale(e.scale)}e._node=i}return e._node}createMesh(e){if(!e._mesh){const t=(e.primitives||[]).map((t,i)=>this.createPrimitive(t,i,e)),i=new dF({id:e.name||e.id,children:t});e._mesh=i}return e._mesh}getVertexCount(e){Qn.warn("getVertexCount() not found")()}createPrimitive(e,t,i){const n=function(e,t){const{id:i,drawMode:n,vertexCount:r,attributes:s,modelOptions:o}=t,a=new wF(e,t);Qn.info(4,"createGLTFModel defines: ",a.defines)();const l=[];l.push(...a.generatedTextures),l.push(...Object.values(s).map(e=>e.buffer));const c=new bF(e,{id:i,drawMode:n,vertexCount:r,modules:[Au],parameters:a.parameters,vs:TF(e,"\n#if (__VERSION__ < 300)\n  #define _attr attribute\n#else\n  #define _attr in\n#endif\n\n  _attr vec4 POSITION;\n\n  #ifdef HAS_NORMALS\n    _attr vec4 NORMAL;\n  #endif\n\n  #ifdef HAS_TANGENTS\n    _attr vec4 TANGENT;\n  #endif\n\n  #ifdef HAS_UV\n    _attr vec2 TEXCOORD_0;\n  #endif\n\n  void main(void) {\n    vec4 _NORMAL = vec4(0.);\n    vec4 _TANGENT = vec4(0.);\n    vec2 _TEXCOORD_0 = vec2(0.);\n\n    #ifdef HAS_NORMALS\n      _NORMAL = NORMAL;\n    #endif\n\n    #ifdef HAS_TANGENTS\n      _TANGENT = TANGENT;\n    #endif\n\n    #ifdef HAS_UV\n      _TEXCOORD_0 = TEXCOORD_0;\n    #endif\n\n    pbr_setPositionNormalTangentUV(POSITION, _NORMAL, _TANGENT, _TEXCOORD_0);\n    gl_Position = u_MVPMatrix * POSITION;\n  }\n"),fs:TF(e,"\n#if (__VERSION__ < 300)\n  #define fragmentColor gl_FragColor\n#else\n  out vec4 fragmentColor;\n#endif\n\n  void main(void) {\n    fragmentColor = pbr_filterColor(vec4(0));\n  }\n"),managedResources:l,...o,defines:{...a.defines,...o.defines}});return c.setProps({attributes:s}),c.setUniforms(a.uniforms),c}(this.gl,Object.assign({id:e.name||"".concat(i.name||i.id,"-primitive-").concat(t),drawMode:e.mode||4,vertexCount:e.indices?e.indices.count:this.getVertexCount(e.attributes),attributes:this.createAttributes(e.attributes,e.indices),material:e.material},this.options));return n.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],n}createAttributes(e,t){const i={};return Object.keys(e).forEach(t=>{i[t]=this.createAccessor(e[t],this.createBuffer(e[t],this.gl.ARRAY_BUFFER))}),t&&(i.indices=this.createAccessor(t,this.createBuffer(t,this.gl.ELEMENT_ARRAY_BUFFER))),Qn.info(4,"glTF Attributes",{attributes:e,indices:t,generated:i})(),i}createBuffer(e,t){e.bufferView||(e.bufferView={});const{bufferView:i}=e;return i.lumaBuffers||(i.lumaBuffers={}),i.lumaBuffers[t]||(i.lumaBuffers[t]=new Ss(this.gl,{id:"from-".concat(i.id),data:i.data||e.value,target:t})),i.lumaBuffers[t]}createAccessor(e,t){return new xs({buffer:t,offset:e.byteOffset||0,stride:e.bufferView.byteStride||0,type:e.componentType,size:SF[e.type]})}createSampler(e){return e}needsPOT(){return!1}}const MF="3.4.15",IF="https://unpkg.com/@loaders.gl/textures@".concat(MF,"/dist/libs/basis_encoder.wasm"),CF="https://unpkg.com/@loaders.gl/textures@".concat(MF,"/dist/libs/basis_encoder.js");let PF,LF;async function RF(e){const t=e.modules||{};return t.basis?t.basis:(PF=PF||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await zt("basis_transcoder.js","textures",e),await zt("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,initializeBasis:n}=e;n(),t({BasisFile:i})})})}(t,i)}(e),await PF)}async function OF(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(LF=LF||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await zt(CF,"textures",e),await zt(IF,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,KTX2File:n,initializeBasis:r,BasisEncoder:s}=e;r(),t({BasisFile:i,KTX2File:n,BasisEncoder:s})})})}(t,i)}(e),await LF)}const DF=33776,BF=33779,FF=35840,NF=35842,kF=36196,zF=37808,UF=["","WEBKIT_","MOZ_"],VF={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"};let jF=null;function GF(e){if(!jF){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,jF=new Set;for(const t of UF)for(const i in VF)if(e&&e.getExtension("".concat(t).concat(i))){jF.add(VF[i])}}return jF}var HF,WF,qF,XF,$F,ZF,YF,JF,KF;(KF=HF||(HF={}))[KF.NONE=0]="NONE",KF[KF.BASISLZ=1]="BASISLZ",KF[KF.ZSTD=2]="ZSTD",KF[KF.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(WF||(WF={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(qF||(qF={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(XF||(XF={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}($F||($F={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(ZF||(ZF={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(YF||(YF={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(JF||(JF={}));const QF=[171,75,84,88,32,50,48,187,13,10,26,10];const eN={etc1:{basisFormat:0,compressed:!0,format:kF},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:DF},bc3:{basisFormat:3,compressed:!0,format:BF},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:FF},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:NF},"astc-4x4":{basisFormat:10,compressed:!0,format:zF},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function tN(e,t,i){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");const e=n.getNumImages(),t=[];for(let r=0;r<e;r++){const e=n.getNumLevels(r),s=[];for(let t=0;t<e;t++)s.push(iN(n,r,t,i));t.push(s)}return t}finally{n.close(),n.delete()}}function iN(e,t,i,n){const r=e.getImageWidth(t,i),s=e.getImageHeight(t,i),o=e.getHasAlpha(),{compressed:a,format:l,basisFormat:c}=sN(n,o),u=e.getImageTranscodedSizeInBytes(t,i,c),h=new Uint8Array(u);if(!e.transcodeImage(h,t,i,c,0,0))throw new Error("failed to start Basis transcoding");return{width:r,height:s,data:h,compressed:a,format:l,hasAlpha:o}}function nN(e,t,i){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=n.getLevels(),t=[];for(let r=0;r<e;r++){t.push(rN(n,r,i));break}return[t]}finally{n.close(),n.delete()}}function rN(e,t,i){const{alphaFlag:n,height:r,width:s}=e.getImageLevelInfo(t,0,0),{compressed:o,format:a,basisFormat:l}=sN(i,n),c=e.getImageTranscodedSizeInBytes(t,0,0,l),u=new Uint8Array(c);if(!e.transcodeImage(u,t,0,0,l,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:s,height:r,data:u,compressed:o,levelSize:c,hasAlpha:n,format:a}}function sN(e,t){let i=e&&e.basis&&e.basis.format;return"auto"===i&&(i=oN()),"object"==typeof i&&(i=t?i.alpha:i.noAlpha),i=i.toLowerCase(),eN[i]}function oN(){const e=GF();return e.has("astc")?"astc-4x4":e.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:e.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:e.has("etc1")?"etc1":e.has("etc2")?"etc2":"rgb565"}const aN={...{name:"Basis",id:mt?"basis":"basis-nodejs",module:"textures",version:"3.4.15",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},parse:async function(e,t){if("auto"===t.basis.containerFormat){if(function(e){const t=new Uint8Array(e);return!(t.byteLength<QF.length||t[0]!==QF[0]||t[1]!==QF[1]||t[2]!==QF[2]||t[3]!==QF[3]||t[4]!==QF[4]||t[5]!==QF[5]||t[6]!==QF[6]||t[7]!==QF[7]||t[8]!==QF[8]||t[9]!==QF[9]||t[10]!==QF[10]||t[11]!==QF[11])}(e)){return nN((await OF(t)).KTX2File,e,t)}const{BasisFile:i}=await RF(t);return tN(i,e,t)}if("encoder"===t.basis.module){const i=await OF(t);return"ktx2"===t.basis.containerFormat?nN(i.KTX2File,e,t):tN(i.BasisFile,e,t)}{const{BasisFile:i}=await RF(t);return tN(i,e,t)}}};function lN(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function cN(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}const uN=["SCALAR","VEC2","VEC3","VEC4"],hN=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],dN=new Map(hN),pN={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fN={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},mN={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function gN(e){return uN[e-1]||uN[0]}function _N(e){const t=dN.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function yN(e,t){const i=mN[e.componentType],n=pN[e.type],r=e.count*n,s=e.count*n*fN[e.componentType];return lN(s>=0&&s<=t.byteLength),{ArrayType:i,length:r,byteLength:s}}function vN(e){let{images:t,bufferViews:i}=e;t=t||[],i=i||[];const n=t.map(e=>e.bufferView);i=i.filter(e=>!n.includes(e));const r=i.reduce((e,t)=>e+t.byteLength,0),s=t.reduce((e,t)=>{const{width:i,height:n}=t.image;return e+i*n},0);return r+Math.ceil(4*s*1.33)}const xN={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class bN{constructor(e){bt(this,"gltf",void 0),bt(this,"sourceBuffers",void 0),bt(this,"byteLength",void 0),this.gltf=e||{json:{...xN},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e);return t?(this.json.extensions||{})[e]||!0:null}getRequiredExtension(e){const t=this.getRequiredExtensions().find(t=>t===e);return t?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}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,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}getTypedArrayForBufferView(e){e=this.getBufferView(e);const t=this.gltf.buffers[e.buffer];lN(t);return new Uint8Array(t.arrayBuffer,(e.byteOffset||0)+t.byteOffset,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,{ArrayType:n,length:r}=yN(e,t);return new n(i,t.byteOffset+e.byteOffset,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer);return new Uint8Array(i.data,t.byteOffset||0,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}setObjectExtension(e,t,i){(e.extensions||{})[t]=i}removeObjectExtension(e,t){const i=e.extensions||{},n=i[t];return delete i[t],n}addExtension(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return lN(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return lN(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(!this.getExtension(e))return;this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e],Array.isArray(this.json.extensionsRemoved)||(this.json.extensionsRemoved=[]);const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const n={mesh:t};return i&&(n.matrix=i),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:n,mode:r=4}=e,s={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);s.primitives[0].indices=e}return Number.isFinite(n)&&(s.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=Fn(e),n=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;lN(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Wt(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:gN(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{size:3};const i=this.addBufferView(e);let n={min:t.min,max:t.max};n.min&&n.max||(n=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:_N(e),count:Math.round(e.length/t.size),min:n.min,max:n.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};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(){var e,t;this.gltf.buffers=[];const i=this.byteLength,n=new ArrayBuffer(i),r=new Uint8Array(n);let s=0;for(const e of this.sourceBuffers||[])s=qt(e,r,s);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=i:this.json.buffers=[{byteLength:i}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(e,t){let i=!0;for(;i;){const n=e.indexOf(t);n>-1?e.splice(n,1):i=!1}}_addAttributes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={};for(const i in e){const n=e[i],r=this._getGltfAttributeName(i),s=this.addBinaryBuffer(n.value,n);t[r]=s}return t}_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,t){const i={min:null,max:null};if(e.length<t)return i;i.min=[],i.max=[];const n=e.subarray(0,t);for(const e of n)i.min.push(e),i.max.push(e);for(let n=t;n<e.length;n+=t)for(let r=0;r<t;r++)i.min[0+r]=Math.min(i.min[0+r],e[n+r]),i.max[0+r]=Math.max(i.max[0+r],e[n+r]);return i}}const wN="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",TN="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",SN=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]),EN=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]),AN={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},MN={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function IN(e,t,i,n,r){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NONE";const o=await async function(){CN||(CN=async function(){let e=wN;WebAssembly.validate(SN)&&(e=TN);const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;++i){const n=e.charCodeAt(i);t[i]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let i=0;for(let n=0;n<e.length;++n)t[i++]=t[n]<60?EN[t[n]]:64*(t[n]-60)+t[++n];return t.buffer.slice(0,i)}(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}());return CN}();!function(e,t,i,n,r,s,o){const a=e.exports.sbrk,l=n+3&-4,c=a(l*r),u=a(s.length),h=new Uint8Array(e.exports.memory.buffer);h.set(s,u);const d=t(c,n,r,u,s.length);0===d&&o&&o(c,l,r);if(i.set(h.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error("Malformed buffer data: ".concat(d))}(o,o.exports[MN[r]],e,t,i,n,o.exports[AN[s||"NONE"]])}let CN;const PN="EXT_meshopt_compression";async function LN(e,t){const i=e.getObjectExtension(t,PN);if(i){const{byteOffset:n=0,byteLength:r=0,byteStride:s,count:o,mode:a,filter:l="NONE",buffer:c}=i,u=e.gltf.buffers[c],h=new Uint8Array(u.arrayBuffer,u.byteOffset+n,r),d=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);return await IN(d,o,s,h,a,l),d}return null}var RN=Object.freeze({__proto__:null,decode:async function(e,t){var i;const n=new bN(e);if(null==t||null===(i=t.gltf)||void 0===i||!i.decompressMeshes)return;const r=[];for(const t of e.json.bufferViews||[])r.push(LN(n,t));await Promise.all(r),n.removeExtension(PN)},name:PN});let ON;(async function(){const e=new Set;for(const t of zn){(ut?await jn(t):Un(t))&&e.add(t)}return e})().then(e=>{ON=e});const DN="EXT_texture_webp";var BN=Object.freeze({__proto__:null,name:DN,preprocess:function(e,t){const i=new bN(e);if(!ON.has("image/webp")){if(i.getRequiredExtensions().includes(DN))throw new Error("gltf: Required extension ".concat(DN," not supported by browser"));return}const{json:n}=i;for(const e of n.textures||[]){const t=i.getObjectExtension(e,DN);t&&(e.source=t.source),i.removeObjectExtension(e,DN)}i.removeExtension(DN)}});const FN="KHR_texture_basisu";var NN=Object.freeze({__proto__:null,name:FN,preprocess:function(e,t){const i=new bN(e),{json:n}=i;for(const e of n.textures||[]){const t=i.getObjectExtension(e,FN);t&&(e.source=t.source),i.removeObjectExtension(e,FN)}i.removeExtension(FN)}});const kN={draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},zN={name:"Draco",id:mt?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:"3.4.15",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:kN};function UN(e,t,i){return oF(e,t,i?VN(i.metadata):void 0)}function VN(e){const t=new Map;for(const i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}const jN={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},GN={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class HN{constructor(e){bt(this,"draco",void 0),bt(this,"decoder",void 0),bt(this,"metadataQuerier",void 0),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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const n=this.decoder.GetEncodedGeometryType(i),r=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(n){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const s=this._getDracoLoaderData(r,n,t),o=this._getMeshData(r,s,t),a=kB(o.attributes),l=function(e,t,i){const n=VN(t.metadata),r=[],s=function(e){const t={};for(const i in e){const n=e[i];t[n.name||"undefined"]=n}return t}(t.attributes);for(const t in e){const i=UN(t,e[t],s[t]);r.push(i)}if(i){const e=UN("indices",i);r.push(e)}return new zB(r,n)}(o.attributes,s,o.indices);return{loader:"draco",loaderData:s,header:{vertexCount:r.num_points(),boundingBox:a},...o,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const n=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:r}}_getDracoAttributes(e,t){const i={};for(let n=0;n<e.num_attributes();n++){const r=this.decoder.GetAttribute(e,n),s=this._getAttributeMetadata(e,n);i[r.unique_id()]={unique_id:r.unique_id(),attribute_type:r.attribute_type(),data_type:r.data_type(),num_components:r.num_components(),byte_offset:r.byte_offset(),byte_stride:r.byte_stride(),normalized:r.normalized(),attribute_index:n,metadata:s};const o=this._getQuantizationTransform(r,t);o&&(i[r.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(r,t);a&&(i[r.unique_id()].octahedron_transform=a)}return i}_getMeshData(e,t,i){const n=this._getMeshAttributes(t,e,i);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?"triangle-strip"===i.topology?{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(e,t,i){const n={};for(const r of Object.values(e.attributes)){const e=this._deduceAttributeName(r,i);r.name=e;const{value:s,size:o}=this._getAttributeValues(t,r);n[e]={value:s,size:o,byteOffset:r.byte_offset,byteStride:r.byte_stride,normalized:r.normalized}}return n}_getTriangleListIndices(e){const t=3*e.num_faces(),i=4*t,n=this.draco._malloc(i);try{return this.decoder.GetTrianglesUInt32Array(e,i,n),new Uint32Array(this.draco.HEAPF32.buffer,n,t).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=e.GetValue(n);return i}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const i=GN[t.data_type],n=t.num_components,r=e.num_points()*n,s=r*i.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,i);let a;const l=this.draco._malloc(s);try{const n=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,n,o,s,l),a=new i(this.draco.HEAPF32.buffer,l,r).slice()}finally{this.draco._free(l)}return{value:a,size:n}}_deduceAttributeName(e,t){const i=e.unique_id;for(const[e,n]of Object.entries(t.extraAttributes||{}))if(n===i)return e;const n=e.attribute_type;for(const e in jN){if(this.draco[e]===n)return jN[e]}const r=t.attributeNameEntry||"name";return e.metadata[r]?e.metadata[r].string:"CUSTOM_ATTRIBUTE_".concat(i)}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const i=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(i)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},i=this.metadataQuerier.NumEntries(e);for(let n=0;n<i;n++){const i=this.metadataQuerier.GetEntryName(e,n);t[i]=this._getDracoMetadataField(e,i)}return t}_getDracoMetadataField(e,t){const i=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,i);const n=function(e){const t=e.size(),i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=e.GetValue(n);return i}(i);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:n}}finally{this.draco.destroy(i)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:i=[]}=e,n=[...t,...i];for(const e of n)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:i=[]}=t,n=e.attribute_type();if(i.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,n=e.attribute_type();if(i.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const WN="https://www.gstatic.com/draco/versioned/decoders/".concat("1.5.5"),qN="".concat(WN,"/draco_decoder.js"),XN="".concat(WN,"/draco_wasm_wrapper.js"),$N="".concat(WN,"/draco_decoder.wasm");let ZN;async function YN(e){const t=e.modules||{};return ZN=t.draco3d?ZN||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):ZN||async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await zt(qN,"draco",e);else[t,i]=await Promise.all([await zt(XN,"draco",e),await zt($N,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await ZN}const JN={...zN,parse:async function(e,t){const{draco:i}=await YN(t),n=new HN(i);try{return n.parseSync(e,null==t?void 0:t.draco)}finally{n.destroy()}}};function KN(e){const{buffer:t,size:i,count:n}=function(e){let t=e,i=1,n=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),n=t.length/i);return{buffer:t,size:i,count:n}}(e);return{value:t,size:i,byteOffset:0,count:n,type:gN(i),componentType:_N(t)}}const QN="KHR_draco_mesh_compression";async function ek(e,t,i,n){const r=e.getObjectExtension(t,QN);if(!r)return;const s=e.getTypedArrayForBufferView(r.bufferView),o=Ht(s.buffer,s.byteOffset),{parse:a}=n,l={...i};delete l["3d-tiles"];const c=await a(o,JN,l,n),u=function(e){const t={};for(const i in e)if("indices"!==i){const n=KN(e[i]);t[i]=n}return t}(c.attributes);for(const[i,n]of Object.entries(u))if(i in t.attributes){const r=e.getAccessor(t.attributes[i]);null!=r&&r.min&&null!=r&&r.max&&(n.min=r.min,n.max=r.max)}t.attributes=u,c.indices&&(t.indices=KN(c.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function tk(e,t){var i;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=r.DracoWriter.encodeSync({attributes:e}),a=null==s||null===(i=s.parseSync)||void 0===i?void 0:i.call(s,{attributes:e}),l=r._addFauxAttributes(a.attributes),c=r.addBufferView(o);return{primitives:[{attributes:l,mode:n,extensions:{[QN]:{bufferView:c,attributes:l}}}]}}function*ik(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var nk=Object.freeze({__proto__:null,decode:async function(e,t,i){var n;if(null==t||null===(n=t.gltf)||void 0===n||!n.decompressMeshes)return;const r=new bN(e),s=[];for(const e of ik(r))r.getObjectExtension(e,QN)&&s.push(ek(r,e,t,i));await Promise.all(s),r.removeExtension(QN)},encode:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new bN(e);for(const e of i.json.meshes||[])tk(e,t),i.addRequiredExtension(QN)},name:QN,preprocess:function(e,t,i){const n=new bN(e);for(const e of ik(n))n.getObjectExtension(e,QN)}});const rk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},sk={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ok="KHR_texture_transform",ak=ok,lk=new gc,ck=new Ec,uk=new Ec;function hk(e,t){var i,n,r;const s=[],o=null===(i=t.json.materials)||void 0===i?void 0:i[e],a=null==o||null===(n=o.pbrMetallicRoughness)||void 0===n?void 0:n.baseColorTexture;a&&dk(t,e,a,s);const l=null==o?void 0:o.emissiveTexture;l&&dk(t,e,l,s);const c=null==o?void 0:o.normalTexture;c&&dk(t,e,c,s);const u=null==o?void 0:o.occlusionTexture;u&&dk(t,e,u,s);const h=null==o||null===(r=o.pbrMetallicRoughness)||void 0===r?void 0:r.metallicRoughnessTexture;h&&dk(t,e,h,s)}function dk(e,t,i,n){const r=function(e,t){var i;const n=null===(i=e.extensions)||void 0===i?void 0:i[ok],{texCoord:r=0}=e,{texCoord:s=r}=n,o=-1!==t.findIndex(e=>{let[t,i]=e;return t===r&&i===s});if(!o){const i=function(e){const{offset:t=[0,0],rotation:i=0,scale:n=[1,1]}=e,r=(new Ec).set(1,0,0,0,1,0,t[0],t[1],1),s=ck.set(Math.cos(i),Math.sin(i),0,-Math.sin(i),Math.cos(i),0,0,0,1),o=uk.set(n[0],0,0,0,n[1],0,0,0,1);return r.multiplyRight(s).multiplyRight(o)}(n);return r!==s&&(e.texCoord=s),t.push([r,s]),{originalTexCoord:r,texCoord:s,matrix:i}}return null}(i,n);if(!r)return;const s=e.json.meshes||[];for(const i of s)for(const n of i.primitives){const i=n.material;Number.isFinite(i)&&t===i&&pk(e,n,r)}}function pk(e,t,i){const{originalTexCoord:n,texCoord:r,matrix:s}=i,o=t.attributes["TEXCOORD_".concat(n)];if(Number.isFinite(o)){var a;const i=null===(a=e.json.accessors)||void 0===a?void 0:a[o];if(i&&i.bufferView){var l;const o=null===(l=e.json.bufferViews)||void 0===l?void 0:l[i.bufferView];if(o){const{arrayBuffer:a,byteOffset:l}=e.buffers[o.buffer],c=(l||0)+(i.byteOffset||0)+(o.byteOffset||0),{ArrayType:u,length:h}=yN(i,o),d=rk[i.type],p=o.byteStride||sk[i.componentType]*d,f=new Float32Array(h);for(let e=0;e<i.count;e++){const t=new u(a,c+e*p,2);lk.set(t[0],t[1],1),lk.transformByMatrix3(s),f.set([lk[0],lk[1]],e*d)}n===r?function(e,t,i,n){e.componentType=5126,i.push({arrayBuffer:n.buffer,byteOffset:0,byteLength:n.buffer.byteLength}),t.buffer=i.length-1,t.byteLength=n.buffer.byteLength,t.byteOffset=0,delete t.byteStride}(i,o,e.buffers,f):function(e,t,i,n,r){n.buffers.push({arrayBuffer:r.buffer,byteOffset:0,byteLength:r.buffer.byteLength});const s=n.json.bufferViews;if(!s)return;s.push({buffer:n.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const o=n.json.accessors;if(!o)return;o.push({bufferView:(null==s?void 0:s.length)-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),i.attributes["TEXCOORD_".concat(e)]=o.length-1}(r,i,t,e,f)}}}}var fk=Object.freeze({__proto__:null,decode:async function(e,t){if(!new bN(e).getExtension(ok))return;const i=e.json.materials||[];for(let t=0;t<i.length;t++)hk(t,e)},name:ak});const mk="KHR_lights_punctual";var gk=Object.freeze({__proto__:null,decode:async function(e){const t=new bN(e),{json:i}=t,n=t.getExtension(mk);n&&(t.json.lights=n.lights,t.removeExtension(mk));for(const e of i.nodes||[]){const i=t.getObjectExtension(e,mk);i&&(e.light=i.light),t.removeObjectExtension(e,mk)}},encode:async function(e){const t=new bN(e),{json:i}=t;if(i.lights){const e=t.addExtension(mk);lN(!e.lights),e.lights=i.lights,delete i.lights}if(t.json.lights){for(const e of t.json.lights){t.addObjectExtension(e.node,mk,e)}delete t.json.lights}},name:mk});const _k="KHR_materials_unlit";const yk="KHR_techniques_webgl";function vk(e,t){const i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)}),Object.keys(i).forEach(e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))}),i}const xk="EXT_feature_metadata";function bk(e,t,i){for(const r in i.properties){var n;const s=null==t||null===(n=t.properties)||void 0===n?void 0:n[r];if(s){const n=wk(e,i.properties[r],t.count,s);s.data=n}}}function wk(e,t,i,n){let r=e.getTypedArrayForBufferView(n.bufferView);switch(t.type){case"STRING":r=function(e,t,i){const n=[],r=new TextDecoder("utf8");let s=0;const o=4;for(let a=0;a<i;a++){const i=t[(a+1)*o]-t[a*o],l=e.subarray(s,i+s),c=r.decode(l);n.push(c),s+=i}return n}(r,e.getTypedArrayForBufferView(n.stringOffsetBufferView),i);break}return r}function Tk(e,t){for(const i in e){const n=e[i];if(n.class===t)return n}return null}const Sk=[RN,BN,NN,nk,gk,Object.freeze({__proto__:null,decode:async function(e){const t=new bN(e),{json:i}=t;for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,_k)}t.removeExtension(_k)},encode:function(e){const t=new bN(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,_k,{}),t.addExtension(_k))},name:_k}),Object.freeze({__proto__:null,decode:async function(e){const t=new bN(e),{json:i}=t,n=t.getExtension(yk);if(n){const e=function(e,t){const{programs:i=[],shaders:n=[],techniques:r=[]}=e,s=new TextDecoder;return n.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=s.decode(t.getTypedArrayForBufferView(e.bufferView))}),i.forEach(e=>{e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]}),r.forEach(e=>{e.program=i[e.program]}),r}(n,t);for(const n of i.materials||[]){const i=t.getObjectExtension(n,yk);i&&(n.technique=Object.assign({},i,e[i.technique]),n.technique.values=vk(n.technique,t)),t.removeObjectExtension(n,yk)}t.removeExtension(yk)}},encode:async function(e,t){},name:yk}),fk,Object.freeze({__proto__:null,decode:async function(e){!function(e){var t;const i=e.getExtension(xk),n=null==i||null===(t=i.schema)||void 0===t?void 0:t.classes,r=null==i?void 0:i.featureTables;if(n&&r)for(const t in n){const i=n[t],s=Tk(r,t);s&&bk(e,s,i)}}(new bN(e))},name:xk})];function Ek(e,t){var i;const n=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in n&&!n[e])}const Ak="KHR_binary_glTF";const Mk={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Ik={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Ck{constructor(){bt(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),bt(this,"json",void 0)}normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return}if(!t.normalize)throw new Error("glTF v1 is not supported.");this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new bN(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,Ak);i&&Object.assign(e,i),t.removeObjectExtension(e,Ak)}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension(Ak)}(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(const t in Mk)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const n in i){const r=i[n];r.id=r.id||n;const s=e[t].length;e[t].push(r),this.idToIndexMap[t][n]=s}}}_convertObjectIdsToArrayIndices(e){for(const t in Mk)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:n}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),n&&(t.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(e[t]=[]);for(const i of e[t])for(const e in i){const t=this._convertIdToIndex(i[e],e);i[e]=t}}_convertIdToIndex(e,t){const i=Ik[t];if(i in this.idToIndexMap){const n=this.idToIndexMap[i][e];if(!Number.isFinite(n))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return n}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const r of e.materials){var t,i,n;r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const s=(null===(t=r.values)||void 0===t?void 0:t.tex)||(null===(i=r.values)||void 0===i?void 0:i.texture2d_0)||(null===(n=r.values)||void 0===n?void 0:n.diffuseTex),o=e.textures.findIndex(e=>e.id===s);-1!==o&&(r.pbrMetallicRoughness.baseColorTexture={index:o})}}}const Pk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Lk={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Rk=10240,Ok=10241,Dk=10242,Bk=10243,Fk=10497,Nk=9729,kk=9986,zk={magFilter:Rk,minFilter:Ok,wrapS:Dk,wrapT:Bk},Uk={[Rk]:Nk,[Ok]:kk,[Dk]:Fk,[Bk]:Fk};class Vk{constructor(){bt(this,"baseUri",""),bt(this,"json",{}),bt(this,"buffers",[]),bt(this,"images",[])}postProcess(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{json:i,buffers:n=[],images:r=[],baseUri:s=""}=e;return lN(i),this.baseUri=s,this.json=i,this.buffers=n,this.images=r,this._resolveTree(this.json,t),this.json}_resolveTree(e){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(e.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(e.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(e.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(e.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(e.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(e.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t))),e.skins&&(e.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(e.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;return this.json[e]&&this.json[e][t]}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map(e=>this.getNode(e))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e},{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const i in t)e.attributes[i]=this.getAccessor(t[i]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e})),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=Lk[e.componentType],e.components=Pk[e.type],e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:i,byteLength:n}=yN(e,e.bufferView),r=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let s=t.arrayBuffer.slice(r,r+n);e.bufferView.byteStride&&(s=this._getValueFromInterleavedBuffer(t,r,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new i(s)}return e}_getValueFromInterleavedBuffer(e,t,i,n,r){const s=new Uint8Array(r*n);for(let o=0;o<r;o++){const r=t+o*i;s.set(new Uint8Array(e.arrayBuffer.slice(r,r+n)),o*n)}return s.buffer}_resolveTexture(e,t){return e.id=e.id||"texture-".concat(t),e.sampler="sampler"in e?this.getSampler(e.sampler):Uk,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||"sampler-".concat(t),e.parameters={};for(const t in e){const i=this._enumSamplerParameter(t);void 0!==i&&(e.parameters[i]=e[t])}return e}_enumSamplerParameter(e){return zk[e]}_resolveImage(e,t){e.id=e.id||"image-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const i=this.images[t];return i&&(e.image=i),e}_resolveBufferView(e,t){const i=e.buffer,n={id:"bufferView-".concat(t),...e,buffer:this.buffers[i]};let r=this.buffers[i].byteOffset||0;return"byteOffset"in e&&(r+=e.byteOffset),n.data=new Uint8Array(this.buffers[i].arrayBuffer,r,e.byteLength),n}_resolveCamera(e,t){return e.id=e.id||"camera-".concat(t),e}}const jk=1735152710,Gk=1313821514,Hk=5130562,Wk=!0;function qk(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=new DataView(t),r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return"".concat(String.fromCharCode(e.getUint8(t+0))).concat(String.fromCharCode(e.getUint8(t+1))).concat(String.fromCharCode(e.getUint8(t+2))).concat(String.fromCharCode(e.getUint8(t+3)))}(n,i+0),s=n.getUint32(i+4,Wk),o=n.getUint32(i+8,Wk);switch(Object.assign(e,{header:{byteOffset:i,byteLength:o,hasBinChunk:!1},type:r,version:s,json:{},binChunks:[]}),i+=12,e.version){case 1:return function(e,t,i){ct(e.header.byteLength>20);const n=t.getUint32(i+0,Wk),r=t.getUint32(i+4,Wk);return i+=8,ct(0===r),Xk(e,t,i,n),i+=n,i+=$k(e,t,i,e.header.byteLength),i}(e,n,i);case 2:return function(e,t,i,n){return ct(e.header.byteLength>20),function(e,t,i,n){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,Wk),s=t.getUint32(i+4,Wk);switch(i+=8,s){case Gk:Xk(e,t,i,r);break;case Hk:$k(e,t,i,r);break;case 0:n.strict||Xk(e,t,i,r);break;case 1:n.strict||$k(e,t,i,r)}i+=Wt(r,4)}}(e,t,i,n),i+e.header.byteLength}(e,n,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function Xk(e,t,i,n){const r=new Uint8Array(t.buffer,i,n),s=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(s),Wt(n,4)}function $k(e,t,i,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:n,arrayBuffer:t.buffer}),Wt(n,4)}async function Zk(e,t){var i,n,r,s;let o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;!function(e,t,i,n){n.uri&&(e.baseUri=n.uri);if(t instanceof ArrayBuffer&&!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new DataView(e),{magic:r=jk}=i,s=n.getUint32(t,!1);return s===r||s===jk}(t,i,n)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Gt(t);else if(t instanceof ArrayBuffer){const r={};i=qk(r,t,i,n.glb),lN("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else lN(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const s=e.json.images||[];e.images=new Array(s.length).fill({})}(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(new Ck).normalize(e,t)}(e,{normalize:null==o||null===(i=o.gltf)||void 0===i?void 0:i.normalize}),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const n=Sk.filter(e=>Ek(e.name,t));for(const s of n){var r;null===(r=s.preprocess)||void 0===r||r.call(s,e,t,i)}}(e,o,a);const l=[];if(null!=o&&null!==(n=o.gltf)&&void 0!==n&&n.loadBuffers&&e.json.buffers&&await async function(e,t,i){const n=e.json.buffers||[];for(let o=0;o<n.length;++o){const a=n[o];if(a.uri){var r,s;const{fetch:n}=i;lN(n);const l=cN(a.uri,t),c=await(null==i||null===(r=i.fetch)||void 0===r?void 0:r.call(i,l)),u=await(null==c||null===(s=c.arrayBuffer)||void 0===s?void 0:s.call(c));e.buffers[o]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete a.uri}else null===e.buffers[o]&&(e.buffers[o]={arrayBuffer:new ArrayBuffer(a.byteLength),byteOffset:0,byteLength:a.byteLength})}}(e,o,a),null!=o&&null!==(r=o.gltf)&&void 0!==r&&r.loadImages){const t=async function(e,t,i){const n=function(e){const t=new Set,i=e.json.textures||[];for(const e of i)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),r=e.json.images||[],s=[];for(const o of n)s.push(Yk(e,r[o],o,t,i));return await Promise.all(s)}(e,o,a);l.push(t)}const c=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const n=Sk.filter(e=>Ek(e.name,t));for(const s of n){var r;await(null===(r=s.decode)||void 0===r?void 0:r.call(s,e,t,i))}}(e,o,a);return l.push(c),await Promise.all(l),null!=o&&null!==(s=o.gltf)&&void 0!==s&&s.postProcess?function(e,t){return(new Vk).postProcess(e,t)}(e,o):e}async function Yk(e,t,i,n,r){const{fetch:s,parse:o}=r;let a;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=cN(t.uri,n),i=await s(e);a=await i.arrayBuffer(),t.bufferView={data:a}}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const n=e.bufferViews[i];lN(n);const r=t[n.buffer];return lN(r),new Uint8Array(r.arrayBuffer,(n.byteOffset||0)+r.byteOffset,n.byteLength)}(e.json,e.buffers,t.bufferView);a=Ht(i.buffer,i.byteOffset,i.byteLength)}lN(a,"glTF image has no data");let l=await o(a,[kn,aN],{mimeType:t.mimeType,basis:n.basis||{format:oN()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),e.images=e.images||[],e.images[i]=l}const Jk={name:"glTF",id:"gltf",module:"gltf",version:"3.4.15",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;t={...Jk.options,...t},t.gltf={...Jk.options.gltf,...t.gltf};const{byteOffset:n=0}=t;return await Zk({},e,n,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};async function Kk(e){const t=[];return e.scenes.forEach(e=>{e.traverse(e=>{Object.values(e.model.getUniforms()).forEach(e=>{!1===e.loaded&&t.push(e)})})}),await async function(e){for(;e();)await new Promise(e=>requestAnimationFrame(e))}(()=>t.some(e=>!e.loaded))}const Qk=[255,255,255,255],ez={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?"object"==typeof e.scene?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.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:e=>e.position},getColor:{type:"accessor",value:Qk},_lighting:"flat",_imageBasedLightingEnvironment:null,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:[Jk]};class tz extends Fm{constructor(...e){super(...e),bt(this,"state",void 0)}getShaders(){const e=[jd,Gd];return"pbr"===this.props._lighting&&e.push(Au),super.getShaders({vs:"#version 300 es\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin mat3 instanceModelMatrix;\nin vec3 instanceTranslation;\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform mat4 sceneModelMatrix;\nuniform bool composeModelMatrix;\nin vec4 POSITION;\n\n#ifdef HAS_UV\n  in vec2 TEXCOORD_0;\n#endif\n\n#ifdef MODULE_PBR\n  #ifdef HAS_NORMALS\n    in vec4 NORMAL;\n  #endif\n#endif\nout vec4 vColor;\n#ifndef MODULE_PBR\n  #ifdef HAS_UV\n    out vec2 vTEXCOORD_0;\n  #endif\n#endif\nvoid main(void) {\n  #if defined(HAS_UV) && !defined(MODULE_PBR)\n    vTEXCOORD_0 = TEXCOORD_0;\n    geometry.uv = vTEXCOORD_0;\n  #endif\n\n  geometry.worldPosition = instancePositions;\n  geometry.pickingColor = instancePickingColors;\n\n  vec3 normal = vec3(0.0, 0.0, 1.0);\n  #ifdef MODULE_PBR\n    #ifdef HAS_NORMALS\n      normal = instanceModelMatrix * (sceneModelMatrix * vec4(NORMAL.xyz, 0.0)).xyz;\n    #endif\n  #endif\n\n  float originalSize = project_size_to_pixel(sizeScale);\n  float clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels);\n\n  vec3 pos = (instanceModelMatrix * (sceneModelMatrix * POSITION).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation;\n  if(composeModelMatrix) {\n    DECKGL_FILTER_SIZE(pos, geometry);\n    geometry.normal = project_normal(normal);\n    geometry.worldPosition += pos;\n    gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n  }\n  else {\n    pos = project_size(pos);\n    DECKGL_FILTER_SIZE(pos, geometry);\n    gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\n    geometry.normal = project_normal(normal);\n  }\n  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n  #ifdef MODULE_PBR\n    pbr_vPosition = geometry.position.xyz;\n    #ifdef HAS_NORMALS\n      pbr_vNormal = geometry.normal;\n    #endif\n\n    #ifdef HAS_UV\n      pbr_vUV = TEXCOORD_0;\n    #else\n      pbr_vUV = vec2(0., 0.);\n    #endif\n    geometry.uv = pbr_vUV;\n  #endif\n\n  vColor = instanceColors;\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\nuniform float opacity;\nin vec4 vColor;\n\nout vec4 fragmentColor;\n#ifndef MODULE_PBR\n  #if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\n    in vec2 vTEXCOORD_0;\n    uniform sampler2D u_BaseColorSampler;\n  #endif\n#endif\n\nvoid main(void) {\n  #ifdef MODULE_PBR\n    fragmentColor = vColor * pbr_filterColor(vec4(0));\n    geometry.uv = pbr_vUV;\n  #else\n    #if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\n      fragmentColor = vColor * texture2D(u_BaseColorSampler, vTEXCOORD_0);\n      geometry.uv = vTEXCOORD_0;\n    #else\n      fragmentColor = vColor;\n    #endif\n  #endif\n\n  fragmentColor.a *= opacity;\n  DECKGL_FILTER_COLOR(fragmentColor, geometry);\n}\n",modules:e})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:5121,size:this.props.colorFormat.length,accessor:"getColor",normalized:!0,defaultValue:Qk,transition:!0},instanceModelMatrix:FB})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.scenegraph!==i.scenegraph?this._updateScenegraph():t._animations!==i._animations&&this._applyAnimationsProp(this.state.scenegraph,this.state.animator,t._animations)}finalizeState(e){super.finalizeState(e),this._deleteScenegraph()}get isLoaded(){var e;return(null===(e=this.state)||void 0===e?void 0:e.scenegraph)&&super.isLoaded}_updateScenegraph(){const e=this.props,{gl:t}=this.context;let i=null;if(e.scenegraph instanceof hF)i={scenes:[e.scenegraph]};else if(e.scenegraph&&!e.scenegraph.gltf){const n=e.scenegraph,r=function(e,t,i){const n=new AF(e,i);return{scenes:n.instantiate(t),animator:n.createAnimator()}}(t,n,this._getModelOptions());i={gltf:n,...r},Kk(r).then(()=>this.setNeedsRedraw())}else e.scenegraph&&(Gn.deprecated("ScenegraphLayer.props.scenegraph","Use GLTFLoader instead of GLTFScenegraphLoader")(),i=e.scenegraph);const n={layer:this,gl:t},r=e.getScene(i,n),s=e.getAnimator(i,n);r instanceof hF?(this._deleteScenegraph(),this._applyAllAttributes(r),this._applyAnimationsProp(r,s,e._animations),this.setState({scenegraph:r,animator:s})):null!==r&&Gn.warn("invalid scenegraph:",r)()}_applyAllAttributes(e){if(this.state.attributesAvailable){const t=this.getAttributeManager().getAttributes();e.traverse(e=>{this._setModelAttributes(e.model,t)})}}_applyAnimationsProp(e,t,i){if(!e||!t||!i)return;const n=t.getAnimations();Object.keys(i).sort().forEach(e=>{const t=i[e];if("*"===e)n.forEach(e=>{Object.assign(e,t)});else if(Number.isFinite(Number(e))){const i=Number(e);i>=0&&i<n.length?Object.assign(n[i],t):Gn.warn("animation ".concat(e," not found"))()}else{const i=n.find(({name:t})=>t===e);i?Object.assign(i,t):Gn.warn("animation ".concat(e," not found"))()}})}_deleteScenegraph(){const{scenegraph:e}=this.state;e instanceof hF&&e.delete()}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t=null;return e&&(t="function"==typeof e?e({gl:this.context.gl,layer:this}):e),{gl:this.context.gl,waitForFullLoad:!0,imageBasedLightingEnvironment:t,modelOptions:{isInstanced:!0,transpileToGLSL100:!ir(this.context.gl),...this.getShaders()},useTangents:!1}}updateAttributes(e){this.setState({attributesAvailable:!0}),this.state.scenegraph&&this.state.scenegraph.traverse(t=>{this._setModelAttributes(t.model,e)})}draw({moduleParameters:e=null,parameters:t={},context:i}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(i.timeline.getTime()),this.setNeedsRedraw());const{viewport:n}=this.context,{sizeScale:r,sizeMinPixels:s,sizeMaxPixels:o,opacity:a,coordinateSystem:l}=this.props,c=this.getNumInstances();this.state.scenegraph.traverse((i,{worldMatrix:u})=>{i.model.setInstanceCount(c),i.updateModuleSettings(e),i.draw({parameters:t,uniforms:{sizeScale:r,opacity:a,sizeMinPixels:s,sizeMaxPixels:o,composeModelMatrix:NB(n,l),sceneModelMatrix:u,u_Camera:i.model.getUniforms().project_uCameraPosition}})})}}bt(tz,"defaultProps",ez),bt(tz,"layerName","ScenegraphLayer");class iz extends uF{getShaders(){const e=super.getShaders();return e.modules.push(Au),{...e,vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nuniform bool pickFeatureIds;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec4 uvRegions;\nin vec3 featureIdsPickingColors;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin mat3 instanceModelMatrix;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\n\nvec2 applyUVRegion(vec2 uv) {\n  #ifdef HAS_UV_REGIONS\n    return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n  #else\n    return uv;\n  #endif\n}\n\nvoid main(void) {\n  vec2 uv = applyUVRegion(texCoords);\n  geometry.uv = uv;\n\n  if (pickFeatureIds) {\n    geometry.pickingColor = featureIdsPickingColors;\n  } else {\n    geometry.pickingColor = instancePickingColors;\n  }\n\n  vTexCoord = uv;\n  cameraPosition = project_uCameraPosition;\n  vColor = vec4(colors * instanceColors.rgb, instanceColors.a);\n\n  vec3 pos = (instanceModelMatrix * positions) * sizeScale;\n  vec3 projectedPosition = project_position(positions);\n  position_commonspace = vec4(projectedPosition, 1.0);\n  gl_Position = project_common_position_to_clipspace(position_commonspace);\n\n  geometry.position = position_commonspace;\n  normals_commonspace = project_normal(instanceModelMatrix * normals);\n  geometry.normal = normals_commonspace;\n\n  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n  #ifdef MODULE_PBR\n    pbr_vPosition = geometry.position.xyz;\n    #ifdef HAS_NORMALS\n      pbr_vNormal = geometry.normal;\n    #endif\n\n    #ifdef HAS_UV\n      pbr_vUV = uv;\n    #else\n      pbr_vUV = vec2(0., 0.);\n    #endif\n    geometry.uv = pbr_vUV;\n  #endif\n\n  DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\n\nprecision highp float;\n\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n  \n#ifdef MODULE_PBR\n\n  fragColor = vColor * pbr_filterColor(vec4(0));\n  geometry.uv = pbr_vUV;\n  fragColor.a *= opacity;\n\n#else\n\n  geometry.uv = vTexCoord;\n\n  vec3 normal;\n  if (flatShading) {\n#ifdef DERIVATIVES_AVAILABLE\n    normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n#else\n    normal = vec3(0.0, 0.0, 1.0);\n#endif\n  } else {\n    normal = normals_commonspace;\n  }\n\n  vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\n  vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n  fragColor = vec4(lightColor, color.a * opacity);\n\n#endif\n\n  DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({featureIdsPickingColors:{type:5121,size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.pbrMaterial!==i.pbrMaterial&&this.updatePbrMaterialUniforms(t.pbrMaterial)}draw(e){const{featureIds:t}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.getUniforms().project_uCameraPosition,pickFeatureIds:Boolean(t)}),super.draw(e))}getModel(e){const{id:t,pbrMaterial:i}=this.props,n=this.parseMaterial(i,e);this.setState({materialParser:n});const r=this.getShaders();var s;(s=e.attributes).COLOR_0||s.colors||(s.colors={constant:!0,value:new Float32Array([1,1,1])});return new Du(this.context.gl,{...this.getShaders(),id:t,geometry:e,defines:{...r.defines,...null==n?void 0:n.defines,HAS_UV_REGIONS:e.attributes.uvRegions},parameters:null==n?void 0:n.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:i}=this.props,n=this.parseMaterial(e,i);this.setState({materialParser:n}),t.setUniforms(n.uniforms)}}parseMaterial(e,t){var i;const n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return null===(i=this.state.materialParser)||void 0===i||i.delete(),new wF(this.context.gl,{attributes:{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},material:{unlit:n,...e},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){const t=this.props.featureIds,i=new Uint8ClampedArray(t.length*e.size),n=[];for(let e=0;e<t.length;e++)this.encodePickingColor(t[e],n),i[3*e]=n[0],i[3*e+1]=n[1],i[3*e+2]=n[2];e.value=i}finalizeState(e){var t;super.finalizeState(e),null===(t=this.state.materialParser)||void 0===t||t.delete(),this.setState({materialParser:null})}}bt(iz,"layerName","MeshLayer"),bt(iz,"defaultProps",{pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}});function nz(e){return e}function rz(e,t=[]){return function(e,t=[],i=nz){return"longitude"in e?(t[0]=i(e.longitude),t[1]=i(e.latitude),t[2]=e.height):"x"in e?(t[0]=i(e.x),t[1]=i(e.y),t[2]=e.z):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,Ol._cartographicRadians?nz:Fl)}function sz(e,t){return function(e,t,i=nz){return"longitude"in t?(t.longitude=i(e[0]),t.latitude=i(e[1]),t.height=e[2]):"x"in t?(t.x=i(e[0]),t.y=i(e[1]),t.z=e[2]):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,Ol._cartographicRadians?nz:Nl)}new gc;const oz=new gc,az=new gc,lz=new gc;const cz=new gc,uz={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"}},hz={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},dz={east:new gc,north:new gc,up:new gc,west:new gc,south:new gc,down:new gc},pz=new gc,fz=new gc,mz=new gc;function gz(e,t,i,n,r,s){const o=uz[t]&&uz[t][i];let a,l,c;Pl(o&&(!n||n===o));const u=cz.copy(r);if(Vl(u.x,0,1e-14)&&Vl(u.y,0,1e-14)){const e=Math.sign(u.z);a=pz.fromArray(hz[t]),"east"!==t&&"west"!==t&&a.scale(e),l=fz.fromArray(hz[i]),"east"!==i&&"west"!==i&&l.scale(e),c=mz.fromArray(hz[n]),"east"!==n&&"west"!==n&&c.scale(e)}else{const{up:r,east:s,north:o}=dz;s.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,r),o.copy(r).cross(s);const{down:h,west:d,south:p}=dz;h.copy(r).scale(-1),d.copy(s).scale(-1),p.copy(o).scale(-1),a=dz[t],l=dz[i],c=dz[n]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=l.x,s[5]=l.y,s[6]=l.z,s[7]=0,s[8]=c.x,s[9]=c.y,s[10]=c.z,s[11]=0,s[12]=u.x,s[13]=u.y,s[14]=u.z,s[15]=1,s}const _z=new gc,yz=new gc,vz=new gc,xz=new gc,bz=new gc,wz=new gc;class Tz{constructor(e=0,t=0,i=0){bt(this,"radii",void 0),bt(this,"radiiSquared",void 0),bt(this,"radiiToTheFourth",void 0),bt(this,"oneOverRadii",void 0),bt(this,"oneOverRadiiSquared",void 0),bt(this,"minimumRadius",void 0),bt(this,"maximumRadius",void 0),bt(this,"centerToleranceSquared",hu),bt(this,"squaredXOverSquaredZ",void 0),Pl(e>=0),Pl(t>=0),Pl(i>=0),this.radii=new gc(e,t,i),this.radiiSquared=new gc(e*e,t*t,i*i),this.radiiToTheFourth=new gc(e*e*e*e,t*t*t*t,i*i*i*i),this.oneOverRadii=new gc(0===e?0:1/e,0===t?0:1/t,0===i?0:1/i),this.oneOverRadiiSquared=new gc(0===e?0:1/(e*e),0===t?0:1/(t*t),0===i?0:1/(i*i)),this.minimumRadius=Math.min(e,t,i),this.maximumRadius=Math.max(e,t,i),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const i=yz,n=vz,[,,r]=e;this.geodeticSurfaceNormalCartographic(e,i),n.copy(this.radiiSquared).scale(i);const s=Math.sqrt(i.dot(n));return n.scale(1/s),i.scale(r),n.add(i),n.to(t)}cartesianToCartographic(e,t=[0,0,0]){wz.from(e);const i=this.scaleToGeodeticSurface(wz,xz);if(!i)return;const n=this.geodeticSurfaceNormal(i,yz),r=bz;r.copy(wz).subtract(i);return sz([Math.atan2(n.y,n.x),Math.asin(n.z),Math.sign(oc(r,wz))*rc(r)],t)}eastNorthUpToFixedFrame(e,t=new Hc){return gz(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,i,n,r=new Hc){return gz(this,e,t,i,n,r)}geocentricSurfaceNormal(e,t=[0,0,0]){return _z.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const i=rz(e),n=i[0],r=i[1],s=Math.cos(r);return _z.set(s*Math.cos(n),s*Math.sin(n),Math.sin(r)).normalize(),_z.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return _z.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,i=[]){const{oneOverRadii:n,oneOverRadiiSquared:r,centerToleranceSquared:s}=t;oz.from(e);const o=oz.x,a=oz.y,l=oz.z,c=n.x,u=n.y,h=n.z,d=o*o*c*c,p=a*a*u*u,f=l*l*h*h,m=d+p+f,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const _=az;if(_.copy(e).scale(g),m<s)return _.to(i);const y=r.x,v=r.y,x=r.z,b=lz;b.set(_.x*y*2,_.y*v*2,_.z*x*2);let w,T,S,E,A=(1-g)*oz.len()/(.5*b.len()),M=0;do{A-=M,w=1/(1+A*y),T=1/(1+A*v),S=1/(1+A*x);const e=w*w,t=T*T,i=S*S;E=d*e+p*t+f*i-1,M=E/(-2*(d*(e*w)*y+p*(t*T)*v+f*(i*S)*x))}while(Math.abs(E)>du);return oz.scale([w,T,S]).to(i)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){xz.from(e);const i=xz.x,n=xz.y,r=xz.z,s=this.oneOverRadiiSquared,o=1/Math.sqrt(i*i*s.x+n*n*s.y+r*r*s.z);return xz.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return xz.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return xz.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,i=[0,0,0]){Pl(Vl(this.radii.x,this.radii.y,pu)),Pl(this.radii.z>0),xz.from(e);const n=xz.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-t))return xz.set(0,0,n).to(i)}}bt(Tz,"WGS84",new Tz(6378137,6378137,6356752.314245179));class Sz{constructor(e,t,i){bt(this,"item",void 0),bt(this,"previous",void 0),bt(this,"next",void 0),this.item=e,this.previous=t,this.next=i}}class Ez{constructor(){bt(this,"head",null),bt(this,"tail",null),bt(this,"_length",0)}get length(){return this._length}add(e){const t=new Sz(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}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,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const i=e.next;e.next=t,this.tail===e?this.tail=t:i.previous=t,t.next=i,t.previous=e,++this._length}}class Az{constructor(){bt(this,"_list",void 0),bt(this,"_sentinel",void 0),bt(this,"_trimTiles",void 0),this._list=new Ez,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;t&&this._list.splice(this._sentinel,t)}add(e,t,i){t._cacheNode||(t._cacheNode=this._list.add(t),i&&i(e,t))}unloadTile(e,t,i){const n=t._cacheNode;n&&(this._list.remove(n),t._cacheNode=null,i&&i(e,t))}unloadTiles(e,t){const i=this._trimTiles;this._trimTiles=!1;const n=1024*e.maximumMemoryUsage*1024,r=this._sentinel;let s=this._list.head;for(;s!==r&&(e.gpuMemoryUsageInBytes>n||i);){const i=s.item;s=s.next,this.unloadTile(e,i,t)}}trim(){this._trimTiles=!0}}const Mz=new gc,Iz=new gc,Cz=new pB([new cB,new cB,new cB,new cB,new cB,new cB]);function Pz(e,t){const{cameraDirection:i,cameraUp:n,height:r}=e,{metersPerUnit:s}=e.distanceScales,o=Rz(e,e.center),a=Tz.WGS84.eastNorthUpToFixedFrame(o),l=e.unprojectPosition(e.cameraPosition),c=Tz.WGS84.cartographicToCartesian(l,new gc),u=new gc(a.transformAsVector(new gc(i).scale(s))).normalize(),h=new gc(a.transformAsVector(new gc(n).scale(s))).normalize();!function(e){const t=e.getFrustumPlanes(),i=Lz(t.near,e.cameraPosition),n=Rz(e,i),r=Rz(e,e.cameraPosition,Iz);let s=0;Cz.planes[s++].fromPointNormal(n,Mz.copy(n).subtract(r));for(const r in t){if("near"===r)continue;const o=Rz(e,Lz(t[r],i,Iz),Iz);Cz.planes[s++].fromPointNormal(o,Mz.copy(n).subtract(o))}}(e);const d=e.constructor,{longitude:p,latitude:f,width:m,bearing:g,zoom:_}=e;return{camera:{position:c,direction:u,up:h},viewport:e,topDownViewport:new d({longitude:p,latitude:f,height:r,width:m,bearing:g,zoom:_,pitch:0}),height:r,cullingVolume:Cz,frameNumber:t,sseDenominator:1.15}}function Lz(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new gc;const n=e.normal.dot(t);return i.copy(e.normal).scale(e.distance-n).add(t),i}function Rz(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new gc;const n=e.unprojectPosition(t);return Tz.WGS84.cartographicToCartesian(n,i)}const Oz=6356752.314245179,Dz=new gc;function Bz(e,t){if(e instanceof oB){const{halfAxes:i}=e,n=function(e){e.getColumn(0,Dz);const t=e.getColumn(1),i=e.getColumn(2),n=Dz.add(t).add(i);return n.len()}(i);return Math.log2(Oz/(n+t[2]))}if(e instanceof GD){const{radius:i}=e;return Math.log2(Oz/(i+t[2]))}if(e.width&&e.height){const{width:t,height:i}=e;return(Math.log2(6378137/t)+Math.log2(6378137/i))/2}return 1}function Fz(e,t,i){const n=Tz.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],new gc),r=Math.sqrt(Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)+Math.pow(n[2]-i[2],2));return Math.log2(Oz/(r+t[2]))}const Nz=0,kz=1,zz=3,Uz=4,Vz=5,jz=1,Gz=2,Hz="empty",Wz="scenegraph",qz="pointcloud",Xz="mesh",$z="I3S",Zz="TILES3D",Yz="geometricError",Jz=1;function Kz(e){return null!=e}const Qz=new gc,eU=new gc,tU=new gc,iU=new gc;function nU(e,t,i){if(ct(e,"3D Tile: boundingVolume must be defined"),e.box)return function(e,t,i){const n=new gc(e[0],e[1],e[2]);t.transform(n,n);let r=[];if(10===e.length){const t=e.slice(3,6),i=new uu;i.fromArray(e,6);const n=new gc([1,0,0]),s=new gc([0,1,0]),o=new gc([0,0,1]);n.transformByQuaternion(i),n.scale(t[0]),s.transformByQuaternion(i),s.scale(t[1]),o.transformByQuaternion(i),o.scale(t[2]),r=[...n.toArray(),...s.toArray(),...o.toArray()]}else r=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const s=t.transformAsVector(r.slice(0,3)),o=t.transformAsVector(r.slice(3,6)),a=t.transformAsVector(r.slice(6,9)),l=new Ec([s[0],s[1],s[2],o[0],o[1],o[2],a[0],a[1],a[2]]);if(Kz(i))return i.center=n,i.halfAxes=l,i;return new oB(n,l)}(e.box,t,i);if(e.region){const[t,i,n,r,s,o]=e.region,a=Tz.WGS84.cartographicToCartesian([kl(t),kl(r),s],tU),l=Tz.WGS84.cartographicToCartesian([kl(n),kl(i),o],iU),c=(new gc).addVectors(a,l).multiplyScalar(.5),u=(new gc).subVectors(a,l).len()/2;return sU([c[0],c[1],c[2],u],new Hc)}if(e.sphere)return sU(e.sphere,t,i);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function rU(e,t){if(e.box)return function(e){const t=oU(),{halfAxes:i}=e,n=new gc(i.getColumn(0)),r=new gc(i.getColumn(1)),s=new gc(i.getColumn(2));for(let i=0;i<2;i++){for(let i=0;i<2;i++){for(let i=0;i<2;i++)Qz.copy(e.center),Qz.add(n),Qz.add(r),Qz.add(s),aU(t,Qz),s.negate();r.negate()}n.negate()}return t}(t);if(e.region){const[t,i,n,r,s,o]=e.region;return[[kl(t),kl(i),s],[kl(n),kl(r),o]]}if(e.sphere)return function(e){const t=oU(),{center:i,radius:n}=e,r=Tz.WGS84.scaleToGeodeticSurface(i,Qz);let s;s=r?Tz.WGS84.geodeticSurfaceNormal(r):new gc(0,0,1);let o=new gc(s[2],-s[1],0);o.len()>0?o.normalize():o=new gc(0,1,0);const a=o.clone().cross(s);for(const e of[o,a,s]){eU.copy(e).scale(n);for(let e=0;e<2;e++)Qz.copy(i),Qz.add(eU),aU(t,Qz),eU.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function sU(e,t,i){const n=new gc(e[0],e[1],e[2]);t.transform(n,n);const r=t.getScale(eU),s=Math.max(Math.max(r[0],r[1]),r[2]),o=e[3]*s;return Kz(i)?(i.center=n,i.radius=o,i):new GD(n,o)}function oU(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function aU(e,t){Tz.WGS84.cartesianToCartographic(t,Qz),e[0][0]=Math.min(e[0][0],Qz[0]),e[0][1]=Math.min(e[0][1],Qz[1]),e[0][2]=Math.min(e[0][2],Qz[2]),e[1][0]=Math.max(e[1][0],Qz[0]),e[1][1]=Math.max(e[1][1],Qz[1]),e[1][2]=Math.max(e[1][2],Qz[2])}function lU(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const i=e.dynamicScreenSpaceErrorFactor,n=function(e,t){const i=e*t;return 1-Math.exp(-i*i)}(t,e.dynamicScreenSpaceErrorComputedDensity)*i;return n}return 0}new gc,new gc,new Hc,new gc,new gc,new gc;const cU=new gc,uU=new gc,hU=new gc,dU=new gc,pU=new gc,fU=new Hc,mU=new Hc;function gU(e,t){const{topDownViewport:i}=t,n=e.header.mbs[1],r=e.header.mbs[0],s=e.header.mbs[2],o=e.header.mbs[3],a=[...e.boundingVolume.center],l=i.unprojectPosition(i.cameraPosition);Tz.WGS84.cartographicToCartesian(l,cU),uU.copy(cU).subtract(a).normalize(),Tz.WGS84.eastNorthUpToFixedFrame(a,fU),mU.copy(fU).invert(),hU.copy(cU).transform(mU);const c=Math.sqrt(hU[0]*hU[0]+hU[1]*hU[1]);dU.copy([hU[0],hU[1],c*c/hU[2]]);const u=dU.transform(fU).subtract(a).normalize(),h=uU.cross(u).normalize().scale(o).add(a),d=Tz.WGS84.cartesianToCartographic(h),p=i.project([r,n,s]),f=i.project(d);return pU.copy(p).subtract(f).magnitude()}class _U{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;bt(this,"_map",new Map),bt(this,"_array",void 0),bt(this,"_length",void 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 ct(e<this._array.length),this._array[e]}set(e,t){ct(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){ct(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){ct(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}const yU={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class vU{traversalFinished(e){return!0}constructor(e){bt(this,"options",void 0),bt(this,"root",null),bt(this,"selectedTiles",{}),bt(this,"requestedTiles",{}),bt(this,"emptyTiles",{}),bt(this,"lastUpdate",(new Date).getTime()),bt(this,"updateDebounceTime",1e3),bt(this,"_traversalStack",new _U),bt(this,"_emptyTraversalStack",new _U),bt(this,"_frameNumber",null),this.options={...yU,...e}}traverse(e,t,i){this.root=e,this.options={...this.options,...i},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const i=this._traversalStack;for(e._selectionDepth=1,i.push(e);i.length>0;){const e=i.pop();let n=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),n=this.updateAndPushChildren(e,t,i,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const r=e.parent,s=Boolean(!r||r._shouldRefine),o=!n;e.hasRenderContent?e.refine===jz?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===Gz&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=n&&s}const n=(new Date).getTime();(this.traversalFinished(t)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const i=e.children;for(const e of i)this.updateTile(e,t)}updateAndPushChildren(e,t,i,n){const{loadSiblings:r,skipLevelOfDetail:s}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===Gz&&e.hasRenderContent&&!s;let l=!1,c=!0;for(const e of o)if(e._selectionDepth=n,e.isVisibleAndInRequestVolume?(i.find(e)&&i.delete(e),i.push(e),l=!0):(a||r)&&(this.loadTile(e,t),this.touchTile(e,t)),a){let i;if(i=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&i,!c)return!1}return l||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:!(!(arguments.length>3&&void 0!==arguments[3]&&arguments[3])&&!e.isVisibleAndInRequestVolume)&&this.shouldRefine(e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2]))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t){let i=e._screenSpaceError;return arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&(i=e.getScreenSpaceError(t,!0)),i>this.options.maximumScreenSpaceError}updateTileVisibility(e,t){const i=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&i.push(e)}else i.push(t.viewport.id);e.updateVisibility(t,i)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let i=!1;for(const n of e.children)n.updateVisibility(t),i=i||n.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(e,t){let i=!0;const n=this._emptyTraversalStack;for(n.push(e);n.length>0&&i;){const e=n.pop();this.updateTile(e,t),e.isVisibleAndInRequestVolume||this.loadTile(e,t),this.touchTile(e,t);if(!e.hasRenderContent&&this.canTraverse(e,t,!1,!0)){const t=e.children;for(const e of t)n.find(e)&&n.delete(e),n.push(e)}else e.contentAvailable||e.hasEmptyContent||(i=!1)}return i}}const xU=new gc;class bU{constructor(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";bt(this,"tileset",void 0),bt(this,"header",void 0),bt(this,"id",void 0),bt(this,"url",void 0),bt(this,"parent",void 0),bt(this,"refine",void 0),bt(this,"type",void 0),bt(this,"contentUrl",void 0),bt(this,"lodMetricType","geometricError"),bt(this,"lodMetricValue",0),bt(this,"boundingVolume",null),bt(this,"content",null),bt(this,"contentState",Nz),bt(this,"gpuMemoryUsageInBytes",0),bt(this,"children",[]),bt(this,"depth",0),bt(this,"viewportIds",[]),bt(this,"transform",new Hc),bt(this,"extensions",null),bt(this,"implicitTiling",null),bt(this,"userData",{}),bt(this,"computedTransform",void 0),bt(this,"hasEmptyContent",!1),bt(this,"hasTilesetContent",!1),bt(this,"traverser",new vU({})),bt(this,"_cacheNode",null),bt(this,"_frameNumber",null),bt(this,"_expireDate",null),bt(this,"_expiredContent",null),bt(this,"_boundingBox",void 0),bt(this,"_distanceToCamera",0),bt(this,"_screenSpaceError",0),bt(this,"_visibilityPlaneMask",void 0),bt(this,"_visible",void 0),bt(this,"_contentBoundingVolume",void 0),bt(this,"_viewerRequestVolume",void 0),bt(this,"_initialTransform",new Hc),bt(this,"_priority",0),bt(this,"_selectedFrame",0),bt(this,"_requestedFrame",0),bt(this,"_selectionDepth",0),bt(this,"_touchedFrame",0),bt(this,"_centerZDepth",0),bt(this,"_shouldRefine",!1),bt(this,"_stackLength",0),bt(this,"_visitedFrame",0),bt(this,"_inRequestVolume",!1),bt(this,"_lodJudge",null),this.header=t,this.tileset=e,this.id=n||t.id,this.url=t.url,this.parent=i,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}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===zz||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Nz}get contentExpired(){return this.contentState===Uz}get contentFailed(){return this.contentState===Vz}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=rU(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case $z:return gU(this,e);case Zz:return function(e,t,i){const n=e.tileset,r=i&&e.parent&&e.parent.lodMetricValue||e.lodMetricValue;if(0===r)return 0;const s=Math.max(e._distanceToCamera,1e-7),{height:o,sseDenominator:a}=t,{viewDistanceScale:l}=n.options;let c=r*o*(l||1)/(s*a);return c-=lU(n,s),c}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,i=this.refine===jz||t;if(i&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===Nz)return-1;const n=this.parent;return Math.max((e.root?e.root._screenSpaceError:0)-(n&&(!i||0===this._screenSpaceError||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError),0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=kz;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=Nz,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,i={...this.tileset.loadOptions,[t.id]:{...this.tileset.loadOptions[t.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await yn(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=zz,this._onContentLoaded(),!0}catch(e){throw this.contentState=Vz,e}finally{e.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=Nz,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const i=this.parent,n=i?i._visibilityPlaneMask:pB.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){this._updateTransform(i?i.computedTransform:this.tileset.modelMatrix)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==pB.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:i}=e,{boundingVolume:n}=this;return i.computeVisibilityWithPlaneMask(n,t)}contentVisibility(){return!0}distanceToTile(e){return Math.sqrt(Math.max(this.boundingVolume.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth(e){let{camera:t}=e;return xU.subVectors(this.boundingVolume.center,t.position),t.direction.dot(xU)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(function(e){return null!=e}(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Uz,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){this.lodMetricType="lodMetricType"in e?e.lodMetricType:this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,this.lodMetricValue="lodMetricValue"in e?e.lodMetricValue:this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue}_initializeTransforms(e){this.transform=e.transform?new Hc(e.transform):new Hc;const t=this.parent,i=this.tileset,n=t&&t.computedTransform?t.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new Hc(n).multiplyRight(this.transform);const r=t&&t._initialTransform?t._initialTransform.clone():new Hc;this._initialTransform=new Hc(r).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=Nz,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=pB.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||Gz}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=nU(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=nU(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=nU(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Hc).clone().multiplyRight(this.transform);!e.equals(this.computedTransform)&&(this.computedTransform=e,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return"i3s"===e?{...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}:{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"};var t}}class wU extends vU{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const i=e.children.length>0;if(e.hasTilesetContent&&i){const i=e.children[0];return this.updateTileVisibility(i,t),void(e._visible=i._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);e.refine===Gz&&e._optimChildrenWithinParent===Jz&&i&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:i}=e;return!(!i||i.hasTilesetContent||i.refine!==jz)&&!this.shouldRefine(e,t,!0)}}class TU{constructor(){bt(this,"frameNumberMap",new Map)}register(e,t){const i=this.frameNumberMap.get(e)||new Map,n=i.get(t)||0;i.set(t,n+1),this.frameNumberMap.set(e,i)}deregister(e,t){const i=this.frameNumberMap.get(e);if(!i)return;const n=i.get(t)||1;i.set(t,n-1)}isZero(e,t){var i;return 0===((null===(i=this.frameNumberMap.get(e))||void 0===i?void 0:i.get(t))||0)}}const SU="REQUESTED",EU="COMPLETED",AU="ERROR";class MU{constructor(){bt(this,"_statusMap",void 0),bt(this,"pendingTilesRegister",new TU),this._statusMap={}}add(e,t,i,n){if(!this._statusMap[t]){const{frameNumber:r,viewport:{id:s}}=n;this._statusMap[t]={request:e,callback:i,key:t,frameState:n,status:SU},this.pendingTilesRegister.register(s,r),e().then(e=>{this._statusMap[t].status=EU;const{frameNumber:i,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,i),this._statusMap[t].callback(e,n)}).catch(e=>{this._statusMap[t].status=AU;const{frameNumber:n,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,n),i(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:i,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,i);const{frameNumber:r,viewport:{id:s}}=t;this.pendingTilesRegister.register(s,r),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class IU extends vU{constructor(e){super(e),bt(this,"_tileManager",void 0),this._tileManager=new MU}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const i=2*gU(e,t);return i<2?"OUT":!e.header.children||i<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const i=e.header.children||[],n=e.children,r=e.tileset;for(const s of i){const i="".concat(s.id,"-").concat(t.viewport.id),o=n&&n.find(e=>e.id===i);if(o)o&&this.updateTile(o,t);else{let n=()=>this._loadTile(s.id,r);this._tileManager.find(i)?this._tileManager.update(i,t):(r.tileset.nodePages&&(n=()=>r.tileset.nodePagesTile.formTileFromNodePages(s.id)),this._tileManager.add(n,i,t=>this._onTileLoad(t,e,i),t))}}return!1}async _loadTile(e,t){const{loader:i}=t,n=t.getTileUrl("".concat(t.url,"/nodes/").concat(e)),r={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await yn(n,i,r)}_onTileLoad(e,t,i){const n=new bU(t.tileset,e,t,i);t.children.push(n);const r=this._tileManager.find(n.id).frameState;this.updateTile(n,r),this._frameNumber===r.frameNumber&&(this.traversalFinished(r)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,r)}}const CU={description:"",ellipsoid:Tz.WGS84,modelMatrix:new Hc,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},PU="Tiles In Tileset(s)",LU="Tiles In Memory",RU="Tiles In View",OU="Tiles To Render",DU="Tiles Loaded",BU="Tiles Loading",FU="Tiles Unloaded",NU="Failed Tile Loads",kU="Points/Vertices",zU="Tile Memory Use";class UU{constructor(e,t){bt(this,"options",void 0),bt(this,"loadOptions",void 0),bt(this,"type",void 0),bt(this,"tileset",void 0),bt(this,"loader",void 0),bt(this,"url",void 0),bt(this,"basePath",void 0),bt(this,"modelMatrix",void 0),bt(this,"ellipsoid",void 0),bt(this,"lodMetricType",void 0),bt(this,"lodMetricValue",void 0),bt(this,"refine",void 0),bt(this,"root",null),bt(this,"roots",{}),bt(this,"asset",{}),bt(this,"description",""),bt(this,"properties",void 0),bt(this,"extras",null),bt(this,"attributions",{}),bt(this,"credits",{}),bt(this,"stats",void 0),bt(this,"contentFormats",{draco:!1,meshopt:!1,dds:!1,ktx2:!1}),bt(this,"cartographicCenter",null),bt(this,"cartesianCenter",null),bt(this,"zoom",1),bt(this,"boundingVolume",null),bt(this,"dynamicScreenSpaceErrorComputedDensity",0),bt(this,"maximumMemoryUsage",32),bt(this,"gpuMemoryUsageInBytes",0),bt(this,"_frameNumber",0),bt(this,"_queryParams",{}),bt(this,"_extensionsUsed",[]),bt(this,"_tiles",{}),bt(this,"_pendingCount",0),bt(this,"selectedTiles",[]),bt(this,"traverseCounter",0),bt(this,"geometricError",0),bt(this,"lastUpdatedVieports",null),bt(this,"_requestedTiles",[]),bt(this,"_emptyTiles",[]),bt(this,"frameStateData",{}),bt(this,"_traverser",void 0),bt(this,"_cache",new Az),bt(this,"_requestScheduler",void 0),bt(this,"updatePromise",null),bt(this,"tilesetInitializationPromise",void 0),this.options={...CU,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||ii(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 Kt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.stats=new Yt({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}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}}setOptions(e){this.options={...this.options,...e}}getTileUrl(e){return e.startsWith("data:")?e:"".concat(e).concat(e.includes("?")?"&":"?").concat(this.queryParams)}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const i=[];for(const e of t){const t=e.id;this._needTraverse(t)?i.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!i.includes(t))continue;const n=Pz(e,this._frameNumber);this._traverser.traverse(this.roots[t],n,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const i=this.frameStateData[t],n=Object.values(this._traverser.selectedTiles),[r,s]=function(e,t,i){if(0===i||e.length<=i)return[e,[]];const n=[],{longitude:r,latitude:s}=t.viewport;for(const[t,i]of e.entries()){const[e,o]=i.header.mbs,a=Math.abs(r-e),l=Math.abs(s-o),c=Math.sqrt(l*l+a*a);n.push([t,c])}const o=n.sort((e,t)=>e[1]-t[1]),a=[];for(let t=0;t<i;t++)a.push(e[o[t][0]]);const l=[];for(let t=i;t<o.length;t++)l.push(e[o[t][0]]);return[a,l]}(n,e,this.options.maximumTilesSelected);i.selectedTiles=r;for(const e of s)e.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(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const i=new Set(e.map(e=>e.id)),n=new Set(t.map(e=>e.id));let r=e.filter(e=>!n.has(e.id)).length>0;return r=r||t.filter(e=>!i.has(e.id)).length>0,r}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const i of this.selectedTiles)i.contentAvailable&&i.content&&(e++,t+=i.content.pointCount?i.content.pointCount:i.content.vertexCount);this.stats.get(RU).count=this.selectedTiles.length,this.stats.get(OU).count=e,this.stats.get(kU).count=t}async _initializeTileSet(e){this.type===$z&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===Zz&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===$z&&this._initializeI3STileset()}calculateViewPropsI3S(){var e;const t=this.tileset.fullExtent;if(t){const{xmin:e,xmax:i,ymin:n,ymax:r,zmin:s,zmax:o}=t;return this.cartographicCenter=new gc(e+(i-e)/2,n+(r-n)/2,s+(o-s)/2),this.cartesianCenter=Tz.WGS84.cartographicToCartesian(this.cartographicCenter,new gc),void(this.zoom=Fz(t,this.cartographicCenter,this.cartesianCenter))}const i=null===(e=this.tileset.store)||void 0===e?void 0:e.extent;if(i){const[e,t,n,r]=i;return this.cartographicCenter=new gc(e+(n-e)/2,t+(r-t)/2,0),this.cartesianCenter=Tz.WGS84.cartographicToCartesian(this.cartographicCenter,new gc),void(this.zoom=function(e,t,i){const[n,r,s,o]=e;return Fz({xmax:s,ymax:o,zmax:0},t,i)}(i,this.cartographicCenter,this.cartesianCenter))}this.cartographicCenter=new gc,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return this.cartographicCenter=new gc,void(this.zoom=1);this.cartographicCenter=0!==t[0]||0!==t[1]||0!==t[2]?Tz.WGS84.cartesianToCartographic(t,new gc):new gc(0,0,-Tz.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=Bz(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(PU),this.stats.get(BU),this.stats.get(LU),this.stats.get(RU),this.stats.get(OU),this.stats.get(DU),this.stats.get(FU),this.stats.get(NU),this.stats.get(kU),this.stats.get(zU,"memory")}_initializeTileHeaders(e,t){const i=new bU(this,e.root,t);if(t&&(t.children.push(i),i.depth=t.depth+1),this.type===Zz){const e=[];for(e.push(i);e.length>0;){const t=e.pop();this.stats.get(PU).incrementCount();const i=t.header.children||[];for(const r of i){var n;const i=new bU(this,r,t);if(null!==(n=i.contentUrl)&&void 0!==n&&n.includes("?session=")){const e=new URL(i.contentUrl).searchParams.get("session");e&&(this._queryParams.session=e)}t.children.push(i),i.depth=t.depth+1,e.push(i)}}}return i}_initializeTraverser(){let e;switch(this.type){case Zz:e=wU;break;case $z:e=IU;break;default:e=vU}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t instanceof Error?t:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get(NU).incrementCount();const i=t.message||t.toString();this.options.onTileError(e,i,e.url)}_onTileLoad(e,t){if(t){if(this.type===$z){var i,n;const e=(null===(i=this.tileset)||void 0===i||null===(n=i.nodePagesTile)||void 0===n?void 0:n.nodesInNodePages)||0;this.stats.get(PU).reset(),this.stats.get(PU).addCount(e)}e&&e.content&&function(e,t){ct(e),ct(t);const{rtcCenter:i,gltfUpAxis:n}=t,{computedTransform:r,boundingVolume:{center:s}}=e;let o=new Hc(r);switch(i&&o.translate(i),n){case"Z":break;case"Y":const e=(new Hc).rotateX(Math.PI/2);o=o.multiplyRight(e);break;case"X":const t=(new Hc).rotateY(-Math.PI/2);o=o.multiplyRight(t)}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new gc(s);t.cartesianModelMatrix=o,t.cartesianOrigin=a;const l=Tz.WGS84.cartesianToCartographic(a,new gc),c=Tz.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=c.multiplyRight(o),t.cartographicOrigin=l,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===$z)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===Zz){var t;const{extensionsRemoved:i=[]}=(null===(t=e.content)||void 0===t?void 0:t.gltf)||{};i.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),i.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),i.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(BU).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(BU).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(DU).incrementCount(),this.stats.get(LU).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(zU).count=this.gpuMemoryUsageInBytes}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(LU).decrementCount(),this.stats.get(FU).incrementCount(),this.stats.get(zU).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const i of t.children)e.push(i);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,i=[];for(i.push(t);i.length>0;){e=i.pop();for(const t of e.children)i.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){const t=new URLSearchParams(e.queryString),i=Object.fromEntries(t.entries());this._queryParams={...this._queryParams,...i}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");"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)}}const VU="3.4.15",jU="cmpt",GU="pnts",HU="b3dm",WU="i3dm",qU="glTF";function XU(e,t,i){ct(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),r=new Uint8Array(e,t,i);return n.decode(r)}const $U={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},ZU={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...$U},YU={[$U.DOUBLE]:Float64Array,[$U.FLOAT]:Float32Array,[$U.UNSIGNED_SHORT]:Uint16Array,[$U.UNSIGNED_INT]:Uint32Array,[$U.UNSIGNED_BYTE]:Uint8Array,[$U.BYTE]:Int8Array,[$U.SHORT]:Int16Array,[$U.INT]:Int32Array},JU={DOUBLE:$U.DOUBLE,FLOAT:$U.FLOAT,UNSIGNED_SHORT:$U.UNSIGNED_SHORT,UNSIGNED_INT:$U.UNSIGNED_INT,UNSIGNED_BYTE:$U.UNSIGNED_BYTE,BYTE:$U.BYTE,SHORT:$U.SHORT,INT:$U.INT},KU="Failed to convert GL type";class QU{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in YU){if(YU[t]===e)return t}throw new Error(KU)}static fromName(e){const t=JU[e];if(!t)throw new Error(KU);return t}static getArrayType(e){switch(e){case $U.UNSIGNED_SHORT_5_6_5:case $U.UNSIGNED_SHORT_4_4_4_4:case $U.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=YU[e];if(!t)throw new Error(KU);return t}}static getByteSize(e){return QU.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(QU.getArrayType(e))}static createTypedArray(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3?arguments[3]:void 0;void 0===n&&(n=(t.byteLength-i)/QU.getByteSize(e));return new(QU.getArrayType(e))(t,i,n)}}function eV(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];const i=e>>5&63,n=31&e;return t[0]=(e>>11&31)<<3,t[1]=i<<2,t[2]=n<<3,t}function tV(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:255;return zl(e,0,t)/t*2-1}function iV(e){return e<0?-1:1}function nV(e,t,i,n){if(function(e,t){if(!e)throw new Error("math.gl assertion failed. ".concat(t))}(n),e<0||e>i||t<0||t>i)throw new Error("x and y must be unsigned normalized integers between 0 and ".concat(i));if(n.x=tV(e,i),n.y=tV(t,i),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const e=n.x;n.x=(1-Math.abs(n.y))*iV(e),n.y=(1-Math.abs(e))*iV(n.y)}return n.normalize()}function rV(e,t,i){return nV(e,t,255,i)}new ic,new gc,new ic,new ic;class sV{constructor(e,t){bt(this,"json",void 0),bt(this,"buffer",void 0),bt(this,"featuresLength",0),bt(this,"_cachedTypedArrays",{}),this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZU.UNSIGNED_INT,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,t,i,1,n.byteOffset):n}getPropertyArray(e,t,i){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(t=QU.fromName(n.componentType)),this._getTypedArrayFromBinary(e,t,i,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,t,n)}getProperty(e,t,i,n,r){const s=this.json[e];if(!s)return s;const o=this.getPropertyArray(e,t,i);if(1===i)return o[n];for(let e=0;e<i;++e)r[e]=o[i*n+e];return r}_getTypedArrayFromBinary(e,t,i,n,r){const s=this._cachedTypedArrays;let o=s[e];return o||(o=QU.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+r,n*i),s[e]=o),o}_getTypedArrayFromArray(e,t,i){const n=this._cachedTypedArrays;let r=n[e];return r||(r=QU.createTypedArray(t,i),n[e]=r),r}}const oV={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},aV={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},lV={SCALAR:(e,t,i)=>{t[i]=e},VEC2:(e,t,i)=>{t[2*i+0]=e[0],t[2*i+1]=e[1]},VEC3:(e,t,i)=>{t[3*i+0]=e[0],t[3*i+1]=e[1],t[3*i+2]=e[2]},VEC4:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT2:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT3:(e,t,i)=>{t[9*i+0]=e[0],t[9*i+1]=e[1],t[9*i+2]=e[2],t[9*i+3]=e[3],t[9*i+4]=e[4],t[9*i+5]=e[5],t[9*i+6]=e[6],t[9*i+7]=e[7],t[9*i+8]=e[8],t[9*i+9]=e[9]},MAT4:(e,t,i)=>{t[16*i+0]=e[0],t[16*i+1]=e[1],t[16*i+2]=e[2],t[16*i+3]=e[3],t[16*i+4]=e[4],t[16*i+5]=e[5],t[16*i+6]=e[6],t[16*i+7]=e[7],t[16*i+8]=e[8],t[16*i+9]=e[9],t[16*i+10]=e[10],t[16*i+11]=e[11],t[16*i+12]=e[12],t[16*i+13]=e[13],t[16*i+14]=e[14],t[16*i+15]=e[15]}};const cV=e=>void 0!==e;function uV(e,t,i){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const r=t.HIERARCHY;return r&&(t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=r,n=r),n?function(e,t){let i,n,r;const s=e.instancesLength,o=e.classes;let a,l=e.classIds,c=e.parentCounts,u=e.parentIds,h=s;cV(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,s));if(cV(c))for(cV(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,s)),a=new Uint16Array(s),h=0,i=0;i<s;++i)a[i]=h,h+=c[i];cV(u)&&cV(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,r=getBinaryAccessor(u),u=r.createArrayBufferView(t.buffer,t.byteOffset+u.byteOffset,h));const d=o.length;for(i=0;i<d;++i){const e=o[i].instances,n=getBinaryProperties(o[i].length,e,t);o[i].instances=combine(n,e)}const p=new Array(d).fill(0),f=new Uint16Array(s);for(i=0;i<s;++i)n=l[i],f[i]=p[n],++p[n];const m={classes:o,classIds:l,classIndexes:f,parentCounts:c,parentIndexes:a,parentIds:u};return function(e){const t=e.classIds,i=t.length;for(let t=0;t<i;++t)dV(e,t,stack)}(m),m}(n,i):null}function hV(e,t,i){if(!e)return;const n=e.parentCounts;return e.parentIds?i(e,t):n>0?function(e,t,i){const n=e.classIds,r=e.parentCounts,s=e.parentIds,o=e.parentIndexes,a=scratchVisited;a.length=Math.max(a.length,n.length);const l=++marker,c=scratchStack;c.length=0,c.push(t);for(;c.length>0;){if(a[t=c.pop()]===l)continue;a[t]=l;const n=i(e,t);if(cV(n))return n;const u=r[t],h=o[t];for(let e=0;e<u;++e){const i=s[h+e];i!==t&&c.push(i)}}return null}(e,t,i):function(e,t,i){let n=!0;for(;n;){const r=i(e,t);if(cV(r))return r;const s=e.parentIds[t];n=s!==t,t=s}throw new Error("traverseHierarchySingleParent")}(e,t,i)}function dV(e,t,i){const n=e.parentCounts,r=e.parentIds,s=e.parentIndexes,o=e.classIds.length;if(!cV(r))return;assert(t<o,"Parent index ".concat(t," exceeds the total number of instances: ").concat(o)),assert(-1===i.indexOf(t),"Circular dependency detected in the batch table hierarchy."),i.push(t);const a=cV(n)?n[t]:1,l=cV(n)?s[t]:t;for(let n=0;n<a;++n){const s=r[l+n];s!==t&&dV(e,s,i)}i.pop(t)}function pV(e){return null!=e}const fV=(e,t)=>e,mV={HIERARCHY:!0,extensions:!0,extras:!0};class gV{constructor(e,t,i){var n;let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};bt(this,"json",void 0),bt(this,"binary",void 0),bt(this,"featureCount",void 0),bt(this,"_extensions",void 0),bt(this,"_properties",void 0),bt(this,"_binaryProperties",void 0),bt(this,"_hierarchy",void 0),ct(i>=0),this.json=e||{},this.binary=t,this.featureCount=i,this._extensions=(null===(n=this.json)||void 0===n?void 0:n.extensions)||{},this._properties={};for(const e in this.json)mV[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),r["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=uV(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),ct("string"==typeof t,t),this._hierarchy){return pV(hV(this._hierarchy,e,(e,i)=>e.classes[e.classIds[i]].name===t))}return!1}isExactClass(e,t){return ct("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){return this._hierarchy.classes[this._hierarchy.classIds[e]].name}}hasProperty(e,t){return this._checkBatchId(e),ct("string"==typeof t,t),pV(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=pV(t)?t:[]).length=0;const i=Object.keys(this._properties);return t.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),ct("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(pV(i))return this._getBinaryProperty(i,e)}const i=this._properties[t];if(pV(i))return fV(i[e]);if(this._hierarchy){const i=this._getHierarchyProperty(e,t);if(pV(i))return i}}setProperty(e,t,i){const n=this.featureCount;if(this._checkBatchId(e),ct("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,i)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,i))return;let r=this._properties[t];pV(r)||(this._properties[t]=new Array(n),r=this._properties[t]),r[e]=fV(i)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,i){e.pack(i,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const i=this._initializeBinaryProperty(t,this._properties[t]);i&&(e=e||{},e[t]=i)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const i=t;ct(this.binary,"Property ".concat(e," requires a batch table binary.")),ct(i.type,"Property ".concat(e," requires a type."));const n=function(e,t,i,n){const{componentType:r}=e;ct(e.componentType);const s="string"==typeof r?QU.fromName(r):r,o=oV[e.type],a=aV[e.type],l=lV[e.type];return{values:QU.createTypedArray(s,t,i+=e.byteOffset,o*n),type:s,size:o,unpacker:a,packer:l}}(i,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const i=hV(this._hierarchy,e,(e,i)=>pV(e.classes[e.classIds[i]].instances[t]));return pV(i)}_getPropertyNamesInHierarchy(e,t){hV(this._hierarchy,e,(e,i)=>{const n=e.classes[e.classIds[i]].instances;for(const e in n)n.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return hV(this._hierarchy,e,(e,i)=>{const n=e.classIndexes[i],r=e.classes[e.classIds[i]].instances[t];return pV(r)?pV(r.typedArray)?this._getBinaryProperty(r,n):fV(r[n]):null})}_setHierarchyProperty(e,t,i,n){const r=hV(this._hierarchy,t,(e,r)=>{const s=e.classIndexes[r],o=e.classes[e.classIds[r]].instances[i];return!!pV(o)&&(ct(r===t,'Inherited property "'.concat(i,'" is read-only.')),pV(o.typedArray)?this._setBinaryProperty(o,s,n):o[s]=fV(n),!0)});return pV(r)}}function _V(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=new DataView(t);if(e.magic=n.getUint32(i,!0),i+=4,e.version=n.getUint32(i,!0),i+=4,e.byteLength=n.getUint32(i,!0),i+=4,1!==e.version)throw new Error("3D Tile Version ".concat(e.version," not supported"));return i}function yV(e,t,i){const n=new DataView(t);let r;e.header=e.header||{};let s=n.getUint32(i,!0),o=n.getUint32(i+=4,!0),a=n.getUint32(i+=4,!0),l=n.getUint32(i+=4,!0);return i+=4,a>=570425344?(i-=8,r=s,a=o,l=0,s=0,o=0):l>=570425344&&(i-=4,r=a,a=s,l=o,s=0,o=0),e.header.featureTableJsonByteLength=s,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=r,i}function vV(e,t,i,n){return i=function(e,t,i){const{featureTableJsonByteLength:n,featureTableBinaryByteLength:r,batchLength:s}=e.header;if(e.featureTableJson={BATCH_LENGTH:s||0},n>0){const r=XU(t,i,n);e.featureTableJson=JSON.parse(r)}return i+=n,e.featureTableBinary=new Uint8Array(t,i,r),i+=r,i}(e,t,i),i=function(e,t,i){const{batchTableJsonByteLength:n,batchTableBinaryByteLength:r}=e.header;if(n>0){const s=XU(t,i,n);e.batchTableJson=JSON.parse(s),i+=n,r>0&&(e.batchTableBinary=new Uint8Array(t,i,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),i+=r)}return i}(e,t,i),i}function xV(e,t,i){if(!(t||e&&e.batchIds&&i))return null;const{batchIds:n,isRGB565:r,pointCount:s}=e;if(n&&i){const e=new Uint8ClampedArray(3*s);for(let t=0;t<s;t++){const r=i.getProperty(n[t],"dimensions").map(e=>255*e);e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2]}return{type:ZU.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(r){const e=new Uint8ClampedArray(3*s);for(let i=0;i<s;i++){const n=eV(t[i]);e[3*i]=n[0],e[3*i+1]=n[1],e[3*i+2]=n[2]}return{type:ZU.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*s?{type:ZU.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:ZU.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}const bV=new gc;function wV(e,t,i){return e.isQuantized?i["3d-tiles"]&&i["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const i=new gc,n=new Float32Array(3*e.pointCount);for(let r=0;r<e.pointCount;r++)i.set(t[3*r],t[3*r+1],t[3*r+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,3*r);return n}(e,t)):{type:ZU.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function TV(e,t,i,n,r){i=vV(e,t,i=yV(e,t,i=_V(e,t,i))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:s,batchTable:o}=function(e){const t=new sV(e.featureTableJson,e.featureTableBinary),i=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(i))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=i,e.featuresLength=i,e.pointsLength=i,e.pointCount=i,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",ZU.FLOAT,3);const n=function(e,t){let i=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",ZU.UNSIGNED_SHORT,1),e.batchIds)){const n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:r,batchTableBinary:s}=e;i=new gV(r,s,n)}return i}(e,t);return{featureTable:t,batchTable:n}}(e);return await async function(e,t,i,n,r){let s,o,a;const l=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];l&&(a=l.properties);const c=t.getExtension("3DTILES_draco_point_compression");if(c){o=c.properties;const t=c.byteOffset,i=c.byteLength;if(!o||!Number.isFinite(t)||!i)throw new Error("Draco properties, byteOffset, and byteLength must be defined");s=e.featureTableBinary.slice(t,t+i),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!s)return!0;const u={buffer:s,properties:{...o,...a},batchTableProperties:a};return await async function(e,t,i,n){const{parse:r}=n,s={...i,draco:{...i.draco,extraAttributes:t.batchTableProperties||{}}};delete s["3d-tiles"];const o=await r(t.buffer,JN,s),a=o.attributes.POSITION&&o.attributes.POSITION.value,l=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,c=o.attributes.NORMAL&&o.attributes.NORMAL.value,u=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,h=c&&o.attributes.NORMAL.value.quantization;if(a&&o.attributes.POSITION.value.quantization){const t=o.POSITION.data.quantization,i=t.range;e.quantizedVolumeScale=new gc(i,i,i),e.quantizedVolumeOffset=new gc(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}h&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const d={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))o.attributes[e]&&o.attributes[e].value&&(d[e.toLowerCase()]=o.attributes[e].value);e.attributes={positions:a,colors:xV(e,l,void 0),normals:c,batchIds:u,...d}}(e,u,n,r)}(e,s,0,n,r),function(e,t,i){if(!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",ZU.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const n=t.getPropertyArray("POSITION_QUANTIZED",ZU.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ZU.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ZU.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=wV(e,n,i)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,s,n),function(e,t,i){if(!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",ZU.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",ZU.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",ZU.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=xV(e,n,i)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",ZU.UNSIGNED_BYTE,4))}(e,s,o),function(e,t){if(!e.attributes.normals){let i=null;t.hasProperty("NORMAL")?i=t.getPropertyArray("NORMAL",ZU.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(i=t.getPropertyArray("NORMAL_OCT16P",ZU.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const i=new Float32Array(3*e.pointsLength);for(let n=0;n<e.pointsLength;n++)rV(t[2*n],t[2*n+1],bV),bV.toArray(i,3*n);return{type:ZU.FLOAT,size:2,value:i}}return{type:ZU.FLOAT,size:2,value:t}}(e,i)}}(e,s),i}const SV=0,EV=1;function AV(e,t,i,n){e.rotateYtoZ=!0;const r=e.byteOffset+e.byteLength-i;if(0===r)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=n["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=Ht(t,i,r),e.gltfByteOffset=0,e.gltfByteLength=r,e.byteOffset+e.byteLength}async function MV(e,t,i,n){const r=i["3d-tiles"]||{};if(function(e,t){switch(t){case SV:const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),i=(new TextDecoder).decode(t);e.gltfUrl=i.replace(/[\s\0]+$/,""),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case EV:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),r.loadGLTF){const{parse:t,fetch:r}=n;e.gltfUrl&&(e.gltfArrayBuffer=await r(e.gltfUrl,i),e.gltfByteOffset=0),e.gltfArrayBuffer&&(e.gltf=await t(e.gltfArrayBuffer,Jk,i,n),e.gpuMemoryUsageInBytes=vN(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function IV(e,t,i,n,r){var s;i=function(e,t,i,n){i=_V(e,t,i),i=yV(e,t,i),i=vV(e,t,i),i=AV(e,t,i,n);const r=new sV(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=r.getGlobalProperty("RTC_CENTER",ZU.FLOAT,3),i}(e,t,i,n),await MV(e,EV,n,r);const o=null==e||null===(s=e.gltf)||void 0===s?void 0:s.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),i}async function CV(e,t,i,n,r){return i=function(e,t,i,n){if(i=_V(e,t,i),1!==e.version)throw new Error("Instanced 3D Model version ".concat(e.version," is not supported"));i=yV(e,t,i);const r=new DataView(t);if(e.gltfFormat=r.getUint32(i,!0),i+=4,i=vV(e,t,i),i=AV(e,t,i,n),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const s=new sV(e.featureTableJson,e.featureTableBinary),o=s.getGlobalProperty("INSTANCES_LENGTH");if(s.featuresLength=o,!Number.isFinite(o))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=s.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=s.getGlobalProperty("RTC_CENTER",ZU.FLOAT,3);new gV(e.batchTableJson,e.batchTableBinary,o);return function(e,t,i,n){const r={instances:new Array(n),batchTable:e._batchTable},s=r.instances,o=new gc;new gc,new gc,new gc;const a=new Ec,l=new uu,c=new gc,u={},h=new Hc,d=[],p=[],f=new gc,m=new gc;for(let i=0;i<n;i++){let n;if(t.hasProperty("POSITION"))n=t.getProperty("POSITION",ZU.FLOAT,3,i,o);else if(t.hasProperty("POSITION_QUANTIZED")){n=t.getProperty("POSITION_QUANTIZED",ZU.UNSIGNED_SHORT,3,i,o);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ZU.FLOAT,3,f);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const r=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ZU.FLOAT,3,m);if(!r)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const s=65535;for(let t=0;t<3;t++)n[t]=n[t]/s*r[t]+e[t]}if(!n)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(o.copy(n),u.translation=o,e.normalUp=t.getProperty("NORMAL_UP",ZU.FLOAT,3,i,d),e.normalRight=t.getProperty("NORMAL_RIGHT",ZU.FLOAT,3,i,p),e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",ZU.UNSIGNED_SHORT,2,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",ZU.UNSIGNED_SHORT,2,p),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(Tz.WGS84.eastNorthUpToFixedFrame(o,h),h.getRotationMatrix3(a)):a.identity()}l.fromMatrix3(a),u.rotation=l,c.set(1,1,1);const r=t.getProperty("SCALE",ZU.FLOAT,1,i);Number.isFinite(r)&&c.multiplyByScalar(r);const g=t.getProperty("SCALE_NON_UNIFORM",ZU.FLOAT,3,i,d);g&&c.scale(g),u.scale=c;let _=t.getProperty("BATCH_ID",ZU.UNSIGNED_SHORT,1,i);void 0===_&&(_=i);const y=(new Hc).fromQuaternion(u.rotation);h.identity(),h.translate(u.translation),h.multiplyRight(y),h.scale(u.scale);const v=h.clone();s[i]={modelMatrix:v,batchId:_}}e.instances=s}(e,s,0,o),i}(e,t,i,n),await MV(e,e.gltfFormat,n,r),i}async function PV(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};switch(r.byteOffset=t,r.type=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=new DataView(e);return"".concat(String.fromCharCode(i.getUint8(t+0))).concat(String.fromCharCode(i.getUint8(t+1))).concat(String.fromCharCode(i.getUint8(t+2))).concat(String.fromCharCode(i.getUint8(t+3)))}(e,t),r.type){case jU:return await async function(e,t,i,n,r,s){i=_V(e,t,i);const o=new DataView(t);for(e.tilesLength=o.getUint32(i,!0),i+=4,e.tiles=[];e.tiles.length<e.tilesLength&&e.byteLength-i>12;){const o={};e.tiles.push(o),i=await s(t,i,n,r,o)}return i}(r,e,t,i,n,PV);case HU:return await IV(r,e,t,i,n);case qU:return await async function(e,t,i,n){e.rotateYtoZ=!0,e.gltfUpAxis=i["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y";const{parse:r}=n;e.gltf=await r(t,Jk,i,n),e.gpuMemoryUsageInBytes=vN(e.gltf)}(r,e,i,n);case WU:return await CV(r,e,t,i,n);case GU:return await TV(r,e,t,i,n);default:throw new Error("3DTileLoader: unknown type ".concat(r.type))}}async function LV(e,t,i,n){const r=e.bufferViews[e[t].bufferView],s=e.buffers[r.buffer];if(null==n||!n.url||!n.fetch)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(s.uri){const e=function(e,t){if(t.startsWith("http")){const i=new URL(e,t);return decodeURI(i.toString())}const i="http://".concat(t),n=new URL(e,i);return"/".concat(n.host).concat(n.pathname)}(s.uri,null==n?void 0:n.url),t=await n.fetch(e),i=await t.arrayBuffer();return new Uint8Array(i,r.byteOffset,r.byteLength)}return new Uint8Array(i,r.byteOffset,r.byteLength)}function RV(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const OV={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:VU,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,i){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const n=RV(e.slice(8,16)),r=new Uint8Array(e,24,n),s=new TextDecoder("utf8").decode(r),o=JSON.parse(s),a=RV(e.slice(16,24));let l=new ArrayBuffer(0);return a&&(l=e.slice(24+n)),"bufferView"in o.tileAvailability&&(o.tileAvailability.explicitBitstream=await LV(o,"tileAvailability",l,i)),"bufferView"in o.contentAvailability&&(o.contentAvailability.explicitBitstream=await LV(o,"contentAvailability",l,i)),"bufferView"in o.childSubtreeAvailability&&(o.childSubtreeAvailability.explicitBitstream=await LV(o,"childSubtreeAvailability",l,i)),o},options:{}};
/**
 * @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
 */var DV=null;try{DV=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 BV(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function FV(e){return!0===(e&&e.__isLong__)}function NV(e){var t=Math.clz32(e&-e);return e?31-t:t}Object.defineProperty(BV.prototype,"__isLong__",{value:!0}),BV.isLong=FV;var kV={},zV={};function UV(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=zV[e])?n:(i=jV(e,0,!0),r&&(zV[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=kV[e])?n:(i=jV(e,e<0?-1:0,!1),r&&(kV[e]=i),i)}function VV(e,t){if(isNaN(e))return t?JV:YV;if(t){if(e<0)return JV;if(e>=XV)return ij}else{if(e<=-$V)return nj;if(e+1>=$V)return tj}return e<0?VV(-e,t).neg():jV(e%qV|0,e/qV|0,t)}function jV(e,t,i){return new BV(e,t,i)}BV.fromInt=UV,BV.fromNumber=VV,BV.fromBits=jV;var GV=Math.pow;function HV(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?JV:YV;if((i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return HV(e.substring(1),t,i).neg();for(var r=VV(GV(i,8)),s=YV,o=0;o<e.length;o+=8){var a=Math.min(8,e.length-o),l=parseInt(e.substring(o,o+a),i);if(a<8){var c=VV(GV(i,a));s=s.mul(c).add(VV(l))}else s=(s=s.mul(r)).add(VV(l))}return s.unsigned=t,s}function WV(e,t){return"number"==typeof e?VV(e,t):"string"==typeof e?HV(e,t):jV(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}BV.fromString=HV,BV.fromValue=WV;var qV=4294967296,XV=qV*qV,$V=XV/2,ZV=UV(1<<24),YV=UV(0);BV.ZERO=YV;var JV=UV(0,!0);BV.UZERO=JV;var KV=UV(1);BV.ONE=KV;var QV=UV(1,!0);BV.UONE=QV;var ej=UV(-1);BV.NEG_ONE=ej;var tj=jV(-1,2147483647,!1);BV.MAX_VALUE=tj;var ij=jV(-1,-1,!0);BV.MAX_UNSIGNED_VALUE=ij;var nj=jV(0,-2147483648,!1);BV.MIN_VALUE=nj;var rj=BV.prototype;rj.toInt=function(){return this.unsigned?this.low>>>0:this.low},rj.toNumber=function(){return this.unsigned?(this.high>>>0)*qV+(this.low>>>0):this.high*qV+(this.low>>>0)},rj.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(nj)){var t=VV(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=VV(GV(e,6),this.unsigned),s=this,o="";;){var a=s.div(r),l=(s.sub(a.mul(r)).toInt()>>>0).toString(e);if((s=a).isZero())return l+o;for(;l.length<6;)l="0"+l;o=""+l+o}},rj.getHighBits=function(){return this.high},rj.getHighBitsUnsigned=function(){return this.high>>>0},rj.getLowBits=function(){return this.low},rj.getLowBitsUnsigned=function(){return this.low>>>0},rj.getNumBitsAbs=function(){if(this.isNegative())return this.eq(nj)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},rj.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},rj.isZero=function(){return 0===this.high&&0===this.low},rj.eqz=rj.isZero,rj.isNegative=function(){return!this.unsigned&&this.high<0},rj.isPositive=function(){return this.unsigned||this.high>=0},rj.isOdd=function(){return!(1&~this.low)},rj.isEven=function(){return!(1&this.low)},rj.equals=function(e){return FV(e)||(e=WV(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},rj.eq=rj.equals,rj.notEquals=function(e){return!this.eq(e)},rj.neq=rj.notEquals,rj.ne=rj.notEquals,rj.lessThan=function(e){return this.comp(e)<0},rj.lt=rj.lessThan,rj.lessThanOrEqual=function(e){return this.comp(e)<=0},rj.lte=rj.lessThanOrEqual,rj.le=rj.lessThanOrEqual,rj.greaterThan=function(e){return this.comp(e)>0},rj.gt=rj.greaterThan,rj.greaterThanOrEqual=function(e){return this.comp(e)>=0},rj.gte=rj.greaterThanOrEqual,rj.ge=rj.greaterThanOrEqual,rj.compare=function(e){if(FV(e)||(e=WV(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&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},rj.comp=rj.compare,rj.negate=function(){return!this.unsigned&&this.eq(nj)?nj:this.not().add(KV)},rj.neg=rj.negate,rj.add=function(e){FV(e)||(e=WV(e));var t=0,i=0,n=0,r=0;return n+=(r+=(65535&this.low)+(65535&e.low))>>>16,i+=(n+=(this.low>>>16)+(e.low>>>16))>>>16,t+=(i+=(65535&this.high)+(65535&e.high))>>>16,t+=(this.high>>>16)+(e.high>>>16),jV((n&=65535)<<16|(r&=65535),(t&=65535)<<16|(i&=65535),this.unsigned)},rj.subtract=function(e){return FV(e)||(e=WV(e)),this.add(e.neg())},rj.sub=rj.subtract,rj.multiply=function(e){if(this.isZero())return this;if(FV(e)||(e=WV(e)),DV)return jV(DV.mul(this.low,this.high,e.low,e.high),DV.get_high(),this.unsigned);if(e.isZero())return this.unsigned?JV:YV;if(this.eq(nj))return e.isOdd()?nj:YV;if(e.eq(nj))return this.isOdd()?nj:YV;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(ZV)&&e.lt(ZV))return VV(this.toNumber()*e.toNumber(),this.unsigned);var t=65535&this.high,i=this.low>>>16,n=65535&this.low,r=65535&e.high,s=e.low>>>16,o=65535&e.low,a=0,l=0,c=0,u=0;return c+=(u+=n*o)>>>16,l+=(c+=i*o)>>>16,c&=65535,l+=(c+=n*s)>>>16,a+=(l+=t*o)>>>16,l&=65535,a+=(l+=i*s)>>>16,l&=65535,a+=(l+=n*r)>>>16,a+=(this.high>>>16)*o+t*s+i*r+n*(e.high>>>16),jV((c&=65535)<<16|(u&=65535),(a&=65535)<<16|(l&=65535),this.unsigned)},rj.mul=rj.multiply,rj.divide=function(e){if(FV(e)||(e=WV(e)),e.isZero())throw Error("division by zero");var t,i,n;if(DV)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?jV((this.unsigned?DV.div_u:DV.div_s)(this.low,this.high,e.low,e.high),DV.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?JV:YV;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return JV;if(e.gt(this.shru(1)))return QV;n=JV}else{if(this.eq(nj))return e.eq(KV)||e.eq(ej)?nj:e.eq(nj)?KV:(t=this.shr(1).div(e).shl(1)).eq(YV)?e.isNegative()?KV:ej:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(nj))return this.unsigned?JV:YV;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();n=YV}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),s=r<=48?1:GV(2,r-48),o=VV(t),a=o.mul(e);a.isNegative()||a.gt(i);)a=(o=VV(t-=s,this.unsigned)).mul(e);o.isZero()&&(o=KV),n=n.add(o),i=i.sub(a)}return n},rj.div=rj.divide,rj.modulo=function(e){return FV(e)||(e=WV(e)),DV?jV((this.unsigned?DV.rem_u:DV.rem_s)(this.low,this.high,e.low,e.high),DV.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},rj.mod=rj.modulo,rj.rem=rj.modulo,rj.not=function(){return jV(~this.low,~this.high,this.unsigned)},rj.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},rj.clz=rj.countLeadingZeros,rj.countTrailingZeros=function(){return this.low?NV(this.low):NV(this.high)+32},rj.ctz=rj.countTrailingZeros,rj.and=function(e){return FV(e)||(e=WV(e)),jV(this.low&e.low,this.high&e.high,this.unsigned)},rj.or=function(e){return FV(e)||(e=WV(e)),jV(this.low|e.low,this.high|e.high,this.unsigned)},rj.xor=function(e){return FV(e)||(e=WV(e)),jV(this.low^e.low,this.high^e.high,this.unsigned)},rj.shiftLeft=function(e){return FV(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jV(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):jV(0,this.low<<e-32,this.unsigned)},rj.shl=rj.shiftLeft,rj.shiftRight=function(e){return FV(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jV(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):jV(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},rj.shr=rj.shiftRight,rj.shiftRightUnsigned=function(e){return FV(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jV(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):jV(32===e?this.high:this.high>>>e-32,0,this.unsigned)},rj.shru=rj.shiftRightUnsigned,rj.shr_u=rj.shiftRightUnsigned,rj.rotateLeft=function(e){var t;return FV(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?jV(this.high,this.low,this.unsigned):e<32?jV(this.low<<e|this.high>>>(t=32-e),this.high<<e|this.low>>>t,this.unsigned):jV(this.high<<(e-=32)|this.low>>>(t=32-e),this.low<<e|this.high>>>t,this.unsigned)},rj.rotl=rj.rotateLeft,rj.rotateRight=function(e){var t;return FV(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?jV(this.high,this.low,this.unsigned):e<32?jV(this.high<<(t=32-e)|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned):jV(this.low<<(t=32-(e-=32))|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)},rj.rotr=rj.rotateRight,rj.toSigned=function(){return this.unsigned?jV(this.low,this.high,!1):this},rj.toUnsigned=function(){return this.unsigned?this:jV(this.low,this.high,!0)},rj.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},rj.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},rj.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},BV.fromBytes=function(e,t,i){return i?BV.fromBytesLE(e,t):BV.fromBytesBE(e,t)},BV.fromBytesLE=function(e,t){return new BV(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},BV.fromBytesBE=function(e,t){return new BV(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(BV.fromBigInt=function(e,t){return jV(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},BV.fromValue=function(e,t){return"bigint"==typeof e?BV.fromBigInt(e,t):WV(e,t)},rj.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});function sj(e){"X"===e&&(e="");const t=e.padEnd(16,"0");return BV.fromString(t,!0,16)}const oj=180/Math.PI;function aj(e,t,i){const n=1<<t;return[(e[0]+i[0])/n,(e[1]+i[1])/n]}function lj(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function cj(e){return[lj(e[0]),lj(e[1])]}function uj(e,t){let[i,n]=t;switch(e){case 0:return[1,i,n];case 1:return[-i,1,n];case 2:return[-i,-n,1];case 3:return[-1,-n,-i];case 4:return[n,-1,-i];case 5:return[n,i,-1];default:throw new Error("Invalid face")}}function hj(e){let[t,i,n]=e;const r=Math.atan2(n,Math.sqrt(t*t+i*i));return[Math.atan2(i,t)*oj,r*oj]}function dj(e,t,i,n){if(0===n){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const n=t[0];t[0]=t[1],t[1]=n}}function pj(e){const{face:t,ij:i,level:n}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(100*Math.pow(2,-n))),o=new Float64Array(4*s*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),u=r[e+1],h=(u[0]-c[0])/s,d=(u[1]-c[1])/s;for(let e=0;e<s;e++){c[0]+=h,c[1]+=d;const e=hj(uj(t,cj(aj(i,n,c))));Math.abs(e[1])>89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,o[a++]=e[0],o[a++]=e[1],l=e[0]}}return o[a++]=o[0],o[a++]=o[1],o}function fj(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=sj(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),n=t.substring(0,3),r=t.substring(3,i),s=r.length/2,o=BV.fromString(n,!0,2).toString(10);let a="";if(0!==s)for(a=BV.fromString(r,!0,2).toString(4);a.length<s;)a="0"+a;return"".concat(o,"/").concat(a)}(t)}(e),i=function(e){if(0===e.length)throw new Error("Invalid Hilbert quad key ".concat(e));const t=e.split("/"),i=parseInt(t[0],10),n=t[1],r=n.length;let s=0;const o=[0,0];for(let e=r-1;e>=0;e--){s=r-e;const t=n[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,s-1);dj(l,o,i,a),o[0]+=l*i,o[1]+=l*a}if(i%2==1){const e=o[0];o[0]=o[1],o[1]=e}return{face:i,ij:o,level:s}}(t);return i}function mj(e){return function(e){const t=cj(aj(e.ij,e.level,[.5,.5]));return hj(uj(e.face,t))}(fj(e))}function gj(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let n=0;n<e.length;n+=2)t.push(e[n]),i.push(e[n+1]);return t.sort((e,t)=>e-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function _j(e,t){const i=(null==t?void 0:t.minimumHeight)||0,n=(null==t?void 0:t.maximumHeight)||0,r=function(e){let t;if(2===e.face||5===e.face){let i=null,n=0;for(let t=0;t<4;t++){const r=pj(fj("".concat(e.face,"/").concat(t)));null==i&&(i=new Float64Array(4*r.length)),i.set(r,n),n+=r.length}t=gj(i)}else t=gj(pj(e));return t}(fj(e)),s=r.west,o=r.south,a=r.east,l=r.north,c=[];return c.push(new gc(s,l,i)),c.push(new gc(a,l,i)),c.push(new gc(a,o,i)),c.push(new gc(s,o,i)),c.push(new gc(s,l,n)),c.push(new gc(a,l,n)),c.push(new gc(a,o,n)),c.push(new gc(s,o,n)),c}function yj(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=_j(t,i),r=mj(t),s=Tz.WGS84.cartographicToCartesian([r[0],r[1],i.maximumHeight]),o=new gc(s[0],s[1],s[2]);n.push(o);const a=function(e,t=new oB){if(!e||0===e.length)return t.halfAxes=new Ec([0,0,0,0,0,0,0,0,0]),t.center=new gc,t;const i=e.length,n=new gc(0,0,0);for(const t of e)n.add(t);const r=1/i;n.multiplyByScalar(r);let s=0,o=0,a=0,l=0,c=0,u=0;for(const t of e){const e=SB.copy(t).subtract(n);s+=e.x*e.x,o+=e.x*e.y,a+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,u+=e.z*e.z}s*=r,o*=r,a*=r,l*=r,c*=r,u*=r;const h=CB;h[0]=s,h[1]=o,h[2]=a,h[3]=o,h[4]=l,h[5]=c,h[6]=a,h[7]=c,h[8]=u;const{unitary:d}=vB(h,PB),p=t.halfAxes.copy(d);let f=p.getColumn(0,AB),m=p.getColumn(1,MB),g=p.getColumn(2,IB),_=-Number.MAX_VALUE,y=-Number.MAX_VALUE,v=-Number.MAX_VALUE,x=Number.MAX_VALUE,b=Number.MAX_VALUE,w=Number.MAX_VALUE;for(const t of e)SB.copy(t),_=Math.max(SB.dot(f),_),y=Math.max(SB.dot(m),y),v=Math.max(SB.dot(g),v),x=Math.min(SB.dot(f),x),b=Math.min(SB.dot(m),b),w=Math.min(SB.dot(g),w);f=f.multiplyByScalar(.5*(x+_)),m=m.multiplyByScalar(.5*(b+y)),g=g.multiplyByScalar(.5*(w+v)),t.center.copy(f).add(m).add(g);const T=EB.set(_-x,y-b,v-w).multiplyByScalar(.5),S=new Ec([T[0],0,0,0,T[1],0,0,0,T[2]]);return t.halfAxes.multiplyRight(S),t}(n);return[...a.center,...a.halfAxes]}const vj={QUADTREE:4,OCTREE:8};function xj(e,t,i){if(null!=e&&e.box){const n=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(BV.fromNumber(2*t+1-4).multiply(i))}(sj(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}(n),s={...e.s2VolumeInfo};if(s.token=r,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,n=i/2,r=t.minimumHeight+i/2;t.minimumHeight=r-n,t.maximumHeight=r+n}return{box:yj(s),s2VolumeInfo:s}}}async function bj(e){const{options:t,parentData:i={mortonIndex:0,x:0,y:0,z:0},childIndex:n=0,globalData:r={level:0,mortonIndex:0,x:0,y:0,z:0},s2VolumeBox:s}=e;let{subtree:o,level:a=0}=e;const{subdivisionScheme:l,subtreeLevels:c,maximumLevel:u,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=t,f={children:[],lodMetricValue:0,contentUrl:""},m=vj[l],g=1&n,_=n>>1&1,y=n>>2&1,v=(m**a-1)/(m-1);let x=Sj(i.mortonIndex,n),b=v+x,w=Sj(i.x,g),T=Sj(i.y,_),S=Sj(i.z,y),E=!1;a+1>c&&(E=wj(o.childSubtreeAvailability,x));const A=Sj(r.x,w),M=Sj(r.y,T),I=Sj(r.z,S),C=a+r.level;if(E){const e=Ej("".concat(p,"/").concat(d),C,A,M,I);o=await yn(e,OV),r.mortonIndex=x,r.x=w,r.y=T,r.z=S,r.level=a,x=0,b=0,w=0,T=0,S=0,a=0}if(!wj(o.tileAvailability,b)||a>u)return f;wj(o.contentAvailability,b)&&(f.contentUrl=Ej(h,C,A,M,I));const P=a+1,L={mortonIndex:x,x:w,y:T,z:S};for(let e=0;e<m;e++){const i=xj(s,e,l),n=await bj({subtree:o,options:t,parentData:L,childIndex:e,level:P,globalData:r,s2VolumeBox:i});if(n.contentUrl||n.children.length){const e=Tj(n,C+1,{childTileX:w,childTileY:T,childTileZ:S},t,s);f.children.push(e)}}return f}function wj(e,t){return"constant"in e?Boolean(e.constant):!!e.explicitBitstream&&function(e,t){const i=Math.floor(e/8);return 1==(t[i]>>e%8&1)}(t,e.explicitBitstream)}function Tj(e,t,i,n,r){const{basePath:s,refine:o,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=n,d=e.contentUrl&&e.contentUrl.replace("".concat(s,"/"),""),p=u/2**t,f=function(e,t,i){if(t.region){const{childTileX:n,childTileY:r,childTileZ:s}=i,[o,a,l,c,u,h]=t.region,d=2**e,p=(l-o)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[o+p*n,o+p*(n+1)],[y,v]=[a+f*r,a+f*(r+1)],[x,b]=[u+m*s,u+m*(s+1)];return{region:[g,y,_,v,x,b]}}if(t.box)return t;throw new Error("Unsupported bounding volume type ".concat(t))}(t,null!=r&&r.box?{box:r.box}:h,i);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(o),type:c(e),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function Sj(e,t){return parseInt(e.toString(2)+t.toString(2),2)}function Ej(e,t,i,n,r){const s=function(e){const t={};for(const i in e)t["{".concat(i,"}")]=e[i];return t}({level:t,x:i,y:n,z:r});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>s[e])}function Aj(e){if(!e.contentUrl)return Hz;const t=e.contentUrl.split("?")[0].split(".").pop();switch(t){case"pnts":return qz;case"i3dm":case"b3dm":case"glb":case"gltf":return Wz;default:return t}}function Mj(e){switch(e){case"REPLACE":case"replace":return Gz;case"ADD":case"add":return jz;default:return e}}function Ij(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,"".concat(t,"/"));return decodeURI(i.toString())}return e.startsWith("/")?e:"".concat(t,"/").concat(e)}function Cj(e,t){if(!e)return null;if(e.content){e.contentUrl=Ij(e.content.uri||e.content.url,t.basePath)}return e.id=e.contentUrl,e.lodMetricType=Yz,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=Aj(e),e.refine=Mj(e.refine),e}async function Pj(e,t,i,n){var r,s;const o=t.basePath,{subdivisionScheme:a,maximumLevel:l,subtreeLevels:c,subtrees:{uri:u}}=i,h=Ij(Ej(u,0,0,0,0),o),d=await yn(h,OV,n),p=Ij(e.content.uri,o),f=null==t||null===(r=t.root)||void 0===r?void 0:r.refine,m=e.geometricError,g=null===(s=e.boundingVolume.extensions)||void 0===s?void 0:s["3DTILES_bounding_volume_S2"];if(g){const t=yj(g);e.boundingVolume={box:t,s2VolumeInfo:g}}const _={contentUrlTemplate:p,subtreesUriTemplate:u,subdivisionScheme:a,subtreeLevels:c,maximumLevel:l,refine:f,basePath:o,lodMetricType:Yz,rootLodMetricValue:m,rootBoundingVolume:e.boundingVolume,getTileType:Aj,getRefine:Mj};return await async function(e,t,i){if(!e)return null;e.lodMetricType=Yz,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform;const{children:n,contentUrl:r}=await bj({subtree:t,options:i,s2VolumeBox:e});r&&(e.contentUrl=r,e.content={uri:r.replace("".concat(i.basePath,"/"),"")});return e.refine=Mj(e.refine),e.type=Aj(e),e.children=n,e.id=e.contentUrl,e}(e,d,_)}function Lj(e){var t;return(null==e||null===(t=e.extensions)||void 0===t?void 0:t["3DTILES_implicit_tiling"])||(null==e?void 0:e.implicitTiling)}const Rj={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:VU,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t,i){const n=t["3d-tiles"]||{};let r;r="auto"===n.isTileset?i.url&&-1!==i.url.indexOf(".json"):n.isTileset;e=r?await async function(e,t,i){var n;const r=JSON.parse((new TextDecoder).decode(e));return r.loader=t.loader||Rj,r.url=i.url,r.queryString=i.queryString,r.basePath=function(e){return ii(e.url)}(r),r.root=await async function(e,t){const i=e.basePath;let n;const r=Lj(null==e?void 0:e.root);n=r&&e.root?await Pj(e.root,e,r,t):Cj(e.root,e);const s=[];for(s.push(n);s.length>0;){const n=(s.pop()||{}).children||[];for(let r of n){const n=Lj(r);n?r=await Pj(r,e,n,t):Cj(r,{basePath:i}),s.push(r)}}return n}(r,t),r.type=Zz,r.lodMetricType=Yz,r.lodMetricValue=(null===(n=r.root)||void 0===n?void 0:n.lodMetricValue)||0,r}(e,t,i):await async function(e,t,i){const n={content:{featureIds:null}},r=0;return await PV(e,r,t,i,n.content),n.content}(e,t,i);return e},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const Oj=[0],Dj={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Rj,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,i)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};let Bj=class extends Nm{constructor(...e){super(...e),bt(this,"state",void 0)}initializeState(){"onTileLoadFail"in this.props&&Gn.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){var e,t;return Boolean((null===(e=this.state)||void 0===e||null===(t=e.tileset3d)||void 0===t?void 0:t.isLoaded())&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,changeFlags:i}){if(e.data&&e.data!==t.data&&this._loadTileset(e.data),i.viewportChanged){const{activeViewports:e}=this.state;Object.keys(e).length&&(this._updateTileset(e),this.state.lastUpdatedViewports=e,this.state.activeViewports={})}if(i.propsChanged){const{layerMap:e}=this.state;for(const t in e)e[t].needsUpdate=!0}}activateViewport(e){const{activeViewports:t,lastUpdatedViewports:i}=this.state;this.internalState.viewport=e,t[e.id]=e;const n=null==i?void 0:i[e.id];n&&e.equals(n)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:t}){const i=t&&t.props.tile;return e.picked&&(e.object=i),e.sourceTile=i,e}filterSubLayer({layer:e,viewport:t}){const{tile:i}=e.props,{id:n}=t;return i.selected&&i.viewportIds.includes(n)}_updateAutoHighlight(e){const t=e.sourceTile,i=this.state.layerMap[null==t?void 0:t.id];i&&i.layer&&i.layer.updateAutoHighlight(e)}async _loadTileset(e){const{loadOptions:t={}}=this.props;let i=this.props.loader||this.props.loaders;Array.isArray(i)&&(i=i[0]);const n={loadOptions:{...t}};let r=e;if(i.preload){const s=await i.preload(e,t);s.url&&(r=s.url),s.headers&&(n.loadOptions.fetch={...n.loadOptions.fetch,headers:s.headers}),Object.assign(n,s)}const s=await yn(r,i,n.loadOptions),o=new UU(s,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...n});this.setState({tileset3d:o,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(o)}_onTileLoad(e){const{lastUpdatedViewports:t}=this.state;this.props.onTileLoad(e),this._updateTileset(t),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;const{tileset3d:t}=this.state,{timeline:i}=this.context,n=Object.keys(e).length;i&&n&&t&&t.selectTiles(Object.values(e)).then(e=>{this.state.frameNumber!==e&&this.setState({frameNumber:e})})}_getSubLayer(e,t){if(!e.content)return null;switch(e.type){case qz:return this._makePointCloudLayer(e,t);case Wz:return this._make3DModelLayer(e);case Xz:return this._makeSimpleMeshLayer(e,t);default:throw new Error("Tile3DLayer: Failed to render layer of type ".concat(e.content.type))}}_makePointCloudLayer(e,t){const{attributes:i,pointCount:n,constantRGBA:r,cartographicOrigin:s,modelMatrix:o}=e.content,{positions:a,normals:l,colors:c}=i;if(!a)return null;const u=t&&t.props.data||{header:{vertexCount:n},attributes:{POSITION:a,NORMAL:l,COLOR_0:c}},{pointSize:h,getPointColor:d}=this.props;return new(this.getSubLayerClass("pointcloud",ey))({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:"".concat(this.id,"-pointcloud-").concat(e.id),tile:e,data:u,coordinateSystem:Zn.METER_OFFSETS,coordinateOrigin:s,modelMatrix:o,getColor:r||d,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:i,cartographicOrigin:n,modelMatrix:r}=e.content;return new(this.getSubLayerClass("scenegraph",tz))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:"".concat(this.id,"-scenegraph-").concat(e.id),tile:e,data:i||Oj,scenegraph:t,coordinateSystem:Zn.METER_OFFSETS,coordinateOrigin:n,modelMatrix:r,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(e,t){const i=e.content,{attributes:n,indices:r,modelMatrix:s,cartographicOrigin:o,coordinateSystem:a=Zn.METER_OFFSETS,material:l,featureIds:c}=i,{_getMeshColor:u}=this.props,h=t&&t.props.mesh||new Hu({drawMode:4,attributes:Fj(n),indices:r});return new(this.getSubLayerClass("mesh",iz))(this.getSubLayerProps({id:"mesh"}),{id:"".concat(this.id,"-mesh-").concat(e.id),tile:e,mesh:h,data:Oj,getColor:u(e),pbrMaterial:l,modelMatrix:s,coordinateOrigin:o,coordinateSystem:a,featureIds:c,_offset:0})}renderLayers(){const{tileset3d:e,layerMap:t}=this.state;return e?e.tiles.map(e=>{const i=t[e.id]=t[e.id]||{tile:e};let{layer:n}=i;return e.selected&&(n?i.needsUpdate&&(n=this._getSubLayer(e,n),i.needsUpdate=!1):n=this._getSubLayer(e)),i.layer=n,n}).filter(Boolean):null}};function Fj(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}bt(Bj,"defaultProps",Dj),bt(Bj,"layerName","Tile3DLayer");const Nj={name:"fog",fs:"\nuniform vec4 fog_color;\nuniform float fog_near;\nuniform float fog_far;\n",getUniforms:e=>e&&e.fog?{fog_color:e.fog.color,fog_near:e.fog.near,fog_far:e.fog.far}:{}},kj={"fs:DECKGL_FILTER_COLOR":"\n    float fog_depth = 1.0 / gl_FragCoord.w;\n    float fog_factor = clamp((fog_far - fog_depth) / (fog_far - fog_near), 0.0, 1.0);\n    // fog_factor is 1 near / 0 far; apply the fog color scaled by its alpha so the\n    // original texture still shows through by (1 - alpha) even at full fog.\n    color.rgb = mix(color.rgb, fog_color.rgb, (1.0 - fog_factor) * fog_color.a);\n"};class zj extends km{getShaders(){return{modules:[Nj],inject:kj}}draw(e,t){e.moduleParameters&&t.opts&&(e.moduleParameters.fog=t.opts.fog)}}zj.extensionName="FogExtension";const Uj=Math.PI/180;function Vj(e){const[t,i,n,r]=F_(e);return[t/255,i/255,n/255,r]}class jj{constructor(e){this.implementation=e,this._updateLights=this._updateLights.bind(this)}onAdd(e,t){const i=this,n=i.implementation,r=n.lightColor,s=e.map,o=i.fog={color:Vj(s),near:0,far:1},a=Object.assign({},n,{type:Bj,extensions:[...n.extensions||[],new zj({fog:o})]}),l={color:r,intensity:2.5},c={color:r,intensity:5,direction:[0,0,-1]};i.map=e,delete a.lightColor,delete a.minzoom,delete a.maxzoom;const u=i.mapboxLayer=new qv(a),h=u.render.bind(u),d=u.onRemove.bind(u);u.render=(...e)=>(i._render(),h(...e)),u.onRemove=(...t)=>(void 0===r&&e.off("light",i._updateLights),d(...t)),s.addLayer(u,t||"poi"),s.setLayerZoomRange(n.id,n.minzoom,n.maxzoom),Vm(s.__deck,l,c),void 0===r&&(e.on("light",i._updateLights),i._updateLights({directional:O_(s),ambient:D_(s)}))}_render(){const e=this.map.map,t=this.fog;t.color=Vj(e),[t.near,t.far]=N_(function(e){const t=e.__deck.getViewports()[0],[i,n,r]=t.center,s=t.viewProjectionMatrix;return Math.abs(s[3]*i+s[7]*n+s[11]*r+s[15])}(e),function(e){const t=e.__deck.getViewports()[0].projectionMatrix;return Math.abs(t[14]/(t[10]+1))}(e))}_updateLights({directional:e,ambient:t}){const[i,n]=e.direction,r=i*Uj,s=n*Uj,o={color:t.color,intensity:2.5*t.intensity},a={color:e.color,intensity:5*e.intensity,direction:[Math.sin(r)*Math.sin(s),Math.cos(r)*Math.sin(s),Math.cos(s)]};Vm(this.map.map.__deck,o,a)}}const Gj=new mP(-1,1,1,-1,0,1);const Hj=new class extends hE{constructor(){super(),this.setAttribute("position",new QS([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new QS([0,2,0,0,2,0],2))}};class Wj{constructor(e){this._mesh=new iA(Hj,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Gj)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}const qj={ubyte4:{TypedArray:Uint8Array,format:fb,type:Qx,unit:4},uint4:{TypedArray:Uint32Array,format:bb,type:rb,unit:4},float4:{TypedArray:Float32Array,format:fb,type:sb,unit:4},float2:{TypedArray:Float32Array,format:vb,type:sb,unit:2}};class Xj extends mA{constructor(...e){if("number"==typeof e[0]){const[t,i,n]=e,{TypedArray:r,format:s,type:o,unit:a}=qj[i],l=Math.ceil(t/n)||1;super(new r(n*l*a),n,l,s,o),Object.assign(this.userData,{size:t,TypedArray:r,unit:a}),this.needsUpdate=!0}else if(2===e.length){const[t,i]=e,{image:n,userData:r,format:s,type:o}=t,{data:a,width:l}=n,{size:c,TypedArray:u,unit:h}=r,d=c+i,p=Math.ceil(d/l)||1;let f;p===n.height?f=a:(f=new u(l*p*h),f.set(a)),super(f,l,p,s,o),Object.assign(this.userData,{size:d,TypedArray:u,unit:h}),this.needsUpdate=!0}else{const[t,i,n]=e,{image:r,userData:s,format:o,type:a}=t,{data:l,width:c}=r,{size:u,TypedArray:h,unit:d}=s,p=u-n,f=Math.ceil(p/c)||1;let m;f===r.height?m=l:(m=new h(c*f*d),m.set(l.subarray(0,i*d)),m.set(l.subarray((i+n)*d,u*d),i*d)),super(m,c,f,o,a),Object.assign(this.userData,{size:p,TypedArray:h,unit:d}),this.needsUpdate=!0}}get size(){return this.userData.size}}class $j{constructor(e,t){const i=this,n=t.chunkSize;i.uintTexture=new Xj(2*e,"uint4",n),i.floatTexture=new Xj(2*e,"float4",n),i.count=e,i.start=0}add(e,t,i,n,r,s){const o=this,{uintTexture:a,floatTexture:l}=o,c=a.image.data,u=l.image.data;for(let h=o.start,d=o.count;h<d;h++){const d=8*h;if(0===c[d+6])return c.set([e,t,i,864e5,864e5,performance.now(),1,s],d),u.set([n,r],d),a.needsUpdate=!0,l.needsUpdate=!0,o.start=h+1,h}}update(e,t,i,n,r,s,o,a,l){const{uintTexture:c,floatTexture:u}=this,h=u.image.data,d=8*e;c.image.data.set([n,n+r],d+3),h.set([t,i,s,o,a,l],d),c.needsUpdate=!0,u.needsUpdate=!0}remove(e){return new Promise(t=>{const i=this,n=i.uintTexture,r=n.image.data,o=8*e;r.set([performance.now(),2],o+5),n.needsUpdate=!0,Ie.start({complete:()=>{r.set([0,0],o+6),n.needsUpdate=!0,i.start=Math.min(e,i.start),t()},duration:s.fadeDuration})})}setMarked(e){this.marked=e}setTracked(e){this.tracked=e}getIDs(e){const t=this,i=t.uintTexture.image.data,n={body:[],delayMarker:[],outline:[]},r={body:[],delayMarker:[],outline:[]},s={body:[],outline:[]},o={body:[],outline:[]};for(let a=0,l=t.count;a<l;a++){const l=8*a;if(0!==i[l+6]){const c=i[l],u=i[l+7],h=0===c?e[4*a+2]<0?n:r:1===c?s:o;h.body.push(a),1===u&&h.delayMarker.push(a),a!==t.marked&&a!==t.tracked||h.outline.push(a)}}return n.body.sort((e,t)=>e%256-t%256),r.body.sort((e,t)=>e%256-t%256),[n,r,s,o]}dispose(){this.uintTexture.dispose(),this.floatTexture.dispose()}}class Zj{constructor(e){const t=this,i=e.chunkSize;t.modelOrigin=e.modelOrigin,t.uintTexture=new Xj(0,"uint4",i),t.floatTexture=new Xj(0,"float2",i),t.groups=new Map,t.groupCount=0,t.freeIndices=[],t.freeBundledIndices=[],t.lookup=new Map,t.loopCount=0}addGroup(e){const t=this,{modelOrigin:i,lookup:n}=t,r=[],s=[],o=t.uintTexture.size;let a=0,l=t.floatTexture.size,c=0,u=1;for(const{id:i,feature:l}of e){const e=Array.isArray(l),h=e?t.freeBundledIndices:t.freeIndices;let d;h.length>0?d=h.pop():(d=o+a,a+=e?l.length:1),r.push(i),n.set(i,{index:d,bundled:e});for(const t of e?l:[l]){const e=t.properties,i=t.geometry.coordinates,n=e["station-offsets"]||[0,e.length];s.push({index:d,coords:i,distances:e.distances,sectionOffsets:n}),d+=1,c+=3*i.length+Math.ceil(n.length/2),u=Math.max(u,i.length)}}t.groups.set(t.groupCount,{ids:r,floatTextureOffset:l,floatTextureSize:c}),t.loopCount=Math.max(t.loopCount,Math.ceil(Math.log2(u)));const h=new Xj(t.uintTexture,a),d=new Xj(t.floatTexture,c);t.uintTexture.dispose(),t.floatTexture.dispose(),t.uintTexture=h,t.floatTexture=d;const p=h.image.data,f=d.image.data;for(const{index:e,coords:t,distances:n,sectionOffsets:r}of s){p.set([l,t.length,l+3*t.length],4*e);for(let e=0,r=t.length;e<r;e++){const r=t[e],s=ae.MercatorCoordinate.fromLngLat(r,r[2]||0),[o,a,,c]=n[e];f.set([o,s.x-i.x,-(s.y-i.y),s.z-i.z,tT.degToRad(-a),c],2*l+6*e)}f.set(r,2*l+6*t.length),l+=Math.ceil(3*t.length+r.length/2)}return h.needsUpdate=!0,d.needsUpdate=!0,t.groupCount++}removeGroup(e){const t=this,{uintTexture:i,groups:n,lookup:r}=t,{ids:s,floatTextureOffset:o,floatTextureSize:a}=n.get(e),l=i.image.data;n.delete(e);for(const e of n.values())e.floatTextureOffset>=o+a&&(e.floatTextureOffset-=a);for(const e of s){const{index:i,bundled:n}=r.get(e);(n?t.freeBundledIndices:t.freeIndices).push(i),r.delete(e)}const c=new Xj(t.floatTexture,o,a);t.floatTexture.dispose(),t.floatTexture=c;for(let e=0,t=i.size;e<t;e++){const t=4*e;l[t]>=o+a&&(l[t]-=a),l[t+2]>=o+a&&(l[t+2]-=a)}i.needsUpdate=!0,c.needsUpdate=!0}getIndex(e){return this.lookup.get(e).index}dispose(){this.uintTexture.dispose(),this.floatTexture.dispose()}}class Yj{constructor(e){const t=this;t.texture=new Xj(0,"ubyte4",e.chunkSize),t.groups=new Map,t.groupCount=0,t.freeIndices=[],t.lookup=new Map}addGroup(e){const t=this,{freeIndices:i,lookup:n}=t,r=[],s=[],o=t.texture.size/4;let a=0;for(const{id:t,color:l}of e){let e;i.length>0?e=i.pop():(e=o+a,a+=1),r.push(t),n.set(t,{index:e}),s.push({index:e,color:l})}t.groups.set(t.groupCount,{ids:r});const l=new Xj(t.texture,4*a);t.texture.dispose(),t.texture=l;const c=l.image.data;for(const{index:e,color:t}of s){const i=Array.isArray(t)?t:[t];c.set([...K(i[0]),255,...K(i[1]||i[0]),255,...K(i[2]||i[0]),255,...K(i[3]||"#00ff00"),255],16*e)}return l.needsUpdate=!0,t.groupCount++}removeGroup(e){const{groups:t,freeIndices:i,lookup:n}=this,r=t.get(e).ids;t.delete(e);for(const e of r)i.push(n.get(e).index),n.delete(e)}getIndex(e){return this.lookup.get(e).index}dispose(){this.texture.dispose()}}class Jj{constructor(e,t){const i=this,n=t.chunkSize,r=Math.ceil(e/n),o=i.dtObject=new $j(e,t),a=i.dtRoute=new Zj(t);i.dtColor=new Yj(t),i.modelOrigin=t.modelOrigin,i.loopCount=0;const l=i.uniforms={zoom:{value:0},time:{value:performance.now()},timeOffset:{value:0},opacityGround:{value:.9},opacityUnderground:{value:.225},textureObject0:{value:o.uintTexture},textureObject1:{value:o.floatTexture},textureRoute0:{value:a.uintTexture},textureRoute1:{value:a.floatTexture},textureData0:{value:null},textureData1:{value:null}},c=i.material=new cC({uniforms:l,vertexShader:"void main() {gl_Position=vec4( position,1.0 );}",fragmentShader:"uniform int zoom;uniform int time;uniform int timeOffset;uniform float opacityGround;uniform float opacityUnderground;uniform usampler2D textureRoute0;uniform sampler2D textureRoute1;uniform usampler2D textureObject0;uniform sampler2D textureObject1;uniform sampler2D textureData0;uniform sampler2D textureData1;layout (location=0) out vec4 outPosition0;layout (location=1) out vec4 outPosition1;uvec4 fetchRoute0( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureRoute0,ref,0 );}vec2 fetchRoute1( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureRoute1,ref,0 ).rg;}uvec4 fetchObject0( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureObject0,ref,0 );}vec4 fetchObject1( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureObject1,ref,0 );}vec4 fetchData0( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureData0,ref,0 );}vec4 fetchData1( uint index ) {ivec2 ref=ivec2( int( index % chunkSize ),int( index/chunkSize ) );return texelFetch( textureData1,ref,0 );}/***Returns the index of the node at the distance*@param distance-the distance*@param offset-the offset in the route texture*@param length-the length of nodes*@returns the index of the node at the distance*/uint indexOfNodeAt( float distance,uint offset,uint length ) {uint start=0u;uint end=length-1u;uint center;bool finished;bool firstHalf;for ( int i=0; i < loopCount; i++) {finished=start==end-1u;center=( start+end )/2u;firstHalf=distance < fetchRoute1( offset+center*3u ).r;start=finished || firstHalf ? start : center;end=finished || ! firstHalf ? end : center;}return offset+start*3u;}void main() {uint instanceID=uint( gl_FragCoord.y )*chunkSize+uint( gl_FragCoord.x );uint index=instanceID*2u;uvec4 object0=fetchObject0( index );uvec4 object1=fetchObject0( index+1u );vec4 object2=fetchObject1( index );vec4 object3=fetchObject1( index+1u );uint objectType=object0.x;uint routeID=object0.y;uint colorID=object0.z;int startTime=int( object0.w );int endTime=int( object1.x );int fadeAnimationStartTime=int( object1.y );uint fadeAnimationType=object1.z;float sectionIndex=object2.x;float nextSectionIndex=object2.y;float accelerationTime=object2.z;float acceleration=object2.w;float decelerationTime=object3.x;float deceleration=object3.y;vec4 data0=fetchData0( instanceID );vec4 data1=fetchData1( instanceID );vec3 prevPosition=data0.xyz;float prevRotateZ=data1.x;float prevRotateX=data1.y;int opacityAnimationStartTime=int( data1.z );uint routeSubID=objectType==0u ? uint( zoom-13 ) : 0u;uvec4 header=fetchRoute0( routeID+routeSubID );uint offset=header.z;vec2 distances=objectType==2u ? vec2( 0.0 ) : fetchRoute1( offset+uint( sectionIndex )/2u );float sectionDistance=objectType==2u ? sectionIndex : uint( sectionIndex ) % 2u==0u ? distances.r : distances.g;distances=objectType==2u ? vec2( 0.0 ) : fetchRoute1( offset+uint( nextSectionIndex )/2u );float nextSectionDistance=objectType==2u ? nextSectionIndex : uint( nextSectionIndex ) % 2u==0u ? distances.r : distances.g;float elapsed=float( clamp( timeOffset-startTime,0,endTime-startTime ) );float left=float( clamp( endTime-timeOffset,0,endTime-startTime ) );float a=elapsed < accelerationTime ? acceleration/2.0*elapsed*elapsed :\nleft < decelerationTime ? 1.0-deceleration/2.0*left*left :\nmax( acceleration*accelerationTime,deceleration*decelerationTime)*( elapsed-accelerationTime/2.0 );float distance=mix( sectionDistance,nextSectionDistance,a );index=indexOfNodeAt( distance,header.x,header.y );vec2 section0=fetchRoute1( index );vec2 section1=fetchRoute1(++index );vec2 section2=fetchRoute1(++index );vec2 section3=fetchRoute1(++index );vec2 section4=fetchRoute1(++index );float baseDistance=section0.r;vec3 currentPosition=vec3( section0.g,section1.r,section1.g );float rotateZ=section2.r;float rotateX=section2.g;float nextDistance=section3.r;vec3 nextPosition=vec3( section3.g,section4.r,section4.g );a=nextDistance !=baseDistance ? ( distance-baseDistance )/( nextDistance-baseDistance ) : 0.0;vec3 position=mix( currentPosition,nextPosition,a );bool prevGround=prevPosition.z >=0.0;bool ground=position.z >=0.0;opacityAnimationStartTime=time >=fadeAnimationStartTime+fadeDuration && ( ( prevGround && ! ground ) || ( ! prevGround && ground ) ) ? time : opacityAnimationStartTime;a=clamp( float( time-opacityAnimationStartTime )/float( fadeDuration ),0.0,1.0 );float opacity0=mix( ground ? opacityUnderground : opacityGround,ground ? opacityGround : opacityUnderground,a );a=clamp( float( time-fadeAnimationStartTime )/float( fadeDuration ),0.0,1.0 );bool fadingIn=fadeAnimationType==1u;bool fadingOut=fadeAnimationType==2u;float opacity1=mix( fadingOut ? 1.0 : 0.0,fadingIn ? 1.0 : 0.0,a );float opacity=opacity0*opacity1;position=fadingOut ? prevPosition : position;rotateZ=fadingOut ? prevRotateZ : rotateZ;rotateX=fadingOut ? prevRotateX : rotateX;outPosition0=vec4( position,float( colorID ) );outPosition1=vec4( rotateZ,rotateX,opacityAnimationStartTime,opacity );}",defines:{chunkSize:`${n}u`,loopCount:i.loopCount,fadeDuration:s.fadeDuration},glslVersion:Iw});i.quad=new Wj(c),i.dataVariable=[];for(let e=0;e<2;e++)i.dataVariable[e]=new ET(n,r,{wrapS:Wx,wrapT:Wx,minFilter:Xx,magFilter:Xx,format:fb,type:sb,depthBuffer:!1,count:2});i.marked=-1,i.tracked=-1,i.currentTextureIndex=0,i.buffer=new Float32Array(n*r*4)}compute(e,t){const i=this,{dataVariable:n,currentTextureIndex:r}=i,s=i.currentTextureIndex=0===r?1:0,o=n[r],a=n[s],l=i.uniforms,c=e.renderer;l.zoom.value=t,l.time.value=performance.now(),l.textureData0.value=o.textures[0],l.textureData1.value=o.textures[1];const u=c.getRenderTarget(),h=c.xr.enabled,d=c.shadowMap.autoUpdate;return c.resetState(),c.xr.enabled=!1,c.shadowMap.autoUpdate=!1,c.setRenderTarget(a),i.quad.render(c),c.xr.enabled=h,c.shadowMap.autoUpdate=d,c.setRenderTarget(u),c.resetState(),[...a.textures,i.dtColor.texture]}addRouteGroup(e){const{dtRoute:t,uniforms:i,material:n}=this,r=t.addGroup(e);return i.textureRoute0.value=t.uintTexture,i.textureRoute1.value=t.floatTexture,n.defines.loopCount=this.loopCount=t.loopCount,n.needsUpdate=!0,r}removeRouteGroup(e){const t=this.dtRoute;t.removeGroup(e),this.uniforms.textureRoute1.value=t.floatTexture}getRouteIndex(e){return this.dtRoute.getIndex(e)}addColorGroup(e){return this.dtColor.addGroup(e)}removeColorGroup(e){this.dtColor.removeGroup(e)}getColorIndex(e){return this.dtColor.getIndex(e)}addInstance(e,t,i,n,r,s){return this.dtObject.add(e,t,i,n,r,s)}updateInstance(e,t,i,n,r,s,o,a,l){this.dtObject.update(e,t,i,n,r,s,o,a,l)}removeInstance(e){return this.dtObject.remove(e)}setMarked(e){this.dtObject.setMarked(e)}setTracked(e){this.dtObject.setTracked(e)}getInstanceIDs(e){const t=this,i=t.dataVariable[t.currentTextureIndex],n=t.buffer;return e.renderer.readRenderTargetPixels(i,0,0,i.width,i.height,n),t.dtObject.getIDs(n)}getInstancePosition(e){const t=this,i=t.uniforms,n=i.timeOffset.value,r=t.dtObject.uintTexture.image.data,s=t.dtObject.floatTexture.image.data,o=r[8*e],a=r[8*e+3],l=r[8*e+4],c=s[8*e],u=s[8*e+1],h=s[8*e+2],d=s[8*e+3],p=s[8*e+4],f=s[8*e+5],m=r[8*e+1]+(0===o?i.zoom.value-13:0),g=t.dtRoute.uintTexture.image.data,_=t.dtRoute.floatTexture.image.data,y=g[4*m+2],v=2===o?c:_[2*y+c],x=2===o?u:_[2*y+u],b=G(n-a,0,l-a),w=G(l-n,0,l-a);let T;T=b<h?d/2*b*b:w<p?1-f/2*w*w:Math.max(d*h,f*p)*(b-h/2);const S=j(v,x,T),E=g[4*m];let A,M=0,I=g[4*m+1]-1;for(let e=0;e<t.loopCount&&M!==I-1;e++)A=Math.floor((M+I)/2),S<_[2*(E+3*A)]?I=A:M=A;const C=E+3*M,P=_[2*C],L=_[2*C+2],R=_[2*C+3],O=_[2*C+4],D=_[2*C+6],B=_[2*C+8],F=_[2*C+9],N=D!==P?(S-P)/(D-P):0,k=j(_[2*C+1],_[2*C+7],N),z=j(L,B,N),U=j(R,F,N),V=t.modelOrigin,H=new ae.MercatorCoordinate(V.x+k,V.y-z,V.z+U),W=tT.radToDeg(-O);return{coord:H.toLngLat(),altitude:H.toAltitude(),bearing:W+(c<u?0:180),_t:T}}setOpacity(e){const t=this.uniforms;t.opacityGround.value=e.ground,t.opacityUnderground.value=e.underground}getOpacity(){const e=this.uniforms;return{ground:e.opacityGround.value,underground:e.opacityUnderground.value}}setTimeOffset(e){this.uniforms.timeOffset.value=e}dispose(){const e=this;e.dtObject.dispose(),e.dtRoute.dispose(),e.dtColor.dispose(),e.quad.dispose(),e.material.dispose();for(let t=0;t<2;t++)e.dataVariable[t].dispose()}}function Kj(e){let t,i,n,r=-1,s=0;for(let o=0;o<e.length;++o){const a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return null;if(void 0===i&&(i=a.itemSize),i!==a.itemSize)return null;if(void 0===n&&(n=a.normalized),n!==a.normalized)return null;if(-1===r&&(r=a.gpuType),r!==a.gpuType)return null;s+=a.count*i}const o=new t(s),a=new YS(o,i,n);let l=0;for(let t=0;t<e.length;++t){const n=e[t];if(n.isInterleavedBufferAttribute){const e=l/i;for(let t=0,r=n.count;t<r;t++)for(let r=0;r<i;r++){const i=n.getComponent(t,r);a.setComponent(t+e,r,i)}}else o.set(n.array,l);l+=n.count*i}return void 0!==r&&(a.gpuType=r),a}function Qj(e,t){if(0===t)return e;if(2===t||1===t){let i=e.getIndex();if(null===i){const t=[],n=e.getAttribute("position");if(void 0===n)return e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const n=i.count-2,r=[];if(2===t)for(let e=1;e<=n;e++)r.push(i.getX(0)),r.push(i.getX(e)),r.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(r.push(i.getX(e)),r.push(i.getX(e+1)),r.push(i.getX(e+2))):(r.push(i.getX(e+2)),r.push(i.getX(e+1)),r.push(i.getX(e)));const s=e.clone();return s.setIndex(r),s.clearGroups(),s}return e}const eG=new Float32Array([].concat(...[0,1,2].map(e=>Array(24).fill(e))));class tG extends hE{constructor(e=1,t=1,i=1,n=.1){super();const r=[new LM(e,t,i),new LM(t,e,n),new LM(n,e,i)],s=function(e,t=!1){const i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),s={},o={},a=e[0].morphTargetsRelative,l=new hE;let c=0;for(let u=0;u<e.length;++u){const h=e[u];let d=0;if(i!==(null!==h.index))return null;for(const e in h.attributes){if(!n.has(e))return null;void 0===s[e]&&(s[e]=[]),s[e].push(h.attributes[e]),d++}if(d!==n.size)return null;if(a!==h.morphTargetsRelative)return null;for(const e in h.morphAttributes){if(!r.has(e))return null;void 0===o[e]&&(o[e]=[]),o[e].push(h.morphAttributes[e])}if(t){let e;if(i)e=h.index.count;else{if(void 0===h.attributes.position)return null;e=h.attributes.position.count}l.addGroup(c,e,u),c+=e}}if(i){let t=0;const i=[];for(let n=0;n<e.length;++n){const r=e[n].index;for(let e=0;e<r.count;++e)i.push(r.getX(e)+t);t+=e[n].attributes.position.count}l.setIndex(i)}for(const e in s){const t=Kj(s[e]);if(!t)return null;l.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let i=0;i<t;++i){const t=[];for(let n=0;n<o[e].length;++n)t.push(o[e][n][i]);const n=Kj(t);if(!n)return null;l.morphAttributes[e].push(n)}}return l}(r);this.copy(s),this.setAttribute("groupIndex",new YS(eG,1)),r.forEach(e=>e.dispose()),s.dispose()}}class iG extends hE{constructor(e=1,t=1,i=1){super();const n=this,r=[],s=[],o=[],a=[],l=[];let c=0;function u(e,t,i,n,u,h,d,p,f,m,g){const _=h/f,y=d/m,v=h/2,x=d/2,b=p/2,w=new rT;let T=0;for(let h=0;h<m;h++)for(let d=0;d<f;d++){for(let r=0;r<4;r++){const c=d+Math.floor(r/2),S=h+Math.floor((r+1)/2)%2;w[e]=(c*_-v)*n,w[t]=(S*y-x)*u,w[i]=b,s.push(w.x,w.y,w.z),w[e]=0,w[t]=0,w[i]=p>0?1:-1,o.push(w.x,w.y,w.z),a.push(c/f,1-S/m),l.push(g[T])}r.push(c,c+1,c+3),r.push(c+1,c+2,c+3),T+=1,c+=4}}u("z","y","x",-1,-1,i,t,e,3,1,[0,1,2]),u("z","y","x",1,-1,i,t,-e,3,1,[2,1,0]),u("x","z","y",1,1,e,i,t,1,3,[5,4,3]),u("x","z","y",1,-1,e,i,-t,1,3,[3,4,5]),u("x","y","z",1,-1,e,t,i,1,1,[0]),u("x","y","z",-1,-1,e,t,-i,1,1,[3]),n.setIndex(r),n.setAttribute("position",new YS(new Float32Array(s),3)),n.setAttribute("normal",new YS(new Float32Array(o),3)),n.setAttribute("uv",new YS(new Float32Array(a),2)),n.setAttribute("groupIndex",new YS(new Float32Array(l),1))}}class nG extends SP{constructor(e,t){super();const i=this,n=new vA(new Int32Array(t),1).setUsage(35048);i.instanceCount=0;for(const t of Object.keys(e.attributes))i.attributes[t]=e.attributes[t].clone();i.index=e.index.clone(),i.setAttribute("instanceID",n)}setInstanceIDs(e){const t=this.getAttribute("instanceID"),i=e.length;t.array.set(e),t.addUpdateRange(0,i),t.needsUpdate=!0,this.instanceCount=i}}class rG{constructor(e,t,i){const n=this,r="CAR"===e?new iG(.88,1.76,.88):"AIRCRAFT"===e?new tG(.88,2.64,.88,.1):new LM(.6,1.2,.6),s="CAR"===e?new LM(.88,1.76,.88):void 0,o=n.uniforms={zoom:{value:i.zoom},cameraZ:{value:i.cameraZ},modelScale:{value:i.modelScale},textureData0:{value:null},textureData1:{value:null},textureColor:{value:null}},a=n.geometry=new nG(r,t),l=n.material=new gC({transparent:!0});l.onBeforeCompile=t=>{Object.assign(t.uniforms,o),t.vertexShader=t.vertexShader.replace("#include <common>","#include <common>\nuniform float zoom;uniform float cameraZ;uniform float modelScale;uniform sampler2D textureData0;uniform sampler2D textureData1;uniform sampler2D textureColor;attribute int instanceID;\n#ifndef BUS\nattribute float groupIndex;\n#endif\nfloat getScale( float zoom,float modelScale) {return pow( 2.0,14.0-clamp( zoom,13.0,19.0 ) )*modelScale*100.0;}\n#ifndef BUS\nmat3 rotateX( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\n1.0,0.0,0.0,0.0,c,s,0.0,-s,c\n);}\n#endif\nmat3 rotateZ( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\nc,s,0.0,-s,c,0.0,0.0,0.0,1.0\n);}vec3 decodeSRGB( vec3 color ) {return mix( color/12.92,pow( ( color+0.055 )/1.055,vec3( 2.4 ) ),step( 0.04045,color ) );}varying vec3 vInstanceColor;varying float vInstanceOpacity;").replace("#include <color_vertex>","#include <color_vertex>\nint width=textureSize( textureData0,0 ).x;ivec2 reference=ivec2( instanceID % width,instanceID/width );vec4 data0=texelFetch( textureData0,reference,0 );vec4 data1=texelFetch( textureData1,reference,0 );vec3 translation=data0.xyz;int colorID=int( data0.w );float rotationX=data1.y;float rotationZ=data1.x;float opacity0=data1.w;width=textureSize( textureColor,0 ).x;reference=ivec2( colorID*4 % width,colorID*4/width );vec3 color0=texelFetch( textureColor,reference,0 ).rgb;reference=ivec2( ( colorID*4+1 ) % width,( colorID*4+1 )/width );vec3 color1=texelFetch( textureColor,reference,0 ).rgb;reference=ivec2( ( colorID*4+2 ) % width,( colorID*4+2 )/width );vec3 color2=texelFetch( textureColor,reference,0 ).rgb;reference=ivec2( ( colorID*4+3 ) % width,( colorID*4+3 )/width );vec3 color3=texelFetch( textureColor,reference,0 ).rgb;\n#ifdef CAR\nfloat mod3=mod( groupIndex,3.0 );vec3 null=vec3( 0.0,1.0,0.0 );vInstanceColor=groupIndex >=3.0 && color3 !=null ? color3 : mod3==0.0 ? color0 : mod3==1.0 ? color1 : color2;\n#endif\n#ifdef AIRCRAFT\nvInstanceColor=groupIndex < 2.0 ? color0 : color1;\n#endif\n#ifdef BUS\nvInstanceColor=color0;\n#endif\nvInstanceColor=decodeSRGB( vInstanceColor );vInstanceOpacity=opacity0;").replace("#include <beginnormal_vertex>","#ifdef BUS\nvec3 objectNormal=rotateZ( rotationZ )*vec3( normal );\n#else\nvec3 objectNormal=rotateZ( rotationZ )*rotateX( rotationX )*vec3( normal );\n#endif").replace("#include <begin_vertex>","float zoom0=zoom+log2( cameraZ/abs( cameraZ-translation.z ) );float scale0=getScale( zoom0,modelScale );\n#ifdef AIRCRAFT\nfloat scale=0.06/0.285*modelScale*100.0;float offsetY=groupIndex==2.0 ? 0.44-1.32*max( scale/scale0,1.0 ) : 0.0;float offsetZ=groupIndex==2.0 ? 0.88 : 0.0;float scaleX=groupIndex==1.0 ? max( scale0,scale ) : scale0;float scaleY=groupIndex==0.0 ? max( scale0,scale ) : scale0;vec3 position0=( position+vec3( 0.0,offsetY,offsetZ ) )*vec3( scaleX,scaleY,scale0 );\n#else\nvec3 position0=position*scale0;\n#endif\nposition0=position0*( 1.0+float( instanceID % 256 )/256.0*0.03 );\n#ifdef BUS\nvec3 transformed=rotateZ( rotationZ )*position0+translation+vec3( 0.0,0.0,0.3*scale0 );\n#else\nvec3 transformed=rotateZ( rotationZ )*rotateX( rotationX )*position0+translation+vec3( 0.0,0.0,0.44*scale0 );\n#endif"),t.fragmentShader=t.fragmentShader.replace("#include <common>","#include <common>\nvarying vec3 vInstanceColor;varying float vInstanceOpacity;").replace("vec4 diffuseColor = vec4( diffuse, opacity );","vec4 diffuseColor=vec4( diffuse*vInstanceColor,opacity*vInstanceOpacity );"),t.defines={[e]:!0}},l.customProgramCacheKey=()=>e;const c=n.mesh=new iA(a,l);c.updateMatrix(),c.matrixAutoUpdate=!1,c.frustumCulled=!1;const u=n.pickingMaterial=new cC({uniforms:o,vertexShader:"uniform float zoom;uniform float cameraZ;uniform float modelScale;uniform sampler2D textureData0;uniform sampler2D textureData1;attribute int instanceID;\n#ifdef AIRCRAFT\nattribute float groupIndex;\n#endif\nfloat getScale( float zoom,float modelScale) {return pow( 2.0,14.0-clamp( zoom,13.0,19.0 ) )*modelScale*100.0;}\n#ifndef BUS\nmat3 rotateX( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\n1.0,0.0,0.0,0.0,c,s,0.0,-s,c\n);}\n#endif\nmat3 rotateZ( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\nc,s,0.0,-s,c,0.0,0.0,0.0,1.0\n);}varying vec3 vIdColor;void main() {int width=textureSize( textureData0,0 ).x;ivec2 reference=ivec2( instanceID % width,instanceID/width );vec4 data0=texelFetch( textureData0,reference,0 );vec4 data1=texelFetch( textureData1,reference,0 );vec3 translation=data0.xyz;float rotationX=data1.y;float rotationZ=data1.x;float opacity0=data1.w;vec3 idColor=vec3( ivec3( instanceID/65536 % 256,instanceID/256 % 256,instanceID % 256 ) )/256.0+0.5/256.0;float zoom0=zoom+log2( cameraZ/abs( cameraZ-translation.z ) );float scale0=getScale( zoom0,modelScale );\n#ifdef AIRCRAFT\nfloat scale=0.06/0.285*modelScale*100.0;float offsetY=groupIndex==2.0 ? 0.44-1.32*max( scale/scale0,1.0 ) : 0.0;float offsetZ=groupIndex==2.0 ? 0.88 : 0.0;float scaleX=groupIndex==1.0 ? max( scale0,scale ) : scale0;float scaleY=groupIndex==0.0 ? max( scale0,scale ) : scale0;vec3 position0=( position+vec3( 0.0,offsetY,offsetZ ) )*vec3( scaleX,scaleY,scale0 );\n#else\nvec3 position0=position*scale0;\n#endif\nposition0=position0*( 1.0+float( instanceID % 256 )/256.0*0.03 );\n#ifdef BUS\nvec3 transformed=rotateZ( rotationZ )*position0+translation+vec3( 0.0,0.0,0.3*scale0 );\n#else\nvec3 transformed=rotateZ( rotationZ )*rotateX( rotationX )*position0+translation+vec3( 0.0,0.0,0.44*scale0 );\n#endif\ngl_Position=projectionMatrix*modelViewMatrix*vec4( transformed,1.0 );vIdColor=idColor;}",fragmentShader:"varying vec3 vIdColor;void main() {gl_FragColor=vec4( vIdColor,1.0 );}",defines:{[e]:!0}}),h=n.pickingMesh=new iA(a,u);h.updateMatrix(),h.matrixAutoUpdate=!1,h.frustumCulled=!1;const d=n.outlineGeometry=new nG(s||r,2),p=n.outlineMaterial=new cC({uniforms:Object.assign({},o,{marked:{value:-1},tracked:{value:-1},intensity:{value:0}}),vertexShader:"uniform float zoom;uniform float cameraZ;uniform float modelScale;uniform sampler2D textureData0;uniform sampler2D textureData1;uniform int marked;uniform int tracked;uniform float intensity;attribute int instanceID;\n#ifdef AIRCRAFT\nattribute float groupIndex;\n#endif\nfloat getScale( float zoom,float modelScale) {return pow( 2.0,14.0-clamp( zoom,13.0,19.0 ) )*modelScale*100.0;}\n#ifndef BUS\nmat3 rotateX( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\n1.0,0.0,0.0,0.0,c,s,0.0,-s,c\n);}\n#endif\nmat3 rotateZ( float angle ) {float s=sin( angle );float c=cos( angle );return mat3(\nc,s,0.0,-s,c,0.0,0.0,0.0,1.0\n);}varying float vInstanceOpacity;void main() {int width=textureSize( textureData0,0 ).x;ivec2 reference=ivec2( instanceID % width,instanceID/width );vec4 data0=texelFetch( textureData0,reference,0 );vec4 data1=texelFetch( textureData1,reference,0 );vec3 translation=data0.xyz;float rotationX=data1.y;float rotationZ=data1.x;float outline=instanceID==marked ? 1.0 : instanceID==tracked ? intensity : 0.0;float zoom0=zoom+log2( cameraZ/abs( cameraZ-translation.z ) );float scale0=getScale( zoom0,modelScale );\n#ifdef AIRCRAFT\nfloat scale=0.06/0.285*modelScale*100.0;float offsetY=groupIndex==2.0 ? 0.44-1.32*max( scale/scale0,1.0 ) : 0.0;float offsetZ=groupIndex==2.0 ? 0.88 : 0.0;float scaleX=groupIndex==1.0 ? max( scale0,scale ) : scale0;float scaleY=groupIndex==0.0 ? max( scale0,scale ) : scale0;vec3 position0=( position+vec3( 0.0,offsetY,offsetZ ) )*vec3( scaleX,scaleY,scale0 );\n#else\nvec3 position0=position*scale0;\n#endif\nposition0=position0*( 1.0+float( instanceID % 256 )/256.0*0.03 );position0=position0+0.1*scale0*sign( position );\n#ifdef BUS\nvec3 transformed=rotateZ( rotationZ )*position0+translation+vec3( 0.0,0.0,0.3*scale0 );\n#else\nvec3 transformed=rotateZ( rotationZ )*rotateX( rotationX )*position0+translation+vec3( 0.0,0.0,0.44*scale0 );\n#endif\ngl_Position=projectionMatrix*modelViewMatrix*vec4( transformed,1.0 );vInstanceOpacity=outline;}",fragmentShader:"varying float vInstanceOpacity;void main() {gl_FragColor=vec4( 1.0,1.0,1.0,vInstanceOpacity );}",defines:{[e]:!0},transparent:!0,side:1}),f=n.outlineMesh=new iA(d,p);if(f.updateMatrix(),f.matrixAutoUpdate=!1,f.frustumCulled=!1,r.dispose(),s&&s.dispose(),"CAR"===e){const e=new YI(1.8,32,32),i=n.delayMarkerGeometry=new nG(e,t),r=n.delayMarkerMaterial=new cC({uniforms:Object.assign({},o,{base:{value:1}}),vertexShader:"uniform float zoom;uniform float cameraZ;uniform float modelScale;uniform sampler2D textureData0;uniform sampler2D textureData1;attribute int instanceID;float getScale( float zoom,float modelScale) {return pow( 2.0,14.0-clamp( zoom,13.0,19.0 ) )*modelScale*100.0;}varying float vIntensity;void main() {int width=textureSize( textureData0,0 ).x;ivec2 reference=ivec2( instanceID % width,instanceID/width );vec4 data0=texelFetch( textureData0,reference,0 );vec4 data1=texelFetch( textureData1,reference,0 );vec3 translation=data0.xyz;float opacity0=data1.w;float delay=1.0;float zoom0=zoom+log2( cameraZ/abs( cameraZ-translation.z ) );float scale=getScale( zoom0,modelScale );vec3 transformed=position*scale+translation+vec3( 0.0,0.0,0.44*scale );gl_Position=projectionMatrix*modelViewMatrix*vec4( transformed,delay );vec3 vNormal=normalize( normalMatrix*normal );vec3 vNormel=normalize( vec3( modelViewMatrix*vec4( transformed,1.0 ) ) );vIntensity=( 1.0+dot( vNormal,vNormel ) )*opacity0;}",fragmentShader:"uniform float base;varying float vIntensity;void main() {vec3 color=mix( vec3( base ),vec3( 1.0,0.6,0.0 ),vIntensity );gl_FragColor=vec4( color,1.0 );}",blending:4,premultipliedAlpha:!0,depthWrite:!1}),s=n.delayMarkerMesh=new iA(i,r);s.updateMatrix(),s.matrixAutoUpdate=!1,s.frustumCulled=!1,e.dispose()}}getMesh(){return this.mesh}getPickingMesh(){return this.pickingMesh}getOutlineMesh(){return this.outlineMesh}getDelayMarkerMesh(){return this.delayMarkerMesh}refreshCameraParams(e){const t=this.uniforms;t.zoom.value=e.zoom,t.cameraZ.value=e.cameraZ}setTextures(e){const t=this.uniforms;t.textureData0.value=e[0],t.textureData1.value=e[1],t.textureColor.value=e[2],this.outlineMaterial.uniforms.intensity.value=Y()}setInstanceIDs(e){const t=this,i=t.delayMarkerGeometry;t.geometry.setInstanceIDs(e.body),t.outlineGeometry.setInstanceIDs(e.outline),i&&i.setInstanceIDs(e.delayMarker)}setMarkedInstanceID(e){this.outlineMaterial.uniforms.marked.value=e}setTrackedInstanceID(e){this.outlineMaterial.uniforms.tracked.value=e}refreshDelayMarkerMesh(e){const{delayMarkerMaterial:t,delayMarkerMesh:i}=this;t&&(t.uniforms.base.value=e?0:1),i&&(i.material.blending=e?2:4)}dispose(){const e=this,{delayMarkerGeometry:t,delayMarkerMaterial:i}=e;e.geometry.dispose(),e.material.dispose(),e.pickingMaterial.dispose(),e.outlineGeometry.dispose(),e.outlineMaterial.dispose(),t&&t.dispose(),i&&i.dispose()}}class sG{constructor(e){const t=this;t.id=e.id,t.type="three",t.lightColor="white",t.objects=new Map,t.onCameraChanged=t.onCameraChanged.bind(t)}onAdd(e,t){const i=this,n=t.scene,r=e.getModelOrigin(),s=t.renderer.capabilities.maxTextureSize,o={zoom:e.getZoom(),cameraZ:e.map.getFreeCameraOptions().position.z,modelScale:e.getModelScale()};i.map=e,i.context=t,i.computeRenderer=new Jj(7700,{modelOrigin:r,chunkSize:s});const a=i.ugCarMeshSet=new rG("CAR",1e3,o),l=i.ogCarMeshSet=new rG("CAR",2500,o),c=i.aircraftMeshSet=new rG("AIRCRAFT",200,o),u=i.busMeshSet=new rG("BUS",4e3,o);n.add(a.getMesh()),n.add(l.getMesh()),n.add(c.getMesh()),n.add(u.getMesh()),n.add(a.getDelayMarkerMesh()),n.add(l.getDelayMarkerMesh()),n.add(a.getOutlineMesh()),n.add(l.getOutlineMesh()),n.add(c.getOutlineMesh()),n.add(u.getOutlineMesh());const h=i.ugPickingScene=new pS;h.background=new cS(16777215),h.add(a.getPickingMesh());const d=i.ogPickingScene=new pS;d.background=new cS(16777215),d.add(l.getPickingMesh()),d.add(c.getPickingMesh()),d.add(u.getPickingMesh()),i.pickingTexture=new ET(1,1),i.pixelBuffer=new Uint8Array(4),i.animationID=Ie.start({callback:()=>{i.needsUpdateInstances=!0},frameRate:1}),e.on("zoom",i.onCameraChanged),e.on("pitch",i.onCameraChanged)}onRemove(e){const t=this;t.computeRenderer.dispose(),t.ugCarMeshSet.dispose(),t.ogCarMeshSet.dispose(),t.aircraftMeshSet.dispose(),t.busMeshSet.dispose(),t.pickingTexture.dispose(),Ie.stop(t.animationID),e.off("zoom",t.onCameraChanged),e.off("pitch",t.onCameraChanged)}prerender(e,t){const i=this,n=i.computeRenderer.compute(t,e.layerZoom);if(i.ugCarMeshSet.setTextures(n),i.ogCarMeshSet.setTextures(n),i.aircraftMeshSet.setTextures(n),i.busMeshSet.setTextures(n),i.needsUpdateInstances){const[e,n,r,s]=i.computeRenderer.getInstanceIDs(t);i.ugCarMeshSet.setInstanceIDs(e),i.ogCarMeshSet.setInstanceIDs(n),i.aircraftMeshSet.setInstanceIDs(r),i.busMeshSet.setInstanceIDs(s),delete i.needsUpdateInstances}}onCameraChanged(){const e=this,t=e.map,i={zoom:t.getZoom(),cameraZ:t.map.getFreeCameraOptions().position.z};e.ugCarMeshSet.refreshCameraParams(i),e.ogCarMeshSet.refreshCameraParams(i),e.aircraftMeshSet.refreshCameraParams(i),e.busMeshSet.refreshCameraParams(i)}setMode(e,t){const i=this,n=i.computeRenderer.getOpacity();let r,o;"none"!==t&&"edit"!==t?r=o=.1:"underground"===e?(r=.9,o=.225):(r=.225,o=.9),Ie.start({callback:(e,t)=>{i.computeRenderer.setOpacity({ground:j(n.ground,o,e/t),underground:j(n.underground,r,e/t)}),i.refreshDelayMarkers(!0)},duration:s.transitionDuration})}addRouteGroup(e){return this.computeRenderer.addRouteGroup(e)}removeRouteGroup(e){this.computeRenderer.removeRouteGroup(e)}addColorGroup(e){return this.computeRenderer.addColorGroup(e)}removeColorGroup(e){this.computeRenderer.removeColorGroup(e)}addObject(e){const t=this;let i,n,r,s,o,a;if("train"===e.type){const{id:l,r:c,v:u,ad:h}=e;i=0,n=t.computeRenderer.getRouteIndex(c.id),h&&h.color?(e.colorGroupIndex=t.computeRenderer.addColorGroup([{id:l,color:h.color}]),r=t.computeRenderer.getColorIndex(l)):r=t.computeRenderer.getColorIndex(u?u.id:c.id),s=e.sectionIndex,o=s+e.sectionLength,a=e.delay?1:0}else if("flight"===e.type){const{a:a,feature:l}=e;i=1,n=t.computeRenderer.getRouteIndex(l.properties.id),r=t.computeRenderer.getColorIndex(a.id),s=0,o=1}else{const{gtfsId:a,feature:l,offsets:c}=e;i=2,n=t.computeRenderer.getRouteIndex(`${a}.${l.properties.id}`),r=t.computeRenderer.getColorIndex(a),s=c[e.sectionIndex],o=c[e.sectionIndex+e.sectionLength]}const l=e.instanceID=t.computeRenderer.addInstance(i,n,r,s,o,a);t.objects.set(l,e),Object.assign(e,t.getObjectPosition(e)),t.needsUpdateInstances=!0}updateObject(e,t,i,n,r,s,o){const a=this;let l,c;if("train"===e.type)l=e.sectionIndex,c=l+e.sectionLength;else if("flight"===e.type)l=0,c=1;else{const t=e.offsets;l=t[e.sectionIndex],c=t[e.sectionIndex+e.sectionLength]}a.computeRenderer.updateInstance(e.instanceID,l,c,t,i,n,r,s,o),Object.assign(e,a.getObjectPosition(e)),a.needsUpdateInstances=!0}getObjectPosition(e){return this.computeRenderer.getInstancePosition(e.instanceID)}removeObject(e){const t=this,{instanceID:i,colorGroupIndex:n}=e;return void 0!==i?(t.objects.delete(i),delete e.instanceID,t.computeRenderer.removeInstance(i).then(()=>{void 0!==n&&(t.computeRenderer.removeColorGroup(n),delete e.colorGroupIndex),t.needsUpdateInstances=!0})):Promise.resolve()}pickObject(e,t){const i=this,{pickingTexture:n,pixelBuffer:r}=i,{renderer:s,camera:o}=i.context,a=s.getContext(),l=window.devicePixelRatio,c="underground"===e?i.ugPickingScene:i.ogPickingScene;return o.setViewOffset(a.drawingBufferWidth,a.drawingBufferHeight,t.x*l|0,t.y*l|0,1,1),s.resetState(),s.setRenderTarget(n),s.render(c,o),s.setRenderTarget(null),s.resetState(),o.clearViewOffset(),s.readRenderTargetPixels(n,0,0,1,1,r),i.objects.get(r[0]<<16|r[1]<<8|r[2])}refreshDelayMarkers(e){const t=this,i=z_(t.map.map,e);t.ugCarMeshSet.refreshDelayMarkerMesh(i),t.ogCarMeshSet.refreshDelayMarkerMesh(i)}setTimeOffset(e){this.computeRenderer.setTimeOffset(e)}markObject(e){const t=this,i=e?e.instanceID:-1;t.computeRenderer.setMarked(i),t.ugCarMeshSet.setMarkedInstanceID(i),t.ogCarMeshSet.setMarkedInstanceID(i),t.aircraftMeshSet.setMarkedInstanceID(i),t.busMeshSet.setMarkedInstanceID(i),t.needsUpdateInstances=!0}trackObject(e){const t=this,i=e?e.instanceID:-1;t.computeRenderer.setTracked(i),t.ugCarMeshSet.setTrackedInstanceID(i),t.ogCarMeshSet.setTrackedInstanceID(i),t.aircraftMeshSet.setTrackedInstanceID(i),t.busMeshSet.setTrackedInstanceID(i),t.needsUpdateInstances=!0}project(e,t){const{map:i,context:n}=this,{width:r,height:s}=i.map.transform,{x:o,y:a,z:l}=i.getModelPosition(e,t),{x:c,y:u}=new rT(o,a,l).project(n.camera);return new ae.Point((c+1)/2*r,(1-u)/2*s)}}
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */const oG=Symbol("Comlink.proxy"),aG=Symbol("Comlink.endpoint"),lG=Symbol("Comlink.releaseProxy"),cG=Symbol("Comlink.finalizer"),uG=Symbol("Comlink.thrown"),hG=e=>"object"==typeof e&&null!==e||"function"==typeof e,dG=new Map([["proxy",{canHandle:e=>hG(e)&&e[oG],serialize(e){const{port1:t,port2:i}=new MessageChannel;return pG(e,t),[i,[i]]},deserialize:e=>(e.start(),mG(e))}],["throw",{canHandle:e=>hG(e)&&uG in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function pG(e,t=globalThis,i=["*"]){t.addEventListener("message",function n(r){if(!r||!r.data)return;if(!function(e,t){for(const i of e){if(t===i||"*"===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}return!1}(i,r.origin))return void console.warn(`Invalid origin '${r.origin}' for comlink proxy`);const{id:s,type:o,path:a}=Object.assign({path:[]},r.data),l=(r.data.argumentList||[]).map(EG);let c;try{const t=a.slice(0,-1).reduce((e,t)=>e[t],e),i=a.reduce((e,t)=>e[t],e);switch(o){case"GET":c=i;break;case"SET":t[a.slice(-1)[0]]=EG(r.data.value),c=!0;break;case"APPLY":c=i.apply(t,l);break;case"CONSTRUCT":c=TG(new i(...l));break;case"ENDPOINT":{const{port1:t,port2:i}=new MessageChannel;pG(e,i),c=function(e,t){return wG.set(e,t),e}(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[uG]:0}}Promise.resolve(c).catch(e=>({value:e,[uG]:0})).then(i=>{const[r,a]=SG(i);t.postMessage(Object.assign(Object.assign({},r),{id:s}),a),"RELEASE"===o&&(t.removeEventListener("message",n),fG(t),cG in e&&"function"==typeof e[cG]&&e[cG]())}).catch(e=>{const[i,n]=SG({value:new TypeError("Unserializable return value"),[uG]:0});t.postMessage(Object.assign(Object.assign({},i),{id:s}),n)})}),t.start&&t.start()}function fG(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function mG(e,t){const i=new Map;return e.addEventListener("message",function(e){const{data:t}=e;if(!t||!t.id)return;const n=i.get(t.id);if(n)try{n(t)}finally{i.delete(t.id)}}),xG(e,i,[],t)}function gG(e){if(e)throw new Error("Proxy has been released and is not useable")}function _G(e){return AG(e,new Map,{type:"RELEASE"}).then(()=>{fG(e)})}const yG=new WeakMap,vG="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(yG.get(e)||0)-1;yG.set(e,t),0===t&&_G(e)});function xG(e,t,i=[],n=function(){}){let r=!1;const s=new Proxy(n,{get(n,o){if(gG(r),o===lG)return()=>{!function(e){vG&&vG.unregister(e)}(s),_G(e),t.clear(),r=!0};if("then"===o){if(0===i.length)return{then:()=>s};const n=AG(e,t,{type:"GET",path:i.map(e=>e.toString())}).then(EG);return n.then.bind(n)}return xG(e,t,[...i,o])},set(n,s,o){gG(r);const[a,l]=SG(o);return AG(e,t,{type:"SET",path:[...i,s].map(e=>e.toString()),value:a},l).then(EG)},apply(n,s,o){gG(r);const a=i[i.length-1];if(a===aG)return AG(e,t,{type:"ENDPOINT"}).then(EG);if("bind"===a)return xG(e,t,i.slice(0,-1));const[l,c]=bG(o);return AG(e,t,{type:"APPLY",path:i.map(e=>e.toString()),argumentList:l},c).then(EG)},construct(n,s){gG(r);const[o,a]=bG(s);return AG(e,t,{type:"CONSTRUCT",path:i.map(e=>e.toString()),argumentList:o},a).then(EG)}});return function(e,t){const i=(yG.get(t)||0)+1;yG.set(t,i),vG&&vG.register(e,t,e)}(s,e),s}function bG(e){const t=e.map(SG);return[t.map(e=>e[0]),(i=t.map(e=>e[1]),Array.prototype.concat.apply([],i))];var i}const wG=new WeakMap;function TG(e){return Object.assign(e,{[oG]:!0})}function SG(e){for(const[t,i]of dG)if(i.canHandle(e)){const[n,r]=i.serialize(e);return[{type:"HANDLER",name:t,value:n},r]}return[{type:"RAW",value:e},wG.get(e)||[]]}function EG(e){switch(e.type){case"HANDLER":return dG.get(e.name).deserialize(e.value);case"RAW":return e.value}}function AG(e,t,i,n){return new Promise(r=>{const s=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(s,r),e.start&&e.start(),e.postMessage(Object.assign({id:s},i),n)})}let MG,IG,CG,PG,LG;const RG=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection"];function OG(e){PG=2,LG=10**6,CG=null,MG=[],IG=[];const t=e.readFields(DG,{});return MG=null,t}function DG(e,t,i){1===e?MG.push(i.readString()):2===e?PG=i.readVarint():3===e?LG=10**i.readVarint():4===e?function(e,t){t.type="FeatureCollection",t.features=[],e.readMessage(NG,t)}(i,t):5===e?BG(i,t):6===e&&FG(i,t)}function BG(e,t){t.type="Feature";const i=e.readMessage(kG,t);return"geometry"in i||(i.geometry=null),i}function FG(e,t){return t.type="Point",e.readMessage(zG,t)}function NG(e,t,i){1===e?t.features.push(BG(i,{})):13===e?IG.push(UG(i)):15===e&&jG(i,t)}function kG(e,t,i){1===e?t.geometry=FG(i,{}):11===e?t.id=i.readString():12===e?t.id=i.readSVarint():13===e?IG.push(UG(i)):14===e?t.properties=jG(i,{}):15===e&&jG(i,t)}function zG(e,t,i){1===e?t.type=RG[i.readVarint()]:2===e?CG=i.readPackedVarint():3===e?function(e,t,i){"Point"===i?e.coordinates=function(e){const t=e.readVarint()+e.pos,i=[];for(;e.pos<t;)i.push(e.readSVarint()/LG);return i}(t):"MultiPoint"===i||"LineString"===i?e.coordinates=HG(t):"MultiLineString"===i?e.coordinates=WG(t):"Polygon"===i?e.coordinates=WG(t,!0):"MultiPolygon"===i&&(e.coordinates=function(e){const t=e.readVarint()+e.pos;if(!CG)return[[GG(e,t,null,!0)]];const i=[];let n=1;for(let r=0;r<CG[0];r++){const r=[];for(let i=0;i<CG[n];i++)r.push(GG(e,t,CG[n+1+i],!0));n+=CG[n]+1,i.push(r)}return CG=null,i}(t))}(t,i,t.type):4===e?(t.geometries=t.geometries||[],t.geometries.push(FG(i,{}))):13===e?IG.push(UG(i)):15===e&&jG(i,t)}function UG(e){const t=e.readVarint()+e.pos;let i=null;for(;e.pos<t;){const t=e.readVarint()>>3;1===t?i=e.readString():2===t?i=e.readDouble():3===t?i=e.readVarint():4===t?i=-e.readVarint():5===t?i=e.readBoolean():6===t&&(i=JSON.parse(e.readString()))}return i}const VG=new Set(["__proto__","constructor","prototype"]);function jG(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=MG[e.readVarint()],n=IG[e.readVarint()];VG.has(i)||(t[i]=n)}return IG=[],t}function GG(e,t,i,n){let r=0;const s=[],o=new Array(PG).fill(0);for(;i?r<i:e.pos<t;){const t=[];for(let i=0;i<PG;i++)o[i]+=e.readSVarint(),t[i]=o[i]/LG;s.push(t),r++}return n&&s.push(s[0]),s}function HG(e){return GG(e,e.readVarint()+e.pos)}function WG(e,t){const i=e.readVarint()+e.pos;if(!CG)return[GG(e,i,null,t)];const n=[];for(const r of CG)n.push(GG(e,i,r,t));return CG=null,n}var qG,XG,$G={},ZG={};var YG,JG,KG,QG,eH,tH={};var iH,nH,rH,sH,oH,aH={};var lH,cH,uH,hH,dH,pH,fH,mH,gH,_H,yH={exports:{}};function vH(){return lH||(lH=1,function(e,t){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;
/**
		     * @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
		     */
var t=null;try{t=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 i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}function r(e){var t=Math.clz32(e&-e);return e?31-t:t}Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=n;var s={},o={};function a(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=o[e])?n:(i=c(e,0,!0),r&&(o[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=s[e])?n:(i=c(e,e<0?-1:0,!1),r&&(s[e]=i),i)}function l(e,t){if(isNaN(e))return t?x:v;if(t){if(e<0)return x;if(e>=g)return E}else{if(e<=-_)return A;if(e+1>=_)return S}return e<0?l(-e,t).neg():c(e%m|0,e/m|0,t)}function c(e,t,n){return new i(e,t,n)}i.fromInt=a,i.fromNumber=l,i.fromBits=c;var u=Math.pow;function h(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?x:v;if((i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return h(e.substring(1),t,i).neg();for(var r=l(u(i,8)),s=v,o=0;o<e.length;o+=8){var a=Math.min(8,e.length-o),c=parseInt(e.substring(o,o+a),i);if(a<8){var d=l(u(i,a));s=s.mul(d).add(l(c))}else s=(s=s.mul(r)).add(l(c))}return s.unsigned=t,s}function d(e,t){return"number"==typeof e?l(e,t):"string"==typeof e?h(e,t):c(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}i.fromString=h,i.fromValue=d;var p=65536,f=1<<24,m=p*p,g=m*m,_=g/2,y=a(f),v=a(0);i.ZERO=v;var x=a(0,!0);i.UZERO=x;var b=a(1);i.ONE=b;var w=a(1,!0);i.UONE=w;var T=a(-1);i.NEG_ONE=T;var S=c(-1,2147483647,!1);i.MAX_VALUE=S;var E=c(-1,-1,!0);i.MAX_UNSIGNED_VALUE=E;var A=c(0,-2147483648,!1);i.MIN_VALUE=A;var M=i.prototype;M.toInt=function(){return this.unsigned?this.low>>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},M.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(A)){var t=l(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=l(u(e,6),this.unsigned),s=this,o="";;){var a=s.div(r),c=(s.sub(a.mul(r)).toInt()>>>0).toString(e);if((s=a).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},M.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&-1===e&&!(0===this.low&&-2097152===this.high)},M.isZero=function(){return 0===this.high&&0===this.low},M.eqz=M.isZero,M.isNegative=function(){return!this.unsigned&&this.high<0},M.isPositive=function(){return this.unsigned||this.high>=0},M.isOdd=function(){return!(1&~this.low)},M.isEven=function(){return!(1&this.low)},M.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},M.eq=M.equals,M.notEquals=function(e){return!this.eq(e)},M.neq=M.notEquals,M.ne=M.notEquals,M.lessThan=function(e){return this.comp(e)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(e){return this.comp(e)<=0},M.lte=M.lessThanOrEqual,M.le=M.lessThanOrEqual,M.greaterThan=function(e){return this.comp(e)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(e){return this.comp(e)>=0},M.gte=M.greaterThanOrEqual,M.ge=M.greaterThanOrEqual,M.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&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},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(b)},M.neg=M.negate,M.add=function(e){n(e)||(e=d(e));var t=0,i=0,r=0,s=0;return r+=(s+=(65535&this.low)+(65535&e.low))>>>16,i+=(r+=(this.low>>>16)+(e.low>>>16))>>>16,t+=(i+=(65535&this.high)+(65535&e.high))>>>16,t+=(this.high>>>16)+(e.high>>>16),c((r&=65535)<<16|(s&=65535),(t&=65535)<<16|(i&=65535),this.unsigned)},M.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},M.sub=M.subtract,M.multiply=function(e){if(this.isZero())return this;if(n(e)||(e=d(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return this.unsigned?x:v;if(this.eq(A))return e.isOdd()?A:v;if(e.eq(A))return this.isOdd()?A:v;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(y)&&e.lt(y))return l(this.toNumber()*e.toNumber(),this.unsigned);var i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=65535&e.high,a=e.low>>>16,u=65535&e.low,h=0,p=0,f=0,m=0;return f+=(m+=s*u)>>>16,p+=(f+=r*u)>>>16,f&=65535,p+=(f+=s*a)>>>16,h+=(p+=i*u)>>>16,p&=65535,h+=(p+=r*a)>>>16,p&=65535,h+=(p+=s*o)>>>16,h+=(this.high>>>16)*u+i*a+r*o+s*(e.high>>>16),c((f&=65535)<<16|(m&=65535),(h&=65535)<<16|(p&=65535),this.unsigned)},M.mul=M.multiply,M.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error("division by zero");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?x:v;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return x;if(e.gt(this.shru(1)))return w;s=x}else{if(this.eq(A))return e.eq(b)||e.eq(T)?A:e.eq(A)?b:(i=this.shr(1).div(e).shl(1)).eq(v)?e.isNegative()?b:T:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(A))return this.unsigned?x:v;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=v}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),a=o<=48?1:u(2,o-48),h=l(i),p=h.mul(e);p.isNegative()||p.gt(r);)p=(h=l(i-=a,this.unsigned)).mul(e);h.isZero()&&(h=b),s=s.add(h),r=r.sub(p)}return s},M.div=M.divide,M.modulo=function(e){return n(e)||(e=d(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},M.mod=M.modulo,M.rem=M.modulo,M.not=function(){return c(~this.low,~this.high,this.unsigned)},M.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},M.clz=M.countLeadingZeros,M.countTrailingZeros=function(){return this.low?r(this.low):r(this.high)+32},M.ctz=M.countTrailingZeros,M.and=function(e){return n(e)||(e=d(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},M.or=function(e){return n(e)||(e=d(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},M.xor=function(e){return n(e)||(e=d(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},M.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):c(0,this.low<<e-32,this.unsigned)},M.shl=M.shiftLeft,M.shiftRight=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):c(32===e?this.high:this.high>>>e-32,0,this.unsigned)},M.shru=M.shiftRightUnsigned,M.shr_u=M.shiftRightUnsigned,M.rotateLeft=function(e){var t;return n(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?c(this.high,this.low,this.unsigned):e<32?c(this.low<<e|this.high>>>(t=32-e),this.high<<e|this.low>>>t,this.unsigned):c(this.high<<(e-=32)|this.low>>>(t=32-e),this.low<<e|this.high>>>t,this.unsigned)},M.rotl=M.rotateLeft,M.rotateRight=function(e){var t;return n(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?c(this.high,this.low,this.unsigned):e<32?c(this.high<<(t=32-e)|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned):c(this.low<<(t=32-(e-=32))|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)},M.rotr=M.rotateRight,M.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},M.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},M.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},M.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(i.fromBigInt=function(e,t){return c(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},i.fromValue=function(e,t){return"bigint"==typeof e?i.fromBigInt(e,t):d(e,t)},M.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e}),e.default=i}(t),e.exports=function(e){return e.default||e}(t)}(yH,yH.exports)),yH.exports}function xH(){return cH||(cH=1,function(e){var t=e;function i(e){return"__proto__"===e||"prototype"===e||"constructor"===e}function n(e){var t="boolean"==typeof arguments[arguments.length-1],n=t?arguments.length-1:arguments.length;t=t&&arguments[arguments.length-1];for(var r=1;r<n;++r){var s=arguments[r];if(s)for(var o=Object.keys(s),a=0;a<o.length;++a)i(o[a])||t&&Object.prototype.hasOwnProperty.call(e,o[a])&&void 0!==e[o[a]]||(e[o[a]]=s[o[a]])}return e}function r(e){function t(e,i){if(!(this instanceof t))return new t(e,i);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),i&&n(this,i)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=(XG||(XG=1,qG=function(e,t){for(var i=new Array(arguments.length-1),n=0,r=2,s=!0;r<arguments.length;)i[n++]=arguments[r++];return new Promise(function(r,o){i[n]=function(e){if(s)if(s=!1,e)o(e);else{for(var t=new Array(arguments.length-1),i=0;i<t.length;)t[i++]=arguments[i];r.apply(null,t)}};try{e.apply(t||null,i)}catch(e){s&&(s=!1,o(e))}})}),qG),t.base64=(YG||(YG=1,function(e){var t=e;t.length=function(e){var t=e.length;if(!t)return 0;for(;t>0&&"="===e.charAt(t-1);)--t;return Math.floor(3*t/4)};for(var i=new Array(64),n=new Array(123),r=0;r<64;)n[i[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;n[45]=62,n[95]=63,t.encode=function(e,t,n){for(var r,s=null,o=[],a=0,l=0;t<n;){var c=e[t++];switch(l){case 0:o[a++]=i[c>>2],r=(3&c)<<4,l=1;break;case 1:o[a++]=i[r|c>>4],r=(15&c)<<2,l=2;break;case 2:o[a++]=i[r|c>>6],o[a++]=i[63&c],l=0}a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0)}return l&&(o[a++]=i[r],o[a++]=61,1===l&&(o[a++]=61)),s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var s="invalid encoding";t.decode=function(e,t,i){for(var r,o=i,a=0,l=0;l<e.length;){var c=e.charCodeAt(l++);if(61===c&&a>1)break;if(void 0===(c=n[c]))throw Error(s);switch(a){case 0:r=c,a=1;break;case 1:t[i++]=r<<2|(48&c)>>4,r=c,a=2;break;case 2:t[i++]=(15&r)<<4|(60&c)>>2,r=c,a=3;break;case 3:t[i++]=(3&r)<<6|c,a=0}}if(1===a)throw Error(s);return i-o};var o=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/[-_]/,l=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;t.test=function(e){return o.test(e)||a.test(e)&&l.test(e)}}(tH)),tH),t.EventEmitter=function(){if(KG)return JG;function e(){this._listeners=Object.create(null)}return KG=1,JG=e,e.prototype.on=function(e,t,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:i||this}),this},e.prototype.off=function(e,t){if(void 0===e)this._listeners=Object.create(null);else if(void 0===t)this._listeners[e]=[];else{var i=this._listeners[e];if(!i)return this;for(var n=0;n<i.length;)i[n].fn===t?i.splice(n,1):++n}return this},e.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var i=[],n=1;n<arguments.length;)i.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,i)}return this},JG}(),t.float=function(){if(eH)return QG;function e(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),i=new Uint8Array(t.buffer),n=128===i[3];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3]}function s(e,n,r){t[0]=e,n[r]=i[3],n[r+1]=i[2],n[r+2]=i[1],n[r+3]=i[0]}function o(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],t[0]}function a(e,n){return i[3]=e[n],i[2]=e[n+1],i[1]=e[n+2],i[0]=e[n+3],t[0]}e.writeFloatLE=n?r:s,e.writeFloatBE=n?s:r,e.readFloatLE=n?o:a,e.readFloatBE=n?a:o}():function(){function s(e,t,i,n){var r=t<0?1:0;if(r&&(t=-t),0===t)e(1/t>0?0:2147483648,i,n);else if(isNaN(t))e(2143289344,i,n);else if(t>34028234663852886e22)e((r<<31|2139095040)>>>0,i,n);else if(t<11754943508222875e-54)e((r<<31|Math.round(t/1401298464324817e-60))>>>0,i,n);else{var s=Math.floor(Math.log(t)/Math.LN2);e((r<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,i,n)}}function o(e,t,i){var n=e(t,i),r=2*(n>>31)+1,s=n>>>23&255,o=8388607&n;return 255===s?o?NaN:r*(1/0):0===s?1401298464324817e-60*r*o:r*Math.pow(2,s-150)*(o+8388608)}e.writeFloatLE=s.bind(null,t),e.writeFloatBE=s.bind(null,i),e.readFloatLE=o.bind(null,n),e.readFloatBE=o.bind(null,r)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),i=new Uint8Array(t.buffer),n=128===i[7];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3],n[r+4]=i[4],n[r+5]=i[5],n[r+6]=i[6],n[r+7]=i[7]}function s(e,n,r){t[0]=e,n[r]=i[7],n[r+1]=i[6],n[r+2]=i[5],n[r+3]=i[4],n[r+4]=i[3],n[r+5]=i[2],n[r+6]=i[1],n[r+7]=i[0]}function o(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],i[4]=e[n+4],i[5]=e[n+5],i[6]=e[n+6],i[7]=e[n+7],t[0]}function a(e,n){return i[7]=e[n],i[6]=e[n+1],i[5]=e[n+2],i[4]=e[n+3],i[3]=e[n+4],i[2]=e[n+5],i[1]=e[n+6],i[0]=e[n+7],t[0]}e.writeDoubleLE=n?r:s,e.writeDoubleBE=n?s:r,e.readDoubleLE=n?o:a,e.readDoubleBE=n?a:o}():function(){function s(e,t,i,n,r,s){var o=n<0?1:0;if(o&&(n=-n),0===n)e(0,r,s+t),e(1/n>0?0:2147483648,r,s+i);else if(isNaN(n))e(0,r,s+t),e(2146959360,r,s+i);else if(n>17976931348623157e292)e(0,r,s+t),e((o<<31|2146435072)>>>0,r,s+i);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,r,s+t),e((o<<31|a/4294967296)>>>0,r,s+i);else{var l=Math.floor(Math.log(n)/Math.LN2);1024===l&&(l=1023),e(4503599627370496*(a=n*Math.pow(2,-l))>>>0,r,s+t),e((o<<31|l+1023<<20|1048576*a&1048575)>>>0,r,s+i)}}}function o(e,t,i,n,r){var s=e(n,r+t),o=e(n,r+i),a=2*(o>>31)+1,l=o>>>20&2047,c=4294967296*(1048575&o)+s;return 2047===l?c?NaN:a*(1/0):0===l?5e-324*a*c:a*Math.pow(2,l-1075)*(c+4503599627370496)}e.writeDoubleLE=s.bind(null,t,0,4),e.writeDoubleBE=s.bind(null,i,4,0),e.readDoubleLE=o.bind(null,n,0,4),e.readDoubleBE=o.bind(null,r,4,0)}(),e}function t(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}function i(e,t,i){t[i]=e>>>24,t[i+1]=e>>>16&255,t[i+2]=e>>>8&255,t[i+3]=255&e}function n(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function r(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}return eH=1,QG=e(e)}(),t.utf8=(iH||(iH=1,function(e){var t,i=e,n=new TextDecoder("utf-8",{ignoreBOM:!0});try{t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch(e){t=n}function r(e,t,i,n){for(var r=t;r<i;){var s=e[r++];if(s<=127)n+=String.fromCharCode(s);else if(s>=192&&s<224){var o=(31&s)<<6|63&e[r++];n+=o>=128?String.fromCharCode(o):"�"}else if(s>=224&&s<240){var a=(15&s)<<12|(63&e[r++])<<6|63&e[r++];n+=a>=2048?String.fromCharCode(a):"�"}else if(s>=240){var l=(7&s)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++];l<65536||l>1114111?n+="�":(l-=65536,n+=String.fromCharCode(55296+(l>>10)),n+=String.fromCharCode(56320+(1023&l)))}}return n}function s(e,t,i,n){var r=0===i&&n===t.length?t:t.subarray(i,n);return e.decode(r)}i.length=function(e){for(var t=0,i=0,n=0;n<e.length;++n)(i=e.charCodeAt(n))<128?t+=1:i<2048?t+=2:55296==(64512&i)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},i.read=function(e,t,i){if(i-t<1)return"";if(i-t>=64)return s(n,e,t,i);for(var o,a,l,c,u,h,d,p,f="",m=t;m+7<i;m+=8){if(128&((o=e[m])|(a=e[m+1])|(l=e[m+2])|(c=e[m+3])|(u=e[m+4])|(h=e[m+5])|(d=e[m+6])|(p=e[m+7])))return r(e,m,i,f);f+=String.fromCharCode(o,a,l,c,u,h,d,p)}for(;m<i;++m){if(128&(o=e[m]))return r(e,m,i,f);f+=String.fromCharCode(o)}return f},i.readStrict=function(e,i,n){if(n-i<1)return"";if(n-i>=64)return s(t,e,i,n);for(var r,o,a,l,c,u,h,d,p="",f=i;f+7<n;f+=8){if(128&((r=e[f])|(o=e[f+1])|(a=e[f+2])|(l=e[f+3])|(c=e[f+4])|(u=e[f+5])|(h=e[f+6])|(d=e[f+7])))return p+s(t,e,f,n);p+=String.fromCharCode(r,o,a,l,c,u,h,d)}for(;f<n;++f){if(128&(r=e[f]))return p+s(t,e,f,n);p+=String.fromCharCode(r)}return p},i.write=function(e,t,i){for(var n,r,s=i,o=0;o<e.length;++o)(n=e.charCodeAt(o))<128?t[i++]=n:n<2048?(t[i++]=n>>6|192,t[i++]=63&n|128):55296==(64512&n)&&56320==(64512&(r=e.charCodeAt(o+1)))?(++o,t[i++]=(n=65536+((1023&n)<<10)+(1023&r))>>18|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128,t[i++]=63&n|128):(t[i++]=n>>12|224,t[i++]=n>>6&63|128,t[i++]=63&n|128);return i-s}}(aH)),aH),t.pool=rH?nH:(rH=1,nH=function(e,t,i){var n=i||8192,r=n>>>1,s=null,o=n;return function(i){if(i<1||i>r)return e(i);o+i>n&&(s=e(n),o=0);var a=t.call(s,o,o+=i);return 7&o&&(o=1+(7|o)),a}}),t.LongBits=function(){if(oH)return sH;var e;function t(e,t){this.lo=e>>>0,this.hi=t>>>0}oH=1,sH=t;var i=t.zero=new t(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return i;var n=e<0;n&&(e=-e);var r=e>>>0,s=(e-r)/4294967296>>>0;return n&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new t(r,s)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if("string"==typeof n||n instanceof String){if(!e)return t.fromNumber(parseInt(n,10));n=e.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):i},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,i=~this.hi>>>0;return t||(i=i+1>>>0),-(t+4294967296*i)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e?new e(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var r=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?i:new t((r.call(e,0)|r.call(e,1)<<8|r.call(e,2)<<16|r.call(e,3)<<24)>>>0,(r.call(e,4)|r.call(e,5)<<8|r.call(e,6)<<16|r.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0===i?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10},t._configure=function(t){e=t},sH}(),t.isUnsafeProperty=i,t.isNode=Boolean(void 0!==ie&&ie&&ie.process&&ie.process.versions&&ie.process.versions.node),t.global=t.isNode&&ie||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||"undefined"!=typeof globalThis&&globalThis||ZG,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var i=e[t];return!(null==i||!Object.hasOwnProperty.call(e,t))&&("object"!=typeof i||(Array.isArray(i)?i.length:Object.keys(i).length)>0)},t.Buffer=function(){try{var e=t.global.Buffer;return e.prototype.utf8Write||t.isNode?e:null}catch(e){return null}}(),t.newBuffer=function(e){var i=t.Buffer;return"number"==typeof e?i?i.allocUnsafe(e):new Uint8Array(e):i?i.from(e):new Uint8Array(e)},t.rawField=function(e,i,n){var r=[],s=e<<3|i;for(s>>>=0;s>127;)r.push(127&s|128),s>>>=7;r.push(s);for(var o=0;o<n.length;++o)r.push(n[o]);return t.newBuffer(r)},t.Array=Uint8Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||function(){try{var e=vH();return e&&e.isLong?e:null}catch(e){return null}}(),t.key2Re=/^(?:true|false|0|1)$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,i){var n=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(n.lo,n.hi,i):n.toNumber(Boolean(i))},t.longFromKey=function(e,i){return t.key64Re.test(e)&&!t.key32Re.test(e)?t.longFromHash(e,i):e},t.boolFromKey=function(e){return"true"===e||"1"===e},t.merge=n,t.nestingLimit=32,t.recursionLimit=100,t.makeProp=function(e,t,i){Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:void 0===i||i,configurable:!0,writable:!0})},t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(e){for(var t={},i=0;i<e.length;++i)t[e[i]]=1;return function(){for(var e=Object.keys(this),i=e.length-1;i>-1;--i)if(1===t[e[i]]&&null!=this[e[i]])return e[i]}},t.oneOfSetter=function(e){return function(t){for(var i=0;i<e.length;++i)e[i]!==t&&delete this[e[i]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0}}(ZG)),ZG}function bH(){if(hH)return uH;hH=1,uH=s;var e,t=xH(),i=t.LongBits,n=t.base64,r=t.utf8;function s(){this.pos=0,this.buf=this.constructor.alloc(64),this.view=null,this.states=null}Object.defineProperty(s.prototype,"len",{configurable:!0,enumerable:!0,get:function(){return this.pos}});var o=function(){return t.Buffer?function(){return(s.create=function(){return new e})()}:function(){return new s}};function a(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function l(e,t,i){for(;e>127;)t[i++]=127&e|128,e>>>=7;return t[i]=e,i+1}function c(e,t,i){for(var n=e.lo,r=e.hi;r;)t[i++]=127&n|128,n=(n>>>7|r<<25)>>>0,r>>>=7;for(;n>127;)t[i++]=127&n|128,n>>>=7;return t[i]=n,i+1}function u(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}s.create=o(),s.alloc=t.pool(s.alloc=function(e){return new Uint8Array(e)},Uint8Array.prototype.subarray),s.prototype._reserve=function(e){var t=this.pos+e;if(t>this.buf.length){var i=this.buf.length<<1;i<t&&(i=t);var n=this.constructor.alloc(i);n.set(this.buf.subarray(0,this.pos),0),this.buf=n,this.view=null}},s.prototype.uint32=function(e){return e>>>=0,this._reserve(5),this.pos=l(e,this.buf,this.pos),this},s.prototype.int32=function(e){return(e|=0)<0?(this._reserve(10),c(i.fromNumber(e),this.buf,this.pos),this.pos+=10,this):this.uint32(e)},s.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},s.prototype.uint64=function(e){var t=i.from(e);return this._reserve(10),this.pos=c(t,this.buf,this.pos),this},s.prototype.int64=s.prototype.uint64,s.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._reserve(10),this.pos=c(t,this.buf,this.pos),this},s.prototype.bool=function(e){return this._reserve(1),this.buf[this.pos++]=e?1:0,this},s.prototype.sfixed32=s.prototype.fixed32=function(e){return this._reserve(4),u(e>>>0,this.buf,this.pos),this.pos+=4,this},s.prototype.fixed64=function(e){var t=i.from(e);return this._reserve(8),u(t.lo,this.buf,this.pos),u(t.hi,this.buf,this.pos+4),this.pos+=8,this},s.prototype.sfixed64=s.prototype.fixed64,s.prototype.float=function(e){return this._reserve(4),t.float.writeFloatLE(e,this.buf,this.pos),this.pos+=4,this},s.prototype.double=function(e){return this._reserve(8),t.float.writeDoubleLE(e,this.buf,this.pos),this.pos+=8,this},s.prototype.bytes=function(e){var i=e.length>>>0;if(!i)return this._reserve(1),this.buf[this.pos++]=0,this;if(t.isString(e)){var r=s.alloc(i=n.length(e));n.decode(e,r,0),e=r}return this.uint32(i),this._reserve(i),this.buf.set(e,this.pos),this.pos+=i,this},s.prototype.raw=function(e){var t=e.length>>>0;return t?(this._reserve(t),this.buf.set(e,this.pos),this.pos+=t,this):this},s.prototype._delim=function(e,t){var i=a(t);return i>1&&this.buf.copyWithin(e+i,e+1,e+1+t),l(t,this.buf,e),this.pos=e+i+t,this},s.prototype.string=function(e){var t=e.length;if(!t)return this._reserve(1),this.buf[this.pos++]=0,this;if(t<128){this._reserve(3*t+5);var i=this.pos;return this._delim(i,r.write(e,this.buf,i+1))}var n=r.length(e);return this.uint32(n),this._reserve(n),n===e.length?function(e,t,i){for(var n=0;n<e.length;)t[i++]=e.charCodeAt(n++)}(e,this.buf,this.pos):r.write(e,this.buf,this.pos),this.pos+=n,this},s.prototype.uint32s=function(e){var t=e.length;this._reserve(5*t+5);for(var i=this.buf,n=this.pos,r=n+1,s=0;s<t;++s)r=l(e[s]>>>0,i,r);return this._delim(n,r-n-1)},s.prototype.int32s=function(e){var t=e.length;this._reserve(10*t+5);for(var n,r=this.buf,s=this.pos,o=s+1,a=0;a<t;++a)o=(n=0|e[a])<0?c(i.fromNumber(n),r,o):l(n,r,o);return this._delim(s,o-s-1)},s.prototype.sint32s=function(e){var t=e.length;this._reserve(5*t+5);for(var i=this.buf,n=this.pos,r=n+1,s=0;s<t;++s)r=l((e[s]<<1^e[s]>>31)>>>0,i,r);return this._delim(n,r-n-1)},s.prototype.uint64s=function(e){var t=e.length;this._reserve(10*t+5);for(var n=this.buf,r=this.pos,s=r+1,o=0;o<t;++o)s=c(i.from(e[o]),n,s);return this._delim(r,s-r-1)},s.prototype.int64s=s.prototype.uint64s,s.prototype.sint64s=function(e){var t=e.length;this._reserve(10*t+5);for(var n=this.buf,r=this.pos,s=r+1,o=0;o<t;++o)s=c(i.from(e[o]).zzEncode(),n,s);return this._delim(r,s-r-1)},s.prototype.bools=function(e){var t=e.length;this.uint32(t),this._reserve(t);for(var i=this.buf,n=this.pos,r=0;r<t;++r)i[n++]=e[r]?1:0;return this.pos+=t,this};function h(e,t,i){var n=e.view;if(n||t<i)return n;var r=e.buf;return e.view=new DataView(r.buffer,r.byteOffset,r.byteLength)}return s.prototype.fixed32s=function(e){var t=e.length,i=4*t;this.uint32(i),this._reserve(i);var n,r=this.pos,s=h(this,t,128);if(s)for(n=0;n<t;++n)s.setUint32(r,e[n]>>>0,!0),r+=4;else{var o=this.buf;for(n=0;n<t;++n)u(e[n]>>>0,o,r),r+=4}return this.pos+=i,this},s.prototype.sfixed32s=s.prototype.fixed32s,s.prototype.fixed64s=function(e){var t=e.length,n=8*t;this.uint32(n),this._reserve(n);var r,s,o=this.pos,a=h(this,t,128);if(a)for(r=0;r<t;++r)s=i.from(e[r]),a.setUint32(o,s.lo,!0),a.setUint32(o+4,s.hi,!0),o+=8;else{var l=this.buf;for(r=0;r<t;++r)u((s=i.from(e[r])).lo,l,o),u(s.hi,l,o+4),o+=8}return this.pos+=n,this},s.prototype.sfixed64s=s.prototype.fixed64s,s.prototype.floats=function(e){var i=e.length,n=4*i;this.uint32(n),this._reserve(n);var r,s=this.pos,o=h(this,i,16);if(o)for(r=0;r<i;++r)o.setFloat32(s,e[r],!0),s+=4;else{var a=this.buf;for(r=0;r<i;++r)t.float.writeFloatLE(e[r],a,s),s+=4}return this.pos+=n,this},s.prototype.doubles=function(e){var i=e.length,n=8*i;this.uint32(n),this._reserve(n);var r,s=this.pos,o=h(this,i,16);if(o)for(r=0;r<i;++r)o.setFloat64(s,e[r],!0),s+=8;else{var a=this.buf;for(r=0;r<i;++r)t.float.writeDoubleLE(e[r],a,s),s+=8}return this.pos+=n,this},s.prototype.fork=function(){return this._reserve(1),(this.states||(this.states=[])).push(this.pos),this.pos+=1,this},s.prototype.reset=function(){var e=this.states;return this.pos=e&&e.length?e.pop():0,this},s.prototype.ldelim=function(){var e,t,i=this.states;if(i&&i.length){var n=i.pop();(t=a(e=this.pos-n-1))>1?(this._reserve(t-1),this.buf.copyWithin(n+t,n+1,n+1+e),this.pos+=t-1,l(e,this.buf,n)):this.buf[n]=e}else t=a(e=this.pos),this._reserve(t),this.buf.copyWithin(t,0,e),l(e,this.buf,0),this.pos+=t;return this},s.prototype.finish=function(e){if(e)return this.buf.subarray(0,this.pos);var t=this.constructor.alloc(this.pos);return t.set(this.buf.subarray(0,this.pos),0),t},s.prototype.finishInto=function(e,t){return void 0===t&&(t=0),e.set(this.buf.subarray(0,this.pos),t),e},s._configure=function(t){e=t,s.create=o(),e._configure()},uH}function wH(){if(mH)return fH;mH=1,fH=s;var e,t=xH(),i=t.LongBits,n=t.utf8;function r(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function s(e){this.buf=e,this.pos=0,this.len=e.length,this.view=null,this.discardUnknown=s.discardUnknown}function o(e){if(Array.isArray(e)&&(e=new Uint8Array(e)),e instanceof Uint8Array)return new s(e);throw Error("illegal buffer")}var a=function(){return t.Buffer?function(i){return(s.create=function(i){return t.Buffer.isBuffer(i)?new e(i):o(i)})(i)}:o};function l(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<4;++t){if(this.pos>=this.len)throw r(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}throw r(this)}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw r(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function c(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function u(){if(this.pos+8>this.len)throw r(this,8);return new i(c(this.buf,this.pos+=4),c(this.buf,this.pos+=4))}s.create=a(),s.prototype.raw=function(e,t){return this.buf.subarray(e,t)},s.prototype.uint32=function(){var e=this.buf,t=this.pos,i=(127&e[t])>>>0;if(e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<7)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<14)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<21)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(15&e[t])<<28)>>>0,e[t++]<128)return this.pos=t,i;for(var n=0;n<5;++n){if(t>=this.len)throw this.pos=t,r(this);if(e[t++]<128)return this.pos=t,i}throw this.pos=t,Error("invalid varint encoding")},s.prototype.tag=function(){var e=this.buf,t=this.pos,i=(127&e[t])>>>0;if(e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<7)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<14)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(127&e[t])<<21)>>>0,e[t++]<128)return this.pos=t,i;if(i=(i|(15&e[t])<<28)>>>0,e[t]<128&&!(112&e[t]))return this.pos=t+1,i;throw this.pos=t+1,Error("invalid tag encoding")},s.prototype.int32=function(){return 0|this.uint32()},s.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},s.prototype.bool=function(){for(var e,t=!1,i=0;i<10;++i){if(this.pos>=this.len)throw r(this);if(127&(e=this.buf[this.pos++])&&(t=!0),e<128)return t}throw Error("invalid varint encoding")},s.prototype.fixed32=function(){if(this.pos+4>this.len)throw r(this,4);return c(this.buf,this.pos+=4)},s.prototype.sfixed32=function(){if(this.pos+4>this.len)throw r(this,4);return 0|c(this.buf,this.pos+=4)},s.prototype.float=function(){if(this.pos+4>this.len)throw r(this,4);var e=t.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},s.prototype.double=function(){if(this.pos+8>this.len)throw r(this,4);var e=t.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},s.prototype.uint32s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.uint32());return e},s.prototype.int32s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.int32());return e},s.prototype.sint32s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.sint32());return e},s.prototype.bools=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.bool());return e};function h(e,t,i){var n=e.view;if(n||t<i)return n;var r=e.buf;return e.view=new DataView(r.buffer,r.byteOffset,r.byteLength)}return s.prototype.fixed32s=function(e){void 0===e&&(e=[]);var t=this.uint32(),i=this.pos+t;if(i>this.len)throw r(this,t);var n=t>>>2,s=e.length,o=this.pos;e.length=s+n;var a=h(this,n,128);if(a)for(var l=0;l<n;++l,o+=4)e[s++]=a.getUint32(o,!0);else for(var u=this.buf,d=0;d<n;++d,o+=4)e[s++]=c(u,o+4);if(this.pos=o,o!==i)throw r(this,4);return e},s.prototype.sfixed32s=function(e){void 0===e&&(e=[]);var t=this.uint32(),i=this.pos+t;if(i>this.len)throw r(this,t);var n=t>>>2,s=e.length,o=this.pos;e.length=s+n;var a=h(this,n,128);if(a)for(var l=0;l<n;++l,o+=4)e[s++]=a.getInt32(o,!0);else for(var u=this.buf,d=0;d<n;++d,o+=4)e[s++]=0|c(u,o+4);if(this.pos=o,o!==i)throw r(this,4);return e},s.prototype.floats=function(e){void 0===e&&(e=[]);var i=this.uint32(),n=this.pos+i;if(n>this.len)throw r(this,i);var s=i>>>2,o=e.length,a=this.pos;e.length=o+s;var l=h(this,s,8);if(l)for(var c=0;c<s;++c,a+=4)e[o++]=l.getFloat32(a,!0);else for(var u=this.buf,d=0;d<s;++d,a+=4)e[o++]=t.float.readFloatLE(u,a);if(this.pos=a,a!==n)throw r(this,4);return e},s.prototype.doubles=function(e){void 0===e&&(e=[]);var i=this.uint32(),n=this.pos+i;if(n>this.len)throw r(this,i);var s=i>>>3,o=e.length,a=this.pos;e.length=o+s;var l=h(this,s,8);if(l)for(var c=0;c<s;++c,a+=8)e[o++]=l.getFloat64(a,!0);else for(var u=this.buf,d=0;d<s;++d,a+=8)e[o++]=t.float.readDoubleLE(u,a);if(this.pos=a,a!==n)throw r(this,8);return e},s.prototype.uint64s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.uint64());return e},s.prototype.int64s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.int64());return e},s.prototype.sint64s=function(e){void 0===e&&(e=[]);for(var t=this.uint32()+this.pos;this.pos<t;)e.push(this.sint64());return e},s.prototype.fixed64s=function(e){void 0===e&&(e=[]);var t=this.uint32(),i=this.pos+t,n=e.length;if(i>this.len)throw r(this,t);var s=t>>>3;e.length=n+s;for(var o=0;o<s;++o)e[n++]=this.fixed64();if(this.pos!==i)throw r(this,8);return e},s.prototype.sfixed64s=function(e){void 0===e&&(e=[]);var t=this.uint32(),i=this.pos+t,n=e.length;if(i>this.len)throw r(this,t);var s=t>>>3;e.length=n+s;for(var o=0;o<s;++o)e[n++]=this.sfixed64();if(this.pos!==i)throw r(this,8);return e},s.prototype.bytes=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw r(this,e);return this.pos=i,this.raw(t,i)},s.prototype.string=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw r(this,e);return this.pos=i,n.read(this.buf,t,i)},s.prototype.stringVerify=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw r(this,e);return this.pos=i,n.readStrict(this.buf,t,i)},s.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw r(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw r(this)}while(128&this.buf[this.pos++]);return this},s.recursionLimit=t.recursionLimit,s.discardUnknown=!0,s.prototype.skipType=function(e,t,i){if(void 0===t&&(t=0),t>s.recursionLimit)throw Error("max depth exceeded");if(0===i)throw Error("illegal tag: field number 0");switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var n=this.tag(),r=n>>>3;if(e=7&n,!r)throw Error("illegal tag: field number 0");if(4===e){if(void 0!==i&&r!==i)throw Error("invalid end group tag");break}this.skipType(e,t+1,r)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},s._configure=function(i){e=i,s.create=a(),e._configure();var n=t.Long?"toLong":"toNumber";t.merge(s.prototype,{int64:function(){return l.call(this)[n](!1)},uint64:function(){return l.call(this)[n](!0)},sint64:function(){return l.call(this).zzDecode()[n](!1)},fixed64:function(){return u.call(this)[n](!0)},sfixed64:function(){return u.call(this)[n](!1)}})},fH}var TH,SH,EH,AH,MH,IH,CH,PH,LH,RH,OH={};function DH(){return EH||(EH=1,function(e){e.Service=function(){if(SH)return TH;SH=1,TH=t;var e=xH();function t(t,i,n){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");e.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(i),this.responseDelimited=Boolean(n)}return(t.prototype=Object.create(e.EventEmitter.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0}})).rpcCall=function t(i,n,r,s,o){if(!s)throw TypeError("request must be specified");var a=this;if(!o)return e.asPromise(t,a,i,n,r,s);if(a.rpcImpl)try{return a.rpcImpl(i,n[a.requestDelimited?"encodeDelimited":"encode"](s).finish(),function(e,t){if(e)return a.emit("error",e,i),o(e);if(null!==t){if(!(t instanceof r))try{t=r[a.responseDelimited?"decodeDelimited":"decode"](t)}catch(e){return a.emit("error",e,i),o(e)}return a.emit("data",t,i),o(null,t)}a.end(!0)})}catch(e){return a.emit("error",e,i),void setTimeout(function(){o(e)},0)}else setTimeout(function(){o(Error("already ended"))},0)},t.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},TH}()}(OH)),OH}function BH(){return IH||(IH=1,function(e){function t(){e.util.LongBits._configure(e.util.Long),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}e.build="minimal",e.Writer=bH(),e.BufferWriter=function(){if(pH)return dH;pH=1,dH=n;var e=bH();n.prototype=Object.create(e.prototype,{constructor:{value:n,writable:!0,enumerable:!1,configurable:!0}});var t,i=xH();function n(){e.call(this)}return n._configure=function(){n.alloc=i.Buffer&&i.Buffer.allocUnsafe,t=i.Buffer&&i.Buffer.prototype.utf8Write?function(e,t,i){return t.utf8Write(e,i)}:function(e,t,i){return t.write(e,i)}},n.prototype.bytes=function(e){i.isString(e)&&(e=i.Buffer.from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&(this._reserve(t),this.buf.set(e,this.pos),this.pos+=t),this},n.prototype.string=function(e){var n=e.length;if(!n)return this._reserve(1),this.buf[this.pos++]=0,this;if(n<128){this._reserve(3*n+5);var r=this.pos,s=this.buf;return this._delim(r,n<40?i.utf8.write(e,s,r+1):t(e,s,r+1))}var o=i.Buffer.byteLength(e);return this.uint32(o),this._reserve(o),t(e,this.buf,this.pos),this.pos+=o,this},n._configure(),dH}(),e.Reader=wH(),e.BufferReader=function(){if(_H)return gH;_H=1,gH=i;var e=wH();i.prototype=Object.create(e.prototype,{constructor:{value:i,writable:!0,enumerable:!1,configurable:!0}});var t=xH();function i(t){e.call(this,t)}return i._configure=function(){t.Buffer&&(i.prototype._slice=t.Buffer.prototype.slice)},i.prototype.raw=function(e,t){return this._slice.call(this.buf,e,t)},i.prototype.string=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw RangeError("index out of range: "+this.pos+" + "+e+" > "+this.len);return this.pos=i,this.buf.utf8Slice?this.buf.utf8Slice(t,i):this.buf.toString("utf-8",t,i)},i._configure(),gH}(),e.util=xH(),e.rpc=DH(),e.roots=MH?AH:(MH=1,AH=Object.create(null)),e.configure=t,t()}($G)),$G}var FH=function(){if(RH)return LH;RH=1;var e,t=PH?CH:(PH=1,CH=BH()),i=t.Reader,n=t.Writer,r=t.util,s=t.roots.default||(t.roots.default={});return s.transit_realtime=((e={}).FeedMessage=function(){function e(e){if(this.entity=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.header=null,e.prototype.entity=r.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),s.transit_realtime.FeedHeader.encode(e.header,t.uint32(10).fork()).ldelim(),null!=e.entity&&e.entity.length)for(var i=0;i<e.entity.length;++i)s.transit_realtime.FeedEntity.encode(e.entity[i],t.uint32(18).fork()).ldelim();if(null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.FeedMessage;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.header=s.transit_realtime.FeedHeader.decode(e,e.uint32(),void 0,o+1,c.header);continue;case 2:if(2!==d)break;c.entity&&c.entity.length||(c.entity=[]),c.entity.push(s.transit_realtime.FeedEntity.decode(e,e.uint32(),void 0,o+1));continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("header"))throw r.ProtocolError("missing required 'header'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(n=s.transit_realtime.FeedHeader.verify(e.header,t+1))return"header."+n;if(null!=e.entity&&e.hasOwnProperty("entity")){if(!Array.isArray(e.entity))return"entity: array expected";for(var i=0;i<e.entity.length;++i){var n;if(n=s.transit_realtime.FeedEntity.verify(e.entity[i],t+1))return"entity."+n}}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.FeedMessage)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.FeedMessage;if(null!=e.header){if("object"!=typeof e.header)throw TypeError(".transit_realtime.FeedMessage.header: object expected");i.header=s.transit_realtime.FeedHeader.fromObject(e.header,t+1)}if(e.entity){if(!Array.isArray(e.entity))throw TypeError(".transit_realtime.FeedMessage.entity: array expected");i.entity=Array(e.entity.length);for(var n=0;n<e.entity.length;++n){if("object"!=typeof e.entity[n])throw TypeError(".transit_realtime.FeedMessage.entity: object expected");i.entity[n]=s.transit_realtime.FeedEntity.fromObject(e.entity[n],t+1)}}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.entity=[]),t.defaults&&(i.header=null),null!=e.header&&e.hasOwnProperty("header")&&(i.header=s.transit_realtime.FeedHeader.toObject(e.header,t)),e.entity&&e.entity.length){i.entity=Array(e.entity.length);for(var n=0;n<e.entity.length;++n)i.entity[n]=s.transit_realtime.FeedEntity.toObject(e.entity[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.FeedMessage"},e}(),e.FeedHeader=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.gtfsRealtimeVersion="",e.prototype.incrementality=0,e.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,e.prototype.feedVersion="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),t.uint32(10).string(e.gtfsRealtimeVersion),null!=e.incrementality&&Object.hasOwnProperty.call(e,"incrementality")&&t.uint32(16).int32(e.incrementality),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(24).uint64(e.timestamp),null!=e.feedVersion&&Object.hasOwnProperty.call(e,"feedVersion")&&t.uint32(34).string(e.feedVersion),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.FeedHeader;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.gtfsRealtimeVersion=e.string();continue;case 2:if(0!==d)break;c.incrementality=e.int32();continue;case 3:if(0!==d)break;c.timestamp=e.uint64();continue;case 4:if(2!==d)break;c.feedVersion=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("gtfsRealtimeVersion"))throw r.ProtocolError("missing required 'gtfsRealtimeVersion'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(!r.isString(e.gtfsRealtimeVersion))return"gtfsRealtimeVersion: string expected";if(null!=e.incrementality&&e.hasOwnProperty("incrementality"))switch(e.incrementality){default:return"incrementality: enum value expected";case 0:case 1:}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(r.isInteger(e.timestamp)||e.timestamp&&r.isInteger(e.timestamp.low)&&r.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null!=e.feedVersion&&e.hasOwnProperty("feedVersion")&&!r.isString(e.feedVersion)?"feedVersion: string expected":null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.FeedHeader)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.FeedHeader;switch(null!=e.gtfsRealtimeVersion&&(i.gtfsRealtimeVersion=String(e.gtfsRealtimeVersion)),e.incrementality){default:if("number"==typeof e.incrementality){i.incrementality=e.incrementality;break}break;case"FULL_DATASET":case 0:i.incrementality=0;break;case"DIFFERENTIAL":case 1:i.incrementality=1}return null!=e.timestamp&&(r.Long?(i.timestamp=r.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?i.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?i.timestamp=e.timestamp:"object"==typeof e.timestamp&&(i.timestamp=new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),null!=e.feedVersion&&(i.feedVersion=String(e.feedVersion)),i},e.toObject=function(e,t){t||(t={});var i={};if(t.defaults){if(i.gtfsRealtimeVersion="",i.incrementality=t.enums===String?"FULL_DATASET":0,r.Long){var n=new r.Long(0,0,!0);i.timestamp=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.timestamp=t.longs===String?"0":0;i.feedVersion=""}return null!=e.gtfsRealtimeVersion&&e.hasOwnProperty("gtfsRealtimeVersion")&&(i.gtfsRealtimeVersion=e.gtfsRealtimeVersion),null!=e.incrementality&&e.hasOwnProperty("incrementality")&&(i.incrementality=t.enums===String?void 0===s.transit_realtime.FeedHeader.Incrementality[e.incrementality]?e.incrementality:s.transit_realtime.FeedHeader.Incrementality[e.incrementality]:e.incrementality),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&(i.timestamp="number"==typeof e.timestamp?t.longs===String?String(e.timestamp):e.timestamp:t.longs===String?r.Long.prototype.toString.call(e.timestamp):t.longs===Number?new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),null!=e.feedVersion&&e.hasOwnProperty("feedVersion")&&(i.feedVersion=e.feedVersion),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.FeedHeader"},e.Incrementality=function(){var e={},t=Object.create(e);return t[e[0]="FULL_DATASET"]=0,t[e[1]="DIFFERENTIAL"]=1,t}(),e}(),e.FeedEntity=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.id="",e.prototype.isDeleted=!1,e.prototype.tripUpdate=null,e.prototype.vehicle=null,e.prototype.alert=null,e.prototype.shape=null,e.prototype.stop=null,e.prototype.tripModifications=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),t.uint32(10).string(e.id),null!=e.isDeleted&&Object.hasOwnProperty.call(e,"isDeleted")&&t.uint32(16).bool(e.isDeleted),null!=e.tripUpdate&&Object.hasOwnProperty.call(e,"tripUpdate")&&s.transit_realtime.TripUpdate.encode(e.tripUpdate,t.uint32(26).fork()).ldelim(),null!=e.vehicle&&Object.hasOwnProperty.call(e,"vehicle")&&s.transit_realtime.VehiclePosition.encode(e.vehicle,t.uint32(34).fork()).ldelim(),null!=e.alert&&Object.hasOwnProperty.call(e,"alert")&&s.transit_realtime.Alert.encode(e.alert,t.uint32(42).fork()).ldelim(),null!=e.shape&&Object.hasOwnProperty.call(e,"shape")&&s.transit_realtime.Shape.encode(e.shape,t.uint32(50).fork()).ldelim(),null!=e.stop&&Object.hasOwnProperty.call(e,"stop")&&s.transit_realtime.Stop.encode(e.stop,t.uint32(58).fork()).ldelim(),null!=e.tripModifications&&Object.hasOwnProperty.call(e,"tripModifications")&&s.transit_realtime.TripModifications.encode(e.tripModifications,t.uint32(66).fork()).ldelim(),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.FeedEntity;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.id=e.string();continue;case 2:if(0!==d)break;c.isDeleted=e.bool();continue;case 3:if(2!==d)break;c.tripUpdate=s.transit_realtime.TripUpdate.decode(e,e.uint32(),void 0,o+1,c.tripUpdate);continue;case 4:if(2!==d)break;c.vehicle=s.transit_realtime.VehiclePosition.decode(e,e.uint32(),void 0,o+1,c.vehicle);continue;case 5:if(2!==d)break;c.alert=s.transit_realtime.Alert.decode(e,e.uint32(),void 0,o+1,c.alert);continue;case 6:if(2!==d)break;c.shape=s.transit_realtime.Shape.decode(e,e.uint32(),void 0,o+1,c.shape);continue;case 7:if(2!==d)break;c.stop=s.transit_realtime.Stop.decode(e,e.uint32(),void 0,o+1,c.stop);continue;case 8:if(2!==d)break;c.tripModifications=s.transit_realtime.TripModifications.decode(e,e.uint32(),void 0,o+1,c.tripModifications);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("id"))throw r.ProtocolError("missing required 'id'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":r.isString(e.id)?null!=e.isDeleted&&e.hasOwnProperty("isDeleted")&&"boolean"!=typeof e.isDeleted?"isDeleted: boolean expected":null!=e.tripUpdate&&e.hasOwnProperty("tripUpdate")&&(i=s.transit_realtime.TripUpdate.verify(e.tripUpdate,t+1))?"tripUpdate."+i:null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(i=s.transit_realtime.VehiclePosition.verify(e.vehicle,t+1))?"vehicle."+i:null!=e.alert&&e.hasOwnProperty("alert")&&(i=s.transit_realtime.Alert.verify(e.alert,t+1))?"alert."+i:null!=e.shape&&e.hasOwnProperty("shape")&&(i=s.transit_realtime.Shape.verify(e.shape,t+1))?"shape."+i:null!=e.stop&&e.hasOwnProperty("stop")&&(i=s.transit_realtime.Stop.verify(e.stop,t+1))?"stop."+i:null!=e.tripModifications&&e.hasOwnProperty("tripModifications")&&(i=s.transit_realtime.TripModifications.verify(e.tripModifications,t+1))?"tripModifications."+i:null:"id: string expected");var i},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.FeedEntity)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.FeedEntity;if(null!=e.id&&(i.id=String(e.id)),null!=e.isDeleted&&(i.isDeleted=Boolean(e.isDeleted)),null!=e.tripUpdate){if("object"!=typeof e.tripUpdate)throw TypeError(".transit_realtime.FeedEntity.tripUpdate: object expected");i.tripUpdate=s.transit_realtime.TripUpdate.fromObject(e.tripUpdate,t+1)}if(null!=e.vehicle){if("object"!=typeof e.vehicle)throw TypeError(".transit_realtime.FeedEntity.vehicle: object expected");i.vehicle=s.transit_realtime.VehiclePosition.fromObject(e.vehicle,t+1)}if(null!=e.alert){if("object"!=typeof e.alert)throw TypeError(".transit_realtime.FeedEntity.alert: object expected");i.alert=s.transit_realtime.Alert.fromObject(e.alert,t+1)}if(null!=e.shape){if("object"!=typeof e.shape)throw TypeError(".transit_realtime.FeedEntity.shape: object expected");i.shape=s.transit_realtime.Shape.fromObject(e.shape,t+1)}if(null!=e.stop){if("object"!=typeof e.stop)throw TypeError(".transit_realtime.FeedEntity.stop: object expected");i.stop=s.transit_realtime.Stop.fromObject(e.stop,t+1)}if(null!=e.tripModifications){if("object"!=typeof e.tripModifications)throw TypeError(".transit_realtime.FeedEntity.tripModifications: object expected");i.tripModifications=s.transit_realtime.TripModifications.fromObject(e.tripModifications,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.id="",i.isDeleted=!1,i.tripUpdate=null,i.vehicle=null,i.alert=null,i.shape=null,i.stop=null,i.tripModifications=null),null!=e.id&&e.hasOwnProperty("id")&&(i.id=e.id),null!=e.isDeleted&&e.hasOwnProperty("isDeleted")&&(i.isDeleted=e.isDeleted),null!=e.tripUpdate&&e.hasOwnProperty("tripUpdate")&&(i.tripUpdate=s.transit_realtime.TripUpdate.toObject(e.tripUpdate,t)),null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(i.vehicle=s.transit_realtime.VehiclePosition.toObject(e.vehicle,t)),null!=e.alert&&e.hasOwnProperty("alert")&&(i.alert=s.transit_realtime.Alert.toObject(e.alert,t)),null!=e.shape&&e.hasOwnProperty("shape")&&(i.shape=s.transit_realtime.Shape.toObject(e.shape,t)),null!=e.stop&&e.hasOwnProperty("stop")&&(i.stop=s.transit_realtime.Stop.toObject(e.stop,t)),null!=e.tripModifications&&e.hasOwnProperty("tripModifications")&&(i.tripModifications=s.transit_realtime.TripModifications.toObject(e.tripModifications,t)),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.FeedEntity"},e}(),e.TripUpdate=function(){function e(e){if(this.stopTimeUpdate=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.trip=null,e.prototype.vehicle=null,e.prototype.stopTimeUpdate=r.emptyArray,e.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,e.prototype.delay=0,e.prototype.tripProperties=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),s.transit_realtime.TripDescriptor.encode(e.trip,t.uint32(10).fork()).ldelim(),null!=e.stopTimeUpdate&&e.stopTimeUpdate.length)for(var i=0;i<e.stopTimeUpdate.length;++i)s.transit_realtime.TripUpdate.StopTimeUpdate.encode(e.stopTimeUpdate[i],t.uint32(18).fork()).ldelim();if(null!=e.vehicle&&Object.hasOwnProperty.call(e,"vehicle")&&s.transit_realtime.VehicleDescriptor.encode(e.vehicle,t.uint32(26).fork()).ldelim(),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(32).uint64(e.timestamp),null!=e.delay&&Object.hasOwnProperty.call(e,"delay")&&t.uint32(40).int32(e.delay),null!=e.tripProperties&&Object.hasOwnProperty.call(e,"tripProperties")&&s.transit_realtime.TripUpdate.TripProperties.encode(e.tripProperties,t.uint32(50).fork()).ldelim(),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripUpdate;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.trip=s.transit_realtime.TripDescriptor.decode(e,e.uint32(),void 0,o+1,c.trip);continue;case 3:if(2!==d)break;c.vehicle=s.transit_realtime.VehicleDescriptor.decode(e,e.uint32(),void 0,o+1,c.vehicle);continue;case 2:if(2!==d)break;c.stopTimeUpdate&&c.stopTimeUpdate.length||(c.stopTimeUpdate=[]),c.stopTimeUpdate.push(s.transit_realtime.TripUpdate.StopTimeUpdate.decode(e,e.uint32(),void 0,o+1));continue;case 4:if(0!==d)break;c.timestamp=e.uint64();continue;case 5:if(0!==d)break;c.delay=e.int32();continue;case 6:if(2!==d)break;c.tripProperties=s.transit_realtime.TripUpdate.TripProperties.decode(e,e.uint32(),void 0,o+1,c.tripProperties);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("trip"))throw r.ProtocolError("missing required 'trip'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(n=s.transit_realtime.TripDescriptor.verify(e.trip,t+1))return"trip."+n;if(null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(n=s.transit_realtime.VehicleDescriptor.verify(e.vehicle,t+1)))return"vehicle."+n;if(null!=e.stopTimeUpdate&&e.hasOwnProperty("stopTimeUpdate")){if(!Array.isArray(e.stopTimeUpdate))return"stopTimeUpdate: array expected";for(var i=0;i<e.stopTimeUpdate.length;++i){var n;if(n=s.transit_realtime.TripUpdate.StopTimeUpdate.verify(e.stopTimeUpdate[i],t+1))return"stopTimeUpdate."+n}}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(r.isInteger(e.timestamp)||e.timestamp&&r.isInteger(e.timestamp.low)&&r.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null!=e.delay&&e.hasOwnProperty("delay")&&!r.isInteger(e.delay)?"delay: integer expected":null!=e.tripProperties&&e.hasOwnProperty("tripProperties")&&(n=s.transit_realtime.TripUpdate.TripProperties.verify(e.tripProperties,t+1))?"tripProperties."+n:null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripUpdate)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripUpdate;if(null!=e.trip){if("object"!=typeof e.trip)throw TypeError(".transit_realtime.TripUpdate.trip: object expected");i.trip=s.transit_realtime.TripDescriptor.fromObject(e.trip,t+1)}if(null!=e.vehicle){if("object"!=typeof e.vehicle)throw TypeError(".transit_realtime.TripUpdate.vehicle: object expected");i.vehicle=s.transit_realtime.VehicleDescriptor.fromObject(e.vehicle,t+1)}if(e.stopTimeUpdate){if(!Array.isArray(e.stopTimeUpdate))throw TypeError(".transit_realtime.TripUpdate.stopTimeUpdate: array expected");i.stopTimeUpdate=Array(e.stopTimeUpdate.length);for(var n=0;n<e.stopTimeUpdate.length;++n){if("object"!=typeof e.stopTimeUpdate[n])throw TypeError(".transit_realtime.TripUpdate.stopTimeUpdate: object expected");i.stopTimeUpdate[n]=s.transit_realtime.TripUpdate.StopTimeUpdate.fromObject(e.stopTimeUpdate[n],t+1)}}if(null!=e.timestamp&&(r.Long?(i.timestamp=r.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?i.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?i.timestamp=e.timestamp:"object"==typeof e.timestamp&&(i.timestamp=new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),null!=e.delay&&(i.delay=0|e.delay),null!=e.tripProperties){if("object"!=typeof e.tripProperties)throw TypeError(".transit_realtime.TripUpdate.tripProperties: object expected");i.tripProperties=s.transit_realtime.TripUpdate.TripProperties.fromObject(e.tripProperties,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.stopTimeUpdate=[]),t.defaults){if(i.trip=null,i.vehicle=null,r.Long){var n=new r.Long(0,0,!0);i.timestamp=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.timestamp=t.longs===String?"0":0;i.delay=0,i.tripProperties=null}if(null!=e.trip&&e.hasOwnProperty("trip")&&(i.trip=s.transit_realtime.TripDescriptor.toObject(e.trip,t)),e.stopTimeUpdate&&e.stopTimeUpdate.length){i.stopTimeUpdate=Array(e.stopTimeUpdate.length);for(var o=0;o<e.stopTimeUpdate.length;++o)i.stopTimeUpdate[o]=s.transit_realtime.TripUpdate.StopTimeUpdate.toObject(e.stopTimeUpdate[o],t)}return null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(i.vehicle=s.transit_realtime.VehicleDescriptor.toObject(e.vehicle,t)),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&(i.timestamp="number"==typeof e.timestamp?t.longs===String?String(e.timestamp):e.timestamp:t.longs===String?r.Long.prototype.toString.call(e.timestamp):t.longs===Number?new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),null!=e.delay&&e.hasOwnProperty("delay")&&(i.delay=e.delay),null!=e.tripProperties&&e.hasOwnProperty("tripProperties")&&(i.tripProperties=s.transit_realtime.TripUpdate.TripProperties.toObject(e.tripProperties,t)),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripUpdate"},e.StopTimeEvent=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.delay=0,e.prototype.time=r.Long?r.Long.fromBits(0,0,!1):0,e.prototype.uncertainty=0,e.prototype.scheduledTime=r.Long?r.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.delay&&Object.hasOwnProperty.call(e,"delay")&&t.uint32(8).int32(e.delay),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(16).int64(e.time),null!=e.uncertainty&&Object.hasOwnProperty.call(e,"uncertainty")&&t.uint32(24).int32(e.uncertainty),null!=e.scheduledTime&&Object.hasOwnProperty.call(e,"scheduledTime")&&t.uint32(32).int64(e.scheduledTime),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripUpdate.StopTimeEvent;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(0!==d)break;c.delay=e.int32();continue;case 2:if(0!==d)break;c.time=e.int64();continue;case 3:if(0!==d)break;c.uncertainty=e.int32();continue;case 4:if(0!==d)break;c.scheduledTime=e.int64();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.delay&&e.hasOwnProperty("delay")&&!r.isInteger(e.delay)?"delay: integer expected":null!=e.time&&e.hasOwnProperty("time")&&!(r.isInteger(e.time)||e.time&&r.isInteger(e.time.low)&&r.isInteger(e.time.high))?"time: integer|Long expected":null!=e.uncertainty&&e.hasOwnProperty("uncertainty")&&!r.isInteger(e.uncertainty)?"uncertainty: integer expected":null!=e.scheduledTime&&e.hasOwnProperty("scheduledTime")&&!(r.isInteger(e.scheduledTime)||e.scheduledTime&&r.isInteger(e.scheduledTime.low)&&r.isInteger(e.scheduledTime.high))?"scheduledTime: integer|Long expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripUpdate.StopTimeEvent)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripUpdate.StopTimeEvent;return null!=e.delay&&(i.delay=0|e.delay),null!=e.time&&(r.Long?(i.time=r.Long.fromValue(e.time)).unsigned=!1:"string"==typeof e.time?i.time=parseInt(e.time,10):"number"==typeof e.time?i.time=e.time:"object"==typeof e.time&&(i.time=new r.LongBits(e.time.low>>>0,e.time.high>>>0).toNumber())),null!=e.uncertainty&&(i.uncertainty=0|e.uncertainty),null!=e.scheduledTime&&(r.Long?(i.scheduledTime=r.Long.fromValue(e.scheduledTime)).unsigned=!1:"string"==typeof e.scheduledTime?i.scheduledTime=parseInt(e.scheduledTime,10):"number"==typeof e.scheduledTime?i.scheduledTime=e.scheduledTime:"object"==typeof e.scheduledTime&&(i.scheduledTime=new r.LongBits(e.scheduledTime.low>>>0,e.scheduledTime.high>>>0).toNumber())),i},e.toObject=function(e,t){t||(t={});var i={};if(t.defaults){if(i.delay=0,r.Long){var n=new r.Long(0,0,!1);i.time=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.time=t.longs===String?"0":0;i.uncertainty=0,r.Long?(n=new r.Long(0,0,!1),i.scheduledTime=t.longs===String?n.toString():t.longs===Number?n.toNumber():n):i.scheduledTime=t.longs===String?"0":0}return null!=e.delay&&e.hasOwnProperty("delay")&&(i.delay=e.delay),null!=e.time&&e.hasOwnProperty("time")&&(i.time="number"==typeof e.time?t.longs===String?String(e.time):e.time:t.longs===String?r.Long.prototype.toString.call(e.time):t.longs===Number?new r.LongBits(e.time.low>>>0,e.time.high>>>0).toNumber():e.time),null!=e.uncertainty&&e.hasOwnProperty("uncertainty")&&(i.uncertainty=e.uncertainty),null!=e.scheduledTime&&e.hasOwnProperty("scheduledTime")&&(i.scheduledTime="number"==typeof e.scheduledTime?t.longs===String?String(e.scheduledTime):e.scheduledTime:t.longs===String?r.Long.prototype.toString.call(e.scheduledTime):t.longs===Number?new r.LongBits(e.scheduledTime.low>>>0,e.scheduledTime.high>>>0).toNumber():e.scheduledTime),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripUpdate.StopTimeEvent"},e}(),e.StopTimeUpdate=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.stopSequence=0,e.prototype.stopId="",e.prototype.arrival=null,e.prototype.departure=null,e.prototype.departureOccupancyStatus=0,e.prototype.scheduleRelationship=0,e.prototype.stopTimeProperties=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.stopSequence&&Object.hasOwnProperty.call(e,"stopSequence")&&t.uint32(8).uint32(e.stopSequence),null!=e.arrival&&Object.hasOwnProperty.call(e,"arrival")&&s.transit_realtime.TripUpdate.StopTimeEvent.encode(e.arrival,t.uint32(18).fork()).ldelim(),null!=e.departure&&Object.hasOwnProperty.call(e,"departure")&&s.transit_realtime.TripUpdate.StopTimeEvent.encode(e.departure,t.uint32(26).fork()).ldelim(),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(34).string(e.stopId),null!=e.scheduleRelationship&&Object.hasOwnProperty.call(e,"scheduleRelationship")&&t.uint32(40).int32(e.scheduleRelationship),null!=e.stopTimeProperties&&Object.hasOwnProperty.call(e,"stopTimeProperties")&&s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.encode(e.stopTimeProperties,t.uint32(50).fork()).ldelim(),null!=e.departureOccupancyStatus&&Object.hasOwnProperty.call(e,"departureOccupancyStatus")&&t.uint32(56).int32(e.departureOccupancyStatus),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripUpdate.StopTimeUpdate;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(0!==d)break;c.stopSequence=e.uint32();continue;case 4:if(2!==d)break;c.stopId=e.string();continue;case 2:if(2!==d)break;c.arrival=s.transit_realtime.TripUpdate.StopTimeEvent.decode(e,e.uint32(),void 0,o+1,c.arrival);continue;case 3:if(2!==d)break;c.departure=s.transit_realtime.TripUpdate.StopTimeEvent.decode(e,e.uint32(),void 0,o+1,c.departure);continue;case 7:if(0!==d)break;c.departureOccupancyStatus=e.int32();continue;case 5:if(0!==d)break;c.scheduleRelationship=e.int32();continue;case 6:if(2!==d)break;c.stopTimeProperties=s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.decode(e,e.uint32(),void 0,o+1,c.stopTimeProperties);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.stopSequence&&e.hasOwnProperty("stopSequence")&&!r.isInteger(e.stopSequence))return"stopSequence: integer expected";if(null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId))return"stopId: string expected";var i;if(null!=e.arrival&&e.hasOwnProperty("arrival")&&(i=s.transit_realtime.TripUpdate.StopTimeEvent.verify(e.arrival,t+1)))return"arrival."+i;if(null!=e.departure&&e.hasOwnProperty("departure")&&(i=s.transit_realtime.TripUpdate.StopTimeEvent.verify(e.departure,t+1)))return"departure."+i;if(null!=e.departureOccupancyStatus&&e.hasOwnProperty("departureOccupancyStatus"))switch(e.departureOccupancyStatus){default:return"departureOccupancyStatus: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:}if(null!=e.scheduleRelationship&&e.hasOwnProperty("scheduleRelationship"))switch(e.scheduleRelationship){default:return"scheduleRelationship: enum value expected";case 0:case 1:case 2:case 3:}return null!=e.stopTimeProperties&&e.hasOwnProperty("stopTimeProperties")&&(i=s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.verify(e.stopTimeProperties,t+1))?"stopTimeProperties."+i:null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripUpdate.StopTimeUpdate)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripUpdate.StopTimeUpdate;if(null!=e.stopSequence&&(i.stopSequence=e.stopSequence>>>0),null!=e.stopId&&(i.stopId=String(e.stopId)),null!=e.arrival){if("object"!=typeof e.arrival)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.arrival: object expected");i.arrival=s.transit_realtime.TripUpdate.StopTimeEvent.fromObject(e.arrival,t+1)}if(null!=e.departure){if("object"!=typeof e.departure)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.departure: object expected");i.departure=s.transit_realtime.TripUpdate.StopTimeEvent.fromObject(e.departure,t+1)}switch(e.departureOccupancyStatus){default:if("number"==typeof e.departureOccupancyStatus){i.departureOccupancyStatus=e.departureOccupancyStatus;break}break;case"EMPTY":case 0:i.departureOccupancyStatus=0;break;case"MANY_SEATS_AVAILABLE":case 1:i.departureOccupancyStatus=1;break;case"FEW_SEATS_AVAILABLE":case 2:i.departureOccupancyStatus=2;break;case"STANDING_ROOM_ONLY":case 3:i.departureOccupancyStatus=3;break;case"CRUSHED_STANDING_ROOM_ONLY":case 4:i.departureOccupancyStatus=4;break;case"FULL":case 5:i.departureOccupancyStatus=5;break;case"NOT_ACCEPTING_PASSENGERS":case 6:i.departureOccupancyStatus=6;break;case"NO_DATA_AVAILABLE":case 7:i.departureOccupancyStatus=7;break;case"NOT_BOARDABLE":case 8:i.departureOccupancyStatus=8}switch(e.scheduleRelationship){default:if("number"==typeof e.scheduleRelationship){i.scheduleRelationship=e.scheduleRelationship;break}break;case"SCHEDULED":case 0:i.scheduleRelationship=0;break;case"SKIPPED":case 1:i.scheduleRelationship=1;break;case"NO_DATA":case 2:i.scheduleRelationship=2;break;case"UNSCHEDULED":case 3:i.scheduleRelationship=3}if(null!=e.stopTimeProperties){if("object"!=typeof e.stopTimeProperties)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.stopTimeProperties: object expected");i.stopTimeProperties=s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.fromObject(e.stopTimeProperties,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.stopSequence=0,i.arrival=null,i.departure=null,i.stopId="",i.scheduleRelationship=t.enums===String?"SCHEDULED":0,i.stopTimeProperties=null,i.departureOccupancyStatus=t.enums===String?"EMPTY":0),null!=e.stopSequence&&e.hasOwnProperty("stopSequence")&&(i.stopSequence=e.stopSequence),null!=e.arrival&&e.hasOwnProperty("arrival")&&(i.arrival=s.transit_realtime.TripUpdate.StopTimeEvent.toObject(e.arrival,t)),null!=e.departure&&e.hasOwnProperty("departure")&&(i.departure=s.transit_realtime.TripUpdate.StopTimeEvent.toObject(e.departure,t)),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),null!=e.scheduleRelationship&&e.hasOwnProperty("scheduleRelationship")&&(i.scheduleRelationship=t.enums===String?void 0===s.transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship[e.scheduleRelationship]?e.scheduleRelationship:s.transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship[e.scheduleRelationship]:e.scheduleRelationship),null!=e.stopTimeProperties&&e.hasOwnProperty("stopTimeProperties")&&(i.stopTimeProperties=s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.toObject(e.stopTimeProperties,t)),null!=e.departureOccupancyStatus&&e.hasOwnProperty("departureOccupancyStatus")&&(i.departureOccupancyStatus=t.enums===String?void 0===s.transit_realtime.VehiclePosition.OccupancyStatus[e.departureOccupancyStatus]?e.departureOccupancyStatus:s.transit_realtime.VehiclePosition.OccupancyStatus[e.departureOccupancyStatus]:e.departureOccupancyStatus),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripUpdate.StopTimeUpdate"},e.ScheduleRelationship=function(){var e={},t=Object.create(e);return t[e[0]="SCHEDULED"]=0,t[e[1]="SKIPPED"]=1,t[e[2]="NO_DATA"]=2,t[e[3]="UNSCHEDULED"]=3,t}(),e.StopTimeProperties=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.assignedStopId="",e.prototype.stopHeadsign="",e.prototype.pickupType=0,e.prototype.dropOffType=0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.assignedStopId&&Object.hasOwnProperty.call(e,"assignedStopId")&&t.uint32(10).string(e.assignedStopId),null!=e.stopHeadsign&&Object.hasOwnProperty.call(e,"stopHeadsign")&&t.uint32(18).string(e.stopHeadsign),null!=e.pickupType&&Object.hasOwnProperty.call(e,"pickupType")&&t.uint32(24).int32(e.pickupType),null!=e.dropOffType&&Object.hasOwnProperty.call(e,"dropOffType")&&t.uint32(32).int32(e.dropOffType),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.assignedStopId=e.string();continue;case 2:if(2!==d)break;c.stopHeadsign=e.string();continue;case 3:if(0!==d)break;c.pickupType=e.int32();continue;case 4:if(0!==d)break;c.dropOffType=e.int32();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.assignedStopId&&e.hasOwnProperty("assignedStopId")&&!r.isString(e.assignedStopId))return"assignedStopId: string expected";if(null!=e.stopHeadsign&&e.hasOwnProperty("stopHeadsign")&&!r.isString(e.stopHeadsign))return"stopHeadsign: string expected";if(null!=e.pickupType&&e.hasOwnProperty("pickupType"))switch(e.pickupType){default:return"pickupType: enum value expected";case 0:case 1:case 2:case 3:}if(null!=e.dropOffType&&e.hasOwnProperty("dropOffType"))switch(e.dropOffType){default:return"dropOffType: enum value expected";case 0:case 1:case 2:case 3:}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties;switch(null!=e.assignedStopId&&(i.assignedStopId=String(e.assignedStopId)),null!=e.stopHeadsign&&(i.stopHeadsign=String(e.stopHeadsign)),e.pickupType){default:if("number"==typeof e.pickupType){i.pickupType=e.pickupType;break}break;case"REGULAR":case 0:i.pickupType=0;break;case"NONE":case 1:i.pickupType=1;break;case"PHONE_AGENCY":case 2:i.pickupType=2;break;case"COORDINATE_WITH_DRIVER":case 3:i.pickupType=3}switch(e.dropOffType){default:if("number"==typeof e.dropOffType){i.dropOffType=e.dropOffType;break}break;case"REGULAR":case 0:i.dropOffType=0;break;case"NONE":case 1:i.dropOffType=1;break;case"PHONE_AGENCY":case 2:i.dropOffType=2;break;case"COORDINATE_WITH_DRIVER":case 3:i.dropOffType=3}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.assignedStopId="",i.stopHeadsign="",i.pickupType=t.enums===String?"REGULAR":0,i.dropOffType=t.enums===String?"REGULAR":0),null!=e.assignedStopId&&e.hasOwnProperty("assignedStopId")&&(i.assignedStopId=e.assignedStopId),null!=e.stopHeadsign&&e.hasOwnProperty("stopHeadsign")&&(i.stopHeadsign=e.stopHeadsign),null!=e.pickupType&&e.hasOwnProperty("pickupType")&&(i.pickupType=t.enums===String?void 0===s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType[e.pickupType]?e.pickupType:s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType[e.pickupType]:e.pickupType),null!=e.dropOffType&&e.hasOwnProperty("dropOffType")&&(i.dropOffType=t.enums===String?void 0===s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType[e.dropOffType]?e.dropOffType:s.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.DropOffPickupType[e.dropOffType]:e.dropOffType),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties"},e.DropOffPickupType=function(){var e={},t=Object.create(e);return t[e[0]="REGULAR"]=0,t[e[1]="NONE"]=1,t[e[2]="PHONE_AGENCY"]=2,t[e[3]="COORDINATE_WITH_DRIVER"]=3,t}(),e}(),e}(),e.TripProperties=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.tripId="",e.prototype.startDate="",e.prototype.startTime="",e.prototype.shapeId="",e.prototype.tripHeadsign="",e.prototype.tripShortName="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.tripId&&Object.hasOwnProperty.call(e,"tripId")&&t.uint32(10).string(e.tripId),null!=e.startDate&&Object.hasOwnProperty.call(e,"startDate")&&t.uint32(18).string(e.startDate),null!=e.startTime&&Object.hasOwnProperty.call(e,"startTime")&&t.uint32(26).string(e.startTime),null!=e.shapeId&&Object.hasOwnProperty.call(e,"shapeId")&&t.uint32(34).string(e.shapeId),null!=e.tripHeadsign&&Object.hasOwnProperty.call(e,"tripHeadsign")&&t.uint32(42).string(e.tripHeadsign),null!=e.tripShortName&&Object.hasOwnProperty.call(e,"tripShortName")&&t.uint32(50).string(e.tripShortName),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripUpdate.TripProperties;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.tripId=e.string();continue;case 2:if(2!==d)break;c.startDate=e.string();continue;case 3:if(2!==d)break;c.startTime=e.string();continue;case 4:if(2!==d)break;c.shapeId=e.string();continue;case 5:if(2!==d)break;c.tripHeadsign=e.string();continue;case 6:if(2!==d)break;c.tripShortName=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.tripId&&e.hasOwnProperty("tripId")&&!r.isString(e.tripId)?"tripId: string expected":null!=e.startDate&&e.hasOwnProperty("startDate")&&!r.isString(e.startDate)?"startDate: string expected":null!=e.startTime&&e.hasOwnProperty("startTime")&&!r.isString(e.startTime)?"startTime: string expected":null!=e.shapeId&&e.hasOwnProperty("shapeId")&&!r.isString(e.shapeId)?"shapeId: string expected":null!=e.tripHeadsign&&e.hasOwnProperty("tripHeadsign")&&!r.isString(e.tripHeadsign)?"tripHeadsign: string expected":null!=e.tripShortName&&e.hasOwnProperty("tripShortName")&&!r.isString(e.tripShortName)?"tripShortName: string expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripUpdate.TripProperties)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripUpdate.TripProperties;return null!=e.tripId&&(i.tripId=String(e.tripId)),null!=e.startDate&&(i.startDate=String(e.startDate)),null!=e.startTime&&(i.startTime=String(e.startTime)),null!=e.shapeId&&(i.shapeId=String(e.shapeId)),null!=e.tripHeadsign&&(i.tripHeadsign=String(e.tripHeadsign)),null!=e.tripShortName&&(i.tripShortName=String(e.tripShortName)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.tripId="",i.startDate="",i.startTime="",i.shapeId="",i.tripHeadsign="",i.tripShortName=""),null!=e.tripId&&e.hasOwnProperty("tripId")&&(i.tripId=e.tripId),null!=e.startDate&&e.hasOwnProperty("startDate")&&(i.startDate=e.startDate),null!=e.startTime&&e.hasOwnProperty("startTime")&&(i.startTime=e.startTime),null!=e.shapeId&&e.hasOwnProperty("shapeId")&&(i.shapeId=e.shapeId),null!=e.tripHeadsign&&e.hasOwnProperty("tripHeadsign")&&(i.tripHeadsign=e.tripHeadsign),null!=e.tripShortName&&e.hasOwnProperty("tripShortName")&&(i.tripShortName=e.tripShortName),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripUpdate.TripProperties"},e}(),e}(),e.VehiclePosition=function(){function e(e){if(this.multiCarriageDetails=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.trip=null,e.prototype.vehicle=null,e.prototype.position=null,e.prototype.currentStopSequence=0,e.prototype.stopId="",e.prototype.currentStatus=2,e.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,e.prototype.congestionLevel=0,e.prototype.occupancyStatus=0,e.prototype.occupancyPercentage=0,e.prototype.multiCarriageDetails=r.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.trip&&Object.hasOwnProperty.call(e,"trip")&&s.transit_realtime.TripDescriptor.encode(e.trip,t.uint32(10).fork()).ldelim(),null!=e.position&&Object.hasOwnProperty.call(e,"position")&&s.transit_realtime.Position.encode(e.position,t.uint32(18).fork()).ldelim(),null!=e.currentStopSequence&&Object.hasOwnProperty.call(e,"currentStopSequence")&&t.uint32(24).uint32(e.currentStopSequence),null!=e.currentStatus&&Object.hasOwnProperty.call(e,"currentStatus")&&t.uint32(32).int32(e.currentStatus),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(40).uint64(e.timestamp),null!=e.congestionLevel&&Object.hasOwnProperty.call(e,"congestionLevel")&&t.uint32(48).int32(e.congestionLevel),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(58).string(e.stopId),null!=e.vehicle&&Object.hasOwnProperty.call(e,"vehicle")&&s.transit_realtime.VehicleDescriptor.encode(e.vehicle,t.uint32(66).fork()).ldelim(),null!=e.occupancyStatus&&Object.hasOwnProperty.call(e,"occupancyStatus")&&t.uint32(72).int32(e.occupancyStatus),null!=e.occupancyPercentage&&Object.hasOwnProperty.call(e,"occupancyPercentage")&&t.uint32(80).uint32(e.occupancyPercentage),null!=e.multiCarriageDetails&&e.multiCarriageDetails.length)for(var i=0;i<e.multiCarriageDetails.length;++i)s.transit_realtime.VehiclePosition.CarriageDetails.encode(e.multiCarriageDetails[i],t.uint32(90).fork()).ldelim();if(null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.VehiclePosition;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.trip=s.transit_realtime.TripDescriptor.decode(e,e.uint32(),void 0,o+1,c.trip);continue;case 8:if(2!==d)break;c.vehicle=s.transit_realtime.VehicleDescriptor.decode(e,e.uint32(),void 0,o+1,c.vehicle);continue;case 2:if(2!==d)break;c.position=s.transit_realtime.Position.decode(e,e.uint32(),void 0,o+1,c.position);continue;case 3:if(0!==d)break;c.currentStopSequence=e.uint32();continue;case 7:if(2!==d)break;c.stopId=e.string();continue;case 4:if(0!==d)break;c.currentStatus=e.int32();continue;case 5:if(0!==d)break;c.timestamp=e.uint64();continue;case 6:if(0!==d)break;c.congestionLevel=e.int32();continue;case 9:if(0!==d)break;c.occupancyStatus=e.int32();continue;case 10:if(0!==d)break;c.occupancyPercentage=e.uint32();continue;case 11:if(2!==d)break;c.multiCarriageDetails&&c.multiCarriageDetails.length||(c.multiCarriageDetails=[]),c.multiCarriageDetails.push(s.transit_realtime.VehiclePosition.CarriageDetails.decode(e,e.uint32(),void 0,o+1));continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.trip&&e.hasOwnProperty("trip")&&(n=s.transit_realtime.TripDescriptor.verify(e.trip,t+1)))return"trip."+n;if(null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(n=s.transit_realtime.VehicleDescriptor.verify(e.vehicle,t+1)))return"vehicle."+n;if(null!=e.position&&e.hasOwnProperty("position")&&(n=s.transit_realtime.Position.verify(e.position,t+1)))return"position."+n;if(null!=e.currentStopSequence&&e.hasOwnProperty("currentStopSequence")&&!r.isInteger(e.currentStopSequence))return"currentStopSequence: integer expected";if(null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId))return"stopId: string expected";if(null!=e.currentStatus&&e.hasOwnProperty("currentStatus"))switch(e.currentStatus){default:return"currentStatus: enum value expected";case 0:case 1:case 2:}if(null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(r.isInteger(e.timestamp)||e.timestamp&&r.isInteger(e.timestamp.low)&&r.isInteger(e.timestamp.high)))return"timestamp: integer|Long expected";if(null!=e.congestionLevel&&e.hasOwnProperty("congestionLevel"))switch(e.congestionLevel){default:return"congestionLevel: enum value expected";case 0:case 1:case 2:case 3:case 4:}if(null!=e.occupancyStatus&&e.hasOwnProperty("occupancyStatus"))switch(e.occupancyStatus){default:return"occupancyStatus: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:}if(null!=e.occupancyPercentage&&e.hasOwnProperty("occupancyPercentage")&&!r.isInteger(e.occupancyPercentage))return"occupancyPercentage: integer expected";if(null!=e.multiCarriageDetails&&e.hasOwnProperty("multiCarriageDetails")){if(!Array.isArray(e.multiCarriageDetails))return"multiCarriageDetails: array expected";for(var i=0;i<e.multiCarriageDetails.length;++i){var n;if(n=s.transit_realtime.VehiclePosition.CarriageDetails.verify(e.multiCarriageDetails[i],t+1))return"multiCarriageDetails."+n}}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.VehiclePosition)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.VehiclePosition;if(null!=e.trip){if("object"!=typeof e.trip)throw TypeError(".transit_realtime.VehiclePosition.trip: object expected");i.trip=s.transit_realtime.TripDescriptor.fromObject(e.trip,t+1)}if(null!=e.vehicle){if("object"!=typeof e.vehicle)throw TypeError(".transit_realtime.VehiclePosition.vehicle: object expected");i.vehicle=s.transit_realtime.VehicleDescriptor.fromObject(e.vehicle,t+1)}if(null!=e.position){if("object"!=typeof e.position)throw TypeError(".transit_realtime.VehiclePosition.position: object expected");i.position=s.transit_realtime.Position.fromObject(e.position,t+1)}switch(null!=e.currentStopSequence&&(i.currentStopSequence=e.currentStopSequence>>>0),null!=e.stopId&&(i.stopId=String(e.stopId)),e.currentStatus){case"INCOMING_AT":case 0:i.currentStatus=0;break;case"STOPPED_AT":case 1:i.currentStatus=1;break;default:if("number"==typeof e.currentStatus){i.currentStatus=e.currentStatus;break}break;case"IN_TRANSIT_TO":case 2:i.currentStatus=2}switch(null!=e.timestamp&&(r.Long?(i.timestamp=r.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?i.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?i.timestamp=e.timestamp:"object"==typeof e.timestamp&&(i.timestamp=new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),e.congestionLevel){default:if("number"==typeof e.congestionLevel){i.congestionLevel=e.congestionLevel;break}break;case"UNKNOWN_CONGESTION_LEVEL":case 0:i.congestionLevel=0;break;case"RUNNING_SMOOTHLY":case 1:i.congestionLevel=1;break;case"STOP_AND_GO":case 2:i.congestionLevel=2;break;case"CONGESTION":case 3:i.congestionLevel=3;break;case"SEVERE_CONGESTION":case 4:i.congestionLevel=4}switch(e.occupancyStatus){default:if("number"==typeof e.occupancyStatus){i.occupancyStatus=e.occupancyStatus;break}break;case"EMPTY":case 0:i.occupancyStatus=0;break;case"MANY_SEATS_AVAILABLE":case 1:i.occupancyStatus=1;break;case"FEW_SEATS_AVAILABLE":case 2:i.occupancyStatus=2;break;case"STANDING_ROOM_ONLY":case 3:i.occupancyStatus=3;break;case"CRUSHED_STANDING_ROOM_ONLY":case 4:i.occupancyStatus=4;break;case"FULL":case 5:i.occupancyStatus=5;break;case"NOT_ACCEPTING_PASSENGERS":case 6:i.occupancyStatus=6;break;case"NO_DATA_AVAILABLE":case 7:i.occupancyStatus=7;break;case"NOT_BOARDABLE":case 8:i.occupancyStatus=8}if(null!=e.occupancyPercentage&&(i.occupancyPercentage=e.occupancyPercentage>>>0),e.multiCarriageDetails){if(!Array.isArray(e.multiCarriageDetails))throw TypeError(".transit_realtime.VehiclePosition.multiCarriageDetails: array expected");i.multiCarriageDetails=Array(e.multiCarriageDetails.length);for(var n=0;n<e.multiCarriageDetails.length;++n){if("object"!=typeof e.multiCarriageDetails[n])throw TypeError(".transit_realtime.VehiclePosition.multiCarriageDetails: object expected");i.multiCarriageDetails[n]=s.transit_realtime.VehiclePosition.CarriageDetails.fromObject(e.multiCarriageDetails[n],t+1)}}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.multiCarriageDetails=[]),t.defaults){if(i.trip=null,i.position=null,i.currentStopSequence=0,i.currentStatus=t.enums===String?"IN_TRANSIT_TO":2,r.Long){var n=new r.Long(0,0,!0);i.timestamp=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.timestamp=t.longs===String?"0":0;i.congestionLevel=t.enums===String?"UNKNOWN_CONGESTION_LEVEL":0,i.stopId="",i.vehicle=null,i.occupancyStatus=t.enums===String?"EMPTY":0,i.occupancyPercentage=0}if(null!=e.trip&&e.hasOwnProperty("trip")&&(i.trip=s.transit_realtime.TripDescriptor.toObject(e.trip,t)),null!=e.position&&e.hasOwnProperty("position")&&(i.position=s.transit_realtime.Position.toObject(e.position,t)),null!=e.currentStopSequence&&e.hasOwnProperty("currentStopSequence")&&(i.currentStopSequence=e.currentStopSequence),null!=e.currentStatus&&e.hasOwnProperty("currentStatus")&&(i.currentStatus=t.enums===String?void 0===s.transit_realtime.VehiclePosition.VehicleStopStatus[e.currentStatus]?e.currentStatus:s.transit_realtime.VehiclePosition.VehicleStopStatus[e.currentStatus]:e.currentStatus),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&(i.timestamp="number"==typeof e.timestamp?t.longs===String?String(e.timestamp):e.timestamp:t.longs===String?r.Long.prototype.toString.call(e.timestamp):t.longs===Number?new r.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),null!=e.congestionLevel&&e.hasOwnProperty("congestionLevel")&&(i.congestionLevel=t.enums===String?void 0===s.transit_realtime.VehiclePosition.CongestionLevel[e.congestionLevel]?e.congestionLevel:s.transit_realtime.VehiclePosition.CongestionLevel[e.congestionLevel]:e.congestionLevel),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),null!=e.vehicle&&e.hasOwnProperty("vehicle")&&(i.vehicle=s.transit_realtime.VehicleDescriptor.toObject(e.vehicle,t)),null!=e.occupancyStatus&&e.hasOwnProperty("occupancyStatus")&&(i.occupancyStatus=t.enums===String?void 0===s.transit_realtime.VehiclePosition.OccupancyStatus[e.occupancyStatus]?e.occupancyStatus:s.transit_realtime.VehiclePosition.OccupancyStatus[e.occupancyStatus]:e.occupancyStatus),null!=e.occupancyPercentage&&e.hasOwnProperty("occupancyPercentage")&&(i.occupancyPercentage=e.occupancyPercentage),e.multiCarriageDetails&&e.multiCarriageDetails.length){i.multiCarriageDetails=Array(e.multiCarriageDetails.length);for(var o=0;o<e.multiCarriageDetails.length;++o)i.multiCarriageDetails[o]=s.transit_realtime.VehiclePosition.CarriageDetails.toObject(e.multiCarriageDetails[o],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.VehiclePosition"},e.VehicleStopStatus=function(){var e={},t=Object.create(e);return t[e[0]="INCOMING_AT"]=0,t[e[1]="STOPPED_AT"]=1,t[e[2]="IN_TRANSIT_TO"]=2,t}(),e.CongestionLevel=function(){var e={},t=Object.create(e);return t[e[0]="UNKNOWN_CONGESTION_LEVEL"]=0,t[e[1]="RUNNING_SMOOTHLY"]=1,t[e[2]="STOP_AND_GO"]=2,t[e[3]="CONGESTION"]=3,t[e[4]="SEVERE_CONGESTION"]=4,t}(),e.OccupancyStatus=function(){var e={},t=Object.create(e);return t[e[0]="EMPTY"]=0,t[e[1]="MANY_SEATS_AVAILABLE"]=1,t[e[2]="FEW_SEATS_AVAILABLE"]=2,t[e[3]="STANDING_ROOM_ONLY"]=3,t[e[4]="CRUSHED_STANDING_ROOM_ONLY"]=4,t[e[5]="FULL"]=5,t[e[6]="NOT_ACCEPTING_PASSENGERS"]=6,t[e[7]="NO_DATA_AVAILABLE"]=7,t[e[8]="NOT_BOARDABLE"]=8,t}(),e.CarriageDetails=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.id="",e.prototype.label="",e.prototype.occupancyStatus=7,e.prototype.occupancyPercentage=-1,e.prototype.carriageSequence=0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.id&&Object.hasOwnProperty.call(e,"id")&&t.uint32(10).string(e.id),null!=e.label&&Object.hasOwnProperty.call(e,"label")&&t.uint32(18).string(e.label),null!=e.occupancyStatus&&Object.hasOwnProperty.call(e,"occupancyStatus")&&t.uint32(24).int32(e.occupancyStatus),null!=e.occupancyPercentage&&Object.hasOwnProperty.call(e,"occupancyPercentage")&&t.uint32(32).int32(e.occupancyPercentage),null!=e.carriageSequence&&Object.hasOwnProperty.call(e,"carriageSequence")&&t.uint32(40).uint32(e.carriageSequence),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.VehiclePosition.CarriageDetails;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.id=e.string();continue;case 2:if(2!==d)break;c.label=e.string();continue;case 3:if(0!==d)break;c.occupancyStatus=e.int32();continue;case 4:if(0!==d)break;c.occupancyPercentage=e.int32();continue;case 5:if(0!==d)break;c.carriageSequence=e.uint32();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.id&&e.hasOwnProperty("id")&&!r.isString(e.id))return"id: string expected";if(null!=e.label&&e.hasOwnProperty("label")&&!r.isString(e.label))return"label: string expected";if(null!=e.occupancyStatus&&e.hasOwnProperty("occupancyStatus"))switch(e.occupancyStatus){default:return"occupancyStatus: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:}return null!=e.occupancyPercentage&&e.hasOwnProperty("occupancyPercentage")&&!r.isInteger(e.occupancyPercentage)?"occupancyPercentage: integer expected":null!=e.carriageSequence&&e.hasOwnProperty("carriageSequence")&&!r.isInteger(e.carriageSequence)?"carriageSequence: integer expected":null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.VehiclePosition.CarriageDetails)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.VehiclePosition.CarriageDetails;switch(null!=e.id&&(i.id=String(e.id)),null!=e.label&&(i.label=String(e.label)),e.occupancyStatus){case"EMPTY":case 0:i.occupancyStatus=0;break;case"MANY_SEATS_AVAILABLE":case 1:i.occupancyStatus=1;break;case"FEW_SEATS_AVAILABLE":case 2:i.occupancyStatus=2;break;case"STANDING_ROOM_ONLY":case 3:i.occupancyStatus=3;break;case"CRUSHED_STANDING_ROOM_ONLY":case 4:i.occupancyStatus=4;break;case"FULL":case 5:i.occupancyStatus=5;break;case"NOT_ACCEPTING_PASSENGERS":case 6:i.occupancyStatus=6;break;default:if("number"==typeof e.occupancyStatus){i.occupancyStatus=e.occupancyStatus;break}break;case"NO_DATA_AVAILABLE":case 7:i.occupancyStatus=7;break;case"NOT_BOARDABLE":case 8:i.occupancyStatus=8}return null!=e.occupancyPercentage&&(i.occupancyPercentage=0|e.occupancyPercentage),null!=e.carriageSequence&&(i.carriageSequence=e.carriageSequence>>>0),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.id="",i.label="",i.occupancyStatus=t.enums===String?"NO_DATA_AVAILABLE":7,i.occupancyPercentage=-1,i.carriageSequence=0),null!=e.id&&e.hasOwnProperty("id")&&(i.id=e.id),null!=e.label&&e.hasOwnProperty("label")&&(i.label=e.label),null!=e.occupancyStatus&&e.hasOwnProperty("occupancyStatus")&&(i.occupancyStatus=t.enums===String?void 0===s.transit_realtime.VehiclePosition.OccupancyStatus[e.occupancyStatus]?e.occupancyStatus:s.transit_realtime.VehiclePosition.OccupancyStatus[e.occupancyStatus]:e.occupancyStatus),null!=e.occupancyPercentage&&e.hasOwnProperty("occupancyPercentage")&&(i.occupancyPercentage=e.occupancyPercentage),null!=e.carriageSequence&&e.hasOwnProperty("carriageSequence")&&(i.carriageSequence=e.carriageSequence),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.VehiclePosition.CarriageDetails"},e}(),e}(),e.Alert=function(){function e(e){if(this.activePeriod=[],this.communicationPeriod=[],this.impactPeriod=[],this.informedEntity=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.activePeriod=r.emptyArray,e.prototype.communicationPeriod=r.emptyArray,e.prototype.impactPeriod=r.emptyArray,e.prototype.informedEntity=r.emptyArray,e.prototype.cause=1,e.prototype.effect=8,e.prototype.url=null,e.prototype.headerText=null,e.prototype.descriptionText=null,e.prototype.ttsHeaderText=null,e.prototype.ttsDescriptionText=null,e.prototype.severityLevel=1,e.prototype.image=null,e.prototype.imageAlternativeText=null,e.prototype.causeDetail=null,e.prototype.effectDetail=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.activePeriod&&e.activePeriod.length)for(var i=0;i<e.activePeriod.length;++i)s.transit_realtime.TimeRange.encode(e.activePeriod[i],t.uint32(10).fork()).ldelim();if(null!=e.communicationPeriod&&e.communicationPeriod.length)for(i=0;i<e.communicationPeriod.length;++i)s.transit_realtime.TimeRange.encode(e.communicationPeriod[i],t.uint32(18).fork()).ldelim();if(null!=e.impactPeriod&&e.impactPeriod.length)for(i=0;i<e.impactPeriod.length;++i)s.transit_realtime.TimeRange.encode(e.impactPeriod[i],t.uint32(26).fork()).ldelim();if(null!=e.informedEntity&&e.informedEntity.length)for(i=0;i<e.informedEntity.length;++i)s.transit_realtime.EntitySelector.encode(e.informedEntity[i],t.uint32(42).fork()).ldelim();if(null!=e.cause&&Object.hasOwnProperty.call(e,"cause")&&t.uint32(48).int32(e.cause),null!=e.effect&&Object.hasOwnProperty.call(e,"effect")&&t.uint32(56).int32(e.effect),null!=e.url&&Object.hasOwnProperty.call(e,"url")&&s.transit_realtime.TranslatedString.encode(e.url,t.uint32(66).fork()).ldelim(),null!=e.headerText&&Object.hasOwnProperty.call(e,"headerText")&&s.transit_realtime.TranslatedString.encode(e.headerText,t.uint32(82).fork()).ldelim(),null!=e.descriptionText&&Object.hasOwnProperty.call(e,"descriptionText")&&s.transit_realtime.TranslatedString.encode(e.descriptionText,t.uint32(90).fork()).ldelim(),null!=e.ttsHeaderText&&Object.hasOwnProperty.call(e,"ttsHeaderText")&&s.transit_realtime.TranslatedString.encode(e.ttsHeaderText,t.uint32(98).fork()).ldelim(),null!=e.ttsDescriptionText&&Object.hasOwnProperty.call(e,"ttsDescriptionText")&&s.transit_realtime.TranslatedString.encode(e.ttsDescriptionText,t.uint32(106).fork()).ldelim(),null!=e.severityLevel&&Object.hasOwnProperty.call(e,"severityLevel")&&t.uint32(112).int32(e.severityLevel),null!=e.image&&Object.hasOwnProperty.call(e,"image")&&s.transit_realtime.TranslatedImage.encode(e.image,t.uint32(122).fork()).ldelim(),null!=e.imageAlternativeText&&Object.hasOwnProperty.call(e,"imageAlternativeText")&&s.transit_realtime.TranslatedString.encode(e.imageAlternativeText,t.uint32(130).fork()).ldelim(),null!=e.causeDetail&&Object.hasOwnProperty.call(e,"causeDetail")&&s.transit_realtime.TranslatedString.encode(e.causeDetail,t.uint32(138).fork()).ldelim(),null!=e.effectDetail&&Object.hasOwnProperty.call(e,"effectDetail")&&s.transit_realtime.TranslatedString.encode(e.effectDetail,t.uint32(146).fork()).ldelim(),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.Alert;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.activePeriod&&c.activePeriod.length||(c.activePeriod=[]),c.activePeriod.push(s.transit_realtime.TimeRange.decode(e,e.uint32(),void 0,o+1));continue;case 2:if(2!==d)break;c.communicationPeriod&&c.communicationPeriod.length||(c.communicationPeriod=[]),c.communicationPeriod.push(s.transit_realtime.TimeRange.decode(e,e.uint32(),void 0,o+1));continue;case 3:if(2!==d)break;c.impactPeriod&&c.impactPeriod.length||(c.impactPeriod=[]),c.impactPeriod.push(s.transit_realtime.TimeRange.decode(e,e.uint32(),void 0,o+1));continue;case 5:if(2!==d)break;c.informedEntity&&c.informedEntity.length||(c.informedEntity=[]),c.informedEntity.push(s.transit_realtime.EntitySelector.decode(e,e.uint32(),void 0,o+1));continue;case 6:if(0!==d)break;c.cause=e.int32();continue;case 7:if(0!==d)break;c.effect=e.int32();continue;case 8:if(2!==d)break;c.url=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.url);continue;case 10:if(2!==d)break;c.headerText=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.headerText);continue;case 11:if(2!==d)break;c.descriptionText=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.descriptionText);continue;case 12:if(2!==d)break;c.ttsHeaderText=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.ttsHeaderText);continue;case 13:if(2!==d)break;c.ttsDescriptionText=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.ttsDescriptionText);continue;case 14:if(0!==d)break;c.severityLevel=e.int32();continue;case 15:if(2!==d)break;c.image=s.transit_realtime.TranslatedImage.decode(e,e.uint32(),void 0,o+1,c.image);continue;case 16:if(2!==d)break;c.imageAlternativeText=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.imageAlternativeText);continue;case 17:if(2!==d)break;c.causeDetail=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.causeDetail);continue;case 18:if(2!==d)break;c.effectDetail=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.effectDetail);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.activePeriod&&e.hasOwnProperty("activePeriod")){if(!Array.isArray(e.activePeriod))return"activePeriod: array expected";for(var i=0;i<e.activePeriod.length;++i)if(n=s.transit_realtime.TimeRange.verify(e.activePeriod[i],t+1))return"activePeriod."+n}if(null!=e.communicationPeriod&&e.hasOwnProperty("communicationPeriod")){if(!Array.isArray(e.communicationPeriod))return"communicationPeriod: array expected";for(i=0;i<e.communicationPeriod.length;++i)if(n=s.transit_realtime.TimeRange.verify(e.communicationPeriod[i],t+1))return"communicationPeriod."+n}if(null!=e.impactPeriod&&e.hasOwnProperty("impactPeriod")){if(!Array.isArray(e.impactPeriod))return"impactPeriod: array expected";for(i=0;i<e.impactPeriod.length;++i)if(n=s.transit_realtime.TimeRange.verify(e.impactPeriod[i],t+1))return"impactPeriod."+n}if(null!=e.informedEntity&&e.hasOwnProperty("informedEntity")){if(!Array.isArray(e.informedEntity))return"informedEntity: array expected";for(i=0;i<e.informedEntity.length;++i)if(n=s.transit_realtime.EntitySelector.verify(e.informedEntity[i],t+1))return"informedEntity."+n}if(null!=e.cause&&e.hasOwnProperty("cause"))switch(e.cause){default:return"cause: enum value expected";case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:}if(null!=e.effect&&e.hasOwnProperty("effect"))switch(e.effect){default:return"effect: enum value expected";case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:}var n;if(null!=e.url&&e.hasOwnProperty("url")&&(n=s.transit_realtime.TranslatedString.verify(e.url,t+1)))return"url."+n;if(null!=e.headerText&&e.hasOwnProperty("headerText")&&(n=s.transit_realtime.TranslatedString.verify(e.headerText,t+1)))return"headerText."+n;if(null!=e.descriptionText&&e.hasOwnProperty("descriptionText")&&(n=s.transit_realtime.TranslatedString.verify(e.descriptionText,t+1)))return"descriptionText."+n;if(null!=e.ttsHeaderText&&e.hasOwnProperty("ttsHeaderText")&&(n=s.transit_realtime.TranslatedString.verify(e.ttsHeaderText,t+1)))return"ttsHeaderText."+n;if(null!=e.ttsDescriptionText&&e.hasOwnProperty("ttsDescriptionText")&&(n=s.transit_realtime.TranslatedString.verify(e.ttsDescriptionText,t+1)))return"ttsDescriptionText."+n;if(null!=e.severityLevel&&e.hasOwnProperty("severityLevel"))switch(e.severityLevel){default:return"severityLevel: enum value expected";case 1:case 2:case 3:case 4:}return null!=e.image&&e.hasOwnProperty("image")&&(n=s.transit_realtime.TranslatedImage.verify(e.image,t+1))?"image."+n:null!=e.imageAlternativeText&&e.hasOwnProperty("imageAlternativeText")&&(n=s.transit_realtime.TranslatedString.verify(e.imageAlternativeText,t+1))?"imageAlternativeText."+n:null!=e.causeDetail&&e.hasOwnProperty("causeDetail")&&(n=s.transit_realtime.TranslatedString.verify(e.causeDetail,t+1))?"causeDetail."+n:null!=e.effectDetail&&e.hasOwnProperty("effectDetail")&&(n=s.transit_realtime.TranslatedString.verify(e.effectDetail,t+1))?"effectDetail."+n:null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.Alert)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.Alert;if(e.activePeriod){if(!Array.isArray(e.activePeriod))throw TypeError(".transit_realtime.Alert.activePeriod: array expected");i.activePeriod=Array(e.activePeriod.length);for(var n=0;n<e.activePeriod.length;++n){if("object"!=typeof e.activePeriod[n])throw TypeError(".transit_realtime.Alert.activePeriod: object expected");i.activePeriod[n]=s.transit_realtime.TimeRange.fromObject(e.activePeriod[n],t+1)}}if(e.communicationPeriod){if(!Array.isArray(e.communicationPeriod))throw TypeError(".transit_realtime.Alert.communicationPeriod: array expected");for(i.communicationPeriod=Array(e.communicationPeriod.length),n=0;n<e.communicationPeriod.length;++n){if("object"!=typeof e.communicationPeriod[n])throw TypeError(".transit_realtime.Alert.communicationPeriod: object expected");i.communicationPeriod[n]=s.transit_realtime.TimeRange.fromObject(e.communicationPeriod[n],t+1)}}if(e.impactPeriod){if(!Array.isArray(e.impactPeriod))throw TypeError(".transit_realtime.Alert.impactPeriod: array expected");for(i.impactPeriod=Array(e.impactPeriod.length),n=0;n<e.impactPeriod.length;++n){if("object"!=typeof e.impactPeriod[n])throw TypeError(".transit_realtime.Alert.impactPeriod: object expected");i.impactPeriod[n]=s.transit_realtime.TimeRange.fromObject(e.impactPeriod[n],t+1)}}if(e.informedEntity){if(!Array.isArray(e.informedEntity))throw TypeError(".transit_realtime.Alert.informedEntity: array expected");for(i.informedEntity=Array(e.informedEntity.length),n=0;n<e.informedEntity.length;++n){if("object"!=typeof e.informedEntity[n])throw TypeError(".transit_realtime.Alert.informedEntity: object expected");i.informedEntity[n]=s.transit_realtime.EntitySelector.fromObject(e.informedEntity[n],t+1)}}switch(e.cause){default:if("number"==typeof e.cause){i.cause=e.cause;break}break;case"UNKNOWN_CAUSE":case 1:i.cause=1;break;case"OTHER_CAUSE":case 2:i.cause=2;break;case"TECHNICAL_PROBLEM":case 3:i.cause=3;break;case"STRIKE":case 4:i.cause=4;break;case"DEMONSTRATION":case 5:i.cause=5;break;case"ACCIDENT":case 6:i.cause=6;break;case"HOLIDAY":case 7:i.cause=7;break;case"WEATHER":case 8:i.cause=8;break;case"MAINTENANCE":case 9:i.cause=9;break;case"CONSTRUCTION":case 10:i.cause=10;break;case"POLICE_ACTIVITY":case 11:i.cause=11;break;case"MEDICAL_EMERGENCY":case 12:i.cause=12;break;case"SPECIAL_EVENT":case 13:i.cause=13}switch(e.effect){case"NO_SERVICE":case 1:i.effect=1;break;case"REDUCED_SERVICE":case 2:i.effect=2;break;case"SIGNIFICANT_DELAYS":case 3:i.effect=3;break;case"DETOUR":case 4:i.effect=4;break;case"ADDITIONAL_SERVICE":case 5:i.effect=5;break;case"MODIFIED_SERVICE":case 6:i.effect=6;break;case"OTHER_EFFECT":case 7:i.effect=7;break;default:if("number"==typeof e.effect){i.effect=e.effect;break}break;case"UNKNOWN_EFFECT":case 8:i.effect=8;break;case"STOP_MOVED":case 9:i.effect=9;break;case"NO_EFFECT":case 10:i.effect=10;break;case"ACCESSIBILITY_ISSUE":case 11:i.effect=11}if(null!=e.url){if("object"!=typeof e.url)throw TypeError(".transit_realtime.Alert.url: object expected");i.url=s.transit_realtime.TranslatedString.fromObject(e.url,t+1)}if(null!=e.headerText){if("object"!=typeof e.headerText)throw TypeError(".transit_realtime.Alert.headerText: object expected");i.headerText=s.transit_realtime.TranslatedString.fromObject(e.headerText,t+1)}if(null!=e.descriptionText){if("object"!=typeof e.descriptionText)throw TypeError(".transit_realtime.Alert.descriptionText: object expected");i.descriptionText=s.transit_realtime.TranslatedString.fromObject(e.descriptionText,t+1)}if(null!=e.ttsHeaderText){if("object"!=typeof e.ttsHeaderText)throw TypeError(".transit_realtime.Alert.ttsHeaderText: object expected");i.ttsHeaderText=s.transit_realtime.TranslatedString.fromObject(e.ttsHeaderText,t+1)}if(null!=e.ttsDescriptionText){if("object"!=typeof e.ttsDescriptionText)throw TypeError(".transit_realtime.Alert.ttsDescriptionText: object expected");i.ttsDescriptionText=s.transit_realtime.TranslatedString.fromObject(e.ttsDescriptionText,t+1)}switch(e.severityLevel){default:if("number"==typeof e.severityLevel){i.severityLevel=e.severityLevel;break}break;case"UNKNOWN_SEVERITY":case 1:i.severityLevel=1;break;case"INFO":case 2:i.severityLevel=2;break;case"WARNING":case 3:i.severityLevel=3;break;case"SEVERE":case 4:i.severityLevel=4}if(null!=e.image){if("object"!=typeof e.image)throw TypeError(".transit_realtime.Alert.image: object expected");i.image=s.transit_realtime.TranslatedImage.fromObject(e.image,t+1)}if(null!=e.imageAlternativeText){if("object"!=typeof e.imageAlternativeText)throw TypeError(".transit_realtime.Alert.imageAlternativeText: object expected");i.imageAlternativeText=s.transit_realtime.TranslatedString.fromObject(e.imageAlternativeText,t+1)}if(null!=e.causeDetail){if("object"!=typeof e.causeDetail)throw TypeError(".transit_realtime.Alert.causeDetail: object expected");i.causeDetail=s.transit_realtime.TranslatedString.fromObject(e.causeDetail,t+1)}if(null!=e.effectDetail){if("object"!=typeof e.effectDetail)throw TypeError(".transit_realtime.Alert.effectDetail: object expected");i.effectDetail=s.transit_realtime.TranslatedString.fromObject(e.effectDetail,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.activePeriod=[],i.communicationPeriod=[],i.impactPeriod=[],i.informedEntity=[]),t.defaults&&(i.cause=t.enums===String?"UNKNOWN_CAUSE":1,i.effect=t.enums===String?"UNKNOWN_EFFECT":8,i.url=null,i.headerText=null,i.descriptionText=null,i.ttsHeaderText=null,i.ttsDescriptionText=null,i.severityLevel=t.enums===String?"UNKNOWN_SEVERITY":1,i.image=null,i.imageAlternativeText=null,i.causeDetail=null,i.effectDetail=null),e.activePeriod&&e.activePeriod.length){i.activePeriod=Array(e.activePeriod.length);for(var n=0;n<e.activePeriod.length;++n)i.activePeriod[n]=s.transit_realtime.TimeRange.toObject(e.activePeriod[n],t)}if(e.communicationPeriod&&e.communicationPeriod.length)for(i.communicationPeriod=Array(e.communicationPeriod.length),n=0;n<e.communicationPeriod.length;++n)i.communicationPeriod[n]=s.transit_realtime.TimeRange.toObject(e.communicationPeriod[n],t);if(e.impactPeriod&&e.impactPeriod.length)for(i.impactPeriod=Array(e.impactPeriod.length),n=0;n<e.impactPeriod.length;++n)i.impactPeriod[n]=s.transit_realtime.TimeRange.toObject(e.impactPeriod[n],t);if(e.informedEntity&&e.informedEntity.length)for(i.informedEntity=Array(e.informedEntity.length),n=0;n<e.informedEntity.length;++n)i.informedEntity[n]=s.transit_realtime.EntitySelector.toObject(e.informedEntity[n],t);return null!=e.cause&&e.hasOwnProperty("cause")&&(i.cause=t.enums===String?void 0===s.transit_realtime.Alert.Cause[e.cause]?e.cause:s.transit_realtime.Alert.Cause[e.cause]:e.cause),null!=e.effect&&e.hasOwnProperty("effect")&&(i.effect=t.enums===String?void 0===s.transit_realtime.Alert.Effect[e.effect]?e.effect:s.transit_realtime.Alert.Effect[e.effect]:e.effect),null!=e.url&&e.hasOwnProperty("url")&&(i.url=s.transit_realtime.TranslatedString.toObject(e.url,t)),null!=e.headerText&&e.hasOwnProperty("headerText")&&(i.headerText=s.transit_realtime.TranslatedString.toObject(e.headerText,t)),null!=e.descriptionText&&e.hasOwnProperty("descriptionText")&&(i.descriptionText=s.transit_realtime.TranslatedString.toObject(e.descriptionText,t)),null!=e.ttsHeaderText&&e.hasOwnProperty("ttsHeaderText")&&(i.ttsHeaderText=s.transit_realtime.TranslatedString.toObject(e.ttsHeaderText,t)),null!=e.ttsDescriptionText&&e.hasOwnProperty("ttsDescriptionText")&&(i.ttsDescriptionText=s.transit_realtime.TranslatedString.toObject(e.ttsDescriptionText,t)),null!=e.severityLevel&&e.hasOwnProperty("severityLevel")&&(i.severityLevel=t.enums===String?void 0===s.transit_realtime.Alert.SeverityLevel[e.severityLevel]?e.severityLevel:s.transit_realtime.Alert.SeverityLevel[e.severityLevel]:e.severityLevel),null!=e.image&&e.hasOwnProperty("image")&&(i.image=s.transit_realtime.TranslatedImage.toObject(e.image,t)),null!=e.imageAlternativeText&&e.hasOwnProperty("imageAlternativeText")&&(i.imageAlternativeText=s.transit_realtime.TranslatedString.toObject(e.imageAlternativeText,t)),null!=e.causeDetail&&e.hasOwnProperty("causeDetail")&&(i.causeDetail=s.transit_realtime.TranslatedString.toObject(e.causeDetail,t)),null!=e.effectDetail&&e.hasOwnProperty("effectDetail")&&(i.effectDetail=s.transit_realtime.TranslatedString.toObject(e.effectDetail,t)),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.Alert"},e.Cause=function(){var e={},t=Object.create(e);return t[e[1]="UNKNOWN_CAUSE"]=1,t[e[2]="OTHER_CAUSE"]=2,t[e[3]="TECHNICAL_PROBLEM"]=3,t[e[4]="STRIKE"]=4,t[e[5]="DEMONSTRATION"]=5,t[e[6]="ACCIDENT"]=6,t[e[7]="HOLIDAY"]=7,t[e[8]="WEATHER"]=8,t[e[9]="MAINTENANCE"]=9,t[e[10]="CONSTRUCTION"]=10,t[e[11]="POLICE_ACTIVITY"]=11,t[e[12]="MEDICAL_EMERGENCY"]=12,t[e[13]="SPECIAL_EVENT"]=13,t}(),e.Effect=function(){var e={},t=Object.create(e);return t[e[1]="NO_SERVICE"]=1,t[e[2]="REDUCED_SERVICE"]=2,t[e[3]="SIGNIFICANT_DELAYS"]=3,t[e[4]="DETOUR"]=4,t[e[5]="ADDITIONAL_SERVICE"]=5,t[e[6]="MODIFIED_SERVICE"]=6,t[e[7]="OTHER_EFFECT"]=7,t[e[8]="UNKNOWN_EFFECT"]=8,t[e[9]="STOP_MOVED"]=9,t[e[10]="NO_EFFECT"]=10,t[e[11]="ACCESSIBILITY_ISSUE"]=11,t}(),e.SeverityLevel=function(){var e={},t=Object.create(e);return t[e[1]="UNKNOWN_SEVERITY"]=1,t[e[2]="INFO"]=2,t[e[3]="WARNING"]=3,t[e[4]="SEVERE"]=4,t}(),e}(),e.TimeRange=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.start=r.Long?r.Long.fromBits(0,0,!0):0,e.prototype.end=r.Long?r.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.start&&Object.hasOwnProperty.call(e,"start")&&t.uint32(8).uint64(e.start),null!=e.end&&Object.hasOwnProperty.call(e,"end")&&t.uint32(16).uint64(e.end),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TimeRange;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(0!==d)break;c.start=e.uint64();continue;case 2:if(0!==d)break;c.end=e.uint64();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.start&&e.hasOwnProperty("start")&&!(r.isInteger(e.start)||e.start&&r.isInteger(e.start.low)&&r.isInteger(e.start.high))?"start: integer|Long expected":null!=e.end&&e.hasOwnProperty("end")&&!(r.isInteger(e.end)||e.end&&r.isInteger(e.end.low)&&r.isInteger(e.end.high))?"end: integer|Long expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TimeRange)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TimeRange;return null!=e.start&&(r.Long?(i.start=r.Long.fromValue(e.start)).unsigned=!0:"string"==typeof e.start?i.start=parseInt(e.start,10):"number"==typeof e.start?i.start=e.start:"object"==typeof e.start&&(i.start=new r.LongBits(e.start.low>>>0,e.start.high>>>0).toNumber(!0))),null!=e.end&&(r.Long?(i.end=r.Long.fromValue(e.end)).unsigned=!0:"string"==typeof e.end?i.end=parseInt(e.end,10):"number"==typeof e.end?i.end=e.end:"object"==typeof e.end&&(i.end=new r.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber(!0))),i},e.toObject=function(e,t){t||(t={});var i={};if(t.defaults){if(r.Long){var n=new r.Long(0,0,!0);i.start=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.start=t.longs===String?"0":0;r.Long?(n=new r.Long(0,0,!0),i.end=t.longs===String?n.toString():t.longs===Number?n.toNumber():n):i.end=t.longs===String?"0":0}return null!=e.start&&e.hasOwnProperty("start")&&(i.start="number"==typeof e.start?t.longs===String?String(e.start):e.start:t.longs===String?r.Long.prototype.toString.call(e.start):t.longs===Number?new r.LongBits(e.start.low>>>0,e.start.high>>>0).toNumber(!0):e.start),null!=e.end&&e.hasOwnProperty("end")&&(i.end="number"==typeof e.end?t.longs===String?String(e.end):e.end:t.longs===String?r.Long.prototype.toString.call(e.end):t.longs===Number?new r.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber(!0):e.end),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TimeRange"},e}(),e.Position=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.latitude=0,e.prototype.longitude=0,e.prototype.bearing=0,e.prototype.odometer=0,e.prototype.speed=0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),t.uint32(13).float(e.latitude),t.uint32(21).float(e.longitude),null!=e.bearing&&Object.hasOwnProperty.call(e,"bearing")&&t.uint32(29).float(e.bearing),null!=e.odometer&&Object.hasOwnProperty.call(e,"odometer")&&t.uint32(33).double(e.odometer),null!=e.speed&&Object.hasOwnProperty.call(e,"speed")&&t.uint32(45).float(e.speed),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.Position;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(5!==d)break;c.latitude=e.float();continue;case 2:if(5!==d)break;c.longitude=e.float();continue;case 3:if(5!==d)break;c.bearing=e.float();continue;case 4:if(1!==d)break;c.odometer=e.double();continue;case 5:if(5!==d)break;c.speed=e.float();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("latitude"))throw r.ProtocolError("missing required 'latitude'",{instance:c});if(!c.hasOwnProperty("longitude"))throw r.ProtocolError("missing required 'longitude'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":"number"!=typeof e.latitude?"latitude: number expected":"number"!=typeof e.longitude?"longitude: number expected":null!=e.bearing&&e.hasOwnProperty("bearing")&&"number"!=typeof e.bearing?"bearing: number expected":null!=e.odometer&&e.hasOwnProperty("odometer")&&"number"!=typeof e.odometer?"odometer: number expected":null!=e.speed&&e.hasOwnProperty("speed")&&"number"!=typeof e.speed?"speed: number expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.Position)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.Position;return null!=e.latitude&&(i.latitude=Number(e.latitude)),null!=e.longitude&&(i.longitude=Number(e.longitude)),null!=e.bearing&&(i.bearing=Number(e.bearing)),null!=e.odometer&&(i.odometer=Number(e.odometer)),null!=e.speed&&(i.speed=Number(e.speed)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.latitude=0,i.longitude=0,i.bearing=0,i.odometer=0,i.speed=0),null!=e.latitude&&e.hasOwnProperty("latitude")&&(i.latitude=t.json&&!isFinite(e.latitude)?String(e.latitude):e.latitude),null!=e.longitude&&e.hasOwnProperty("longitude")&&(i.longitude=t.json&&!isFinite(e.longitude)?String(e.longitude):e.longitude),null!=e.bearing&&e.hasOwnProperty("bearing")&&(i.bearing=t.json&&!isFinite(e.bearing)?String(e.bearing):e.bearing),null!=e.odometer&&e.hasOwnProperty("odometer")&&(i.odometer=t.json&&!isFinite(e.odometer)?String(e.odometer):e.odometer),null!=e.speed&&e.hasOwnProperty("speed")&&(i.speed=t.json&&!isFinite(e.speed)?String(e.speed):e.speed),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.Position"},e}(),e.TripDescriptor=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.tripId="",e.prototype.routeId="",e.prototype.directionId=0,e.prototype.startTime="",e.prototype.startDate="",e.prototype.scheduleRelationship=0,e.prototype.modifiedTrip=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.tripId&&Object.hasOwnProperty.call(e,"tripId")&&t.uint32(10).string(e.tripId),null!=e.startTime&&Object.hasOwnProperty.call(e,"startTime")&&t.uint32(18).string(e.startTime),null!=e.startDate&&Object.hasOwnProperty.call(e,"startDate")&&t.uint32(26).string(e.startDate),null!=e.scheduleRelationship&&Object.hasOwnProperty.call(e,"scheduleRelationship")&&t.uint32(32).int32(e.scheduleRelationship),null!=e.routeId&&Object.hasOwnProperty.call(e,"routeId")&&t.uint32(42).string(e.routeId),null!=e.directionId&&Object.hasOwnProperty.call(e,"directionId")&&t.uint32(48).uint32(e.directionId),null!=e.modifiedTrip&&Object.hasOwnProperty.call(e,"modifiedTrip")&&s.transit_realtime.TripDescriptor.ModifiedTripSelector.encode(e.modifiedTrip,t.uint32(58).fork()).ldelim(),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripDescriptor;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.tripId=e.string();continue;case 5:if(2!==d)break;c.routeId=e.string();continue;case 6:if(0!==d)break;c.directionId=e.uint32();continue;case 2:if(2!==d)break;c.startTime=e.string();continue;case 3:if(2!==d)break;c.startDate=e.string();continue;case 4:if(0!==d)break;c.scheduleRelationship=e.int32();continue;case 7:if(2!==d)break;c.modifiedTrip=s.transit_realtime.TripDescriptor.ModifiedTripSelector.decode(e,e.uint32(),void 0,o+1,c.modifiedTrip);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.tripId&&e.hasOwnProperty("tripId")&&!r.isString(e.tripId))return"tripId: string expected";if(null!=e.routeId&&e.hasOwnProperty("routeId")&&!r.isString(e.routeId))return"routeId: string expected";if(null!=e.directionId&&e.hasOwnProperty("directionId")&&!r.isInteger(e.directionId))return"directionId: integer expected";if(null!=e.startTime&&e.hasOwnProperty("startTime")&&!r.isString(e.startTime))return"startTime: string expected";if(null!=e.startDate&&e.hasOwnProperty("startDate")&&!r.isString(e.startDate))return"startDate: string expected";if(null!=e.scheduleRelationship&&e.hasOwnProperty("scheduleRelationship"))switch(e.scheduleRelationship){default:return"scheduleRelationship: enum value expected";case 0:case 1:case 2:case 3:case 5:case 6:case 7:case 8:}if(null!=e.modifiedTrip&&e.hasOwnProperty("modifiedTrip")){var i=s.transit_realtime.TripDescriptor.ModifiedTripSelector.verify(e.modifiedTrip,t+1);if(i)return"modifiedTrip."+i}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripDescriptor)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripDescriptor;switch(null!=e.tripId&&(i.tripId=String(e.tripId)),null!=e.routeId&&(i.routeId=String(e.routeId)),null!=e.directionId&&(i.directionId=e.directionId>>>0),null!=e.startTime&&(i.startTime=String(e.startTime)),null!=e.startDate&&(i.startDate=String(e.startDate)),e.scheduleRelationship){default:if("number"==typeof e.scheduleRelationship){i.scheduleRelationship=e.scheduleRelationship;break}break;case"SCHEDULED":case 0:i.scheduleRelationship=0;break;case"ADDED":case 1:i.scheduleRelationship=1;break;case"UNSCHEDULED":case 2:i.scheduleRelationship=2;break;case"CANCELED":case 3:i.scheduleRelationship=3;break;case"REPLACEMENT":case 5:i.scheduleRelationship=5;break;case"DUPLICATED":case 6:i.scheduleRelationship=6;break;case"DELETED":case 7:i.scheduleRelationship=7;break;case"NEW":case 8:i.scheduleRelationship=8}if(null!=e.modifiedTrip){if("object"!=typeof e.modifiedTrip)throw TypeError(".transit_realtime.TripDescriptor.modifiedTrip: object expected");i.modifiedTrip=s.transit_realtime.TripDescriptor.ModifiedTripSelector.fromObject(e.modifiedTrip,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.tripId="",i.startTime="",i.startDate="",i.scheduleRelationship=t.enums===String?"SCHEDULED":0,i.routeId="",i.directionId=0,i.modifiedTrip=null),null!=e.tripId&&e.hasOwnProperty("tripId")&&(i.tripId=e.tripId),null!=e.startTime&&e.hasOwnProperty("startTime")&&(i.startTime=e.startTime),null!=e.startDate&&e.hasOwnProperty("startDate")&&(i.startDate=e.startDate),null!=e.scheduleRelationship&&e.hasOwnProperty("scheduleRelationship")&&(i.scheduleRelationship=t.enums===String?void 0===s.transit_realtime.TripDescriptor.ScheduleRelationship[e.scheduleRelationship]?e.scheduleRelationship:s.transit_realtime.TripDescriptor.ScheduleRelationship[e.scheduleRelationship]:e.scheduleRelationship),null!=e.routeId&&e.hasOwnProperty("routeId")&&(i.routeId=e.routeId),null!=e.directionId&&e.hasOwnProperty("directionId")&&(i.directionId=e.directionId),null!=e.modifiedTrip&&e.hasOwnProperty("modifiedTrip")&&(i.modifiedTrip=s.transit_realtime.TripDescriptor.ModifiedTripSelector.toObject(e.modifiedTrip,t)),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripDescriptor"},e.ScheduleRelationship=function(){var e={},t=Object.create(e);return t[e[0]="SCHEDULED"]=0,t[e[1]="ADDED"]=1,t[e[2]="UNSCHEDULED"]=2,t[e[3]="CANCELED"]=3,t[e[5]="REPLACEMENT"]=5,t[e[6]="DUPLICATED"]=6,t[e[7]="DELETED"]=7,t[e[8]="NEW"]=8,t}(),e.ModifiedTripSelector=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.modificationsId="",e.prototype.affectedTripId="",e.prototype.startTime="",e.prototype.startDate="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.modificationsId&&Object.hasOwnProperty.call(e,"modificationsId")&&t.uint32(10).string(e.modificationsId),null!=e.affectedTripId&&Object.hasOwnProperty.call(e,"affectedTripId")&&t.uint32(18).string(e.affectedTripId),null!=e.startTime&&Object.hasOwnProperty.call(e,"startTime")&&t.uint32(26).string(e.startTime),null!=e.startDate&&Object.hasOwnProperty.call(e,"startDate")&&t.uint32(34).string(e.startDate),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripDescriptor.ModifiedTripSelector;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.modificationsId=e.string();continue;case 2:if(2!==d)break;c.affectedTripId=e.string();continue;case 3:if(2!==d)break;c.startTime=e.string();continue;case 4:if(2!==d)break;c.startDate=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.modificationsId&&e.hasOwnProperty("modificationsId")&&!r.isString(e.modificationsId)?"modificationsId: string expected":null!=e.affectedTripId&&e.hasOwnProperty("affectedTripId")&&!r.isString(e.affectedTripId)?"affectedTripId: string expected":null!=e.startTime&&e.hasOwnProperty("startTime")&&!r.isString(e.startTime)?"startTime: string expected":null!=e.startDate&&e.hasOwnProperty("startDate")&&!r.isString(e.startDate)?"startDate: string expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripDescriptor.ModifiedTripSelector)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripDescriptor.ModifiedTripSelector;return null!=e.modificationsId&&(i.modificationsId=String(e.modificationsId)),null!=e.affectedTripId&&(i.affectedTripId=String(e.affectedTripId)),null!=e.startTime&&(i.startTime=String(e.startTime)),null!=e.startDate&&(i.startDate=String(e.startDate)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.modificationsId="",i.affectedTripId="",i.startTime="",i.startDate=""),null!=e.modificationsId&&e.hasOwnProperty("modificationsId")&&(i.modificationsId=e.modificationsId),null!=e.affectedTripId&&e.hasOwnProperty("affectedTripId")&&(i.affectedTripId=e.affectedTripId),null!=e.startTime&&e.hasOwnProperty("startTime")&&(i.startTime=e.startTime),null!=e.startDate&&e.hasOwnProperty("startDate")&&(i.startDate=e.startDate),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripDescriptor.ModifiedTripSelector"},e}(),e}(),e.VehicleDescriptor=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.id="",e.prototype.label="",e.prototype.licensePlate="",e.prototype.wheelchairAccessible=0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.id&&Object.hasOwnProperty.call(e,"id")&&t.uint32(10).string(e.id),null!=e.label&&Object.hasOwnProperty.call(e,"label")&&t.uint32(18).string(e.label),null!=e.licensePlate&&Object.hasOwnProperty.call(e,"licensePlate")&&t.uint32(26).string(e.licensePlate),null!=e.wheelchairAccessible&&Object.hasOwnProperty.call(e,"wheelchairAccessible")&&t.uint32(32).int32(e.wheelchairAccessible),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.VehicleDescriptor;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.id=e.string();continue;case 2:if(2!==d)break;c.label=e.string();continue;case 3:if(2!==d)break;c.licensePlate=e.string();continue;case 4:if(0!==d)break;c.wheelchairAccessible=e.int32();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.id&&e.hasOwnProperty("id")&&!r.isString(e.id))return"id: string expected";if(null!=e.label&&e.hasOwnProperty("label")&&!r.isString(e.label))return"label: string expected";if(null!=e.licensePlate&&e.hasOwnProperty("licensePlate")&&!r.isString(e.licensePlate))return"licensePlate: string expected";if(null!=e.wheelchairAccessible&&e.hasOwnProperty("wheelchairAccessible"))switch(e.wheelchairAccessible){default:return"wheelchairAccessible: enum value expected";case 0:case 1:case 2:case 3:}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.VehicleDescriptor)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.VehicleDescriptor;switch(null!=e.id&&(i.id=String(e.id)),null!=e.label&&(i.label=String(e.label)),null!=e.licensePlate&&(i.licensePlate=String(e.licensePlate)),e.wheelchairAccessible){default:if("number"==typeof e.wheelchairAccessible){i.wheelchairAccessible=e.wheelchairAccessible;break}break;case"NO_VALUE":case 0:i.wheelchairAccessible=0;break;case"UNKNOWN":case 1:i.wheelchairAccessible=1;break;case"WHEELCHAIR_ACCESSIBLE":case 2:i.wheelchairAccessible=2;break;case"WHEELCHAIR_INACCESSIBLE":case 3:i.wheelchairAccessible=3}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.id="",i.label="",i.licensePlate="",i.wheelchairAccessible=t.enums===String?"NO_VALUE":0),null!=e.id&&e.hasOwnProperty("id")&&(i.id=e.id),null!=e.label&&e.hasOwnProperty("label")&&(i.label=e.label),null!=e.licensePlate&&e.hasOwnProperty("licensePlate")&&(i.licensePlate=e.licensePlate),null!=e.wheelchairAccessible&&e.hasOwnProperty("wheelchairAccessible")&&(i.wheelchairAccessible=t.enums===String?void 0===s.transit_realtime.VehicleDescriptor.WheelchairAccessible[e.wheelchairAccessible]?e.wheelchairAccessible:s.transit_realtime.VehicleDescriptor.WheelchairAccessible[e.wheelchairAccessible]:e.wheelchairAccessible),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.VehicleDescriptor"},e.WheelchairAccessible=function(){var e={},t=Object.create(e);return t[e[0]="NO_VALUE"]=0,t[e[1]="UNKNOWN"]=1,t[e[2]="WHEELCHAIR_ACCESSIBLE"]=2,t[e[3]="WHEELCHAIR_INACCESSIBLE"]=3,t}(),e}(),e.EntitySelector=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.agencyId="",e.prototype.routeId="",e.prototype.routeType=0,e.prototype.trip=null,e.prototype.stopId="",e.prototype.directionId=0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.agencyId&&Object.hasOwnProperty.call(e,"agencyId")&&t.uint32(10).string(e.agencyId),null!=e.routeId&&Object.hasOwnProperty.call(e,"routeId")&&t.uint32(18).string(e.routeId),null!=e.routeType&&Object.hasOwnProperty.call(e,"routeType")&&t.uint32(24).int32(e.routeType),null!=e.trip&&Object.hasOwnProperty.call(e,"trip")&&s.transit_realtime.TripDescriptor.encode(e.trip,t.uint32(34).fork()).ldelim(),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(42).string(e.stopId),null!=e.directionId&&Object.hasOwnProperty.call(e,"directionId")&&t.uint32(48).uint32(e.directionId),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.EntitySelector;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.agencyId=e.string();continue;case 2:if(2!==d)break;c.routeId=e.string();continue;case 3:if(0!==d)break;c.routeType=e.int32();continue;case 4:if(2!==d)break;c.trip=s.transit_realtime.TripDescriptor.decode(e,e.uint32(),void 0,o+1,c.trip);continue;case 5:if(2!==d)break;c.stopId=e.string();continue;case 6:if(0!==d)break;c.directionId=e.uint32();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.agencyId&&e.hasOwnProperty("agencyId")&&!r.isString(e.agencyId))return"agencyId: string expected";if(null!=e.routeId&&e.hasOwnProperty("routeId")&&!r.isString(e.routeId))return"routeId: string expected";if(null!=e.routeType&&e.hasOwnProperty("routeType")&&!r.isInteger(e.routeType))return"routeType: integer expected";if(null!=e.trip&&e.hasOwnProperty("trip")){var i=s.transit_realtime.TripDescriptor.verify(e.trip,t+1);if(i)return"trip."+i}return null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId)?"stopId: string expected":null!=e.directionId&&e.hasOwnProperty("directionId")&&!r.isInteger(e.directionId)?"directionId: integer expected":null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.EntitySelector)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.EntitySelector;if(null!=e.agencyId&&(i.agencyId=String(e.agencyId)),null!=e.routeId&&(i.routeId=String(e.routeId)),null!=e.routeType&&(i.routeType=0|e.routeType),null!=e.trip){if("object"!=typeof e.trip)throw TypeError(".transit_realtime.EntitySelector.trip: object expected");i.trip=s.transit_realtime.TripDescriptor.fromObject(e.trip,t+1)}return null!=e.stopId&&(i.stopId=String(e.stopId)),null!=e.directionId&&(i.directionId=e.directionId>>>0),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.agencyId="",i.routeId="",i.routeType=0,i.trip=null,i.stopId="",i.directionId=0),null!=e.agencyId&&e.hasOwnProperty("agencyId")&&(i.agencyId=e.agencyId),null!=e.routeId&&e.hasOwnProperty("routeId")&&(i.routeId=e.routeId),null!=e.routeType&&e.hasOwnProperty("routeType")&&(i.routeType=e.routeType),null!=e.trip&&e.hasOwnProperty("trip")&&(i.trip=s.transit_realtime.TripDescriptor.toObject(e.trip,t)),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),null!=e.directionId&&e.hasOwnProperty("directionId")&&(i.directionId=e.directionId),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.EntitySelector"},e}(),e.TranslatedString=function(){function e(e){if(this.translation=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.translation=r.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.translation&&e.translation.length)for(var i=0;i<e.translation.length;++i)s.transit_realtime.TranslatedString.Translation.encode(e.translation[i],t.uint32(10).fork()).ldelim();if(null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TranslatedString;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.translation&&c.translation.length||(c.translation=[]),c.translation.push(s.transit_realtime.TranslatedString.Translation.decode(e,e.uint32(),void 0,o+1));continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.translation&&e.hasOwnProperty("translation")){if(!Array.isArray(e.translation))return"translation: array expected";for(var i=0;i<e.translation.length;++i){var n=s.transit_realtime.TranslatedString.Translation.verify(e.translation[i],t+1);if(n)return"translation."+n}}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TranslatedString)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TranslatedString;if(e.translation){if(!Array.isArray(e.translation))throw TypeError(".transit_realtime.TranslatedString.translation: array expected");i.translation=Array(e.translation.length);for(var n=0;n<e.translation.length;++n){if("object"!=typeof e.translation[n])throw TypeError(".transit_realtime.TranslatedString.translation: object expected");i.translation[n]=s.transit_realtime.TranslatedString.Translation.fromObject(e.translation[n],t+1)}}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.translation=[]),e.translation&&e.translation.length){i.translation=Array(e.translation.length);for(var n=0;n<e.translation.length;++n)i.translation[n]=s.transit_realtime.TranslatedString.Translation.toObject(e.translation[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TranslatedString"},e.Translation=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.text="",e.prototype.language="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),t.uint32(10).string(e.text),null!=e.language&&Object.hasOwnProperty.call(e,"language")&&t.uint32(18).string(e.language),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TranslatedString.Translation;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.text=e.string();continue;case 2:if(2!==d)break;c.language=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("text"))throw r.ProtocolError("missing required 'text'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":r.isString(e.text)?null!=e.language&&e.hasOwnProperty("language")&&!r.isString(e.language)?"language: string expected":null:"text: string expected")},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TranslatedString.Translation)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TranslatedString.Translation;return null!=e.text&&(i.text=String(e.text)),null!=e.language&&(i.language=String(e.language)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.text="",i.language=""),null!=e.text&&e.hasOwnProperty("text")&&(i.text=e.text),null!=e.language&&e.hasOwnProperty("language")&&(i.language=e.language),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TranslatedString.Translation"},e}(),e}(),e.TranslatedImage=function(){function e(e){if(this.localizedImage=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.localizedImage=r.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.localizedImage&&e.localizedImage.length)for(var i=0;i<e.localizedImage.length;++i)s.transit_realtime.TranslatedImage.LocalizedImage.encode(e.localizedImage[i],t.uint32(10).fork()).ldelim();if(null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TranslatedImage;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.localizedImage&&c.localizedImage.length||(c.localizedImage=[]),c.localizedImage.push(s.transit_realtime.TranslatedImage.LocalizedImage.decode(e,e.uint32(),void 0,o+1));continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.localizedImage&&e.hasOwnProperty("localizedImage")){if(!Array.isArray(e.localizedImage))return"localizedImage: array expected";for(var i=0;i<e.localizedImage.length;++i){var n=s.transit_realtime.TranslatedImage.LocalizedImage.verify(e.localizedImage[i],t+1);if(n)return"localizedImage."+n}}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TranslatedImage)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TranslatedImage;if(e.localizedImage){if(!Array.isArray(e.localizedImage))throw TypeError(".transit_realtime.TranslatedImage.localizedImage: array expected");i.localizedImage=Array(e.localizedImage.length);for(var n=0;n<e.localizedImage.length;++n){if("object"!=typeof e.localizedImage[n])throw TypeError(".transit_realtime.TranslatedImage.localizedImage: object expected");i.localizedImage[n]=s.transit_realtime.TranslatedImage.LocalizedImage.fromObject(e.localizedImage[n],t+1)}}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.localizedImage=[]),e.localizedImage&&e.localizedImage.length){i.localizedImage=Array(e.localizedImage.length);for(var n=0;n<e.localizedImage.length;++n)i.localizedImage[n]=s.transit_realtime.TranslatedImage.LocalizedImage.toObject(e.localizedImage[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TranslatedImage"},e.LocalizedImage=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.url="",e.prototype.mediaType="",e.prototype.language="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),t.uint32(10).string(e.url),t.uint32(18).string(e.mediaType),null!=e.language&&Object.hasOwnProperty.call(e,"language")&&t.uint32(26).string(e.language),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TranslatedImage.LocalizedImage;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.url=e.string();continue;case 2:if(2!==d)break;c.mediaType=e.string();continue;case 3:if(2!==d)break;c.language=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");if(!c.hasOwnProperty("url"))throw r.ProtocolError("missing required 'url'",{instance:c});if(!c.hasOwnProperty("mediaType"))throw r.ProtocolError("missing required 'mediaType'",{instance:c});return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":r.isString(e.url)?r.isString(e.mediaType)?null!=e.language&&e.hasOwnProperty("language")&&!r.isString(e.language)?"language: string expected":null:"mediaType: string expected":"url: string expected")},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TranslatedImage.LocalizedImage)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TranslatedImage.LocalizedImage;return null!=e.url&&(i.url=String(e.url)),null!=e.mediaType&&(i.mediaType=String(e.mediaType)),null!=e.language&&(i.language=String(e.language)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.url="",i.mediaType="",i.language=""),null!=e.url&&e.hasOwnProperty("url")&&(i.url=e.url),null!=e.mediaType&&e.hasOwnProperty("mediaType")&&(i.mediaType=e.mediaType),null!=e.language&&e.hasOwnProperty("language")&&(i.language=e.language),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TranslatedImage.LocalizedImage"},e}(),e}(),e.Shape=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.shapeId="",e.prototype.encodedPolyline="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.shapeId&&Object.hasOwnProperty.call(e,"shapeId")&&t.uint32(10).string(e.shapeId),null!=e.encodedPolyline&&Object.hasOwnProperty.call(e,"encodedPolyline")&&t.uint32(18).string(e.encodedPolyline),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.Shape;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.shapeId=e.string();continue;case 2:if(2!==d)break;c.encodedPolyline=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.shapeId&&e.hasOwnProperty("shapeId")&&!r.isString(e.shapeId)?"shapeId: string expected":null!=e.encodedPolyline&&e.hasOwnProperty("encodedPolyline")&&!r.isString(e.encodedPolyline)?"encodedPolyline: string expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.Shape)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.Shape;return null!=e.shapeId&&(i.shapeId=String(e.shapeId)),null!=e.encodedPolyline&&(i.encodedPolyline=String(e.encodedPolyline)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.shapeId="",i.encodedPolyline=""),null!=e.shapeId&&e.hasOwnProperty("shapeId")&&(i.shapeId=e.shapeId),null!=e.encodedPolyline&&e.hasOwnProperty("encodedPolyline")&&(i.encodedPolyline=e.encodedPolyline),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.Shape"},e}(),e.Stop=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.stopId="",e.prototype.stopCode=null,e.prototype.stopName=null,e.prototype.ttsStopName=null,e.prototype.stopDesc=null,e.prototype.stopLat=0,e.prototype.stopLon=0,e.prototype.zoneId="",e.prototype.stopUrl=null,e.prototype.parentStation="",e.prototype.stopTimezone="",e.prototype.wheelchairBoarding=0,e.prototype.levelId="",e.prototype.platformCode=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(10).string(e.stopId),null!=e.stopCode&&Object.hasOwnProperty.call(e,"stopCode")&&s.transit_realtime.TranslatedString.encode(e.stopCode,t.uint32(18).fork()).ldelim(),null!=e.stopName&&Object.hasOwnProperty.call(e,"stopName")&&s.transit_realtime.TranslatedString.encode(e.stopName,t.uint32(26).fork()).ldelim(),null!=e.ttsStopName&&Object.hasOwnProperty.call(e,"ttsStopName")&&s.transit_realtime.TranslatedString.encode(e.ttsStopName,t.uint32(34).fork()).ldelim(),null!=e.stopDesc&&Object.hasOwnProperty.call(e,"stopDesc")&&s.transit_realtime.TranslatedString.encode(e.stopDesc,t.uint32(42).fork()).ldelim(),null!=e.stopLat&&Object.hasOwnProperty.call(e,"stopLat")&&t.uint32(53).float(e.stopLat),null!=e.stopLon&&Object.hasOwnProperty.call(e,"stopLon")&&t.uint32(61).float(e.stopLon),null!=e.zoneId&&Object.hasOwnProperty.call(e,"zoneId")&&t.uint32(66).string(e.zoneId),null!=e.stopUrl&&Object.hasOwnProperty.call(e,"stopUrl")&&s.transit_realtime.TranslatedString.encode(e.stopUrl,t.uint32(74).fork()).ldelim(),null!=e.parentStation&&Object.hasOwnProperty.call(e,"parentStation")&&t.uint32(90).string(e.parentStation),null!=e.stopTimezone&&Object.hasOwnProperty.call(e,"stopTimezone")&&t.uint32(98).string(e.stopTimezone),null!=e.wheelchairBoarding&&Object.hasOwnProperty.call(e,"wheelchairBoarding")&&t.uint32(104).int32(e.wheelchairBoarding),null!=e.levelId&&Object.hasOwnProperty.call(e,"levelId")&&t.uint32(114).string(e.levelId),null!=e.platformCode&&Object.hasOwnProperty.call(e,"platformCode")&&s.transit_realtime.TranslatedString.encode(e.platformCode,t.uint32(122).fork()).ldelim(),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.Stop;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.stopId=e.string();continue;case 2:if(2!==d)break;c.stopCode=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.stopCode);continue;case 3:if(2!==d)break;c.stopName=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.stopName);continue;case 4:if(2!==d)break;c.ttsStopName=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.ttsStopName);continue;case 5:if(2!==d)break;c.stopDesc=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.stopDesc);continue;case 6:if(5!==d)break;c.stopLat=e.float();continue;case 7:if(5!==d)break;c.stopLon=e.float();continue;case 8:if(2!==d)break;c.zoneId=e.string();continue;case 9:if(2!==d)break;c.stopUrl=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.stopUrl);continue;case 11:if(2!==d)break;c.parentStation=e.string();continue;case 12:if(2!==d)break;c.stopTimezone=e.string();continue;case 13:if(0!==d)break;c.wheelchairBoarding=e.int32();continue;case 14:if(2!==d)break;c.levelId=e.string();continue;case 15:if(2!==d)break;c.platformCode=s.transit_realtime.TranslatedString.decode(e,e.uint32(),void 0,o+1,c.platformCode);continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId))return"stopId: string expected";var i;if(null!=e.stopCode&&e.hasOwnProperty("stopCode")&&(i=s.transit_realtime.TranslatedString.verify(e.stopCode,t+1)))return"stopCode."+i;if(null!=e.stopName&&e.hasOwnProperty("stopName")&&(i=s.transit_realtime.TranslatedString.verify(e.stopName,t+1)))return"stopName."+i;if(null!=e.ttsStopName&&e.hasOwnProperty("ttsStopName")&&(i=s.transit_realtime.TranslatedString.verify(e.ttsStopName,t+1)))return"ttsStopName."+i;if(null!=e.stopDesc&&e.hasOwnProperty("stopDesc")&&(i=s.transit_realtime.TranslatedString.verify(e.stopDesc,t+1)))return"stopDesc."+i;if(null!=e.stopLat&&e.hasOwnProperty("stopLat")&&"number"!=typeof e.stopLat)return"stopLat: number expected";if(null!=e.stopLon&&e.hasOwnProperty("stopLon")&&"number"!=typeof e.stopLon)return"stopLon: number expected";if(null!=e.zoneId&&e.hasOwnProperty("zoneId")&&!r.isString(e.zoneId))return"zoneId: string expected";if(null!=e.stopUrl&&e.hasOwnProperty("stopUrl")&&(i=s.transit_realtime.TranslatedString.verify(e.stopUrl,t+1)))return"stopUrl."+i;if(null!=e.parentStation&&e.hasOwnProperty("parentStation")&&!r.isString(e.parentStation))return"parentStation: string expected";if(null!=e.stopTimezone&&e.hasOwnProperty("stopTimezone")&&!r.isString(e.stopTimezone))return"stopTimezone: string expected";if(null!=e.wheelchairBoarding&&e.hasOwnProperty("wheelchairBoarding"))switch(e.wheelchairBoarding){default:return"wheelchairBoarding: enum value expected";case 0:case 1:case 2:}return null!=e.levelId&&e.hasOwnProperty("levelId")&&!r.isString(e.levelId)?"levelId: string expected":null!=e.platformCode&&e.hasOwnProperty("platformCode")&&(i=s.transit_realtime.TranslatedString.verify(e.platformCode,t+1))?"platformCode."+i:null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.Stop)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.Stop;if(null!=e.stopId&&(i.stopId=String(e.stopId)),null!=e.stopCode){if("object"!=typeof e.stopCode)throw TypeError(".transit_realtime.Stop.stopCode: object expected");i.stopCode=s.transit_realtime.TranslatedString.fromObject(e.stopCode,t+1)}if(null!=e.stopName){if("object"!=typeof e.stopName)throw TypeError(".transit_realtime.Stop.stopName: object expected");i.stopName=s.transit_realtime.TranslatedString.fromObject(e.stopName,t+1)}if(null!=e.ttsStopName){if("object"!=typeof e.ttsStopName)throw TypeError(".transit_realtime.Stop.ttsStopName: object expected");i.ttsStopName=s.transit_realtime.TranslatedString.fromObject(e.ttsStopName,t+1)}if(null!=e.stopDesc){if("object"!=typeof e.stopDesc)throw TypeError(".transit_realtime.Stop.stopDesc: object expected");i.stopDesc=s.transit_realtime.TranslatedString.fromObject(e.stopDesc,t+1)}if(null!=e.stopLat&&(i.stopLat=Number(e.stopLat)),null!=e.stopLon&&(i.stopLon=Number(e.stopLon)),null!=e.zoneId&&(i.zoneId=String(e.zoneId)),null!=e.stopUrl){if("object"!=typeof e.stopUrl)throw TypeError(".transit_realtime.Stop.stopUrl: object expected");i.stopUrl=s.transit_realtime.TranslatedString.fromObject(e.stopUrl,t+1)}switch(null!=e.parentStation&&(i.parentStation=String(e.parentStation)),null!=e.stopTimezone&&(i.stopTimezone=String(e.stopTimezone)),e.wheelchairBoarding){default:if("number"==typeof e.wheelchairBoarding){i.wheelchairBoarding=e.wheelchairBoarding;break}break;case"UNKNOWN":case 0:i.wheelchairBoarding=0;break;case"AVAILABLE":case 1:i.wheelchairBoarding=1;break;case"NOT_AVAILABLE":case 2:i.wheelchairBoarding=2}if(null!=e.levelId&&(i.levelId=String(e.levelId)),null!=e.platformCode){if("object"!=typeof e.platformCode)throw TypeError(".transit_realtime.Stop.platformCode: object expected");i.platformCode=s.transit_realtime.TranslatedString.fromObject(e.platformCode,t+1)}return i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.stopId="",i.stopCode=null,i.stopName=null,i.ttsStopName=null,i.stopDesc=null,i.stopLat=0,i.stopLon=0,i.zoneId="",i.stopUrl=null,i.parentStation="",i.stopTimezone="",i.wheelchairBoarding=t.enums===String?"UNKNOWN":0,i.levelId="",i.platformCode=null),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),null!=e.stopCode&&e.hasOwnProperty("stopCode")&&(i.stopCode=s.transit_realtime.TranslatedString.toObject(e.stopCode,t)),null!=e.stopName&&e.hasOwnProperty("stopName")&&(i.stopName=s.transit_realtime.TranslatedString.toObject(e.stopName,t)),null!=e.ttsStopName&&e.hasOwnProperty("ttsStopName")&&(i.ttsStopName=s.transit_realtime.TranslatedString.toObject(e.ttsStopName,t)),null!=e.stopDesc&&e.hasOwnProperty("stopDesc")&&(i.stopDesc=s.transit_realtime.TranslatedString.toObject(e.stopDesc,t)),null!=e.stopLat&&e.hasOwnProperty("stopLat")&&(i.stopLat=t.json&&!isFinite(e.stopLat)?String(e.stopLat):e.stopLat),null!=e.stopLon&&e.hasOwnProperty("stopLon")&&(i.stopLon=t.json&&!isFinite(e.stopLon)?String(e.stopLon):e.stopLon),null!=e.zoneId&&e.hasOwnProperty("zoneId")&&(i.zoneId=e.zoneId),null!=e.stopUrl&&e.hasOwnProperty("stopUrl")&&(i.stopUrl=s.transit_realtime.TranslatedString.toObject(e.stopUrl,t)),null!=e.parentStation&&e.hasOwnProperty("parentStation")&&(i.parentStation=e.parentStation),null!=e.stopTimezone&&e.hasOwnProperty("stopTimezone")&&(i.stopTimezone=e.stopTimezone),null!=e.wheelchairBoarding&&e.hasOwnProperty("wheelchairBoarding")&&(i.wheelchairBoarding=t.enums===String?void 0===s.transit_realtime.Stop.WheelchairBoarding[e.wheelchairBoarding]?e.wheelchairBoarding:s.transit_realtime.Stop.WheelchairBoarding[e.wheelchairBoarding]:e.wheelchairBoarding),null!=e.levelId&&e.hasOwnProperty("levelId")&&(i.levelId=e.levelId),null!=e.platformCode&&e.hasOwnProperty("platformCode")&&(i.platformCode=s.transit_realtime.TranslatedString.toObject(e.platformCode,t)),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.Stop"},e.WheelchairBoarding=function(){var e={},t=Object.create(e);return t[e[0]="UNKNOWN"]=0,t[e[1]="AVAILABLE"]=1,t[e[2]="NOT_AVAILABLE"]=2,t}(),e}(),e.TripModifications=function(){function e(e){if(this.selectedTrips=[],this.startTimes=[],this.serviceDates=[],this.modifications=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.selectedTrips=r.emptyArray,e.prototype.startTimes=r.emptyArray,e.prototype.serviceDates=r.emptyArray,e.prototype.modifications=r.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.selectedTrips&&e.selectedTrips.length)for(var i=0;i<e.selectedTrips.length;++i)s.transit_realtime.TripModifications.SelectedTrips.encode(e.selectedTrips[i],t.uint32(10).fork()).ldelim();if(null!=e.startTimes&&e.startTimes.length)for(i=0;i<e.startTimes.length;++i)t.uint32(18).string(e.startTimes[i]);if(null!=e.serviceDates&&e.serviceDates.length)for(i=0;i<e.serviceDates.length;++i)t.uint32(26).string(e.serviceDates[i]);if(null!=e.modifications&&e.modifications.length)for(i=0;i<e.modifications.length;++i)s.transit_realtime.TripModifications.Modification.encode(e.modifications[i],t.uint32(34).fork()).ldelim();if(null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripModifications;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.selectedTrips&&c.selectedTrips.length||(c.selectedTrips=[]),c.selectedTrips.push(s.transit_realtime.TripModifications.SelectedTrips.decode(e,e.uint32(),void 0,o+1));continue;case 2:if(2!==d)break;c.startTimes&&c.startTimes.length||(c.startTimes=[]),c.startTimes.push(e.string());continue;case 3:if(2!==d)break;c.serviceDates&&c.serviceDates.length||(c.serviceDates=[]),c.serviceDates.push(e.string());continue;case 4:if(2!==d)break;c.modifications&&c.modifications.length||(c.modifications=[]),c.modifications.push(s.transit_realtime.TripModifications.Modification.decode(e,e.uint32(),void 0,o+1));continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.selectedTrips&&e.hasOwnProperty("selectedTrips")){if(!Array.isArray(e.selectedTrips))return"selectedTrips: array expected";for(var i=0;i<e.selectedTrips.length;++i)if(n=s.transit_realtime.TripModifications.SelectedTrips.verify(e.selectedTrips[i],t+1))return"selectedTrips."+n}if(null!=e.startTimes&&e.hasOwnProperty("startTimes")){if(!Array.isArray(e.startTimes))return"startTimes: array expected";for(i=0;i<e.startTimes.length;++i)if(!r.isString(e.startTimes[i]))return"startTimes: string[] expected"}if(null!=e.serviceDates&&e.hasOwnProperty("serviceDates")){if(!Array.isArray(e.serviceDates))return"serviceDates: array expected";for(i=0;i<e.serviceDates.length;++i)if(!r.isString(e.serviceDates[i]))return"serviceDates: string[] expected"}if(null!=e.modifications&&e.hasOwnProperty("modifications")){if(!Array.isArray(e.modifications))return"modifications: array expected";for(i=0;i<e.modifications.length;++i){var n;if(n=s.transit_realtime.TripModifications.Modification.verify(e.modifications[i],t+1))return"modifications."+n}}return null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripModifications)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripModifications;if(e.selectedTrips){if(!Array.isArray(e.selectedTrips))throw TypeError(".transit_realtime.TripModifications.selectedTrips: array expected");i.selectedTrips=Array(e.selectedTrips.length);for(var n=0;n<e.selectedTrips.length;++n){if("object"!=typeof e.selectedTrips[n])throw TypeError(".transit_realtime.TripModifications.selectedTrips: object expected");i.selectedTrips[n]=s.transit_realtime.TripModifications.SelectedTrips.fromObject(e.selectedTrips[n],t+1)}}if(e.startTimes){if(!Array.isArray(e.startTimes))throw TypeError(".transit_realtime.TripModifications.startTimes: array expected");for(i.startTimes=Array(e.startTimes.length),n=0;n<e.startTimes.length;++n)i.startTimes[n]=String(e.startTimes[n])}if(e.serviceDates){if(!Array.isArray(e.serviceDates))throw TypeError(".transit_realtime.TripModifications.serviceDates: array expected");for(i.serviceDates=Array(e.serviceDates.length),n=0;n<e.serviceDates.length;++n)i.serviceDates[n]=String(e.serviceDates[n])}if(e.modifications){if(!Array.isArray(e.modifications))throw TypeError(".transit_realtime.TripModifications.modifications: array expected");for(i.modifications=Array(e.modifications.length),n=0;n<e.modifications.length;++n){if("object"!=typeof e.modifications[n])throw TypeError(".transit_realtime.TripModifications.modifications: object expected");i.modifications[n]=s.transit_realtime.TripModifications.Modification.fromObject(e.modifications[n],t+1)}}return i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.selectedTrips=[],i.startTimes=[],i.serviceDates=[],i.modifications=[]),e.selectedTrips&&e.selectedTrips.length){i.selectedTrips=Array(e.selectedTrips.length);for(var n=0;n<e.selectedTrips.length;++n)i.selectedTrips[n]=s.transit_realtime.TripModifications.SelectedTrips.toObject(e.selectedTrips[n],t)}if(e.startTimes&&e.startTimes.length)for(i.startTimes=Array(e.startTimes.length),n=0;n<e.startTimes.length;++n)i.startTimes[n]=e.startTimes[n];if(e.serviceDates&&e.serviceDates.length)for(i.serviceDates=Array(e.serviceDates.length),n=0;n<e.serviceDates.length;++n)i.serviceDates[n]=e.serviceDates[n];if(e.modifications&&e.modifications.length)for(i.modifications=Array(e.modifications.length),n=0;n<e.modifications.length;++n)i.modifications[n]=s.transit_realtime.TripModifications.Modification.toObject(e.modifications[n],t);return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripModifications"},e.Modification=function(){function e(e){if(this.replacementStops=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.startStopSelector=null,e.prototype.endStopSelector=null,e.prototype.propagatedModificationDelay=0,e.prototype.replacementStops=r.emptyArray,e.prototype.serviceAlertId="",e.prototype.lastModifiedTime=r.Long?r.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.startStopSelector&&Object.hasOwnProperty.call(e,"startStopSelector")&&s.transit_realtime.StopSelector.encode(e.startStopSelector,t.uint32(10).fork()).ldelim(),null!=e.endStopSelector&&Object.hasOwnProperty.call(e,"endStopSelector")&&s.transit_realtime.StopSelector.encode(e.endStopSelector,t.uint32(18).fork()).ldelim(),null!=e.propagatedModificationDelay&&Object.hasOwnProperty.call(e,"propagatedModificationDelay")&&t.uint32(24).int32(e.propagatedModificationDelay),null!=e.replacementStops&&e.replacementStops.length)for(var i=0;i<e.replacementStops.length;++i)s.transit_realtime.ReplacementStop.encode(e.replacementStops[i],t.uint32(34).fork()).ldelim();if(null!=e.serviceAlertId&&Object.hasOwnProperty.call(e,"serviceAlertId")&&t.uint32(42).string(e.serviceAlertId),null!=e.lastModifiedTime&&Object.hasOwnProperty.call(e,"lastModifiedTime")&&t.uint32(48).uint64(e.lastModifiedTime),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripModifications.Modification;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.startStopSelector=s.transit_realtime.StopSelector.decode(e,e.uint32(),void 0,o+1,c.startStopSelector);continue;case 2:if(2!==d)break;c.endStopSelector=s.transit_realtime.StopSelector.decode(e,e.uint32(),void 0,o+1,c.endStopSelector);continue;case 3:if(0!==d)break;c.propagatedModificationDelay=e.int32();continue;case 4:if(2!==d)break;c.replacementStops&&c.replacementStops.length||(c.replacementStops=[]),c.replacementStops.push(s.transit_realtime.ReplacementStop.decode(e,e.uint32(),void 0,o+1));continue;case 5:if(2!==d)break;c.serviceAlertId=e.string();continue;case 6:if(0!==d)break;c.lastModifiedTime=e.uint64();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.startStopSelector&&e.hasOwnProperty("startStopSelector")&&(n=s.transit_realtime.StopSelector.verify(e.startStopSelector,t+1)))return"startStopSelector."+n;if(null!=e.endStopSelector&&e.hasOwnProperty("endStopSelector")&&(n=s.transit_realtime.StopSelector.verify(e.endStopSelector,t+1)))return"endStopSelector."+n;if(null!=e.propagatedModificationDelay&&e.hasOwnProperty("propagatedModificationDelay")&&!r.isInteger(e.propagatedModificationDelay))return"propagatedModificationDelay: integer expected";if(null!=e.replacementStops&&e.hasOwnProperty("replacementStops")){if(!Array.isArray(e.replacementStops))return"replacementStops: array expected";for(var i=0;i<e.replacementStops.length;++i){var n;if(n=s.transit_realtime.ReplacementStop.verify(e.replacementStops[i],t+1))return"replacementStops."+n}}return null!=e.serviceAlertId&&e.hasOwnProperty("serviceAlertId")&&!r.isString(e.serviceAlertId)?"serviceAlertId: string expected":null!=e.lastModifiedTime&&e.hasOwnProperty("lastModifiedTime")&&!(r.isInteger(e.lastModifiedTime)||e.lastModifiedTime&&r.isInteger(e.lastModifiedTime.low)&&r.isInteger(e.lastModifiedTime.high))?"lastModifiedTime: integer|Long expected":null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripModifications.Modification)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripModifications.Modification;if(null!=e.startStopSelector){if("object"!=typeof e.startStopSelector)throw TypeError(".transit_realtime.TripModifications.Modification.startStopSelector: object expected");i.startStopSelector=s.transit_realtime.StopSelector.fromObject(e.startStopSelector,t+1)}if(null!=e.endStopSelector){if("object"!=typeof e.endStopSelector)throw TypeError(".transit_realtime.TripModifications.Modification.endStopSelector: object expected");i.endStopSelector=s.transit_realtime.StopSelector.fromObject(e.endStopSelector,t+1)}if(null!=e.propagatedModificationDelay&&(i.propagatedModificationDelay=0|e.propagatedModificationDelay),e.replacementStops){if(!Array.isArray(e.replacementStops))throw TypeError(".transit_realtime.TripModifications.Modification.replacementStops: array expected");i.replacementStops=Array(e.replacementStops.length);for(var n=0;n<e.replacementStops.length;++n){if("object"!=typeof e.replacementStops[n])throw TypeError(".transit_realtime.TripModifications.Modification.replacementStops: object expected");i.replacementStops[n]=s.transit_realtime.ReplacementStop.fromObject(e.replacementStops[n],t+1)}}return null!=e.serviceAlertId&&(i.serviceAlertId=String(e.serviceAlertId)),null!=e.lastModifiedTime&&(r.Long?(i.lastModifiedTime=r.Long.fromValue(e.lastModifiedTime)).unsigned=!0:"string"==typeof e.lastModifiedTime?i.lastModifiedTime=parseInt(e.lastModifiedTime,10):"number"==typeof e.lastModifiedTime?i.lastModifiedTime=e.lastModifiedTime:"object"==typeof e.lastModifiedTime&&(i.lastModifiedTime=new r.LongBits(e.lastModifiedTime.low>>>0,e.lastModifiedTime.high>>>0).toNumber(!0))),i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.replacementStops=[]),t.defaults)if(i.startStopSelector=null,i.endStopSelector=null,i.propagatedModificationDelay=0,i.serviceAlertId="",r.Long){var n=new r.Long(0,0,!0);i.lastModifiedTime=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else i.lastModifiedTime=t.longs===String?"0":0;if(null!=e.startStopSelector&&e.hasOwnProperty("startStopSelector")&&(i.startStopSelector=s.transit_realtime.StopSelector.toObject(e.startStopSelector,t)),null!=e.endStopSelector&&e.hasOwnProperty("endStopSelector")&&(i.endStopSelector=s.transit_realtime.StopSelector.toObject(e.endStopSelector,t)),null!=e.propagatedModificationDelay&&e.hasOwnProperty("propagatedModificationDelay")&&(i.propagatedModificationDelay=e.propagatedModificationDelay),e.replacementStops&&e.replacementStops.length){i.replacementStops=Array(e.replacementStops.length);for(var o=0;o<e.replacementStops.length;++o)i.replacementStops[o]=s.transit_realtime.ReplacementStop.toObject(e.replacementStops[o],t)}return null!=e.serviceAlertId&&e.hasOwnProperty("serviceAlertId")&&(i.serviceAlertId=e.serviceAlertId),null!=e.lastModifiedTime&&e.hasOwnProperty("lastModifiedTime")&&(i.lastModifiedTime="number"==typeof e.lastModifiedTime?t.longs===String?String(e.lastModifiedTime):e.lastModifiedTime:t.longs===String?r.Long.prototype.toString.call(e.lastModifiedTime):t.longs===Number?new r.LongBits(e.lastModifiedTime.low>>>0,e.lastModifiedTime.high>>>0).toNumber(!0):e.lastModifiedTime),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripModifications.Modification"},e}(),e.SelectedTrips=function(){function e(e){if(this.tripIds=[],e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.tripIds=r.emptyArray,e.prototype.shapeId="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.tripIds&&e.tripIds.length)for(var i=0;i<e.tripIds.length;++i)t.uint32(10).string(e.tripIds[i]);if(null!=e.shapeId&&Object.hasOwnProperty.call(e,"shapeId")&&t.uint32(18).string(e.shapeId),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.TripModifications.SelectedTrips;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(2!==d)break;c.tripIds&&c.tripIds.length||(c.tripIds=[]),c.tripIds.push(e.string());continue;case 2:if(2!==d)break;c.shapeId=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){if("object"!=typeof e||null===e)return"object expected";if(void 0===t&&(t=0),t>r.recursionLimit)return"max depth exceeded";if(null!=e.tripIds&&e.hasOwnProperty("tripIds")){if(!Array.isArray(e.tripIds))return"tripIds: array expected";for(var i=0;i<e.tripIds.length;++i)if(!r.isString(e.tripIds[i]))return"tripIds: string[] expected"}return null!=e.shapeId&&e.hasOwnProperty("shapeId")&&!r.isString(e.shapeId)?"shapeId: string expected":null},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.TripModifications.SelectedTrips)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.TripModifications.SelectedTrips;if(e.tripIds){if(!Array.isArray(e.tripIds))throw TypeError(".transit_realtime.TripModifications.SelectedTrips.tripIds: array expected");i.tripIds=Array(e.tripIds.length);for(var n=0;n<e.tripIds.length;++n)i.tripIds[n]=String(e.tripIds[n])}return null!=e.shapeId&&(i.shapeId=String(e.shapeId)),i},e.toObject=function(e,t){t||(t={});var i={};if((t.arrays||t.defaults)&&(i.tripIds=[]),t.defaults&&(i.shapeId=""),e.tripIds&&e.tripIds.length){i.tripIds=Array(e.tripIds.length);for(var n=0;n<e.tripIds.length;++n)i.tripIds[n]=e.tripIds[n]}return null!=e.shapeId&&e.hasOwnProperty("shapeId")&&(i.shapeId=e.shapeId),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.TripModifications.SelectedTrips"},e}(),e}(),e.StopSelector=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.stopSequence=0,e.prototype.stopId="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.stopSequence&&Object.hasOwnProperty.call(e,"stopSequence")&&t.uint32(8).uint32(e.stopSequence),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(18).string(e.stopId),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.StopSelector;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(0!==d)break;c.stopSequence=e.uint32();continue;case 2:if(2!==d)break;c.stopId=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.stopSequence&&e.hasOwnProperty("stopSequence")&&!r.isInteger(e.stopSequence)?"stopSequence: integer expected":null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId)?"stopId: string expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.StopSelector)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.StopSelector;return null!=e.stopSequence&&(i.stopSequence=e.stopSequence>>>0),null!=e.stopId&&(i.stopId=String(e.stopId)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.stopSequence=0,i.stopId=""),null!=e.stopSequence&&e.hasOwnProperty("stopSequence")&&(i.stopSequence=e.stopSequence),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.StopSelector"},e}(),e.ReplacementStop=function(){function e(e){if(e)for(var t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&"__proto__"!==t[i]&&(this[t[i]]=e[t[i]])}return e.prototype.travelTimeToStop=0,e.prototype.stopId="",e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=n.create()),null!=e.travelTimeToStop&&Object.hasOwnProperty.call(e,"travelTimeToStop")&&t.uint32(8).int32(e.travelTimeToStop),null!=e.stopId&&Object.hasOwnProperty.call(e,"stopId")&&t.uint32(18).string(e.stopId),null!=e.$unknowns&&Object.hasOwnProperty.call(e,"$unknowns"))for(var i=0;i<e.$unknowns.length;++i)t.raw(e.$unknowns[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t,n,o,a){if(e instanceof i||(e=i.create(e)),void 0===o&&(o=0),o>i.recursionLimit)throw Error("max depth exceeded");for(var l=void 0===t?e.len:e.pos+t,c=a||new s.transit_realtime.ReplacementStop;e.pos<l;){var u=e.pos,h=e.tag();if(h===n){n=void 0;break}var d=7&h;switch(h>>>=3){case 1:if(0!==d)break;c.travelTimeToStop=e.int32();continue;case 2:if(2!==d)break;c.stopId=e.string();continue}e.skipType(d,o,h),r.makeProp(c,"$unknowns",!1),(c.$unknowns||(c.$unknowns=[])).push(e.raw(u,e.pos))}if(void 0!==n)throw Error("missing end group");return c},e.decodeDelimited=function(e){return e instanceof i||(e=new i(e)),this.decode(e,e.uint32())},e.verify=function(e,t){return"object"!=typeof e||null===e?"object expected":(void 0===t&&(t=0),t>r.recursionLimit?"max depth exceeded":null!=e.travelTimeToStop&&e.hasOwnProperty("travelTimeToStop")&&!r.isInteger(e.travelTimeToStop)?"travelTimeToStop: integer expected":null!=e.stopId&&e.hasOwnProperty("stopId")&&!r.isString(e.stopId)?"stopId: string expected":null)},e.fromObject=function(e,t){if(e instanceof s.transit_realtime.ReplacementStop)return e;if(void 0===t&&(t=0),t>r.recursionLimit)throw Error("max depth exceeded");var i=new s.transit_realtime.ReplacementStop;return null!=e.travelTimeToStop&&(i.travelTimeToStop=0|e.travelTimeToStop),null!=e.stopId&&(i.stopId=String(e.stopId)),i},e.toObject=function(e,t){t||(t={});var i={};return t.defaults&&(i.travelTimeToStop=0,i.stopId=""),null!=e.travelTimeToStop&&e.hasOwnProperty("travelTimeToStop")&&(i.travelTimeToStop=e.travelTimeToStop),null!=e.stopId&&e.hasOwnProperty("stopId")&&(i.stopId=e.stopId),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/transit_realtime.ReplacementStop"},e}(),e),LH=s}(),NH=ne(FH);const kH=4294967296,zH="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class UH{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,i=this.length){let n;for(;n=this.nextField(i);)e(n,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*kH;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*kH;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf,i=t[this.pos++];if(i<128)return i;let n,r=127&i;return n=t[this.pos++],r|=(127&n)<<7,n<128?r:(n=t[this.pos++],r|=(127&n)<<14,n<128?r:(n=t[this.pos++],r|=(127&n)<<21,n<128?r:(n=t[this.pos],r|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,s;if(s=n[i.pos++],r=(112&s)>>4,s<128)return VH(e,r,t);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return VH(e,r,t);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return VH(e,r,t);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return VH(e,r,t);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return VH(e,r,t);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return VH(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(r,e,this))))}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&zH?zH.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r<i;){const t=e[r];let s,o,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(s=e[r+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===c?(s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;const t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}}function VH(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function jH(e){return`timetable-${"Weekday"===e.getCalendar()?"weekday":"holiday"}.json.gz`}function GH(e){const t=e.getCalendar();return"Saturday"===t?["timetable-saturday.json.gz"]:"Holiday"===t?["timetable-sunday-holiday.json.gz"]:[]}function HH(e,t,i){return"JR-East.LimitedExpress"===t&&i[0].match(/NaritaAirportTerminal1|Takao|Ofuna|Omiya|Ikebukuro|Shinjuku/)?e.replace(/JR-East\.(NaritaAirportBranch|Narita|Sobu)/,"JR-East.SobuRapid"):e}function WH(e){return void 0!==e.expiresAt&&Date.now()>=new Date(e.expiresAt).getTime()}function qH(e,t,i){const n=URL.createObjectURL(new Blob(['!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var t=6371008.8,e={meters:t,metres:t,millimeters:6371008800,millimetres:6371008800,centimeters:637100880,centimetres:637100880,kilometers:6371.0088,kilometres:6371.0088,miles:3958.761333810546,nauticalmiles:t/1852,inches:39.37*t,yards:5825721.287490856,feet:20902260.511392,radians:1,degrees:57.22891354143274};function n(t,e,n){if(!l(n=n||{}))throw new Error("options is invalid");var i=n.bbox,r=n.id;if(void 0===t)throw new Error("geometry is required");if(e&&e.constructor!==Object)throw new Error("properties must be an Object");i&&c(i),r&&p(r);var o={type:"Feature"};return r&&(o.id=r),i&&(o.bbox=i),o.properties=e||{},o.geometry=t,o}function i(t,e,i){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!u(t[0])||!u(t[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:t},e,i)}function r(t,e,i){if(!t)throw new Error("coordinates is required");if(t.length<2)throw new Error("coordinates must be an array of two or more positions");if(!u(t[0][1])||!u(t[0][1]))throw new Error("coordinates must contain numbers");return n({type:"LineString",coordinates:t},e,i)}function o(t,e){if(!l(e=e||{}))throw new Error("options is invalid");var n=e.bbox,i=e.id;if(!t)throw new Error("No features passed");if(!Array.isArray(t))throw new Error("features must be an Array");n&&c(n),i&&p(i);var r={type:"FeatureCollection"};return i&&(r.id=i),n&&(r.bbox=n),r.features=t,r}function s(t,n){if(null==t)throw new Error("radians is required");if(n&&"string"!=typeof n)throw new Error("units must be a string");var i=e[n||"kilometers"];if(!i)throw new Error(n+" units is invalid");return t*i}function a(t){if(null==t)throw new Error("degrees is required");return t%360*Math.PI/180}function u(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function l(t){return!!t&&t.constructor===Object}function c(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!u(t))throw new Error("bbox must only contain numbers")})}function p(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}function h(t,e,n){if(null!==t)for(var i,r,o,s,a,u,l,c,p=0,f=0,g=t.type,d="FeatureCollection"===g,y="Feature"===g,_=d?t.features.length:1,m=0;m<_;m++){a=(c=!!(l=d?t.features[m].geometry:y?t.geometry:t)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var v=0;v<a;v++){var I=0,x=0;if(null!==(s=c?l.geometries[v]:l)){u=s.coordinates;var E=s.type;switch(p=0,E){case null:break;case"Point":if(!1===e(u,f,m,I,x))return!1;f++,I++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===e(u[i],f,m,I,x))return!1;f++,"MultiPoint"===E&&I++}"LineString"===E&&I++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(r=0;r<u[i].length-p;r++){if(!1===e(u[i][r],f,m,I,x))return!1;f++}"MultiLineString"===E&&I++,"Polygon"===E&&x++}"Polygon"===E&&I++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for("MultiPolygon"===E&&(x=0),r=0;r<u[i].length;r++){for(o=0;o<u[i][r].length-p;o++){if(!1===e(u[i][r][o],f,m,I,x))return!1;f++}x++}I++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===h(s.geometries[i],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function f(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function g(t,e){var n,i,r,o,s,a,u,l,c,p,h=0,f="FeatureCollection"===t.type,g="Feature"===t.type,d=f?t.features.length:1;for(n=0;n<d;n++){for(l=f?t.features[n].properties:g?t.properties:{},c=f?t.features[n].bbox:g?t.bbox:void 0,p=f?t.features[n].id:g?t.id:void 0,s=(u=!!(a=f?t.features[n].geometry:g?t.geometry:t)&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=u?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,h,l,c,p))return!1;break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===e(o.geometries[i],h,l,c,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,h,l,c,p))return!1;h++}}function d(t){var e=[1/0,1/0,-1/0,-1/0];return h(t,function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])}),e}var y,_={exports:{}};var m=(y||(y=1,function(t){function e(){}function n(t){this.message=t||""}function i(t){this.message=t||""}function r(t){this.message=t||""}function o(){}function s(t){return null===t?Dt:t.color}function a(t){return null===t?null:t.parent}function u(t,e){null!==t&&(t.color=e)}function l(t){return null===t?null:t.left}function c(t){return null===t?null:t.right}function p(){this.root_=null,this.size_=0}function h(){}function f(){this.array_=[],arguments[0]instanceof It&&this.addAll(arguments[0])}function g(){}function d(t){this.message=t||""}function y(){this.array_=[]}"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(t){if(null==this)throw new TypeError(this+" is not an object");var e=Object(this),n=Math.max(Math.min(e.length,9007199254740991),0)||0,i=1 in arguments&&parseInt(Number(arguments[1]),10)||0;i=i<0?Math.max(n+i,0):Math.min(i,n);var r=2 in arguments&&void 0!==arguments[2]?parseInt(Number(arguments[2]),10)||0:n;for(r=r<0?Math.max(n+arguments[2],0):Math.min(r,n);i<r;)e[i]=t,++i;return e},writable:!0}),Number.isFinite=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},Number.parseFloat=Number.parseFloat||parseFloat,Number.isNaN=Number.isNaN||function(t){return t!=t},Math.trunc=Math.trunc||function(t){return t<0?Math.ceil(t):Math.floor(t)};var _=function(){};_.prototype.interfaces_=function(){return[]},_.prototype.getClass=function(){return _},_.prototype.equalsWithTolerance=function(t,e,n){return Math.abs(t-e)<=n};var m=function(t){function e(e){t.call(this,e),this.name="IllegalArgumentException",this.message=e,this.stack=(new t).stack}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),v=function(){},I={MAX_VALUE:{configurable:!0}};v.isNaN=function(t){return Number.isNaN(t)},v.doubleToLongBits=function(t){return t},v.longBitsToDouble=function(t){return t},v.isInfinite=function(t){return!Number.isFinite(t)},I.MAX_VALUE.get=function(){return Number.MAX_VALUE},Object.defineProperties(v,I);var x=function(){},E=function(){},N=function(){},w=function t(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)this.x=0,this.y=0,this.z=t.NULL_ORDINATE;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.z=e.z}else 2===arguments.length?(this.x=arguments[0],this.y=arguments[1],this.z=t.NULL_ORDINATE):3===arguments.length&&(this.x=arguments[0],this.y=arguments[1],this.z=arguments[2])},C={DimensionalComparator:{configurable:!0},serialVersionUID:{configurable:!0},NULL_ORDINATE:{configurable:!0},X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0}};w.prototype.setOrdinate=function(t,e){switch(t){case w.X:this.x=e;break;case w.Y:this.y=e;break;case w.Z:this.z=e;break;default:throw new m("Invalid ordinate index: "+t)}},w.prototype.equals2D=function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!_.equalsWithTolerance(this.x,e.x,n)&&!!_.equalsWithTolerance(this.y,e.y,n)}},w.prototype.getOrdinate=function(t){switch(t){case w.X:return this.x;case w.Y:return this.y;case w.Z:return this.z}throw new m("Invalid ordinate index: "+t)},w.prototype.equals3D=function(t){return this.x===t.x&&this.y===t.y&&(this.z===t.z||v.isNaN(this.z))&&v.isNaN(t.z)},w.prototype.equals=function(t){return t instanceof w&&this.equals2D(t)},w.prototype.equalInZ=function(t,e){return _.equalsWithTolerance(this.z,t.z,e)},w.prototype.compareTo=function(t){return this.x<t.x?-1:this.x>t.x?1:this.y<t.y?-1:this.y>t.y?1:0},w.prototype.clone=function(){},w.prototype.copy=function(){return new w(this)},w.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},w.prototype.distance3D=function(t){var e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return Math.sqrt(e*e+n*n+i*i)},w.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},w.prototype.hashCode=function(){var t=17;return 37*(t=37*t+w.hashCode(this.x))+w.hashCode(this.y)},w.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},w.prototype.interfaces_=function(){return[x,E,e]},w.prototype.getClass=function(){return w},w.hashCode=function(){if(1===arguments.length){var t=v.doubleToLongBits(arguments[0]);return Math.trunc((t^t)>>>32)}},C.DimensionalComparator.get=function(){return S},C.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},C.NULL_ORDINATE.get=function(){return v.NaN},C.X.get=function(){return 0},C.Y.get=function(){return 1},C.Z.get=function(){return 2},Object.defineProperties(w,C);var S=function(t){if(this._dimensionsToTest=2,0===arguments.length);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new m("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}};S.prototype.compare=function(t,e){var n=t,i=e,r=S.compare(n.x,i.x);if(0!==r)return r;var o=S.compare(n.y,i.y);return 0!==o?o:this._dimensionsToTest<=2?0:S.compare(n.z,i.z)},S.prototype.interfaces_=function(){return[N]},S.prototype.getClass=function(){return S},S.compare=function(t,e){return t<e?-1:t>e?1:v.isNaN(t)?v.isNaN(e)?0:-1:v.isNaN(e)?1:0};var b=function(){};b.prototype.create=function(){},b.prototype.interfaces_=function(){return[]},b.prototype.getClass=function(){return b};var L=function(){},O={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};L.prototype.interfaces_=function(){return[]},L.prototype.getClass=function(){return L},L.toLocationSymbol=function(t){switch(t){case L.EXTERIOR:return"e";case L.BOUNDARY:return"b";case L.INTERIOR:return"i";case L.NONE:return"-"}throw new m("Unknown location value: "+t)},O.INTERIOR.get=function(){return 0},O.BOUNDARY.get=function(){return 1},O.EXTERIOR.get=function(){return 2},O.NONE.get=function(){return-1},Object.defineProperties(L,O);var T=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},P=function(){},R={LOG_10:{configurable:!0}};P.prototype.interfaces_=function(){return[]},P.prototype.getClass=function(){return P},P.log10=function(t){var e=Math.log(t);return v.isInfinite(e)||v.isNaN(e)?e:e/P.LOG_10},P.min=function(t,e,n,i){var r=t;return e<r&&(r=e),n<r&&(r=n),i<r&&(r=i),r},P.clamp=function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],n=arguments[2];return t<e?e:t>n?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],o=arguments[2];return i<r?r:i>o?o:i}},P.wrap=function(t,e){return t<0?e- -t%e:t%e},P.max=function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var i=arguments[1],r=arguments[2],o=arguments[3],s=arguments[0];return i>s&&(s=i),r>s&&(s=r),o>s&&(s=o),s}},P.average=function(t,e){return(t+e)/2},R.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(P,R);var M=function(t){this.str=t};M.prototype.append=function(t){this.str+=t},M.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},M.prototype.toString=function(t){return this.str};var D=function(t){this.value=t};D.prototype.intValue=function(){return this.value},D.prototype.compareTo=function(t){return this.value<t?-1:this.value>t?1:0},D.isNaN=function(t){return Number.isNaN(t)};var A=function(){};A.isWhitespace=function(t){return t<=32&&t>=0||127===t},A.toUpperCase=function(t){return t.toUpperCase()};var F=function t(){this._hi=0,this._lo=0,0===arguments.length?this.init(0):1===arguments.length?"number"==typeof arguments[0]||arguments[0]instanceof t?this.init(arguments[0]):"string"==typeof arguments[0]&&t.call(this,t.parse(arguments[0])):2===arguments.length&&this.init(arguments[0],arguments[1])},G={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};F.prototype.le=function(t){return(this._hi<t._hi||this._hi===t._hi)&&this._lo<=t._lo},F.prototype.extractSignificantDigits=function(t,e){var n=this.abs(),i=F.magnitude(n._hi),r=F.TEN.pow(i);(n=n.divide(r)).gt(F.TEN)?(n=n.divide(F.TEN),i+=1):n.lt(F.ONE)&&(n=n.multiply(F.TEN),i-=1);for(var o=i+1,s=new M,a=F.MAX_PRINT_DIGITS-1,u=0;u<=a;u++){t&&u===o&&s.append(".");var l=Math.trunc(n._hi);if(l<0)break;var c=!1,p=0;l>9?(c=!0,p="9"):p="0"+l,s.append(p),n=n.subtract(F.valueOf(l)).multiply(F.TEN),c&&n.selfAdd(F.TEN);var h=!0,f=F.magnitude(n._hi);if(f<0&&Math.abs(f)>=a-u&&(h=!1),!h)break}return e[0]=i,s.toString()},F.prototype.sqr=function(){return this.multiply(this)},F.prototype.doubleValue=function(){return this._hi+this._lo},F.prototype.subtract=function(){return arguments[0]instanceof F?this.add(arguments[0].negate()):"number"==typeof arguments[0]?this.add(-arguments[0]):void 0},F.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},F.prototype.isZero=function(){return 0===this._hi&&0===this._lo},F.prototype.selfSubtract=function(){if(arguments[0]instanceof F){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},F.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},F.prototype.min=function(t){return this.le(t)?this:t},F.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof F){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0])return this.selfDivide(arguments[0],0)}else if(2===arguments.length){var e=arguments[0],n=null,i=null,r=null,o=null,s=null,a=null,u=null,l=null;return this._hi=l=(s=this._hi/e)+(a=(this._hi-(u=s*e)-(l=(n=(a=F.SPLIT*s)-(n=a-s))*(r=(l=F.SPLIT*e)-(r=l-e))-u+n*(o=e-r)+(i=s-n)*r+i*o)+this._lo-s*arguments[1])/e),this._lo=s-l+a,this}},F.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},F.prototype.divide=function(){if(arguments[0]instanceof F){var t=arguments[0],e=null,n=null,i=null,r=null,o=null,s=null,a=null,u=null;return n=(o=this._hi/t._hi)-(e=(s=F.SPLIT*o)-(e=s-o)),u=e*(i=(u=F.SPLIT*t._hi)-(i=u-t._hi))-(a=o*t._hi)+e*(r=t._hi-i)+n*i+n*r,new F(u=o+(s=(this._hi-a-u+this._lo-o*t._lo)/t._hi),o-u+s)}if("number"==typeof arguments[0]){var l=arguments[0];return v.isNaN(l)?F.createNaN():F.copy(this).selfDivide(l,0)}},F.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},F.prototype.pow=function(t){if(0===t)return F.valueOf(1);var e=new F(this),n=F.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2==1&&n.selfMultiply(e),(i/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},F.prototype.ceil=function(){if(this.isNaN())return F.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new F(t,e)},F.prototype.compareTo=function(t){return this._hi<t._hi?-1:this._hi>t._hi?1:this._lo<t._lo?-1:this._lo>t._lo?1:0},F.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},F.prototype.setValue=function(){return arguments[0]instanceof F||"number"==typeof arguments[0]?(this.init(arguments[0]),this):void 0},F.prototype.max=function(t){return this.ge(t)?this:t},F.prototype.sqrt=function(){if(this.isZero())return F.valueOf(0);if(this.isNegative())return F.NaN;var t=1/Math.sqrt(this._hi),e=F.valueOf(this._hi*t),n=this.subtract(e.sqr())._hi*(.5*t);return e.add(n)},F.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof F){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0],n=null,i=null,r=null,o=null,s=null;return this._hi=(n=(r=this._hi+e)+(s=e-(o=r-this._hi)+(this._hi-(r-o))+this._lo))+(i=s+(r-n)),this._lo=i+(n-this._hi),this}}else if(2===arguments.length){var a=arguments[0],u=arguments[1],l=null,c=null,p=null,h=null,f=null,g=null,d=null;f=(h=this._hi+a)-(g=h-this._hi),p=(c=this._lo+u)-(d=c-this._lo);var y=(l=h+(g=(f=a-g+(this._hi-f))+c))+(g=(p=u-d+(this._lo-p))+(g+(h-l))),_=g+(l-y);return this._hi=y,this._lo=_,this}},F.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof F){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0])return this.selfMultiply(arguments[0],0)}else if(2===arguments.length){var e=arguments[0],n=null,i=null,r=null,o=null,s=null,a=null;n=(s=F.SPLIT*this._hi)-this._hi,n=s-n;var u=(s=this._hi*e)+(a=n*(r=(a=F.SPLIT*e)-(r=a-e))-s+n*(o=e-r)+(i=this._hi-n)*r+i*o+(this._hi*arguments[1]+this._lo*e)),l=a+(n=s-u);return this._hi=u,this._lo=l,this}},F.prototype.selfSqr=function(){return this.selfMultiply(this)},F.prototype.floor=function(){if(this.isNaN())return F.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new F(t,e)},F.prototype.negate=function(){return this.isNaN()?this:new F(-this._hi,-this._lo)},F.prototype.clone=function(){},F.prototype.multiply=function(){if(arguments[0]instanceof F){var t=arguments[0];return t.isNaN()?F.createNaN():F.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return v.isNaN(e)?F.createNaN():F.copy(this).selfMultiply(e,0)}},F.prototype.isNaN=function(){return v.isNaN(this._hi)},F.prototype.intValue=function(){return Math.trunc(this._hi)},F.prototype.toString=function(){var t=F.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},F.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),i=e[0]+1,r=n;return"."===n.charAt(0)?r="0"+n:i<0?r="0."+F.stringOfChar("0",-i)+n:-1===n.indexOf(".")&&(r=n+F.stringOfChar("0",i-n.length)+".0"),this.isNegative()?"-"+r:r},F.prototype.reciprocal=function(){var t=null,e=null,n=null,i=null,r=null,o=null,s=null,a=null;e=(r=1/this._hi)-(t=(o=F.SPLIT*r)-(t=o-r)),n=(a=F.SPLIT*this._hi)-this._hi;var u=r+(o=(1-(s=r*this._hi)-(a=t*(n=a-n)-s+t*(i=this._hi-n)+e*n+e*i)-r*this._lo)/this._hi);return new F(u,r-u+o)},F.prototype.toSciNotation=function(){if(this.isZero())return F.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),i=F.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new Error("Found leading zero: "+n);var r="";n.length>1&&(r=n.substring(1));var o=n.charAt(0)+"."+r;return this.isNegative()?"-"+o+i:o+i},F.prototype.abs=function(){return this.isNaN()?F.NaN:this.isNegative()?this.negate():new F(this)},F.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0},F.prototype.lt=function(t){return(this._hi<t._hi||this._hi===t._hi)&&this._lo<t._lo},F.prototype.add=function(){if(arguments[0]instanceof F){var t=arguments[0];return F.copy(this).selfAdd(t)}if("number"==typeof arguments[0]){var e=arguments[0];return F.copy(this).selfAdd(e)}},F.prototype.init=function(){if(1===arguments.length){if("number"==typeof arguments[0])this._hi=arguments[0],this._lo=0;else if(arguments[0]instanceof F){var t=arguments[0];this._hi=t._hi,this._lo=t._lo}}else if(2===arguments.length){var e=arguments[1];this._hi=arguments[0],this._lo=e}},F.prototype.gt=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>t._lo},F.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0},F.prototype.trunc=function(){return this.isNaN()?F.NaN:this.isPositive()?this.floor():this.ceil()},F.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},F.prototype.interfaces_=function(){return[e,x,E]},F.prototype.getClass=function(){return F},F.sqr=function(t){return F.valueOf(t).selfMultiply(t)},F.valueOf=function(){return"string"==typeof arguments[0]?F.parse(arguments[0]):"number"==typeof arguments[0]?new F(arguments[0]):void 0},F.sqrt=function(t){return F.valueOf(t).sqrt()},F.parse=function(t){for(var e=0,n=t.length;A.isWhitespace(t.charAt(e));)e++;var i=!1;if(e<n){var r=t.charAt(e);"-"!==r&&"+"!==r||(e++,"-"===r&&(i=!0))}for(var o=new F,s=0,a=0,u=0;!(e>=n);){var l=t.charAt(e);if(e++,A.isDigit(l)){var c=l-"0";o.selfMultiply(F.TEN),o.selfAdd(c),s++}else{if("."!==l){if("e"===l||"E"===l){var p=t.substring(e);try{u=D.parseInt(p)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+p+" in string "+t):e}break}throw new Error("Unexpected character \'"+l+"\' at position "+e+" in string "+t)}a=s}}var h=o,f=s-a-u;if(0===f)h=o;else if(f>0){var g=F.TEN.pow(f);h=o.divide(g)}else if(f<0){var d=F.TEN.pow(-f);h=o.multiply(d)}return i?h.negate():h},F.createNaN=function(){return new F(v.NaN,v.NaN)},F.copy=function(t){return new F(t)},F.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i},F.stringOfChar=function(t,e){for(var n=new M,i=0;i<e;i++)n.append(t);return n.toString()},G.PI.get=function(){return new F(3.141592653589793,12246467991473532e-32)},G.TWO_PI.get=function(){return new F(6.283185307179586,24492935982947064e-32)},G.PI_2.get=function(){return new F(1.5707963267948966,6123233995736766e-32)},G.E.get=function(){return new F(2.718281828459045,14456468917292502e-32)},G.NaN.get=function(){return new F(v.NaN,v.NaN)},G.EPS.get=function(){return 123259516440783e-46},G.SPLIT.get=function(){return 134217729},G.MAX_PRINT_DIGITS.get=function(){return 32},G.TEN.get=function(){return F.valueOf(10)},G.ONE.get=function(){return F.valueOf(1)},G.SCI_NOT_EXPONENT_CHAR.get=function(){return"E"},G.SCI_NOT_ZERO.get=function(){return"0.0E0"},Object.defineProperties(F,G);var V=function(){},q={DP_SAFE_EPSILON:{configurable:!0}};V.prototype.interfaces_=function(){return[]},V.prototype.getClass=function(){return V},V.orientationIndex=function(t,e,n){var i=V.orientationIndexFilter(t,e,n);if(i<=1)return i;var r=F.valueOf(e.x).selfAdd(-t.x),o=F.valueOf(e.y).selfAdd(-t.y),s=F.valueOf(n.x).selfAdd(-e.x),a=F.valueOf(n.y).selfAdd(-e.y);return r.selfMultiply(a).selfSubtract(o.selfMultiply(s)).signum()},V.signOfDet2x2=function(t,e,n,i){return t.multiply(i).selfSubtract(e.multiply(n)).signum()},V.intersection=function(t,e,n,i){var r=F.valueOf(i.y).selfSubtract(n.y).selfMultiply(F.valueOf(e.x).selfSubtract(t.x)),o=F.valueOf(i.x).selfSubtract(n.x).selfMultiply(F.valueOf(e.y).selfSubtract(t.y)),s=r.subtract(o),a=F.valueOf(i.x).selfSubtract(n.x).selfMultiply(F.valueOf(t.y).selfSubtract(n.y)),u=F.valueOf(i.y).selfSubtract(n.y).selfMultiply(F.valueOf(t.x).selfSubtract(n.x)),l=a.subtract(u).selfDivide(s).doubleValue(),c=F.valueOf(t.x).selfAdd(F.valueOf(e.x).selfSubtract(t.x).selfMultiply(l)).doubleValue(),p=F.valueOf(e.x).selfSubtract(t.x).selfMultiply(F.valueOf(t.y).selfSubtract(n.y)),h=F.valueOf(e.y).selfSubtract(t.y).selfMultiply(F.valueOf(t.x).selfSubtract(n.x)),f=p.subtract(h).selfDivide(s).doubleValue(),g=F.valueOf(n.y).selfAdd(F.valueOf(i.y).selfSubtract(n.y).selfMultiply(f)).doubleValue();return new w(c,g)},V.orientationIndexFilter=function(t,e,n){var i=null,r=(t.x-n.x)*(e.y-n.y),o=(t.y-n.y)*(e.x-n.x),s=r-o;if(r>0){if(o<=0)return V.signum(s);i=r+o}else{if(!(r<0))return V.signum(s);if(o>=0)return V.signum(s);i=-r-o}var a=V.DP_SAFE_EPSILON*i;return s>=a||-s>=a?V.signum(s):2},V.signum=function(t){return t>0?1:t<0?-1:0},q.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(V,q);var B=function(){},z={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};z.X.get=function(){return 0},z.Y.get=function(){return 1},z.Z.get=function(){return 2},z.M.get=function(){return 3},B.prototype.setOrdinate=function(t,e,n){},B.prototype.size=function(){},B.prototype.getOrdinate=function(t,e){},B.prototype.getCoordinate=function(){},B.prototype.getCoordinateCopy=function(t){},B.prototype.getDimension=function(){},B.prototype.getX=function(t){},B.prototype.clone=function(){},B.prototype.expandEnvelope=function(t){},B.prototype.copy=function(){},B.prototype.getY=function(t){},B.prototype.toCoordinateArray=function(){},B.prototype.interfaces_=function(){return[E]},B.prototype.getClass=function(){return B},Object.defineProperties(B,z);var U=function(){},k=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(U),X=function(){};X.arraycopy=function(t,e,n,i,r){for(var o=0,s=e;s<e+r;s++)n[i+o]=t[s],o++},X.getProperty=function(t){return{"line.separator":"\\n"}[t]};var Y=function t(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[1];this.x=arguments[0],this.y=n,this.w=1}else if(arguments[0]instanceof t&&arguments[1]instanceof t){var i=arguments[0],r=arguments[1];this.x=i.y*r.w-r.y*i.w,this.y=r.x*i.w-i.x*r.w,this.w=i.x*r.y-r.x*i.y}else if(arguments[0]instanceof w&&arguments[1]instanceof w){var o=arguments[0],s=arguments[1];this.x=o.y-s.y,this.y=s.x-o.x,this.w=o.x*s.y-s.x*o.y}}else if(3===arguments.length){var a=arguments[1],u=arguments[2];this.x=arguments[0],this.y=a,this.w=u}else if(4===arguments.length){var l=arguments[0],c=arguments[1],p=arguments[2],h=arguments[3],f=l.y-c.y,g=c.x-l.x,d=l.x*c.y-c.x*l.y,y=p.y-h.y,_=h.x-p.x,m=p.x*h.y-h.x*p.y;this.x=g*m-_*d,this.y=y*d-f*m,this.w=f*_-y*g}};Y.prototype.getY=function(){var t=this.y/this.w;if(v.isNaN(t)||v.isInfinite(t))throw new k;return t},Y.prototype.getX=function(){var t=this.x/this.w;if(v.isNaN(t)||v.isInfinite(t))throw new k;return t},Y.prototype.getCoordinate=function(){var t=new w;return t.x=this.getX(),t.y=this.getY(),t},Y.prototype.interfaces_=function(){return[]},Y.prototype.getClass=function(){return Y},Y.intersection=function(t,e,n,i){var r=t.y-e.y,o=e.x-t.x,s=t.x*e.y-e.x*t.y,a=n.y-i.y,u=i.x-n.x,l=n.x*i.y-i.x*n.y,c=r*u-a*o,p=(o*l-u*s)/c,h=(a*s-r*l)/c;if(v.isNaN(p)||v.isInfinite(p)||v.isNaN(h)||v.isInfinite(h))throw new k;return new w(p,h)};var j=function t(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length)if(arguments[0]instanceof w){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else arguments[0]instanceof t&&this.init(arguments[0]);else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else 4===arguments.length&&this.init(arguments[0],arguments[1],arguments[2],arguments[3])},H={serialVersionUID:{configurable:!0}};j.prototype.getArea=function(){return this.getWidth()*this.getHeight()},j.prototype.equals=function(t){if(!(t instanceof j))return!1;var e=t;return this.isNull()?e.isNull():this._maxx===e.getMaxX()&&this._maxy===e.getMaxY()&&this._minx===e.getMinX()&&this._miny===e.getMinY()},j.prototype.intersection=function(t){return this.isNull()||t.isNull()||!this.intersects(t)?new j:new j(this._minx>t._minx?this._minx:t._minx,this._maxx<t._maxx?this._maxx:t._maxx,this._miny>t._miny?this._miny:t._miny,this._maxy<t._maxy?this._maxy:t._maxy)},j.prototype.isNull=function(){return this._maxx<this._minx},j.prototype.getMaxX=function(){return this._maxx},j.prototype.covers=function(){if(1===arguments.length){if(arguments[0]instanceof w){var t=arguments[0];return this.covers(t.x,t.y)}if(arguments[0]instanceof j){var e=arguments[0];return!this.isNull()&&!e.isNull()&&e.getMinX()>=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&i>=this._miny&&i<=this._maxy}},j.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof j){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny)}if(arguments[0]instanceof w){var e=arguments[0];return this.intersects(e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&!(n>this._maxx||n<this._minx||i>this._maxy||i<this._miny)}},j.prototype.getMinY=function(){return this._miny},j.prototype.getMinX=function(){return this._minx},j.prototype.expandToInclude=function(){if(1===arguments.length){if(arguments[0]instanceof w){var t=arguments[0];this.expandToInclude(t.x,t.y)}else if(arguments[0]instanceof j){var e=arguments[0];if(e.isNull())return null;this.isNull()?(this._minx=e.getMinX(),this._maxx=e.getMaxX(),this._miny=e.getMinY(),this._maxy=e.getMaxY()):(e._minx<this._minx&&(this._minx=e._minx),e._maxx>this._maxx&&(this._maxx=e._maxx),e._miny<this._miny&&(this._miny=e._miny),e._maxy>this._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=i,this._maxy=i):(n<this._minx&&(this._minx=n),n>this._maxx&&(this._maxx=n),i<this._miny&&(this._miny=i),i>this._maxy&&(this._maxy=i))}},j.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t<e?t:e},j.prototype.getWidth=function(){return this.isNull()?0:this._maxx-this._minx},j.prototype.compareTo=function(t){var e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this._minx<e._minx?-1:this._minx>e._minx?1:this._miny<e._miny?-1:this._miny>e._miny?1:this._maxx<e._maxx?-1:this._maxx>e._maxx?1:this._maxy<e._maxy?-1:this._maxy>e._maxy?1:0},j.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},j.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},j.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},j.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},j.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},j.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}},j.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof j)return this.covers(arguments[0]);if(arguments[0]instanceof w)return this.covers(arguments[0])}else if(2===arguments.length)return this.covers(arguments[0],arguments[1])},j.prototype.centre=function(){return this.isNull()?null:new w((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},j.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof w){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof j){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];r<o?(this._minx=r,this._maxx=o):(this._minx=o,this._maxx=r),s<a?(this._miny=s,this._maxy=a):(this._miny=a,this._maxy=s)}},j.prototype.getMaxY=function(){return this._maxy},j.prototype.distance=function(t){if(this.intersects(t))return 0;var e=0;this._maxx<t._minx?e=t._minx-this._maxx:this._minx>t._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxy<t._miny?n=t._miny-this._maxy:this._miny>t._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},j.prototype.hashCode=function(){var t=17;return 37*(t=37*(t=37*(t=37*t+w.hashCode(this._minx))+w.hashCode(this._maxx))+w.hashCode(this._miny))+w.hashCode(this._maxy)},j.prototype.interfaces_=function(){return[x,e]},j.prototype.getClass=function(){return j},j.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.x<e.x?t.x:e.x)&&n.x<=(t.x>e.x?t.x:e.x)&&n.y>=(t.y<e.y?t.y:e.y)&&n.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),u=Math.max(o.x,s.x),l=Math.min(i.x,r.x),c=Math.max(i.x,r.x);return!(l>u||c<a||(a=Math.min(o.y,s.y),u=Math.max(o.y,s.y),l=Math.min(i.y,r.y),c=Math.max(i.y,r.y),l>u||c<a))}},H.serialVersionUID.get=function(){return 0x51845cd552189800},Object.defineProperties(j,H);var W={typeStr:/^\\s*(\\w+)\\s*\\(\\s*(.*)\\s*\\)\\s*$/,emptyTypeStr:/^\\s*(\\w+)\\s*EMPTY\\s*$/,spaces:/\\s+/,parenComma:/\\)\\s*,\\s*\\(/,doubleParenComma:/\\)\\s*\\)\\s*,\\s*\\(\\s*\\(/,trimParens:/^\\s*\\(?(.*?)\\)?\\s*$/},J=function(t){this.geometryFactory=t||new _e};J.prototype.read=function(t){var e,n;t=t.replace(/[\\n\\r]/g," ");var i=W.typeStr.exec(t);if(-1!==t.search("EMPTY")&&((i=W.emptyTypeStr.exec(t))[2]=void 0),i&&(n=i[1].toLowerCase(),Q[n]&&(e=Q[n].apply(this,[i[2]]))),void 0===e)throw new Error("Could not parse WKT "+t);return e},J.prototype.write=function(t){return this.extractGeometry(t)},J.prototype.extractGeometry=function(t){var e=t.getGeometryType().toLowerCase();if(!K[e])return null;var n=e.toUpperCase();return t.isEmpty()?n+" EMPTY":n+"("+K[e].apply(this,[t])+")"};var K={coordinate:function(t){return t.x+" "+t.y},point:function(t){return K.coordinate.call(this,t._coordinates._coordinates[0])},multipoint:function(t){for(var e=[],n=0,i=t._geometries.length;n<i;++n)e.push("("+K.point.apply(this,[t._geometries[n]])+")");return e.join(",")},linestring:function(t){for(var e=[],n=0,i=t._points._coordinates.length;n<i;++n)e.push(K.coordinate.apply(this,[t._points._coordinates[n]]));return e.join(",")},linearring:function(t){for(var e=[],n=0,i=t._points._coordinates.length;n<i;++n)e.push(K.coordinate.apply(this,[t._points._coordinates[n]]));return e.join(",")},multilinestring:function(t){for(var e=[],n=0,i=t._geometries.length;n<i;++n)e.push("("+K.linestring.apply(this,[t._geometries[n]])+")");return e.join(",")},polygon:function(t){var e=[];e.push("("+K.linestring.apply(this,[t._shell])+")");for(var n=0,i=t._holes.length;n<i;++n)e.push("("+K.linestring.apply(this,[t._holes[n]])+")");return e.join(",")},multipolygon:function(t){for(var e=[],n=0,i=t._geometries.length;n<i;++n)e.push("("+K.polygon.apply(this,[t._geometries[n]])+")");return e.join(",")},geometrycollection:function(t){for(var e=[],n=0,i=t._geometries.length;n<i;++n)e.push(this.extractGeometry(t._geometries[n]));return e.join(",")}},Q={point:function(t){if(void 0===t)return this.geometryFactory.createPoint();var e=t.trim().split(W.spaces);return this.geometryFactory.createPoint(new w(Number.parseFloat(e[0]),Number.parseFloat(e[1])))},multipoint:function(t){if(void 0===t)return this.geometryFactory.createMultiPoint();for(var e,n=t.trim().split(","),i=[],r=0,o=n.length;r<o;++r)e=n[r].replace(W.trimParens,"$1"),i.push(Q.point.apply(this,[e]));return this.geometryFactory.createMultiPoint(i)},linestring:function(t){if(void 0===t)return this.geometryFactory.createLineString();for(var e,n=t.trim().split(","),i=[],r=0,o=n.length;r<o;++r)e=n[r].trim().split(W.spaces),i.push(new w(Number.parseFloat(e[0]),Number.parseFloat(e[1])));return this.geometryFactory.createLineString(i)},linearring:function(t){if(void 0===t)return this.geometryFactory.createLinearRing();for(var e,n=t.trim().split(","),i=[],r=0,o=n.length;r<o;++r)e=n[r].trim().split(W.spaces),i.push(new w(Number.parseFloat(e[0]),Number.parseFloat(e[1])));return this.geometryFactory.createLinearRing(i)},multilinestring:function(t){if(void 0===t)return this.geometryFactory.createMultiLineString();for(var e,n=t.trim().split(W.parenComma),i=[],r=0,o=n.length;r<o;++r)e=n[r].replace(W.trimParens,"$1"),i.push(Q.linestring.apply(this,[e]));return this.geometryFactory.createMultiLineString(i)},polygon:function(t){if(void 0===t)return this.geometryFactory.createPolygon();for(var e,n,i,r,o=t.trim().split(W.parenComma),s=[],a=0,u=o.length;a<u;++a)e=o[a].replace(W.trimParens,"$1"),n=Q.linestring.apply(this,[e]),i=this.geometryFactory.createLinearRing(n._points),0===a?r=i:s.push(i);return this.geometryFactory.createPolygon(r,s)},multipolygon:function(t){if(void 0===t)return this.geometryFactory.createMultiPolygon();for(var e,n=t.trim().split(W.doubleParenComma),i=[],r=0,o=n.length;r<o;++r)e=n[r].replace(W.trimParens,"$1"),i.push(Q.polygon.apply(this,[e]));return this.geometryFactory.createMultiPolygon(i)},geometrycollection:function(t){if(void 0===t)return this.geometryFactory.createGeometryCollection();for(var e=(t=t.replace(/,\\s*([A-Za-z])/g,"|$1")).trim().split("|"),n=[],i=0,r=e.length;i<r;++i)n.push(this.read(e[i]));return this.geometryFactory.createGeometryCollection(n)}},$=function(t){this.parser=new J(t)};$.prototype.write=function(t){return this.parser.write(t)},$.toLineString=function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"};var Z=function(t){function e(e){t.call(this,e),this.name="RuntimeException",this.message=e,this.stack=(new t).stack}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),tt=function(t){function e(){t.call(this),0===arguments.length?t.call(this):1===arguments.length&&t.call(this,arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Z),et=function(){};et.prototype.interfaces_=function(){return[]},et.prototype.getClass=function(){return et},et.shouldNeverReachHere=function(){if(0===arguments.length)et.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new tt("Should never reach here"+(null!==t?": "+t:""))}},et.isTrue=function(){var t;if(1===arguments.length)et.isTrue(arguments[0],null);else if(2===arguments.length&&(t=arguments[1],!arguments[0]))throw null===t?new tt:new tt(t)},et.equals=function(){var t,e,n;if(2===arguments.length)et.equals(t=arguments[0],e=arguments[1],null);else if(3===arguments.length&&(n=arguments[2],!(e=arguments[1]).equals(t=arguments[0])))throw new tt("Expected "+t+" but encountered "+e+(null!==n?": "+n:""))};var nt=function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new w,this._intPt[1]=new w,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0},it={DONT_INTERSECT:{configurable:!0},DO_INTERSECT:{configurable:!0},COLLINEAR:{configurable:!0},NO_INTERSECTION:{configurable:!0},POINT_INTERSECTION:{configurable:!0},COLLINEAR_INTERSECTION:{configurable:!0}};nt.prototype.getIndexAlongSegment=function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]},nt.prototype.getTopologySummary=function(){var t=new M;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()},nt.prototype.computeIntersection=function(t,e,n,i){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(t,e,n,i)},nt.prototype.getIntersectionNum=function(){return this._result},nt.prototype.computeIntLineIndex=function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},nt.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},nt.prototype.setPrecisionModel=function(t){this._precisionModel=t},nt.prototype.isInteriorIntersection=function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;e<this._result;e++)if(!this._intPt[e].equals2D(this._inputLines[t][0])&&!this._intPt[e].equals2D(this._inputLines[t][1]))return!0;return!1}},nt.prototype.getIntersection=function(t){return this._intPt[t]},nt.prototype.isEndPoint=function(){return this.hasIntersection()&&!this._isProper},nt.prototype.hasIntersection=function(){return this._result!==nt.NO_INTERSECTION},nt.prototype.getEdgeDistance=function(t,e){return nt.computeEdgeDistance(this._intPt[e],this._inputLines[t][0],this._inputLines[t][1])},nt.prototype.isCollinear=function(){return this._result===nt.COLLINEAR_INTERSECTION},nt.prototype.toString=function(){return $.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+$.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()},nt.prototype.getEndpoint=function(t,e){return this._inputLines[t][e]},nt.prototype.isIntersection=function(t){for(var e=0;e<this._result;e++)if(this._intPt[e].equals2D(t))return!0;return!1},nt.prototype.getIntersectionAlongSegment=function(t,e){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[t][e]]},nt.prototype.interfaces_=function(){return[]},nt.prototype.getClass=function(){return nt},nt.computeEdgeDistance=function(t,e,n){var i=Math.abs(n.x-e.x),r=Math.abs(n.y-e.y),o=-1;if(t.equals(e))o=0;else if(t.equals(n))o=i>r?i:r;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=i>r?s:a)||t.equals(e)||(o=Math.max(s,a))}return et.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},nt.nonRobustComputeEdgeDistance=function(t,e,n){var i=t.x-e.x,r=t.y-e.y,o=Math.sqrt(i*i+r*r);return et.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},it.DONT_INTERSECT.get=function(){return 0},it.DO_INTERSECT.get=function(){return 1},it.COLLINEAR.get=function(){return 2},it.NO_INTERSECTION.get=function(){return 0},it.POINT_INTERSECTION.get=function(){return 1},it.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(nt,it);var rt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isInSegmentEnvelopes=function(t){var e=new j(this._inputLines[0][0],this._inputLines[0][1]),n=new j(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],n=arguments[1],i=arguments[2];if(this._isProper=!1,j.intersects(n,i,e)&&0===at.orientationIndex(n,i,e)&&0===at.orientationIndex(i,n,e))return this._isProper=!0,(e.equals(n)||e.equals(i))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(t,e,n,i,r){r.x=this.smallestInAbsValue(t.x,e.x,n.x,i.x),r.y=this.smallestInAbsValue(t.y,e.y,n.y,i.y),t.x-=r.x,t.y-=r.y,e.x-=r.x,e.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},e.prototype.safeHCoordinateIntersection=function(t,n,i,r){var o=null;try{o=Y.intersection(t,n,i,r)}catch(s){if(!(s instanceof k))throw s;o=e.nearestEndpoint(t,n,i,r)}return o},e.prototype.intersection=function(t,n,i,r){var o=this.intersectionWithNormalization(t,n,i,r);return this.isInSegmentEnvelopes(o)||(o=new w(e.nearestEndpoint(t,n,i,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o},e.prototype.smallestInAbsValue=function(t,e,n,i){var r=t,o=Math.abs(r);return Math.abs(e)<o&&(r=e,o=Math.abs(e)),Math.abs(n)<o&&(r=n,o=Math.abs(n)),Math.abs(i)<o&&(r=i),r},e.prototype.checkDD=function(t,e,n,i,r){var o=V.intersection(t,e,n,i),s=this.isInSegmentEnvelopes(o);X.out.println("DD in env = "+s+"  --------------------- "+o),r.distance(o)>1e-4&&X.out.println("Distance = "+r.distance(o))},e.prototype.intersectionWithNormalization=function(t,e,n,i){var r=new w(t),o=new w(e),s=new w(n),a=new w(i),u=new w;this.normalizeToEnvCentre(r,o,s,a,u);var l=this.safeHCoordinateIntersection(r,o,s,a);return l.x+=u.x,l.y+=u.y,l},e.prototype.computeCollinearIntersection=function(e,n,i,r){var o=j.intersects(e,n,i),s=j.intersects(e,n,r),a=j.intersects(i,r,e),u=j.intersects(i,r,n);return o&&s?(this._intPt[0]=i,this._intPt[1]=r,t.COLLINEAR_INTERSECTION):a&&u?(this._intPt[0]=e,this._intPt[1]=n,t.COLLINEAR_INTERSECTION):o&&a?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||s||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&u?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||s||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&a?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||o||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&u?(this._intPt[0]=r,this._intPt[1]=n,!r.equals(n)||o||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(t,e,n,i,r){var o=t.x<e.x?t.x:e.x,s=t.y<e.y?t.y:e.y,a=t.x>e.x?t.x:e.x,u=t.y>e.y?t.y:e.y,l=n.x<i.x?n.x:i.x,c=n.y<i.y?n.y:i.y,p=n.x>i.x?n.x:i.x,h=n.y>i.y?n.y:i.y,f=((s>c?s:c)+(u<h?u:h))/2;r.x=((o>l?o:l)+(a<p?a:p))/2,r.y=f,t.x-=r.x,t.y-=r.y,e.x-=r.x,e.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},e.prototype.computeIntersect=function(e,n,i,r){if(this._isProper=!1,!j.intersects(e,n,i,r))return t.NO_INTERSECTION;var o=at.orientationIndex(e,n,i),s=at.orientationIndex(e,n,r);if(o>0&&s>0||o<0&&s<0)return t.NO_INTERSECTION;var a=at.orientationIndex(i,r,e),u=at.orientationIndex(i,r,n);return a>0&&u>0||a<0&&u<0?t.NO_INTERSECTION:0===o&&0===s&&0===a&&0===u?this.computeCollinearIntersection(e,n,i,r):(0===o||0===s||0===a||0===u?(this._isProper=!1,e.equals2D(i)||e.equals2D(r)?this._intPt[0]=e:n.equals2D(i)||n.equals2D(r)?this._intPt[0]=n:0===o?this._intPt[0]=new w(i):0===s?this._intPt[0]=new w(r):0===a?this._intPt[0]=new w(e):0===u&&(this._intPt[0]=new w(n))):(this._isProper=!0,this._intPt[0]=this.intersection(e,n,i,r)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(t,e,n,i){var r=t,o=at.distancePointLine(t,n,i),s=at.distancePointLine(e,n,i);return s<o&&(o=s,r=e),(s=at.distancePointLine(n,t,e))<o&&(o=s,r=n),(s=at.distancePointLine(i,t,e))<o&&(o=s,r=i),r},e}(nt),ot=function(){};ot.prototype.interfaces_=function(){return[]},ot.prototype.getClass=function(){return ot},ot.orientationIndex=function(t,e,n){return ot.signOfDet2x2(e.x-t.x,e.y-t.y,n.x-e.x,n.y-e.y)},ot.signOfDet2x2=function(t,e,n,i){var r=null,o=null,s=null;if(r=1,0===t||0===i)return 0===e||0===n?0:e>0?n>0?-r:r:n>0?r:-r;if(0===e||0===n)return i>0?t>0?r:-r:t>0?-r:r;if(e>0?i>0?e<=i||(r=-r,o=t,t=n,n=o,o=e,e=i,i=o):e<=-i?(r=-r,n=-n,i=-i):(o=t,t=-n,n=o,o=e,e=-i,i=o):i>0?-e<=i?(r=-r,t=-t,e=-e):(o=-t,t=n,n=o,o=-e,e=i,i=o):e>=i?(t=-t,e=-e,n=-n,i=-i):(r=-r,o=-t,t=-n,n=o,o=-e,e=-i,i=o),t>0){if(!(n>0))return r;if(!(t<=n))return r}else{if(n>0)return-r;if(!(t>=n))return-r;r=-r,t=-t,n=-n}for(;;){if((i-=(s=Math.floor(n/t))*e)<0)return-r;if(i>e)return r;if(t>(n-=s*t)+n){if(e<i+i)return r}else{if(e>i+i)return-r;n=t-n,i=e-i,r=-r}if(0===i)return 0===n?0:-r;if(0===n)return r;if((e-=(s=Math.floor(t/n))*i)<0)return r;if(e>i)return-r;if(n>(t-=s*n)+t){if(i<e+e)return-r}else{if(i>e+e)return r;t=n-t,e=i-e,r=-r}if(0===e)return 0===t?0:r;if(0===t)return-r}};var st=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1,this._p=arguments[0]};st.prototype.countSegment=function(t,e){if(t.x<this._p.x&&e.x<this._p.x)return null;if(this._p.x===e.x&&this._p.y===e.y)return this._isPointOnSegment=!0,null;if(t.y===this._p.y&&e.y===this._p.y){var n=t.x,i=e.x;return n>i&&(n=e.x,i=t.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var r=t.y-this._p.y,o=e.y-this._p.y,s=ot.signOfDet2x2(t.x-this._p.x,r,e.x-this._p.x,o);if(0===s)return this._isPointOnSegment=!0,null;o<r&&(s=-s),s>0&&this._crossingCount++}},st.prototype.isPointInPolygon=function(){return this.getLocation()!==L.EXTERIOR},st.prototype.getLocation=function(){return this._isPointOnSegment?L.BOUNDARY:this._crossingCount%2==1?L.INTERIOR:L.EXTERIOR},st.prototype.isOnSegment=function(){return this._isPointOnSegment},st.prototype.interfaces_=function(){return[]},st.prototype.getClass=function(){return st},st.locatePointInRing=function(){if(arguments[0]instanceof w&&T(arguments[1],B)){for(var t=arguments[1],e=new st(arguments[0]),n=new w,i=new w,r=1;r<t.size();r++)if(t.getCoordinate(r,n),t.getCoordinate(r-1,i),e.countSegment(n,i),e.isOnSegment())return e.getLocation();return e.getLocation()}if(arguments[0]instanceof w&&arguments[1]instanceof Array){for(var o=arguments[1],s=new st(arguments[0]),a=1;a<o.length;a++)if(s.countSegment(o[a],o[a-1]),s.isOnSegment())return s.getLocation();return s.getLocation()}};var at=function(){},ut={CLOCKWISE:{configurable:!0},RIGHT:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},LEFT:{configurable:!0},COLLINEAR:{configurable:!0},STRAIGHT:{configurable:!0}};at.prototype.interfaces_=function(){return[]},at.prototype.getClass=function(){return at},at.orientationIndex=function(t,e,n){return V.orientationIndex(t,e,n)},at.signedArea=function(){if(arguments[0]instanceof Array){var t=arguments[0];if(t.length<3)return 0;for(var e=0,n=t[0].x,i=1;i<t.length-1;i++)e+=(t[i].x-n)*(t[i-1].y-t[i+1].y);return e/2}if(T(arguments[0],B)){var r=arguments[0],o=r.size();if(o<3)return 0;var s=new w,a=new w,u=new w;r.getCoordinate(0,a),r.getCoordinate(1,u);var l=a.x;u.x-=l;for(var c=0,p=1;p<o-1;p++)s.y=a.y,a.x=u.x,a.y=u.y,r.getCoordinate(p+1,u),u.x-=l,c+=a.x*(s.y-u.y);return c/2}},at.distanceLineLine=function(t,e,n,i){if(t.equals(e))return at.distancePointLine(t,n,i);if(n.equals(i))return at.distancePointLine(i,t,e);var r=!1;if(j.intersects(t,e,n,i)){var o=(e.x-t.x)*(i.y-n.y)-(e.y-t.y)*(i.x-n.x);if(0===o)r=!0;else{var s=((t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y))/o,a=((t.y-n.y)*(i.x-n.x)-(t.x-n.x)*(i.y-n.y))/o;(a<0||a>1||s<0||s>1)&&(r=!0)}}else r=!0;return r?P.min(at.distancePointLine(t,n,i),at.distancePointLine(e,n,i),at.distancePointLine(n,t,e),at.distancePointLine(i,t,e)):0},at.isPointInRing=function(t,e){return at.locatePointInRing(t,e)!==L.EXTERIOR},at.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new w;t.getCoordinate(0,i);for(var r=i.x,o=i.y,s=1;s<e;s++){t.getCoordinate(s,i);var a=i.x,u=i.y,l=a-r,c=u-o;n+=Math.sqrt(l*l+c*c),r=a,o=u}return n},at.isCCW=function(t){var e=t.length-1;if(e<3)throw new m("Ring has fewer than 4 points, so orientation cannot be determined");for(var n=t[0],i=0,r=1;r<=e;r++){var o=t[r];o.y>n.y&&(n=o,i=r)}var s=i;do{(s-=1)<0&&(s=e)}while(t[s].equals2D(n)&&s!==i);var a=i;do{a=(a+1)%e}while(t[a].equals2D(n)&&a!==i);var u=t[s],l=t[a];if(u.equals2D(n)||l.equals2D(n)||u.equals2D(l))return!1;var c=at.computeOrientation(u,n,l);return 0===c?u.x>l.x:c>0},at.locatePointInRing=function(t,e){return st.locatePointInRing(t,e)},at.distancePointLinePerpendicular=function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y);return Math.abs(((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i)*Math.sqrt(i)},at.computeOrientation=function(t,e,n){return at.orientationIndex(t,e,n)},at.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new m("Line array must contain at least one vertex");for(var n=t.distance(e[0]),i=0;i<e.length-1;i++){var r=at.distancePointLine(t,e[i],e[i+1]);r<n&&(n=r)}return n}if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];if(s.x===a.x&&s.y===a.y)return o.distance(s);var u=(a.x-s.x)*(a.x-s.x)+(a.y-s.y)*(a.y-s.y),l=((o.x-s.x)*(a.x-s.x)+(o.y-s.y)*(a.y-s.y))/u;return l<=0?o.distance(s):l>=1?o.distance(a):Math.abs(((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/u)*Math.sqrt(u)}},at.isOnLine=function(t,e){for(var n=new rt,i=1;i<e.length;i++)if(n.computeIntersection(t,e[i-1],e[i]),n.hasIntersection())return!0;return!1},ut.CLOCKWISE.get=function(){return-1},ut.RIGHT.get=function(){return at.CLOCKWISE},ut.COUNTERCLOCKWISE.get=function(){return 1},ut.LEFT.get=function(){return at.COUNTERCLOCKWISE},ut.COLLINEAR.get=function(){return 0},ut.STRAIGHT.get=function(){return at.COLLINEAR},Object.defineProperties(at,ut);var lt=function(){};lt.prototype.filter=function(t){},lt.prototype.interfaces_=function(){return[]},lt.prototype.getClass=function(){return lt};var ct=function(){var t=arguments[0];this._envelope=null,this._factory=null,this._SRID=null,this._userData=null,this._factory=t,this._SRID=t.getSRID()},pt={serialVersionUID:{configurable:!0},SORTINDEX_POINT:{configurable:!0},SORTINDEX_MULTIPOINT:{configurable:!0},SORTINDEX_LINESTRING:{configurable:!0},SORTINDEX_LINEARRING:{configurable:!0},SORTINDEX_MULTILINESTRING:{configurable:!0},SORTINDEX_POLYGON:{configurable:!0},SORTINDEX_MULTIPOLYGON:{configurable:!0},SORTINDEX_GEOMETRYCOLLECTION:{configurable:!0},geometryChangedFilter:{configurable:!0}};ct.prototype.isGeometryCollection=function(){return this.getSortIndex()===ct.SORTINDEX_GEOMETRYCOLLECTION},ct.prototype.getFactory=function(){return this._factory},ct.prototype.getGeometryN=function(t){return this},ct.prototype.getArea=function(){return 0},ct.prototype.isRectangle=function(){return!1},ct.prototype.equals=function(){if(arguments[0]instanceof ct){var t=arguments[0];return null!==t&&this.equalsTopo(t)}if(arguments[0]instanceof Object){var e=arguments[0];return e instanceof ct&&this.equalsExact(e)}},ct.prototype.equalsExact=function(t){return this===t||this.equalsExact(t,0)},ct.prototype.geometryChanged=function(){this.apply(ct.geometryChangedFilter)},ct.prototype.geometryChangedAction=function(){this._envelope=null},ct.prototype.equalsNorm=function(t){return null!==t&&this.norm().equalsExact(t.norm())},ct.prototype.getLength=function(){return 0},ct.prototype.getNumGeometries=function(){return 1},ct.prototype.compareTo=function(){if(1===arguments.length){var t=arguments[0],e=t;return this.getSortIndex()!==e.getSortIndex()?this.getSortIndex()-e.getSortIndex():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return this.getSortIndex()!==n.getSortIndex()?this.getSortIndex()-n.getSortIndex():this.isEmpty()&&n.isEmpty()?0:this.isEmpty()?-1:n.isEmpty()?1:this.compareToSameClass(n,i)}},ct.prototype.getUserData=function(){return this._userData},ct.prototype.getSRID=function(){return this._SRID},ct.prototype.getEnvelope=function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())},ct.prototype.checkNotGeometryCollection=function(t){if(t.getSortIndex()===ct.SORTINDEX_GEOMETRYCOLLECTION)throw new m("This method does not support GeometryCollection arguments")},ct.prototype.equal=function(t,e,n){return 0===n?t.equals(e):t.distance(e)<=n},ct.prototype.norm=function(){var t=this.copy();return t.normalize(),t},ct.prototype.getPrecisionModel=function(){return this._factory.getPrecisionModel()},ct.prototype.getEnvelopeInternal=function(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new j(this._envelope)},ct.prototype.setSRID=function(t){this._SRID=t},ct.prototype.setUserData=function(t){this._userData=t},ct.prototype.compare=function(t,e){for(var n=t.iterator(),i=e.iterator();n.hasNext()&&i.hasNext();){var r=n.next(),o=i.next(),s=r.compareTo(o);if(0!==s)return s}return n.hasNext()?1:i.hasNext()?-1:0},ct.prototype.hashCode=function(){return this.getEnvelopeInternal().hashCode()},ct.prototype.isGeometryCollectionOrDerived=function(){return this.getSortIndex()===ct.SORTINDEX_GEOMETRYCOLLECTION||this.getSortIndex()===ct.SORTINDEX_MULTIPOINT||this.getSortIndex()===ct.SORTINDEX_MULTILINESTRING||this.getSortIndex()===ct.SORTINDEX_MULTIPOLYGON},ct.prototype.interfaces_=function(){return[E,x,e]},ct.prototype.getClass=function(){return ct},ct.hasNonEmptyElements=function(t){for(var e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1},ct.hasNullElements=function(t){for(var e=0;e<t.length;e++)if(null===t[e])return!0;return!1},pt.serialVersionUID.get=function(){return 0x799ea46522854c00},pt.SORTINDEX_POINT.get=function(){return 0},pt.SORTINDEX_MULTIPOINT.get=function(){return 1},pt.SORTINDEX_LINESTRING.get=function(){return 2},pt.SORTINDEX_LINEARRING.get=function(){return 3},pt.SORTINDEX_MULTILINESTRING.get=function(){return 4},pt.SORTINDEX_POLYGON.get=function(){return 5},pt.SORTINDEX_MULTIPOLYGON.get=function(){return 6},pt.SORTINDEX_GEOMETRYCOLLECTION.get=function(){return 7},pt.geometryChangedFilter.get=function(){return ht},Object.defineProperties(ct,pt);var ht=function(){};ht.interfaces_=function(){return[lt]},ht.filter=function(t){t.geometryChangedAction()};var ft=function(){};ft.prototype.filter=function(t){},ft.prototype.interfaces_=function(){return[]},ft.prototype.getClass=function(){return ft};var gt=function(){},dt={Mod2BoundaryNodeRule:{configurable:!0},EndPointBoundaryNodeRule:{configurable:!0},MultiValentEndPointBoundaryNodeRule:{configurable:!0},MonoValentEndPointBoundaryNodeRule:{configurable:!0},MOD2_BOUNDARY_RULE:{configurable:!0},ENDPOINT_BOUNDARY_RULE:{configurable:!0},MULTIVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},MONOVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},OGC_SFS_BOUNDARY_RULE:{configurable:!0}};gt.prototype.isInBoundary=function(t){},gt.prototype.interfaces_=function(){return[]},gt.prototype.getClass=function(){return gt},dt.Mod2BoundaryNodeRule.get=function(){return yt},dt.EndPointBoundaryNodeRule.get=function(){return _t},dt.MultiValentEndPointBoundaryNodeRule.get=function(){return mt},dt.MonoValentEndPointBoundaryNodeRule.get=function(){return vt},dt.MOD2_BOUNDARY_RULE.get=function(){return new yt},dt.ENDPOINT_BOUNDARY_RULE.get=function(){return new _t},dt.MULTIVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new mt},dt.MONOVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new vt},dt.OGC_SFS_BOUNDARY_RULE.get=function(){return gt.MOD2_BOUNDARY_RULE},Object.defineProperties(gt,dt);var yt=function(){};yt.prototype.isInBoundary=function(t){return t%2==1},yt.prototype.interfaces_=function(){return[gt]},yt.prototype.getClass=function(){return yt};var _t=function(){};_t.prototype.isInBoundary=function(t){return t>0},_t.prototype.interfaces_=function(){return[gt]},_t.prototype.getClass=function(){return _t};var mt=function(){};mt.prototype.isInBoundary=function(t){return t>1},mt.prototype.interfaces_=function(){return[gt]},mt.prototype.getClass=function(){return mt};var vt=function(){};vt.prototype.isInBoundary=function(t){return 1===t},vt.prototype.interfaces_=function(){return[gt]},vt.prototype.getClass=function(){return vt};var It=function(){};It.prototype.add=function(){},It.prototype.addAll=function(){},It.prototype.isEmpty=function(){},It.prototype.iterator=function(){},It.prototype.size=function(){},It.prototype.toArray=function(){},It.prototype.remove=function(){},(n.prototype=new Error).name="IndexOutOfBoundsException";var xt=function(){};xt.prototype.hasNext=function(){},xt.prototype.next=function(){},xt.prototype.remove=function(){};var Et=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e}(It);(i.prototype=new Error).name="NoSuchElementException";var Nt=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof It&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,It]},e.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},e.prototype.clear=function(){this.array_=[]},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},e.prototype.iterator=function(){return new wt(this)},e.prototype.get=function(t){if(t<0||t>=this.size())throw new n;return this.array_[t]},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.size=function(){return this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},e.prototype.remove=function(t){for(var e=!1,n=0,i=this.array_.length;n<i;n++)if(this.array_[n]===t){this.array_.splice(n,1),e=!0;break}return e},e}(Et),wt=function(t){function e(e){t.call(this),this.arrayList_=e,this.position_=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.next=function(){if(this.position_===this.arrayList_.size())throw new i;return this.arrayList_.get(this.position_++)},e.prototype.hasNext=function(){return this.position_<this.arrayList_.size()},e.prototype.set=function(t){return this.arrayList_.set(this.position_-1,t)},e.prototype.remove=function(){this.arrayList_.remove(this.arrayList_.get(this.position_))},e}(xt),Ct=function(t){function e(){if(t.call(this),0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.ensureCapacity(e.length),this.add(e,!0)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.ensureCapacity(n.length),this.add(n,i)}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={coordArrayType:{configurable:!0}};return n.coordArrayType.get=function(){return new Array(0).fill(null)},e.prototype.getCoordinate=function(t){return this.get(t)},e.prototype.addAll=function(){if(2===arguments.length){for(var e=arguments[1],n=!1,i=arguments[0].iterator();i.hasNext();)this.add(i.next(),e),n=!0;return n}return t.prototype.addAll.apply(this,arguments)},e.prototype.clone=function(){for(var e=t.prototype.clone.call(this),n=0;n<this.size();n++)e.add(n,this.get(n).copy());return e},e.prototype.toCoordinateArray=function(){return this.toArray(e.coordArrayType)},e.prototype.add=function(){if(1===arguments.length)t.prototype.add.call(this,arguments[0]);else if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1])return this.add(arguments[0],arguments[1],!0),!0;if(arguments[0]instanceof w&&"boolean"==typeof arguments[1]){var e=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(e))return null;t.prototype.add.call(this,e)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1])return this.add(arguments[0],arguments[1]),!0}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var n=arguments[0],i=arguments[1];if(arguments[2])for(var r=0;r<n.length;r++)this.add(n[r],i);else for(var o=n.length-1;o>=0;o--)this.add(n[o],i);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof w){var s=arguments[0],a=arguments[1];if(!arguments[2]){var u=this.size();if(u>0){if(s>0&&this.get(s-1).equals2D(a))return null;if(s<u&&this.get(s).equals2D(a))return null}}t.prototype.add.call(this,s,a)}}else if(4===arguments.length){var l=arguments[0],c=arguments[1],p=arguments[2],h=arguments[3],f=1;p>h&&(f=-1);for(var g=p;g!==h;g+=f)this.add(l[g],c);return!0}},e.prototype.closeRing=function(){this.size()>0&&this.add(new w(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,n),e}(Nt),St=function(){},bt={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};bt.ForwardComparator.get=function(){return Lt},bt.BidirectionalComparator.get=function(){return Ot},bt.coordArrayType.get=function(){return new Array(0).fill(null)},St.prototype.interfaces_=function(){return[]},St.prototype.getClass=function(){return St},St.isRing=function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))},St.ptNotInList=function(t,e){for(var n=0;n<t.length;n++){var i=t[n];if(St.indexOf(i,e)<0)return i}return null},St.scroll=function(t,e){var n=St.indexOf(e,t);if(n<0)return null;var i=new Array(t.length).fill(null);X.arraycopy(t,n,i,0,t.length-n),X.arraycopy(t,0,i,t.length-n,n),X.arraycopy(i,0,t,0,t.length)},St.equals=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].equals(e[n]))return!1;return!0}if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];if(i===r)return!0;if(null===i||null===r)return!1;if(i.length!==r.length)return!1;for(var s=0;s<i.length;s++)if(0!==o.compare(i[s],r[s]))return!1;return!0}},St.intersection=function(t,e){for(var n=new Ct,i=0;i<t.length;i++)e.intersects(t[i])&&n.add(t[i],!0);return n.toCoordinateArray()},St.hasRepeatedPoints=function(t){for(var e=1;e<t.length;e++)if(t[e-1].equals(t[e]))return!0;return!1},St.removeRepeatedPoints=function(t){return St.hasRepeatedPoints(t)?new Ct(t,!1).toCoordinateArray():t},St.reverse=function(t){for(var e=t.length-1,n=Math.trunc(e/2),i=0;i<=n;i++){var r=t[i];t[i]=t[e-i],t[e-i]=r}},St.removeNull=function(t){for(var e=0,n=0;n<t.length;n++)null!==t[n]&&e++;var i=new Array(e).fill(null);if(0===e)return i;for(var r=0,o=0;o<t.length;o++)null!==t[o]&&(i[r++]=t[o]);return i},St.copyDeep=function(){if(1===arguments.length){for(var t=arguments[0],e=new Array(t.length).fill(null),n=0;n<t.length;n++)e[n]=new w(t[n]);return e}if(5===arguments.length)for(var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4],u=0;u<a;u++)o[s+u]=new w(i[r+u])},St.isEqualReversed=function(t,e){for(var n=0;n<t.length;n++)if(0!==t[n].compareTo(e[t.length-n-1]))return!1;return!0},St.envelope=function(t){for(var e=new j,n=0;n<t.length;n++)e.expandToInclude(t[n]);return e},St.toCoordinateArray=function(t){return t.toArray(St.coordArrayType)},St.atLeastNCoordinatesOrNothing=function(t,e){return e.length>=t?e:[]},St.indexOf=function(t,e){for(var n=0;n<e.length;n++)if(t.equals(e[n]))return n;return-1},St.increasingDirection=function(t){for(var e=0;e<Math.trunc(t.length/2);e++){var n=t[e].compareTo(t[t.length-1-e]);if(0!==n)return n}return 1},St.compare=function(t,e){for(var n=0;n<t.length&&n<e.length;){var i=t[n].compareTo(e[n]);if(0!==i)return i;n++}return n<e.length?-1:n<t.length?1:0},St.minCoordinate=function(t){for(var e=null,n=0;n<t.length;n++)(null===e||e.compareTo(t[n])>0)&&(e=t[n]);return e},St.extract=function(t,e,n){e=P.clamp(e,0,t.length);var i=(n=P.clamp(n,-1,t.length))-e+1;n<0&&(i=0),e>=t.length&&(i=0),n<e&&(i=0);var r=new Array(i).fill(null);if(0===i)return r;for(var o=0,s=e;s<=n;s++)r[o++]=t[s];return r},Object.defineProperties(St,bt);var Lt=function(){};Lt.prototype.compare=function(t,e){return St.compare(t,e)},Lt.prototype.interfaces_=function(){return[N]},Lt.prototype.getClass=function(){return Lt};var Ot=function(){};Ot.prototype.compare=function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;var r=St.compare(n,i);return St.isEqualReversed(n,i)?0:r},Ot.prototype.OLDcompare=function(t,e){var n=t,i=e;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;for(var r=St.increasingDirection(n),o=St.increasingDirection(i),s=r>0?0:n.length-1,a=o>0?0:n.length-1,u=0;u<n.length;u++){var l=n[s].compareTo(i[a]);if(0!==l)return l;s+=r,a+=o}return 0},Ot.prototype.interfaces_=function(){return[N]},Ot.prototype.getClass=function(){return Ot};var Tt=function(){};Tt.prototype.get=function(){},Tt.prototype.put=function(){},Tt.prototype.size=function(){},Tt.prototype.values=function(){},Tt.prototype.entrySet=function(){};var Pt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Tt);(r.prototype=new Error).name="OperationNotSupported",(o.prototype=new It).contains=function(){};var Rt=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof It&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.contains=function(t){for(var e=0,n=this.array_.length;e<n;e++)if(this.array_[e]===t)return!0;return!1},e.prototype.add=function(t){return!this.contains(t)&&(this.array_.push(t),!0)},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.remove=function(t){throw new Error},e.prototype.size=function(){return this.array_.length},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},e.prototype.iterator=function(){return new Mt(this)},e}(o),Mt=function(t){function e(e){t.call(this),this.hashSet_=e,this.position_=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.next=function(){if(this.position_===this.hashSet_.size())throw new i;return this.hashSet_.array_[this.position_++]},e.prototype.hasNext=function(){return this.position_<this.hashSet_.size()},e.prototype.remove=function(){throw new r},e}(xt),Dt=0;(p.prototype=new Pt).get=function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null},p.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:Dt,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var o=r.value;return r.value=e,o}r=r.right}}while(null!==r);var s={key:t,left:null,right:null,value:e,parent:n,color:Dt,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null},p.prototype.fixAfterInsertion=function(t){for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(a(t)===l(a(a(t)))){var e=c(a(a(t)));1===s(e)?(u(a(t),Dt),u(e,Dt),u(a(a(t)),1),t=a(a(t))):(t===c(a(t))&&(t=a(t),this.rotateLeft(t)),u(a(t),Dt),u(a(a(t)),1),this.rotateRight(a(a(t))))}else{var n=l(a(a(t)));1===s(n)?(u(a(t),Dt),u(n,Dt),u(a(a(t)),1),t=a(a(t))):(t===l(a(t))&&(t=a(t),this.rotateRight(t)),u(a(t),Dt),u(a(a(t)),1),this.rotateLeft(a(a(t))))}this.root_.color=Dt},p.prototype.values=function(){var t=new Nt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=p.successor(e));)t.add(e.value);return t},p.prototype.entrySet=function(){var t=new Rt,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=p.successor(e));)t.add(e);return t},p.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},p.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},p.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},p.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var n=t.parent,i=t;null!==n&&i===n.right;)i=n,n=n.parent;return n},p.prototype.size=function(){return this.size_};var At=function(){};At.prototype.interfaces_=function(){return[]},At.prototype.getClass=function(){return At},h.prototype=new o,(f.prototype=new h).contains=function(t){for(var e=0,n=this.array_.length;e<n;e++)if(0===this.array_[e].compareTo(t))return!0;return!1},f.prototype.add=function(t){if(this.contains(t))return!1;for(var e=0,n=this.array_.length;e<n;e++)if(1===this.array_[e].compareTo(t))return this.array_.splice(e,0,t),!0;return this.array_.push(t),!0},f.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},f.prototype.remove=function(t){throw new r},f.prototype.size=function(){return this.array_.length},f.prototype.isEmpty=function(){return 0===this.array_.length},f.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},f.prototype.iterator=function(){return new Ft(this)};var Ft=function(t){this.treeSet_=t,this.position_=0};Ft.prototype.next=function(){if(this.position_===this.treeSet_.size())throw new i;return this.treeSet_.array_[this.position_++]},Ft.prototype.hasNext=function(){return this.position_<this.treeSet_.size()},Ft.prototype.remove=function(){throw new r};var Gt=function(){};Gt.sort=function(){var t,e,n,i,r=arguments[0];if(1===arguments.length)i=function(t,e){return t.compareTo(e)},r.sort(i);else if(2===arguments.length)n=arguments[1],i=function(t,e){return n.compare(t,e)},r.sort(i);else if(3===arguments.length){(e=r.slice(arguments[1],arguments[2])).sort();var o=r.slice(0,arguments[1]).concat(e,r.slice(arguments[2],r.length));for(r.splice(0,r.length),t=0;t<o.length;t++)r.push(o[t])}else if(4===arguments.length)for(e=r.slice(arguments[1],arguments[2]),n=arguments[3],i=function(t,e){return n.compare(t,e)},e.sort(i),o=r.slice(0,arguments[1]).concat(e,r.slice(arguments[2],r.length)),r.splice(0,r.length),t=0;t<o.length;t++)r.push(o[t])},Gt.asList=function(t){for(var e=new Nt,n=0,i=t.length;n<i;n++)e.add(t[n]);return e};var Vt=function(){},qt={P:{configurable:!0},L:{configurable:!0},A:{configurable:!0},FALSE:{configurable:!0},TRUE:{configurable:!0},DONTCARE:{configurable:!0},SYM_FALSE:{configurable:!0},SYM_TRUE:{configurable:!0},SYM_DONTCARE:{configurable:!0},SYM_P:{configurable:!0},SYM_L:{configurable:!0},SYM_A:{configurable:!0}};qt.P.get=function(){return 0},qt.L.get=function(){return 1},qt.A.get=function(){return 2},qt.FALSE.get=function(){return-1},qt.TRUE.get=function(){return-2},qt.DONTCARE.get=function(){return-3},qt.SYM_FALSE.get=function(){return"F"},qt.SYM_TRUE.get=function(){return"T"},qt.SYM_DONTCARE.get=function(){return"*"},qt.SYM_P.get=function(){return"0"},qt.SYM_L.get=function(){return"1"},qt.SYM_A.get=function(){return"2"},Vt.prototype.interfaces_=function(){return[]},Vt.prototype.getClass=function(){return Vt},Vt.toDimensionSymbol=function(t){switch(t){case Vt.FALSE:return Vt.SYM_FALSE;case Vt.TRUE:return Vt.SYM_TRUE;case Vt.DONTCARE:return Vt.SYM_DONTCARE;case Vt.P:return Vt.SYM_P;case Vt.L:return Vt.SYM_L;case Vt.A:return Vt.SYM_A}throw new m("Unknown dimension value: "+t)},Vt.toDimensionValue=function(t){switch(A.toUpperCase(t)){case Vt.SYM_FALSE:return Vt.FALSE;case Vt.SYM_TRUE:return Vt.TRUE;case Vt.SYM_DONTCARE:return Vt.DONTCARE;case Vt.SYM_P:return Vt.P;case Vt.SYM_L:return Vt.L;case Vt.SYM_A:return Vt.A}throw new m("Unknown dimension symbol: "+t)},Object.defineProperties(Vt,qt);var Bt=function(){};Bt.prototype.filter=function(t){},Bt.prototype.interfaces_=function(){return[]},Bt.prototype.getClass=function(){return Bt};var zt=function(){};zt.prototype.filter=function(t,e){},zt.prototype.isDone=function(){},zt.prototype.isGeometryChanged=function(){},zt.prototype.interfaces_=function(){return[]},zt.prototype.getClass=function(){return zt};var Ut=function(t){function e(e,n){if(t.call(this,n),this._geometries=e||[],t.hasNullElements(this._geometries))throw new m("geometries must not contain null elements")}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){for(var t=new j,e=0;e<this._geometries.length;e++)t.expandToInclude(this._geometries[e].getEnvelopeInternal());return t},e.prototype.getGeometryN=function(t){return this._geometries[t]},e.prototype.getSortIndex=function(){return t.SORTINDEX_GEOMETRYCOLLECTION},e.prototype.getCoordinates=function(){for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=0;n<this._geometries.length;n++)for(var i=this._geometries[n].getCoordinates(),r=0;r<i.length;r++)t[++e]=i[r];return t},e.prototype.getArea=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getArea();return t},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e;if(this._geometries.length!==i._geometries.length)return!1;for(var r=0;r<this._geometries.length;r++)if(!this._geometries[r].equalsExact(i._geometries[r],n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){for(var t=0;t<this._geometries.length;t++)this._geometries[t].normalize();Gt.sort(this._geometries)},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()},e.prototype.getBoundaryDimension=function(){for(var t=Vt.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getBoundaryDimension());return t},e.prototype.getDimension=function(){for(var t=Vt.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getDimension());return t},e.prototype.getLength=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getLength();return t},e.prototype.getNumPoints=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getNumPoints();return t},e.prototype.getNumGeometries=function(){return this._geometries.length},e.prototype.reverse=function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<this._geometries.length;e++)t[e]=this._geometries[e].reverse();return this.getFactory().createGeometryCollection(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){var t=arguments[0],e=new f(Gt.asList(this._geometries)),n=new f(Gt.asList(t._geometries));return this.compare(e,n)}if(2===arguments.length){for(var i=arguments[1],r=arguments[0],o=this.getNumGeometries(),s=r.getNumGeometries(),a=0;a<o&&a<s;){var u=this.getGeometryN(a),l=r.getGeometryN(a),c=u.compareToSameClass(l,i);if(0!==c)return c;a++}return a<o?1:a<s?-1:0}},e.prototype.apply=function(){if(T(arguments[0],ft))for(var t=arguments[0],e=0;e<this._geometries.length;e++)this._geometries[e].apply(t);else if(T(arguments[0],zt)){var n=arguments[0];if(0===this._geometries.length)return null;for(var i=0;i<this._geometries.length&&(this._geometries[i].apply(n),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else if(T(arguments[0],Bt)){var r=arguments[0];r.filter(this);for(var o=0;o<this._geometries.length;o++)this._geometries[o].apply(r)}else if(T(arguments[0],lt)){var s=arguments[0];s.filter(this);for(var a=0;a<this._geometries.length;a++)this._geometries[a].apply(s)}},e.prototype.getBoundary=function(){return this.checkNotGeometryCollection(this),et.shouldNeverReachHere(),null},e.prototype.clone=function(){var e=t.prototype.clone.call(this);e._geometries=new Array(this._geometries.length).fill(null);for(var n=0;n<this._geometries.length;n++)e._geometries[n]=this._geometries[n].clone();return e},e.prototype.getGeometryType=function(){return"GeometryCollection"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.isEmpty=function(){for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isEmpty())return!1;return!0},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x4f07bcb1f857d800},Object.defineProperties(e,n),e}(ct),kt=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return ct.SORTINDEX_MULTILINESTRING},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?Vt.FALSE:0},e.prototype.isClosed=function(){if(this.isEmpty())return!1;for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isClosed())return!1;return!0},e.prototype.getDimension=function(){return 1},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n<this._geometries.length;n++)e[t-1-n]=this._geometries[n].reverse();return this.getFactory().createMultiLineString(e)},e.prototype.getBoundary=function(){return new Xt(this).getBoundary()},e.prototype.getGeometryType=function(){return"MultiLineString"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[At]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x7155d2ab4afa8000},Object.defineProperties(e,n),e}(Ut),Xt=function(){if(this._geom=null,this._geomFact=null,this._bnRule=null,this._endpointMap=null,1===arguments.length){var t=arguments[0],e=gt.MOD2_BOUNDARY_RULE;this._geom=t,this._geomFact=t.getFactory(),this._bnRule=e}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this._geom=n,this._geomFact=n.getFactory(),this._bnRule=i}};Xt.prototype.boundaryMultiLineString=function(t){if(this._geom.isEmpty())return this.getEmptyMultiPoint();var e=this.computeBoundaryCoordinates(t);return 1===e.length?this._geomFact.createPoint(e[0]):this._geomFact.createMultiPointFromCoords(e)},Xt.prototype.getBoundary=function(){return this._geom instanceof Jt?this.boundaryLineString(this._geom):this._geom instanceof kt?this.boundaryMultiLineString(this._geom):this._geom.getBoundary()},Xt.prototype.boundaryLineString=function(t){return this._geom.isEmpty()?this.getEmptyMultiPoint():t.isClosed()?this._bnRule.isInBoundary(2)?t.getStartPoint():this._geomFact.createMultiPoint():this._geomFact.createMultiPoint([t.getStartPoint(),t.getEndPoint()])},Xt.prototype.getEmptyMultiPoint=function(){return this._geomFact.createMultiPoint()},Xt.prototype.computeBoundaryCoordinates=function(t){var e=new Nt;this._endpointMap=new p;for(var n=0;n<t.getNumGeometries();n++){var i=t.getGeometryN(n);0!==i.getNumPoints()&&(this.addEndpoint(i.getCoordinateN(0)),this.addEndpoint(i.getCoordinateN(i.getNumPoints()-1)))}for(var r=this._endpointMap.entrySet().iterator();r.hasNext();){var o=r.next(),s=o.getValue().count;this._bnRule.isInBoundary(s)&&e.add(o.getKey())}return St.toCoordinateArray(e)},Xt.prototype.addEndpoint=function(t){var e=this._endpointMap.get(t);null===e&&(e=new Yt,this._endpointMap.put(t,e)),e.count++},Xt.prototype.interfaces_=function(){return[]},Xt.prototype.getClass=function(){return Xt},Xt.getBoundary=function(){return 1===arguments.length?new Xt(arguments[0]).getBoundary():2===arguments.length?new Xt(arguments[0],arguments[1]).getBoundary():void 0};var Yt=function(){this.count=null};Yt.prototype.interfaces_=function(){return[]},Yt.prototype.getClass=function(){return Yt};var jt=function(){},Ht={NEWLINE:{configurable:!0},SIMPLE_ORDINATE_FORMAT:{configurable:!0}};jt.prototype.interfaces_=function(){return[]},jt.prototype.getClass=function(){return jt},jt.chars=function(t,e){for(var n=new Array(e).fill(null),i=0;i<e;i++)n[i]=t;return String(n)},jt.getStackTrace=function(){if(1===arguments.length){var t=arguments[0],e=new function(){},n=new function(){};return t.printStackTrace(n),e.toString()}if(2===arguments.length){for(var i=arguments[1],r="",o=new function(){}(new function(){}(jt.getStackTrace(arguments[0]))),s=0;s<i;s++)try{r+=o.readLine()+jt.NEWLINE}catch(t){if(!(t instanceof g))throw t;et.shouldNeverReachHere()}return r}},jt.split=function(t,e){for(var n=e.length,i=new Nt,r=""+t,o=r.indexOf(e);o>=0;){var s=r.substring(0,o);i.add(s),o=(r=r.substring(o+n)).indexOf(e)}r.length>0&&i.add(r);for(var a=new Array(i.size()).fill(null),u=0;u<a.length;u++)a[u]=i.get(u);return a},jt.toString=function(){if(1===arguments.length)return jt.SIMPLE_ORDINATE_FORMAT.format(arguments[0])},jt.spaces=function(t){return jt.chars(" ",t)},Ht.NEWLINE.get=function(){return X.getProperty("line.separator")},Ht.SIMPLE_ORDINATE_FORMAT.get=function(){return new function(){}},Object.defineProperties(jt,Ht);var Wt=function(){};Wt.prototype.interfaces_=function(){return[]},Wt.prototype.getClass=function(){return Wt},Wt.copyCoord=function(t,e,n,i){for(var r=Math.min(t.getDimension(),n.getDimension()),o=0;o<r;o++)n.setOrdinate(i,o,t.getOrdinate(e,o))},Wt.isRing=function(t){var e=t.size();return 0===e||!(e<=3)&&t.getOrdinate(0,B.X)===t.getOrdinate(e-1,B.X)&&t.getOrdinate(0,B.Y)===t.getOrdinate(e-1,B.Y)},Wt.isEqual=function(t,e){var n=t.size();if(n!==e.size())return!1;for(var i=Math.min(t.getDimension(),e.getDimension()),r=0;r<n;r++)for(var o=0;o<i;o++){var s=t.getOrdinate(r,o),a=e.getOrdinate(r,o);if(!(t.getOrdinate(r,o)===e.getOrdinate(r,o)||v.isNaN(s)&&v.isNaN(a)))return!1}return!0},Wt.extend=function(t,e,n){var i=t.create(n,e.getDimension()),r=e.size();if(Wt.copy(e,0,i,0,r),r>0)for(var o=r;o<n;o++)Wt.copy(e,r-1,i,o,1);return i},Wt.reverse=function(t){for(var e=t.size()-1,n=Math.trunc(e/2),i=0;i<=n;i++)Wt.swap(t,i,e-i)},Wt.swap=function(t,e,n){if(e===n)return null;for(var i=0;i<t.getDimension();i++){var r=t.getOrdinate(e,i);t.setOrdinate(e,i,t.getOrdinate(n,i)),t.setOrdinate(n,i,r)}},Wt.copy=function(t,e,n,i,r){for(var o=0;o<r;o++)Wt.copyCoord(t,e+o,n,i+o)},Wt.toString=function(){if(1===arguments.length){var t=arguments[0],e=t.size();if(0===e)return"()";var n=t.getDimension(),i=new M;i.append("(");for(var r=0;r<e;r++){r>0&&i.append(" ");for(var o=0;o<n;o++)o>0&&i.append(","),i.append(jt.toString(t.getOrdinate(r,o)))}return i.append(")"),i.toString()}},Wt.ensureValidRing=function(t,e){var n=e.size();return 0===n?e:n<=3?Wt.createClosedRing(t,e,4):e.getOrdinate(0,B.X)===e.getOrdinate(n-1,B.X)&&e.getOrdinate(0,B.Y)===e.getOrdinate(n-1,B.Y)?e:Wt.createClosedRing(t,e,n+1)},Wt.createClosedRing=function(t,e,n){var i=t.create(n,e.getDimension()),r=e.size();Wt.copy(e,0,i,0,r);for(var o=r;o<n;o++)Wt.copy(e,0,i,o,1);return i};var Jt=function(t){function e(e,n){t.call(this,n),this._points=null,this.init(e)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){return this.isEmpty()?new j:this._points.expandEnvelope(new j)},e.prototype.isRing=function(){return this.isClosed()&&this.isSimple()},e.prototype.getSortIndex=function(){return t.SORTINDEX_LINESTRING},e.prototype.getCoordinates=function(){return this._points.toCoordinateArray()},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e;if(this._points.size()!==i._points.size())return!1;for(var r=0;r<this._points.size();r++)if(!this.equal(this._points.getCoordinate(r),i._points.getCoordinate(r),n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){for(var t=0;t<Math.trunc(this._points.size()/2);t++){var e=this._points.size()-1-t;if(!this._points.getCoordinate(t).equals(this._points.getCoordinate(e)))return this._points.getCoordinate(t).compareTo(this._points.getCoordinate(e))>0&&Wt.reverse(this._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?Vt.FALSE:0},e.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},e.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},e.prototype.getDimension=function(){return 1},e.prototype.getLength=function(){return at.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var t=this._points.copy();return Wt.reverse(t),this.getFactory().createLineString(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e<this._points.size()&&n<t._points.size();){var i=this._points.getCoordinate(e).compareTo(t._points.getCoordinate(n));if(0!==i)return i;e++,n++}return e<this._points.size()?1:n<t._points.size()?-1:0}if(2===arguments.length)return arguments[1].compare(this._points,arguments[0]._points)},e.prototype.apply=function(){if(T(arguments[0],ft))for(var t=arguments[0],e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e));else if(T(arguments[0],zt)){var n=arguments[0];if(0===this._points.size())return null;for(var i=0;i<this._points.size()&&(n.filter(this._points,i),!n.isDone());i++);n.isGeometryChanged()&&this.geometryChanged()}else(T(arguments[0],Bt)||T(arguments[0],lt))&&arguments[0].filter(this)},e.prototype.getBoundary=function(){return new Xt(this).getBoundary()},e.prototype.isEquivalentClass=function(t){return t instanceof e},e.prototype.clone=function(){var e=t.prototype.clone.call(this);return e._points=this._points.clone(),e},e.prototype.getCoordinateN=function(t){return this._points.getCoordinate(t)},e.prototype.getGeometryType=function(){return"LineString"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.getCoordinateSequence=function(){return this._points},e.prototype.isEmpty=function(){return 0===this._points.size()},e.prototype.init=function(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new m("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this._points=t},e.prototype.isCoordinate=function(t){for(var e=0;e<this._points.size();e++)if(this._points.getCoordinate(e).equals(t))return!0;return!1},e.prototype.getStartPoint=function(){return this.isEmpty()?null:this.getPointN(0)},e.prototype.getPointN=function(t){return this.getFactory().createPoint(this._points.getCoordinate(t))},e.prototype.interfaces_=function(){return[At]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x2b2b51ba435c8e00},Object.defineProperties(e,n),e}(ct),Kt=function(){};Kt.prototype.interfaces_=function(){return[]},Kt.prototype.getClass=function(){return Kt};var Qt=function(t){function e(e,n){t.call(this,n),this._coordinates=e||null,this.init(this._coordinates)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){if(this.isEmpty())return new j;var t=new j;return t.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),t},e.prototype.getSortIndex=function(){return t.SORTINDEX_POINT},e.prototype.getCoordinates=function(){return this.isEmpty()?[]:[this.getCoordinate()]},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&(!(!this.isEmpty()||!e.isEmpty())||this.isEmpty()===e.isEmpty()&&this.equal(e.getCoordinate(),this.getCoordinate(),n))}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){},e.prototype.getCoordinate=function(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null},e.prototype.getBoundaryDimension=function(){return Vt.FALSE},e.prototype.getDimension=function(){return 0},e.prototype.getNumPoints=function(){return this.isEmpty()?0:1},e.prototype.reverse=function(){return this.copy()},e.prototype.getX=function(){if(null===this.getCoordinate())throw new Error("getX called on empty Point");return this.getCoordinate().x},e.prototype.compareToSameClass=function(){if(1===arguments.length){var t=arguments[0];return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length)return arguments[1].compare(this._coordinates,arguments[0]._coordinates)},e.prototype.apply=function(){if(T(arguments[0],ft)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(T(arguments[0],zt)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else(T(arguments[0],Bt)||T(arguments[0],lt))&&arguments[0].filter(this)},e.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},e.prototype.clone=function(){var e=t.prototype.clone.call(this);return e._coordinates=this._coordinates.clone(),e},e.prototype.getGeometryType=function(){return"Point"},e.prototype.copy=function(){return new e(this._coordinates.copy(),this._factory)},e.prototype.getCoordinateSequence=function(){return this._coordinates},e.prototype.getY=function(){if(null===this.getCoordinate())throw new Error("getY called on empty Point");return this.getCoordinate().y},e.prototype.isEmpty=function(){return 0===this._coordinates.size()},e.prototype.init=function(t){null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),et.isTrue(t.size()<=1),this._coordinates=t},e.prototype.isSimple=function(){return!0},e.prototype.interfaces_=function(){return[Kt]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x44077bad161cbc00},Object.defineProperties(e,n),e}(ct),$t=function(){};$t.prototype.interfaces_=function(){return[]},$t.prototype.getClass=function(){return $t};var Zt=function(t){function e(e,n,i){if(t.call(this,i),this._shell=null,this._holes=null,null===e&&(e=this.getFactory().createLinearRing()),null===n&&(n=[]),t.hasNullElements(n))throw new m("holes must not contain null elements");if(e.isEmpty()&&t.hasNonEmptyElements(n))throw new m("shell is empty but holes are not");this._shell=e,this._holes=n}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){return this._shell.getEnvelopeInternal()},e.prototype.getSortIndex=function(){return t.SORTINDEX_POLYGON},e.prototype.getCoordinates=function(){if(this.isEmpty())return[];for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=this._shell.getCoordinates(),i=0;i<n.length;i++)t[++e]=n[i];for(var r=0;r<this._holes.length;r++)for(var o=this._holes[r].getCoordinates(),s=0;s<o.length;s++)t[++e]=o[s];return t},e.prototype.getArea=function(){var t=0;t+=Math.abs(at.signedArea(this._shell.getCoordinateSequence()));for(var e=0;e<this._holes.length;e++)t-=Math.abs(at.signedArea(this._holes[e].getCoordinateSequence()));return t},e.prototype.isRectangle=function(){if(0!==this.getNumInteriorRing())return!1;if(null===this._shell)return!1;if(5!==this._shell.getNumPoints())return!1;for(var t=this._shell.getCoordinateSequence(),e=this.getEnvelopeInternal(),n=0;n<5;n++){var i=t.getX(n);if(i!==e.getMinX()&&i!==e.getMaxX())return!1;var r=t.getY(n);if(r!==e.getMinY()&&r!==e.getMaxY())return!1}for(var o=t.getX(0),s=t.getY(0),a=1;a<=4;a++){var u=t.getX(a),l=t.getY(a);if(u!==o==(l!==s))return!1;o=u,s=l}return!0},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e;if(!this._shell.equalsExact(i._shell,n))return!1;if(this._holes.length!==i._holes.length)return!1;for(var r=0;r<this._holes.length;r++)if(!this._holes[r].equalsExact(i._holes[r],n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){if(0===arguments.length){this.normalize(this._shell,!0);for(var t=0;t<this._holes.length;t++)this.normalize(this._holes[t],!1);Gt.sort(this._holes)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(e.isEmpty())return null;var i=new Array(e.getCoordinates().length-1).fill(null);X.arraycopy(e.getCoordinates(),0,i,0,i.length);var r=St.minCoordinate(e.getCoordinates());St.scroll(i,r),X.arraycopy(i,0,e.getCoordinates(),0,i.length),e.getCoordinates()[i.length]=i[0],at.isCCW(e.getCoordinates())===n&&St.reverse(e.getCoordinates())}},e.prototype.getCoordinate=function(){return this._shell.getCoordinate()},e.prototype.getNumInteriorRing=function(){return this._holes.length},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.getLength=function(){var t=0;t+=this._shell.getLength();for(var e=0;e<this._holes.length;e++)t+=this._holes[e].getLength();return t},e.prototype.getNumPoints=function(){for(var t=this._shell.getNumPoints(),e=0;e<this._holes.length;e++)t+=this._holes[e].getNumPoints();return t},e.prototype.reverse=function(){var t=this.copy();t._shell=this._shell.copy().reverse(),t._holes=new Array(this._holes.length).fill(null);for(var e=0;e<this._holes.length;e++)t._holes[e]=this._holes[e].copy().reverse();return t},e.prototype.convexHull=function(){return this.getExteriorRing().convexHull()},e.prototype.compareToSameClass=function(){if(1===arguments.length)return this._shell.compareToSameClass(arguments[0]._shell);if(2===arguments.length){var t=arguments[1],e=arguments[0],n=this._shell.compareToSameClass(e._shell,t);if(0!==n)return n;for(var i=this.getNumInteriorRing(),r=e.getNumInteriorRing(),o=0;o<i&&o<r;){var s=this.getInteriorRingN(o),a=e.getInteriorRingN(o),u=s.compareToSameClass(a,t);if(0!==u)return u;o++}return o<i?1:o<r?-1:0}},e.prototype.apply=function(t){if(T(t,ft)){this._shell.apply(t);for(var e=0;e<this._holes.length;e++)this._holes[e].apply(t)}else if(T(t,zt)){if(this._shell.apply(t),!t.isDone())for(var n=0;n<this._holes.length&&(this._holes[n].apply(t),!t.isDone());n++);t.isGeometryChanged()&&this.geometryChanged()}else if(T(t,Bt))t.filter(this);else if(T(t,lt)){t.filter(this),this._shell.apply(t);for(var i=0;i<this._holes.length;i++)this._holes[i].apply(t)}},e.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var t=new Array(this._holes.length+1).fill(null);t[0]=this._shell;for(var e=0;e<this._holes.length;e++)t[e+1]=this._holes[e];return t.length<=1?this.getFactory().createLinearRing(t[0].getCoordinateSequence()):this.getFactory().createMultiLineString(t)},e.prototype.clone=function(){var e=t.prototype.clone.call(this);e._shell=this._shell.clone(),e._holes=new Array(this._holes.length).fill(null);for(var n=0;n<this._holes.length;n++)e._holes[n]=this._holes[n].clone();return e},e.prototype.getGeometryType=function(){return"Polygon"},e.prototype.copy=function(){for(var t=this._shell.copy(),n=new Array(this._holes.length).fill(null),i=0;i<n.length;i++)n[i]=this._holes[i].copy();return new e(t,n,this._factory)},e.prototype.getExteriorRing=function(){return this._shell},e.prototype.isEmpty=function(){return this._shell.isEmpty()},e.prototype.getInteriorRingN=function(t){return this._holes[t]},e.prototype.interfaces_=function(){return[$t]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x307ffefd8dc97200},Object.defineProperties(e,n),e}(ct),te=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return ct.SORTINDEX_MULTIPOINT},e.prototype.isValid=function(){return!0},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getCoordinate=function(){return 1===arguments.length?this._geometries[arguments[0]].getCoordinate():t.prototype.getCoordinate.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return Vt.FALSE},e.prototype.getDimension=function(){return 0},e.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},e.prototype.getGeometryType=function(){return"MultiPoint"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[Kt]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x6fb1ed4162e0fc00},Object.defineProperties(e,n),e}(Ut),ee=function(t){function e(e,n){e instanceof w&&n instanceof _e&&(e=n.getCoordinateSequenceFactory().create(e)),t.call(this,e,n),this.validateConstruction()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={MINIMUM_VALID_SIZE:{configurable:!0},serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return ct.SORTINDEX_LINEARRING},e.prototype.getBoundaryDimension=function(){return Vt.FALSE},e.prototype.isClosed=function(){return!!this.isEmpty()||t.prototype.isClosed.call(this)},e.prototype.reverse=function(){var t=this._points.copy();return Wt.reverse(t),this.getFactory().createLinearRing(t)},e.prototype.validateConstruction=function(){if(!this.isEmpty()&&!t.prototype.isClosed.call(this))throw new m("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<e.MINIMUM_VALID_SIZE)throw new m("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")},e.prototype.getGeometryType=function(){return"LinearRing"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.MINIMUM_VALID_SIZE.get=function(){return 4},n.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(e,n),e}(Jt),ne=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return ct.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.reverse=function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e<this._geometries.length;e++)t[e]=this._geometries[e].reverse();return this.getFactory().createMultiPolygon(t)},e.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var t=new Nt,e=0;e<this._geometries.length;e++)for(var n=this._geometries[e].getBoundary(),i=0;i<n.getNumGeometries();i++)t.add(n.getGeometryN(i));var r=new Array(t.size()).fill(null);return this.getFactory().createMultiLineString(t.toArray(r))},e.prototype.getGeometryType=function(){return"MultiPolygon"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[$t]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x7a5aa1369171980},Object.defineProperties(e,n),e}(Ut),ie=function(t){this._factory=t||null,this._isUserDataCopied=!1},re={NoOpGeometryOperation:{configurable:!0},CoordinateOperation:{configurable:!0},CoordinateSequenceOperation:{configurable:!0}};ie.prototype.setCopyUserData=function(t){this._isUserDataCopied=t},ie.prototype.edit=function(t,e){if(null===t)return null;var n=this.editInternal(t,e);return this._isUserDataCopied&&n.setUserData(t.getUserData()),n},ie.prototype.editInternal=function(t,e){return null===this._factory&&(this._factory=t.getFactory()),t instanceof Ut?this.editGeometryCollection(t,e):t instanceof Zt?this.editPolygon(t,e):t instanceof Qt||t instanceof Jt?e.edit(t,this._factory):(et.shouldNeverReachHere("Unsupported Geometry class: "+t.getClass().getName()),null)},ie.prototype.editGeometryCollection=function(t,e){for(var n=e.edit(t,this._factory),i=new Nt,r=0;r<n.getNumGeometries();r++){var o=this.edit(n.getGeometryN(r),e);null===o||o.isEmpty()||i.add(o)}return n.getClass()===te?this._factory.createMultiPoint(i.toArray([])):n.getClass()===kt?this._factory.createMultiLineString(i.toArray([])):n.getClass()===ne?this._factory.createMultiPolygon(i.toArray([])):this._factory.createGeometryCollection(i.toArray([]))},ie.prototype.editPolygon=function(t,e){var n=e.edit(t,this._factory);if(null===n&&(n=this._factory.createPolygon(null)),n.isEmpty())return n;var i=this.edit(n.getExteriorRing(),e);if(null===i||i.isEmpty())return this._factory.createPolygon();for(var r=new Nt,o=0;o<n.getNumInteriorRing();o++){var s=this.edit(n.getInteriorRingN(o),e);null===s||s.isEmpty()||r.add(s)}return this._factory.createPolygon(i,r.toArray([]))},ie.prototype.interfaces_=function(){return[]},ie.prototype.getClass=function(){return ie},ie.GeometryEditorOperation=function(){},re.NoOpGeometryOperation.get=function(){return oe},re.CoordinateOperation.get=function(){return se},re.CoordinateSequenceOperation.get=function(){return ae},Object.defineProperties(ie,re);var oe=function(){};oe.prototype.edit=function(t,e){return t},oe.prototype.interfaces_=function(){return[ie.GeometryEditorOperation]},oe.prototype.getClass=function(){return oe};var se=function(){};se.prototype.edit=function(t,e){var n=this.editCoordinates(t.getCoordinates(),t);return null===n?t:t instanceof ee?e.createLinearRing(n):t instanceof Jt?e.createLineString(n):t instanceof Qt?n.length>0?e.createPoint(n[0]):e.createPoint():t},se.prototype.interfaces_=function(){return[ie.GeometryEditorOperation]},se.prototype.getClass=function(){return se};var ae=function(){};ae.prototype.edit=function(t,e){return t instanceof ee?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Jt?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof Qt?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},ae.prototype.interfaces_=function(){return[ie.GeometryEditorOperation]},ae.prototype.getClass=function(){return ae};var ue=function(){if(this._dimension=3,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var t=arguments[0];this._coordinates=new Array(t).fill(null);for(var e=0;e<t;e++)this._coordinates[e]=new w}else if(T(arguments[0],B)){var n=arguments[0];if(null===n)return this._coordinates=new Array(0).fill(null),null;this._dimension=n.getDimension(),this._coordinates=new Array(n.size()).fill(null);for(var i=0;i<this._coordinates.length;i++)this._coordinates[i]=n.getCoordinateCopy(i)}}else if(2===arguments.length)if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var r=arguments[0],o=arguments[1];this._coordinates=r,this._dimension=o,null===r&&(this._coordinates=new Array(0).fill(null))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var s=arguments[0],a=arguments[1];this._coordinates=new Array(s).fill(null),this._dimension=a;for(var u=0;u<s;u++)this._coordinates[u]=new w}},le={serialVersionUID:{configurable:!0}};ue.prototype.setOrdinate=function(t,e,n){switch(e){case B.X:this._coordinates[t].x=n;break;case B.Y:this._coordinates[t].y=n;break;case B.Z:this._coordinates[t].z=n;break;default:throw new m("invalid ordinateIndex")}},ue.prototype.size=function(){return this._coordinates.length},ue.prototype.getOrdinate=function(t,e){switch(e){case B.X:return this._coordinates[t].x;case B.Y:return this._coordinates[t].y;case B.Z:return this._coordinates[t].z}return v.NaN},ue.prototype.getCoordinate=function(){if(1===arguments.length)return this._coordinates[arguments[0]];if(2===arguments.length){var t=arguments[0],e=arguments[1];e.x=this._coordinates[t].x,e.y=this._coordinates[t].y,e.z=this._coordinates[t].z}},ue.prototype.getCoordinateCopy=function(t){return new w(this._coordinates[t])},ue.prototype.getDimension=function(){return this._dimension},ue.prototype.getX=function(t){return this._coordinates[t].x},ue.prototype.clone=function(){for(var t=new Array(this.size()).fill(null),e=0;e<this._coordinates.length;e++)t[e]=this._coordinates[e].clone();return new ue(t,this._dimension)},ue.prototype.expandEnvelope=function(t){for(var e=0;e<this._coordinates.length;e++)t.expandToInclude(this._coordinates[e]);return t},ue.prototype.copy=function(){for(var t=new Array(this.size()).fill(null),e=0;e<this._coordinates.length;e++)t[e]=this._coordinates[e].copy();return new ue(t,this._dimension)},ue.prototype.toString=function(){if(this._coordinates.length>0){var t=new M(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e<this._coordinates.length;e++)t.append(", "),t.append(this._coordinates[e]);return t.append(")"),t.toString()}return"()"},ue.prototype.getY=function(t){return this._coordinates[t].y},ue.prototype.toCoordinateArray=function(){return this._coordinates},ue.prototype.interfaces_=function(){return[B,e]},ue.prototype.getClass=function(){return ue},le.serialVersionUID.get=function(){return-0xcb44a778db18e00},Object.defineProperties(ue,le);var ce=function(){},pe={serialVersionUID:{configurable:!0},instanceObject:{configurable:!0}};ce.prototype.readResolve=function(){return ce.instance()},ce.prototype.create=function(){if(1===arguments.length){if(arguments[0]instanceof Array)return new ue(arguments[0]);if(T(arguments[0],B))return new ue(arguments[0])}else if(2===arguments.length){var t=arguments[0],e=arguments[1];return e>3&&(e=3),e<2?new ue(t):new ue(t,e)}},ce.prototype.interfaces_=function(){return[b,e]},ce.prototype.getClass=function(){return ce},ce.instance=function(){return ce.instanceObject},pe.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},pe.instanceObject.get=function(){return new ce},Object.defineProperties(ce,pe);var he=function(t){function e(){t.call(this),this.map_=new Map}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return this.map_.get(t)||null},e.prototype.put=function(t,e){return this.map_.set(t,e),e},e.prototype.values=function(){for(var t=new Nt,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},e.prototype.entrySet=function(){var t=new Rt;return this.map_.entries().forEach(function(e){return t.add(e)}),t},e.prototype.size=function(){return this.map_.size()},e}(Tt),fe=function t(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof de){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var i=arguments[0];this._modelType=i._modelType,this._scale=i._scale}},ge={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};fe.prototype.equals=function(t){return t instanceof fe&&this._modelType===t._modelType&&this._scale===t._scale},fe.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits();return new D(n).compareTo(new D(i))},fe.prototype.getScale=function(){return this._scale},fe.prototype.isFloating=function(){return this._modelType===fe.FLOATING||this._modelType===fe.FLOATING_SINGLE},fe.prototype.getType=function(){return this._modelType},fe.prototype.toString=function(){var t="UNKNOWN";return this._modelType===fe.FLOATING?t="Floating":this._modelType===fe.FLOATING_SINGLE?t="Floating-Single":this._modelType===fe.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},fe.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];return v.isNaN(t)||this._modelType===fe.FLOATING_SINGLE?t:this._modelType===fe.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof w){var e=arguments[0];if(this._modelType===fe.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},fe.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===fe.FLOATING?t=16:this._modelType===fe.FLOATING_SINGLE?t=6:this._modelType===fe.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},fe.prototype.setScale=function(t){this._scale=Math.abs(t)},fe.prototype.interfaces_=function(){return[e,x]},fe.prototype.getClass=function(){return fe},fe.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},ge.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},ge.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(fe,ge);var de=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},ye={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};de.prototype.readResolve=function(){return de.nameToTypeMap.get(this._name)},de.prototype.toString=function(){return this._name},de.prototype.interfaces_=function(){return[e]},de.prototype.getClass=function(){return de},ye.serialVersionUID.get=function(){return-552860263173159e4},ye.nameToTypeMap.get=function(){return new he},Object.defineProperties(de,ye),fe.Type=de,fe.FIXED=new de("FIXED"),fe.FLOATING=new de("FLOATING"),fe.FLOATING_SINGLE=new de("FLOATING SINGLE");var _e=function t(){this._precisionModel=new fe,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?T(arguments[0],b)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof fe&&(this._precisionModel=arguments[0]):2===arguments.length?(this._precisionModel=arguments[0],this._SRID=arguments[1]):3===arguments.length&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]))},me={serialVersionUID:{configurable:!0}};_e.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new w(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new w(t.getMinX(),t.getMinY()),new w(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new w(t.getMinX(),t.getMinY()),new w(t.getMinX(),t.getMaxY()),new w(t.getMaxX(),t.getMaxY()),new w(t.getMaxX(),t.getMinY()),new w(t.getMinX(),t.getMinY())]),null)},_e.prototype.createLineString=function(t){return t?t instanceof Array?new Jt(this.getCoordinateSequenceFactory().create(t),this):T(t,B)?new Jt(t,this):void 0:new Jt(this.getCoordinateSequenceFactory().create([]),this)},_e.prototype.createMultiLineString=function(){return 0===arguments.length?new kt(null,this):1===arguments.length?new kt(arguments[0],this):void 0},_e.prototype.buildGeometry=function(t){for(var e=null,n=!1,i=!1,r=t.iterator();r.hasNext();){var o=r.next(),s=o.getClass();null===e&&(e=s),s!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(i=!0)}if(null===e)return this.createGeometryCollection();if(n||i)return this.createGeometryCollection(_e.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof Zt)return this.createMultiPolygon(_e.toPolygonArray(t));if(a instanceof Jt)return this.createMultiLineString(_e.toLineStringArray(t));if(a instanceof Qt)return this.createMultiPoint(_e.toPointArray(t));et.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},_e.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},_e.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof w){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(T(arguments[0],B))return new Qt(arguments[0],this)}},_e.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},_e.prototype.createPolygon=function(){if(0===arguments.length)return new Zt(null,null,this);if(1===arguments.length){if(T(arguments[0],B))return this.createPolygon(this.createLinearRing(arguments[0]));if(arguments[0]instanceof Array)return this.createPolygon(this.createLinearRing(arguments[0]));if(arguments[0]instanceof ee)return this.createPolygon(arguments[0],null)}else if(2===arguments.length)return new Zt(arguments[0],arguments[1],this)},_e.prototype.getSRID=function(){return this._SRID},_e.prototype.createGeometryCollection=function(){return 0===arguments.length?new Ut(null,this):1===arguments.length?new Ut(arguments[0],this):void 0},_e.prototype.createGeometry=function(t){return new ie(this).edit(t,{edit:function(){if(2===arguments.length)return this._coordinateSequenceFactory.create(arguments[0])}})},_e.prototype.getPrecisionModel=function(){return this._precisionModel},_e.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(T(arguments[0],B))return new ee(arguments[0],this)}},_e.prototype.createMultiPolygon=function(){return 0===arguments.length?new ne(null,this):1===arguments.length?new ne(arguments[0],this):void 0},_e.prototype.createMultiPoint=function(){if(0===arguments.length)return new te(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new te(arguments[0],this);if(arguments[0]instanceof Array){var t=arguments[0];return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(T(arguments[0],B)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var n=new Array(e.size()).fill(null),i=0;i<e.size();i++){var r=this.getCoordinateSequenceFactory().create(1,e.getDimension());Wt.copy(e,i,r,0,1),n[i]=this.createPoint(r)}return this.createMultiPoint(n)}}},_e.prototype.interfaces_=function(){return[e]},_e.prototype.getClass=function(){return _e},_e.toMultiPolygonArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toGeometryArray=function(t){if(null===t)return null;var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.getDefaultCoordinateSequenceFactory=function(){return ce.instance()},_e.toMultiLineStringArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toLineStringArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toMultiPointArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toLinearRingArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toPointArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.toPolygonArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},_e.createPointFromInternalCoord=function(t,e){return e.getPrecisionModel().makePrecise(t),e.getFactory().createPoint(t)},me.serialVersionUID.get=function(){return-0x5ea75f2051eeb400},Object.defineProperties(_e,me);var ve=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],Ie=function(t){this.geometryFactory=t||new _e};Ie.prototype.read=function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!xe[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==ve.indexOf(n)?xe[n].apply(this,[e.coordinates]):xe[n].apply(this,"GeometryCollection"===n?[e.geometries]:[e])},Ie.prototype.write=function(t){var e=t.getGeometryType();if(!Ee[e])throw new Error("Geometry is not supported");return Ee[e].apply(this,[t])};var xe={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){if(!xe[t.geometry.type])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=xe.bbox.apply(this,[t.bbox])),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n<t.features.length;++n)e.features.push(this.read(t.features[n]))}return t.bbox&&(e.bbox=this.parse.bbox.apply(this,[t.bbox])),e},coordinates:function(t){for(var e=[],n=0;n<t.length;++n){var i=t[n];e.push(new w(i[0],i[1]))}return e},bbox:function(t){return this.geometryFactory.createLinearRing([new w(t[0],t[1]),new w(t[2],t[1]),new w(t[2],t[3]),new w(t[0],t[3]),new w(t[0],t[1])])},Point:function(t){var e=new w(t[0],t[1]);return this.geometryFactory.createPoint(e)},MultiPoint:function(t){for(var e=[],n=0;n<t.length;++n)e.push(xe.Point.apply(this,[t[n]]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=xe.coordinates.apply(this,[t]);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push(xe.LineString.apply(this,[t[n]]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=xe.coordinates.apply(this,[t[0]]),n=this.geometryFactory.createLinearRing(e),i=[],r=1;r<t.length;++r){var o=xe.coordinates.apply(this,[t[r]]),s=this.geometryFactory.createLinearRing(o);i.push(s)}return this.geometryFactory.createPolygon(n,i)},MultiPolygon:function(t){for(var e=[],n=0;n<t.length;++n)e.push(xe.Polygon.apply(this,[t[n]]));return this.geometryFactory.createMultiPolygon(e)},GeometryCollection:function(t){for(var e=[],n=0;n<t.length;++n)e.push(this.read(t[n]));return this.geometryFactory.createGeometryCollection(e)}},Ee={coordinate:function(t){return[t.x,t.y]},Point:function(t){return{type:"Point",coordinates:Ee.coordinate.apply(this,[t.getCoordinate()])}},MultiPoint:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=Ee.Point.apply(this,[t._geometries[n]]);e.push(i.coordinates)}return{type:"MultiPoint",coordinates:e}},LineString:function(t){for(var e=[],n=t.getCoordinates(),i=0;i<n.length;++i)e.push(Ee.coordinate.apply(this,[n[i]]));return{type:"LineString",coordinates:e}},MultiLineString:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=Ee.LineString.apply(this,[t._geometries[n]]);e.push(i.coordinates)}return{type:"MultiLineString",coordinates:e}},Polygon:function(t){var e=[],n=Ee.LineString.apply(this,[t._shell]);e.push(n.coordinates);for(var i=0;i<t._holes.length;++i){var r=Ee.LineString.apply(this,[t._holes[i]]);e.push(r.coordinates)}return{type:"Polygon",coordinates:e}},MultiPolygon:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=Ee.Polygon.apply(this,[t._geometries[n]]);e.push(i.coordinates)}return{type:"MultiPolygon",coordinates:e}},GeometryCollection:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var i=t._geometries[n],r=i.getGeometryType();e.push(Ee[r].apply(this,[i]))}return{type:"GeometryCollection",geometries:e}}},Ne=function(t){this.geometryFactory=t||new _e,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new Ie(this.geometryFactory)};Ne.prototype.read=function(t){var e=this.parser.read(t);return this.precisionModel.getType()===fe.FIXED&&this.reducePrecision(e),e},Ne.prototype.reducePrecision=function(t){var e,n;if(t.coordinate)this.precisionModel.makePrecise(t.coordinate);else if(t.points)for(e=0,n=t.points.length;e<n;e++)this.precisionModel.makePrecise(t.points[e]);else if(t.geometries)for(e=0,n=t.geometries.length;e<n;e++)this.reducePrecision(t.geometries[e])};var we=function(){this.parser=new Ie(this.geometryFactory)};we.prototype.write=function(t){return this.parser.write(t)};var Ce=function(){},Se={ON:{configurable:!0},LEFT:{configurable:!0},RIGHT:{configurable:!0}};Ce.prototype.interfaces_=function(){return[]},Ce.prototype.getClass=function(){return Ce},Ce.opposite=function(t){return t===Ce.LEFT?Ce.RIGHT:t===Ce.RIGHT?Ce.LEFT:t},Se.ON.get=function(){return 0},Se.LEFT.get=function(){return 1},Se.RIGHT.get=function(){return 2},Object.defineProperties(Ce,Se),(d.prototype=new Error).name="EmptyStackException",(y.prototype=new Et).add=function(t){return this.array_.push(t),!0},y.prototype.get=function(t){if(t<0||t>=this.size())throw new Error;return this.array_[t]},y.prototype.push=function(t){return this.array_.push(t),t},y.prototype.pop=function(t){if(0===this.array_.length)throw new d;return this.array_.pop()},y.prototype.peek=function(){if(0===this.array_.length)throw new d;return this.array_[this.array_.length-1]},y.prototype.empty=function(){return 0===this.array_.length},y.prototype.isEmpty=function(){return this.empty()},y.prototype.search=function(t){return this.array_.indexOf(t)},y.prototype.size=function(){return this.array_.length},y.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t};var be=function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null};be.prototype.getCoordinate=function(){return this._minCoord},be.prototype.getRightmostSide=function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n},be.prototype.findRightmostEdgeAtVertex=function(){var t=this._minDe.getEdge().getCoordinates();et.isTrue(this._minIndex>0&&this._minIndex<t.length,"rightmost point expected to be interior vertex of edge");var e=t[this._minIndex-1],n=t[this._minIndex+1],i=at.computeOrientation(this._minCoord,n,e),r=!1;(e.y<this._minCoord.y&&n.y<this._minCoord.y&&i===at.COUNTERCLOCKWISE||e.y>this._minCoord.y&&n.y>this._minCoord.y&&i===at.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)},be.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var i=Ce.LEFT;return n[e].y<n[e+1].y&&(i=Ce.RIGHT),i},be.prototype.getEdge=function(){return this._orientedDe},be.prototype.checkForRightmostCoordinate=function(t){for(var e=t.getEdge().getCoordinates(),n=0;n<e.length-1;n++)(null===this._minCoord||e[n].x>this._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])},be.prototype.findRightmostEdgeAtNode=function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)},be.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}et.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Ce.LEFT&&(this._orientedDe=this._minDe.getSym())},be.prototype.interfaces_=function(){return[]},be.prototype.getClass=function(){return be};var Le=function(t){function e(n,i){t.call(this,e.msgWithCoord(n,i)),this.pt=i?new w(i):null,this.name="TopologyException"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCoordinate=function(){return this.pt},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.msgWithCoord=function(t,e){return e?t:t+" [ "+e+" ]"},e}(Z),Oe=function(){this.array_=[]};Oe.prototype.addLast=function(t){this.array_.push(t)},Oe.prototype.removeFirst=function(){return this.array_.shift()},Oe.prototype.isEmpty=function(){return 0===this.array_.length};var Te=function(){this._finder=null,this._dirEdgeList=new Nt,this._nodes=new Nt,this._rightMostCoord=null,this._env=null,this._finder=new be};Te.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)},Te.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},Te.prototype.computeNodeDepth=function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new Le("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var r=t.getEdges().iterator();r.hasNext();){var o=r.next();o.setVisited(!0),this.copySymDepths(o)}},Te.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(Ce.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},Te.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},Te.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(Ce.RIGHT)>=1&&e.getDepth(Ce.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},Te.prototype.computeDepths=function(t){var e=new Rt,n=new Oe,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}},Te.prototype.compareTo=function(t){return this._rightMostCoord.x<t._rightMostCoord.x?-1:this._rightMostCoord.x>t._rightMostCoord.x?1:0},Te.prototype.getEnvelope=function(){if(null===this._env){for(var t=new j,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),i=0;i<n.length-1;i++)t.expandToInclude(n[i]);this._env=t}return this._env},Te.prototype.addReachable=function(t){var e=new y;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}},Te.prototype.copySymDepths=function(t){var e=t.getSym();e.setDepth(Ce.LEFT,t.getDepth(Ce.RIGHT)),e.setDepth(Ce.RIGHT,t.getDepth(Ce.LEFT))},Te.prototype.add=function(t,e){t.setVisited(!0),this._nodes.add(t);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();this._dirEdgeList.add(i);var r=i.getSym().getNode();r.isVisited()||e.push(r)}},Te.prototype.getNodes=function(){return this._nodes},Te.prototype.getDirectedEdges=function(){return this._dirEdgeList},Te.prototype.interfaces_=function(){return[x]},Te.prototype.getClass=function(){return Te};var Pe=function t(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array)this.init(arguments[0].length);else if(Number.isInteger(arguments[0])){var e=arguments[0];this.init(1),this.location[Ce.ON]=e}else if(arguments[0]instanceof t){var n=arguments[0];if(this.init(n.location.length),null!==n)for(var i=0;i<this.location.length;i++)this.location[i]=n.location[i]}}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this.init(3),this.location[Ce.ON]=r,this.location[Ce.LEFT]=o,this.location[Ce.RIGHT]=s}};Pe.prototype.setAllLocations=function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t},Pe.prototype.isNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==L.NONE)return!1;return!0},Pe.prototype.setAllLocationsIfNull=function(t){for(var e=0;e<this.location.length;e++)this.location[e]===L.NONE&&(this.location[e]=t)},Pe.prototype.isLine=function(){return 1===this.location.length},Pe.prototype.merge=function(t){if(t.location.length>this.location.length){var e=new Array(3).fill(null);e[Ce.ON]=this.location[Ce.ON],e[Ce.LEFT]=L.NONE,e[Ce.RIGHT]=L.NONE,this.location=e}for(var n=0;n<this.location.length;n++)this.location[n]===L.NONE&&n<t.location.length&&(this.location[n]=t.location[n])},Pe.prototype.getLocations=function(){return this.location},Pe.prototype.flip=function(){if(this.location.length<=1)return null;var t=this.location[Ce.LEFT];this.location[Ce.LEFT]=this.location[Ce.RIGHT],this.location[Ce.RIGHT]=t},Pe.prototype.toString=function(){var t=new M;return this.location.length>1&&t.append(L.toLocationSymbol(this.location[Ce.LEFT])),t.append(L.toLocationSymbol(this.location[Ce.ON])),this.location.length>1&&t.append(L.toLocationSymbol(this.location[Ce.RIGHT])),t.toString()},Pe.prototype.setLocations=function(t,e,n){this.location[Ce.ON]=t,this.location[Ce.LEFT]=e,this.location[Ce.RIGHT]=n},Pe.prototype.get=function(t){return t<this.location.length?this.location[t]:L.NONE},Pe.prototype.isArea=function(){return this.location.length>1},Pe.prototype.isAnyNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===L.NONE)return!0;return!1},Pe.prototype.setLocation=function(){1===arguments.length?this.setLocation(Ce.ON,arguments[0]):2===arguments.length&&(this.location[arguments[0]]=arguments[1])},Pe.prototype.init=function(t){this.location=new Array(t).fill(null),this.setAllLocations(L.NONE)},Pe.prototype.isEqualOnSide=function(t,e){return this.location[e]===t.location[e]},Pe.prototype.allPositionsEqual=function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0},Pe.prototype.interfaces_=function(){return[]},Pe.prototype.getClass=function(){return Pe};var Re=function t(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var e=arguments[0];this.elt[0]=new Pe(e),this.elt[1]=new Pe(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.elt[0]=new Pe(n.elt[0]),this.elt[1]=new Pe(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new Pe(L.NONE),this.elt[1]=new Pe(L.NONE),this.elt[i].setLocation(r)}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.elt[0]=new Pe(o,s,a),this.elt[1]=new Pe(o,s,a)}else if(4===arguments.length){var u=arguments[0],l=arguments[1],c=arguments[2],p=arguments[3];this.elt[0]=new Pe(L.NONE,L.NONE,L.NONE),this.elt[1]=new Pe(L.NONE,L.NONE,L.NONE),this.elt[u].setLocations(l,c,p)}};Re.prototype.getGeometryCount=function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t},Re.prototype.setAllLocations=function(t,e){this.elt[t].setAllLocations(e)},Re.prototype.isNull=function(t){return this.elt[t].isNull()},Re.prototype.setAllLocationsIfNull=function(){if(1===arguments.length){var t=arguments[0];this.setAllLocationsIfNull(0,t),this.setAllLocationsIfNull(1,t)}else 2===arguments.length&&this.elt[arguments[0]].setAllLocationsIfNull(arguments[1])},Re.prototype.isLine=function(t){return this.elt[t].isLine()},Re.prototype.merge=function(t){for(var e=0;e<2;e++)null===this.elt[e]&&null!==t.elt[e]?this.elt[e]=new Pe(t.elt[e]):this.elt[e].merge(t.elt[e])},Re.prototype.flip=function(){this.elt[0].flip(),this.elt[1].flip()},Re.prototype.getLocation=function(){return 1===arguments.length?this.elt[arguments[0]].get(Ce.ON):2===arguments.length?this.elt[arguments[0]].get(arguments[1]):void 0},Re.prototype.toString=function(){var t=new M;return null!==this.elt[0]&&(t.append("A:"),t.append(this.elt[0].toString())),null!==this.elt[1]&&(t.append(" B:"),t.append(this.elt[1].toString())),t.toString()},Re.prototype.isArea=function(){return 0===arguments.length?this.elt[0].isArea()||this.elt[1].isArea():1===arguments.length?this.elt[arguments[0]].isArea():void 0},Re.prototype.isAnyNull=function(t){return this.elt[t].isAnyNull()},Re.prototype.setLocation=function(){2===arguments.length?this.elt[arguments[0]].setLocation(Ce.ON,arguments[1]):3===arguments.length&&this.elt[arguments[0]].setLocation(arguments[1],arguments[2])},Re.prototype.isEqualOnSide=function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)},Re.prototype.allPositionsEqual=function(t,e){return this.elt[t].allPositionsEqual(e)},Re.prototype.toLine=function(t){this.elt[t].isArea()&&(this.elt[t]=new Pe(this.elt[t].location[0]))},Re.prototype.interfaces_=function(){return[]},Re.prototype.getClass=function(){return Re},Re.toLineLabel=function(t){for(var e=new Re(L.NONE),n=0;n<2;n++)e.setLocation(n,t.getLocation(n));return e};var Me=function(){this._startDe=null,this._maxNodeDegree=-1,this._edges=new Nt,this._pts=new Nt,this._label=new Re(L.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new Nt,this._geometryFactory=null;var t=arguments[0];this._geometryFactory=arguments[1],this.computePoints(t),this.computeRing()};Me.prototype.computeRing=function(){if(null!==this._ring)return null;for(var t=new Array(this._pts.size()).fill(null),e=0;e<this._pts.size();e++)t[e]=this._pts.get(e);this._ring=this._geometryFactory.createLinearRing(t),this._isHole=at.isCCW(this._ring.getCoordinates())},Me.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},Me.prototype.computePoints=function(t){this._startDe=t;var e=t,n=!0;do{if(null===e)throw new Le("Found null DirectedEdge");if(e.getEdgeRing()===this)throw new Le("Directed Edge visited twice during ring-building at "+e.getCoordinate());this._edges.add(e);var i=e.getLabel();et.isTrue(i.isArea()),this.mergeLabel(i),this.addPoints(e.getEdge(),e.isForward(),n),n=!1,this.setEdgeRing(e,this),e=this.getNext(e)}while(e!==this._startDe)},Me.prototype.getLinearRing=function(){return this._ring},Me.prototype.getCoordinate=function(t){return this._pts.get(t)},Me.prototype.computeMaxNodeDegree=function(){this._maxNodeDegree=0;var t=this._startDe;do{var e=t.getNode().getEdges().getOutgoingDegree(this);e>this._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2},Me.prototype.addPoints=function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var o=r;o<i.length;o++)this._pts.add(i[o])}else{var s=i.length-2;n&&(s=i.length-1);for(var a=s;a>=0;a--)this._pts.add(i[a])}},Me.prototype.isHole=function(){return this._isHole},Me.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},Me.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!at.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0},Me.prototype.addHole=function(t){this._holes.add(t)},Me.prototype.isShell=function(){return null===this._shell},Me.prototype.getLabel=function(){return this._label},Me.prototype.getEdges=function(){return this._edges},Me.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},Me.prototype.getShell=function(){return this._shell},Me.prototype.mergeLabel=function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,Ce.RIGHT);if(n===L.NONE)return null;if(this._label.getLocation(e)===L.NONE)return this._label.setLocation(e,n),null}},Me.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},Me.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n<this._holes.size();n++)e[n]=this._holes.get(n).getLinearRing();return t.createPolygon(this.getLinearRing(),e)},Me.prototype.interfaces_=function(){return[]},Me.prototype.getClass=function(){return Me};var De=function(t){function e(){t.call(this,arguments[0],arguments[1])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setEdgeRing=function(t,e){t.setMinEdgeRing(e)},e.prototype.getNext=function(t){return t.getNextMin()},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Me),Ae=function(t){function e(){t.call(this,arguments[0],arguments[1])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildMinimalRings=function(){var t=new Nt,e=this._startDe;do{if(null===e.getMinEdgeRing()){var n=new De(e,this._geometryFactory);t.add(n)}e=e.getNext()}while(e!==this._startDe);return t},e.prototype.setEdgeRing=function(t,e){t.setEdgeRing(e)},e.prototype.linkDirectedEdgesForMinimalEdgeRings=function(){var t=this._startDe;do{t.getNode().getEdges().linkMinimalDirectedEdges(this),t=t.getNext()}while(t!==this._startDe)},e.prototype.getNext=function(t){return t.getNext()},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Me),Fe=function(){this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0===arguments.length||1===arguments.length&&(this._label=arguments[0])};Fe.prototype.setVisited=function(t){this._isVisited=t},Fe.prototype.setInResult=function(t){this._isInResult=t},Fe.prototype.isCovered=function(){return this._isCovered},Fe.prototype.isCoveredSet=function(){return this._isCoveredSet},Fe.prototype.setLabel=function(t){this._label=t},Fe.prototype.getLabel=function(){return this._label},Fe.prototype.setCovered=function(t){this._isCovered=t,this._isCoveredSet=!0},Fe.prototype.updateIM=function(t){et.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(t)},Fe.prototype.isInResult=function(){return this._isInResult},Fe.prototype.isVisited=function(){return this._isVisited},Fe.prototype.interfaces_=function(){return[]},Fe.prototype.getClass=function(){return Fe};var Ge=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[1];this._coord=arguments[0],this._edges=e,this._label=new Re(0,L.NONE)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1},e.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},e.prototype.getCoordinate=function(){return this._coord},e.prototype.print=function(t){t.println("node "+this._coord+" lbl: "+this._label)},e.prototype.computeIM=function(t){},e.prototype.computeMergedLocation=function(t,e){var n=L.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==L.BOUNDARY&&(n=i)}return n},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],n=arguments[1];null===this._label?this._label=new Re(e,n):this._label.setLocation(e,n)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){if(arguments[0]instanceof e)this.mergeLabel(arguments[0]._label);else if(arguments[0]instanceof Re)for(var t=arguments[0],n=0;n<2;n++){var i=this.computeMergedLocation(t,n);this._label.getLocation(n)===L.NONE&&this._label.setLocation(n,i)}},e.prototype.add=function(t){this._edges.insert(t),t.setNode(this)},e.prototype.setLabelBoundary=function(t){if(null===this._label)return null;var e=L.NONE;null!==this._label&&(e=this._label.getLocation(t)),this._label.setLocation(t,e===L.BOUNDARY?L.INTERIOR:L.BOUNDARY)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Fe),Ve=function(){this.nodeMap=new p,this.nodeFact=null,this.nodeFact=arguments[0]};Ve.prototype.find=function(t){return this.nodeMap.get(t)},Ve.prototype.addNode=function(){if(arguments[0]instanceof w){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Ge){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}},Ve.prototype.print=function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)},Ve.prototype.iterator=function(){return this.nodeMap.values().iterator()},Ve.prototype.values=function(){return this.nodeMap.values()},Ve.prototype.getBoundaryNodes=function(t){for(var e=new Nt,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===L.BOUNDARY&&e.add(i)}return e},Ve.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},Ve.prototype.interfaces_=function(){return[]},Ve.prototype.getClass=function(){return Ve};var qe=function(){},Be={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};qe.prototype.interfaces_=function(){return[]},qe.prototype.getClass=function(){return qe},qe.isNorthern=function(t){return t===qe.NE||t===qe.NW},qe.isOpposite=function(t,e){return t!==e&&2==(t-e+4)%4},qe.commonHalfPlane=function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=t<e?t:e;return 0===n&&3===(t>e?t:e)?3:n},qe.isInHalfPlane=function(t,e){return e===qe.SE?t===qe.SE||t===qe.SW:t===e||t===e+1},qe.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new m("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?qe.NE:qe.SE:e>=0?qe.NW:qe.SW}if(arguments[0]instanceof w&&arguments[1]instanceof w){var n=arguments[0],i=arguments[1];if(i.x===n.x&&i.y===n.y)throw new m("Cannot compute the quadrant for two identical points "+n);return i.x>=n.x?i.y>=n.y?qe.NE:qe.SE:i.y>=n.y?qe.NW:qe.SW}},Be.NE.get=function(){return 0},Be.NW.get=function(){return 1},Be.SW.get=function(){return 2},Be.SE.get=function(){return 3},Object.defineProperties(qe,Be);var ze=function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length)this._edge=arguments[0];else if(3===arguments.length){var t=arguments[1],e=arguments[2];this._edge=arguments[0],this.init(t,e),this._label=null}else if(4===arguments.length){var n=arguments[1],i=arguments[2],r=arguments[3];this._edge=arguments[0],this.init(n,i),this._label=r}};ze.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant<t._quadrant?-1:at.computeOrientation(t._p0,t._p1,this._p1)},ze.prototype.getDy=function(){return this._dy},ze.prototype.getCoordinate=function(){return this._p0},ze.prototype.setNode=function(t){this._node=t},ze.prototype.print=function(t){var e=Math.atan2(this._dy,this._dx),n=this.getClass().getName(),i=n.lastIndexOf("."),r=n.substring(i+1);t.print("  "+r+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+e+"   "+this._label)},ze.prototype.compareTo=function(t){return this.compareDirection(t)},ze.prototype.getDirectedCoordinate=function(){return this._p1},ze.prototype.getDx=function(){return this._dx},ze.prototype.getLabel=function(){return this._label},ze.prototype.getEdge=function(){return this._edge},ze.prototype.getQuadrant=function(){return this._quadrant},ze.prototype.getNode=function(){return this._node},ze.prototype.toString=function(){var t=Math.atan2(this._dy,this._dx),e=this.getClass().getName(),n=e.lastIndexOf(".");return"  "+e.substring(n+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+t+"   "+this._label},ze.prototype.computeLabel=function(t){},ze.prototype.init=function(t,e){this._p0=t,this._p1=e,this._dx=e.x-t.x,this._dy=e.y-t.y,this._quadrant=qe.quadrant(this._dx,this._dy),et.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")},ze.prototype.interfaces_=function(){return[x]},ze.prototype.getClass=function(){return ze};var Ue=function(t){function e(){var e=arguments[0],n=arguments[1];if(t.call(this,e),this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999],this._isForward=n,n)this.init(e.getCoordinate(0),e.getCoordinate(1));else{var i=e.getNumPoints()-1;this.init(e.getCoordinate(i),e.getCoordinate(i-1))}this.computeDirectedLabel()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getNextMin=function(){return this._nextMin},e.prototype.getDepth=function(t){return this._depth[t]},e.prototype.setVisited=function(t){this._isVisited=t},e.prototype.computeDirectedLabel=function(){this._label=new Re(this._edge.getLabel()),this._isForward||this._label.flip()},e.prototype.getNext=function(){return this._next},e.prototype.setDepth=function(t,e){if(-999!==this._depth[t]&&this._depth[t]!==e)throw new Le("assigned depths do not match",this.getCoordinate());this._depth[t]=e},e.prototype.isInteriorAreaEdge=function(){for(var t=!0,e=0;e<2;e++)this._label.isArea(e)&&this._label.getLocation(e,Ce.LEFT)===L.INTERIOR&&this._label.getLocation(e,Ce.RIGHT)===L.INTERIOR||(t=!1);return t},e.prototype.setNextMin=function(t){this._nextMin=t},e.prototype.print=function(e){t.prototype.print.call(this,e),e.print(" "+this._depth[Ce.LEFT]+"/"+this._depth[Ce.RIGHT]),e.print(" ("+this.getDepthDelta()+")"),this._isInResult&&e.print(" inResult")},e.prototype.setMinEdgeRing=function(t){this._minEdgeRing=t},e.prototype.isLineEdge=function(){var t=this._label.isLine(0)||this._label.isLine(1),e=!this._label.isArea(0)||this._label.allPositionsEqual(0,L.EXTERIOR),n=!this._label.isArea(1)||this._label.allPositionsEqual(1,L.EXTERIOR);return t&&e&&n},e.prototype.setEdgeRing=function(t){this._edgeRing=t},e.prototype.getMinEdgeRing=function(){return this._minEdgeRing},e.prototype.getDepthDelta=function(){var t=this._edge.getDepthDelta();return this._isForward||(t=-t),t},e.prototype.setInResult=function(t){this._isInResult=t},e.prototype.getSym=function(){return this._sym},e.prototype.isForward=function(){return this._isForward},e.prototype.getEdge=function(){return this._edge},e.prototype.printEdge=function(t){this.print(t),t.print(" "),this._isForward?this._edge.print(t):this._edge.printReverse(t)},e.prototype.setSym=function(t){this._sym=t},e.prototype.setVisitedEdge=function(t){this.setVisited(t),this._sym.setVisited(t)},e.prototype.setEdgeDepths=function(t,e){var n=this.getEdge().getDepthDelta();this._isForward||(n=-n);var i=1;t===Ce.LEFT&&(i=-1);var r=Ce.opposite(t),o=e+n*i;this.setDepth(t,e),this.setDepth(r,o)},e.prototype.getEdgeRing=function(){return this._edgeRing},e.prototype.isInResult=function(){return this._isInResult},e.prototype.setNext=function(t){this._next=t},e.prototype.isVisited=function(){return this._isVisited},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.depthFactor=function(t,e){return t===L.EXTERIOR&&e===L.INTERIOR?1:t===L.INTERIOR&&e===L.EXTERIOR?-1:0},e}(ze),ke=function(){};ke.prototype.createNode=function(t){return new Ge(t,null)},ke.prototype.interfaces_=function(){return[]},ke.prototype.getClass=function(){return ke};var Xe=function(){this._edges=new Nt,this._nodes=null,this._edgeEndList=new Nt,0===arguments.length?this._nodes=new Ve(new ke):1===arguments.length&&(this._nodes=new Ve(arguments[0]))};Xe.prototype.printEdges=function(t){t.println("Edges:");for(var e=0;e<this._edges.size();e++){t.println("edge "+e+":");var n=this._edges.get(e);n.print(t),n.eiList.print(t)}},Xe.prototype.find=function(t){return this._nodes.find(t)},Xe.prototype.addNode=function(){return arguments[0]instanceof Ge||arguments[0]instanceof w?this._nodes.addNode(arguments[0]):void 0},Xe.prototype.getNodeIterator=function(){return this._nodes.iterator()},Xe.prototype.linkResultDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()},Xe.prototype.debugPrintln=function(t){X.out.println(t)},Xe.prototype.isBoundaryNode=function(t,e){var n=this._nodes.find(e);if(null===n)return!1;var i=n.getLabel();return null!==i&&i.getLocation(t)===L.BOUNDARY},Xe.prototype.linkAllDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()},Xe.prototype.matchInSameDirection=function(t,e,n,i){return!!t.equals(n)&&at.computeOrientation(t,e,i)===at.COLLINEAR&&qe.quadrant(t,e)===qe.quadrant(n,i)},Xe.prototype.getEdgeEnds=function(){return this._edgeEndList},Xe.prototype.debugPrint=function(t){X.out.print(t)},Xe.prototype.getEdgeIterator=function(){return this._edges.iterator()},Xe.prototype.findEdgeInSameDirection=function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(this.matchInSameDirection(t,e,r[0],r[1]))return i;if(this.matchInSameDirection(t,e,r[r.length-1],r[r.length-2]))return i}return null},Xe.prototype.insertEdge=function(t){this._edges.add(t)},Xe.prototype.findEdgeEnd=function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null},Xe.prototype.addEdges=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this._edges.add(n);var i=new Ue(n,!0),r=new Ue(n,!1);i.setSym(r),r.setSym(i),this.add(i),this.add(r)}},Xe.prototype.add=function(t){this._nodes.add(t),this._edgeEndList.add(t)},Xe.prototype.getNodes=function(){return this._nodes.values()},Xe.prototype.findEdge=function(t,e){for(var n=0;n<this._edges.size();n++){var i=this._edges.get(n),r=i.getCoordinates();if(t.equals(r[0])&&e.equals(r[1]))return i}return null},Xe.prototype.interfaces_=function(){return[]},Xe.prototype.getClass=function(){return Xe},Xe.linkResultDirectedEdges=function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()};var Ye=function(){this._geometryFactory=null,this._shellList=new Nt,this._geometryFactory=arguments[0]};Ye.prototype.sortShellsAndHoles=function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isHole()?n.add(r):e.add(r)}},Ye.prototype.computePolygons=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next().toPolygon(this._geometryFactory);e.add(i)}return e},Ye.prototype.placeFreeHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();if(null===i.getShell()){var r=this.findEdgeRingContaining(i,t);if(null===r)throw new Le("unable to assign hole to a shell",i.getCoordinate(0));i.setShell(r)}}},Ye.prototype.buildMinimalEdgeRings=function(t,e,n){for(var i=new Nt,r=t.iterator();r.hasNext();){var o=r.next();if(o.getMaxNodeDegree()>2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else i.add(o)}return i},Ye.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();)if(e.next().containsPoint(t))return!0;return!1},Ye.prototype.buildMaximalEdgeRings=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new Ae(i,this._geometryFactory);e.add(r),r.setInResult()}}return e},Ye.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}},Ye.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Ye.prototype.findEdgeRingContaining=function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),c=l.getEnvelopeInternal();null!==o&&(s=o.getLinearRing().getEnvelopeInternal());var p=!1;c.contains(i)&&at.isPointInRing(r,l.getCoordinates())&&(p=!0),p&&(null===o||s.contains(c))&&(o=u)}return o},Ye.prototype.findShell=function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return et.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},Ye.prototype.add=function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0];Xe.linkResultDirectedEdges(arguments[1]);var n=this.buildMaximalEdgeRings(e),i=new Nt,r=this.buildMinimalEdgeRings(n,this._shellList,i);this.sortShellsAndHoles(r,this._shellList,i),this.placeFreeHoles(this._shellList,i)}},Ye.prototype.interfaces_=function(){return[]},Ye.prototype.getClass=function(){return Ye};var je=function(){};je.prototype.getBounds=function(){},je.prototype.interfaces_=function(){return[]},je.prototype.getClass=function(){return je};var He=function(){this._bounds=null,this._item=null;var t=arguments[1];this._bounds=arguments[0],this._item=t};He.prototype.getItem=function(){return this._item},He.prototype.getBounds=function(){return this._bounds},He.prototype.interfaces_=function(){return[je,e]},He.prototype.getClass=function(){return He};var We=function(){this._size=null,this._items=null,this._size=0,this._items=new Nt,this._items.add(null)};We.prototype.poll=function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t},We.prototype.size=function(){return this._size},We.prototype.reorder=function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)},We.prototype.clear=function(){this._size=0,this._items.clear()},We.prototype.isEmpty=function(){return 0===this._size},We.prototype.add=function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)},We.prototype.interfaces_=function(){return[]},We.prototype.getClass=function(){return We};var Je=function(){};Je.prototype.visitItem=function(t){},Je.prototype.interfaces_=function(){return[]},Je.prototype.getClass=function(){return Je};var Ke=function(){};Ke.prototype.insert=function(t,e){},Ke.prototype.remove=function(t,e){},Ke.prototype.query=function(){},Ke.prototype.interfaces_=function(){return[]},Ke.prototype.getClass=function(){return Ke};var Qe=function(){this._childBoundables=new Nt,this._bounds=null,this._level=null,0===arguments.length||1===arguments.length&&(this._level=arguments[0])},$e={serialVersionUID:{configurable:!0}};Qe.prototype.getLevel=function(){return this._level},Qe.prototype.size=function(){return this._childBoundables.size()},Qe.prototype.getChildBoundables=function(){return this._childBoundables},Qe.prototype.addChildBoundable=function(t){et.isTrue(null===this._bounds),this._childBoundables.add(t)},Qe.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},Qe.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},Qe.prototype.interfaces_=function(){return[je,e]},Qe.prototype.getClass=function(){return Qe},$e.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties(Qe,$e);var Ze=function(){};Ze.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},Ze.min=function(t){return Ze.sort(t),t.get(0)},Ze.sort=function(t,e){var n=t.toArray();e?Gt.sort(n,e):Gt.sort(n);for(var i=t.iterator(),r=0,o=n.length;r<o;r++)i.next(),i.set(n[r])},Ze.singletonList=function(t){var e=new Nt;return e.add(t),e};var tn=function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var t=arguments[1],e=arguments[2];this._boundable1=arguments[0],this._boundable2=t,this._itemDistance=e,this._distance=this.distance()};tn.prototype.expandToQueue=function(t,e){var n=tn.isComposite(this._boundable1),i=tn.isComposite(this._boundable2);if(n&&i)return tn.area(this._boundable1)>tn.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,t,e),null;if(i)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new m("neither boundable is composite")},tn.prototype.isLeaves=function(){return!(tn.isComposite(this._boundable1)||tn.isComposite(this._boundable2))},tn.prototype.compareTo=function(t){return this._distance<t._distance?-1:this._distance>t._distance?1:0},tn.prototype.expand=function(t,e,n,i){for(var r=t.getChildBoundables().iterator();r.hasNext();){var o=r.next(),s=new tn(o,e,this._itemDistance);s.getDistance()<i&&n.add(s)}},tn.prototype.getBoundable=function(t){return 0===t?this._boundable1:this._boundable2},tn.prototype.getDistance=function(){return this._distance},tn.prototype.distance=function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())},tn.prototype.interfaces_=function(){return[x]},tn.prototype.getClass=function(){return tn},tn.area=function(t){return t.getBounds().getArea()},tn.isComposite=function(t){return t instanceof Qe};var en=function t(){if(this._root=null,this._built=!1,this._itemBoundables=new Nt,this._nodeCapacity=null,0===arguments.length)this._nodeCapacity=t.DEFAULT_NODE_CAPACITY;else if(1===arguments.length){var e=arguments[0];et.isTrue(e>1,"Node capacity must be greater than 1"),this._nodeCapacity=e}},nn={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};en.prototype.getNodeCapacity=function(){return this._nodeCapacity},en.prototype.lastNode=function(t){return t.get(t.size()-1)},en.prototype.size=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof Qe?t+=this.size(n):n instanceof He&&(t+=1)}return t}},en.prototype.removeItem=function(t,e){for(var n=null,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof He&&r.getItem()===e&&(n=r)}return null!==n&&(t.getChildBoundables().remove(n),!0)},en.prototype.itemsTree=function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new Nt:t}if(1===arguments.length){for(var e=arguments[0],n=new Nt,i=e.getChildBoundables().iterator();i.hasNext();){var r=i.next();if(r instanceof Qe){var o=this.itemsTree(r);null!==o&&n.add(o)}else r instanceof He?n.add(r.getItem()):et.shouldNeverReachHere()}return n.size()<=0?null:n}},en.prototype.insert=function(t,e){et.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new He(t,e))},en.prototype.boundablesAtLevel=function(){if(1===arguments.length){var t=arguments[0],e=new Nt;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];if(et.isTrue(n>-2),i.getLevel()===n)return r.add(i),null;for(var o=i.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof Qe?this.boundablesAtLevel(n,s,r):(et.isTrue(s instanceof He),-1===n&&r.add(s))}return null}},en.prototype.query=function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new Nt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.query(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.query(n,this._root,i)}else if(3===arguments.length)if(T(arguments[2],Je)&&arguments[0]instanceof Object&&arguments[1]instanceof Qe)for(var r=arguments[0],o=arguments[2],s=arguments[1].getChildBoundables(),a=0;a<s.size();a++){var u=s.get(a);this.getIntersectsOp().intersects(u.getBounds(),r)&&(u instanceof Qe?this.query(r,u,o):u instanceof He?o.visitItem(u.getItem()):et.shouldNeverReachHere())}else if(T(arguments[2],Et)&&arguments[0]instanceof Object&&arguments[1]instanceof Qe)for(var l=arguments[0],c=arguments[2],p=arguments[1].getChildBoundables(),h=0;h<p.size();h++){var f=p.get(h);this.getIntersectsOp().intersects(f.getBounds(),l)&&(f instanceof Qe?this.query(l,f,c):f instanceof He?c.add(f.getItem()):et.shouldNeverReachHere())}},en.prototype.build=function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0},en.prototype.getRoot=function(){return this.build(),this._root},en.prototype.remove=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=this.removeItem(i,r);if(o)return!0;for(var s=null,a=i.getChildBoundables().iterator();a.hasNext();){var u=a.next();if(this.getIntersectsOp().intersects(u.getBounds(),n)&&u instanceof Qe&&(o=this.remove(n,u,r))){s=u;break}}return null!==s&&s.getChildBoundables().isEmpty()&&i.getChildBoundables().remove(s),o}},en.prototype.createHigherLevels=function(t,e){et.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)},en.prototype.depth=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof Qe){var i=this.depth(n);i>t&&(t=i)}}return t+1}},en.prototype.createParentBoundables=function(t,e){et.isTrue(!t.isEmpty());var n=new Nt;n.add(this.createNode(e));var i=new Nt(t);Ze.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var o=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n},en.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},en.prototype.interfaces_=function(){return[e]},en.prototype.getClass=function(){return en},en.compareDoubles=function(t,e){return t>e?1:t<e?-1:0},nn.IntersectsOp.get=function(){return rn},nn.serialVersionUID.get=function(){return-0x35ef64c82d4c5400},nn.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(en,nn);var rn=function(){},on=function(){};on.prototype.distance=function(t,e){},on.prototype.interfaces_=function(){return[]},on.prototype.getClass=function(){return on};var sn=function(t){function n(e){t.call(this,e=e||n.DEFAULT_NODE_CAPACITY)}t&&(n.__proto__=t),(n.prototype=Object.create(t&&t.prototype)).constructor=n;var i={STRtreeNode:{configurable:!0},serialVersionUID:{configurable:!0},xComparator:{configurable:!0},yComparator:{configurable:!0},intersectsOp:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};return n.prototype.createParentBoundablesFromVerticalSlices=function(t,e){et.isTrue(t.length>0);for(var n=new Nt,i=0;i<t.length;i++)n.addAll(this.createParentBoundablesFromVerticalSlice(t[i],e));return n},n.prototype.createNode=function(t){return new an(t)},n.prototype.size=function(){return 0===arguments.length?t.prototype.size.call(this):t.prototype.size.apply(this,arguments)},n.prototype.insert=function(){if(2!==arguments.length)return t.prototype.insert.apply(this,arguments);var e=arguments[0],n=arguments[1];if(e.isNull())return null;t.prototype.insert.call(this,e,n)},n.prototype.getIntersectsOp=function(){return n.intersectsOp},n.prototype.verticalSlices=function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),i=new Array(e).fill(null),r=t.iterator(),o=0;o<e;o++){i[o]=new Nt;for(var s=0;r.hasNext()&&s<n;){var a=r.next();i[o].add(a),s++}}return i},n.prototype.query=function(){if(1===arguments.length)return t.prototype.query.call(this,arguments[0]);2===arguments.length?t.prototype.query.call(this,arguments[0],arguments[1]):3===arguments.length&&(T(arguments[2],Je)&&arguments[0]instanceof Object&&arguments[1]instanceof Qe||T(arguments[2],Et)&&arguments[0]instanceof Object&&arguments[1]instanceof Qe)&&t.prototype.query.call(this,arguments[0],arguments[1],arguments[2])},n.prototype.getComparator=function(){return n.yComparator},n.prototype.createParentBoundablesFromVerticalSlice=function(e,n){return t.prototype.createParentBoundables.call(this,e,n)},n.prototype.remove=function(){return 2===arguments.length?t.prototype.remove.call(this,arguments[0],arguments[1]):t.prototype.remove.apply(this,arguments)},n.prototype.depth=function(){return 0===arguments.length?t.prototype.depth.call(this):t.prototype.depth.apply(this,arguments)},n.prototype.createParentBoundables=function(t,e){et.isTrue(!t.isEmpty());var i=Math.trunc(Math.ceil(t.size()/this.getNodeCapacity())),r=new Nt(t);Ze.sort(r,n.xComparator);var o=this.verticalSlices(r,Math.trunc(Math.ceil(Math.sqrt(i))));return this.createParentBoundablesFromVerticalSlices(o,e)},n.prototype.nearestNeighbour=function(){if(1===arguments.length){if(T(arguments[0],on)){var t=arguments[0],e=new tn(this.getRoot(),this.getRoot(),t);return this.nearestNeighbour(e)}if(arguments[0]instanceof tn)return this.nearestNeighbour(arguments[0],v.POSITIVE_INFINITY)}else if(2===arguments.length){if(arguments[0]instanceof n&&T(arguments[1],on)){var i=arguments[0],r=arguments[1],o=new tn(this.getRoot(),i.getRoot(),r);return this.nearestNeighbour(o)}if(arguments[0]instanceof tn&&"number"==typeof arguments[1]){var s=arguments[0],a=arguments[1],u=null,l=new We;for(l.add(s);!l.isEmpty()&&a>0;){var c=l.poll(),p=c.getDistance();if(p>=a)break;c.isLeaves()?(a=p,u=c):c.expandToQueue(l,a)}return[u.getBoundable(0).getItem(),u.getBoundable(1).getItem()]}}else if(3===arguments.length){var h=arguments[2],f=new He(arguments[0],arguments[1]),g=new tn(this.getRoot(),f,h);return this.nearestNeighbour(g)[0]}},n.prototype.interfaces_=function(){return[Ke,e]},n.prototype.getClass=function(){return n},n.centreX=function(t){return n.avg(t.getMinX(),t.getMaxX())},n.avg=function(t,e){return(t+e)/2},n.centreY=function(t){return n.avg(t.getMinY(),t.getMaxY())},i.STRtreeNode.get=function(){return an},i.serialVersionUID.get=function(){return 0x39920f7d5f261e0},i.xComparator.get=function(){return{interfaces_:function(){return[N]},compare:function(e,i){return t.compareDoubles(n.centreX(e.getBounds()),n.centreX(i.getBounds()))}}},i.yComparator.get=function(){return{interfaces_:function(){return[N]},compare:function(e,i){return t.compareDoubles(n.centreY(e.getBounds()),n.centreY(i.getBounds()))}}},i.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(t,e){return t.intersects(e)}}},i.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(n,i),n}(en),an=function(t){function e(){t.call(this,arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new j(n.getBounds()):t.expandToInclude(n.getBounds())}return t},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Qe),un=function(){};un.prototype.interfaces_=function(){return[]},un.prototype.getClass=function(){return un},un.relativeSign=function(t,e){return t<e?-1:t>e?1:0},un.compare=function(t,e,n){if(e.equals2D(n))return 0;var i=un.relativeSign(e.x,n.x),r=un.relativeSign(e.y,n.y);switch(t){case 0:return un.compareValue(i,r);case 1:return un.compareValue(r,i);case 2:return un.compareValue(r,-i);case 3:return un.compareValue(-i,r);case 4:return un.compareValue(-i,-r);case 5:return un.compareValue(-r,-i);case 6:return un.compareValue(-r,i);case 7:return un.compareValue(i,-r)}return et.shouldNeverReachHere("invalid octant value"),0},un.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var ln=function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._segString=t,this.coord=new w(e),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))};ln.prototype.getCoordinate=function(){return this.coord},ln.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},ln.prototype.compareTo=function(t){var e=t;return this.segmentIndex<e.segmentIndex?-1:this.segmentIndex>e.segmentIndex?1:this.coord.equals2D(e.coord)?0:un.compare(this._segmentOctant,this.coord,e.coord)},ln.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},ln.prototype.isInterior=function(){return this._isInterior},ln.prototype.interfaces_=function(){return[x]},ln.prototype.getClass=function(){return ln};var cn=function(){this._nodeMap=new p,this._edge=null,this._edge=arguments[0]};cn.prototype.getSplitCoordinates=function(){var t=new Ct;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()},cn.prototype.addCollapsedNodes=function(){var t=new Nt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}},cn.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},cn.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e<this._edge.size()-2;e++){var n=this._edge.getCoordinate(e),i=this._edge.getCoordinate(e+2);n.equals2D(i)&&t.add(new D(e+1))}},cn.prototype.addEdgeCoordinates=function(t,e,n){var i=this._edge.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);n.add(new w(t.coord),!1);for(var o=t.segmentIndex+1;o<=e.segmentIndex;o++)n.add(this._edge.getCoordinate(o));r&&n.add(new w(e.coord))},cn.prototype.iterator=function(){return this._nodeMap.values().iterator()},cn.prototype.addSplitEdges=function(t){this.addEndpoints(),this.addCollapsedNodes();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}},cn.prototype.findCollapseIndex=function(t,e,n){if(!t.coord.equals2D(e.coord))return!1;var i=e.segmentIndex-t.segmentIndex;return e.isInterior()||i--,1===i&&(n[0]=t.segmentIndex+1,!0)},cn.prototype.findCollapsesFromInsertedNodes=function(t){for(var e=new Array(1).fill(null),n=this.iterator(),i=n.next();n.hasNext();){var r=n.next();this.findCollapseIndex(i,r,e)&&t.add(new D(e[0])),i=r}},cn.prototype.getEdge=function(){return this._edge},cn.prototype.addEndpoints=function(){var t=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(t),t)},cn.prototype.createSplitEdge=function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=this._edge.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new w(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this._edge.getCoordinate(a);return r&&(o[s]=new w(e.coord)),new gn(o,this._edge.getData())},cn.prototype.add=function(t,e){var n=new ln(this._edge,t,e,this._edge.getSegmentOctant(e)),i=this._nodeMap.get(n);return null!==i?(et.isTrue(i.coord.equals2D(t),"Found equal nodes with different coordinates"),i):(this._nodeMap.put(n,n),n)},cn.prototype.checkSplitEdgesCorrectness=function(t){var e=this._edge.getCoordinates(),n=t.get(0).getCoordinate(0);if(!n.equals2D(e[0]))throw new Z("bad split edge start point at "+n);var i=t.get(t.size()-1).getCoordinates(),r=i[i.length-1];if(!r.equals2D(e[e.length-1]))throw new Z("bad split edge end point at "+r)},cn.prototype.interfaces_=function(){return[]},cn.prototype.getClass=function(){return cn};var pn=function(){};pn.prototype.interfaces_=function(){return[]},pn.prototype.getClass=function(){return pn},pn.octant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new m("Cannot compute the octant for point ( "+t+", "+e+" )");var n=Math.abs(t),i=Math.abs(e);return t>=0?e>=0?n>=i?0:1:n>=i?7:6:e>=0?n>=i?3:2:n>=i?4:5}if(arguments[0]instanceof w&&arguments[1]instanceof w){var r=arguments[0],o=arguments[1],s=o.x-r.x,a=o.y-r.y;if(0===s&&0===a)throw new m("Cannot compute the octant for two identical points "+r);return pn.octant(s,a)}};var hn=function(){};hn.prototype.getCoordinates=function(){},hn.prototype.size=function(){},hn.prototype.getCoordinate=function(t){},hn.prototype.isClosed=function(){},hn.prototype.setData=function(t){},hn.prototype.getData=function(){},hn.prototype.interfaces_=function(){return[]},hn.prototype.getClass=function(){return hn};var fn=function(){};fn.prototype.addIntersection=function(t,e){},fn.prototype.interfaces_=function(){return[hn]},fn.prototype.getClass=function(){return fn};var gn=function(){this._nodeList=new cn(this),this._pts=null,this._data=null;var t=arguments[1];this._pts=arguments[0],this._data=t};gn.prototype.getCoordinates=function(){return this._pts},gn.prototype.size=function(){return this._pts.length},gn.prototype.getCoordinate=function(t){return this._pts[t]},gn.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},gn.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},gn.prototype.setData=function(t){this._data=t},gn.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:pn.octant(t,e)},gn.prototype.getData=function(){return this._data},gn.prototype.addIntersection=function(){if(2===arguments.length)this.addIntersectionNode(arguments[0],arguments[1]);else if(4===arguments.length){var t=arguments[1],e=new w(arguments[0].getIntersection(arguments[3]));this.addIntersection(e,t)}},gn.prototype.toString=function(){return $.toLineString(new ue(this._pts))},gn.prototype.getNodeList=function(){return this._nodeList},gn.prototype.addIntersectionNode=function(t,e){var n=e,i=n+1;return i<this._pts.length&&t.equals2D(this._pts[i])&&(n=i),this._nodeList.add(t,n)},gn.prototype.addIntersections=function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)},gn.prototype.interfaces_=function(){return[fn]},gn.prototype.getClass=function(){return gn},gn.getNodedSubstrings=function(){if(1===arguments.length){var t=arguments[0],e=new Nt;return gn.getNodedSubstrings(t,e),e}if(2===arguments.length)for(var n=arguments[1],i=arguments[0].iterator();i.hasNext();)i.next().getNodeList().addSplitEdges(n)};var dn=function(){if(this.p0=null,this.p1=null,0===arguments.length)this.p0=new w,this.p1=new w;else if(1===arguments.length){var t=arguments[0];this.p0=new w(t.p0),this.p1=new w(t.p1)}else if(2===arguments.length)this.p0=arguments[0],this.p1=arguments[1];else if(4===arguments.length){var e=arguments[2],n=arguments[3];this.p0=new w(arguments[0],arguments[1]),this.p1=new w(e,n)}},yn={serialVersionUID:{configurable:!0}};dn.prototype.minX=function(){return Math.min(this.p0.x,this.p1.x)},dn.prototype.orientationIndex=function(){if(arguments[0]instanceof dn){var t=arguments[0],e=at.orientationIndex(this.p0,this.p1,t.p0),n=at.orientationIndex(this.p0,this.p1,t.p1);return e>=0&&n>=0||e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof w)return at.orientationIndex(this.p0,this.p1,arguments[0])},dn.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},dn.prototype.isVertical=function(){return this.p0.x===this.p1.x},dn.prototype.equals=function(t){if(!(t instanceof dn))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},dn.prototype.intersection=function(t){var e=new rt;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},dn.prototype.project=function(){if(arguments[0]instanceof w){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new w(t);var e=this.projectionFactor(t),n=new w;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof dn){var i=arguments[0],r=this.projectionFactor(i.p0),o=this.projectionFactor(i.p1);if(r>=1&&o>=1)return null;if(r<=0&&o<=0)return null;var s=this.project(i.p0);r<0&&(s=this.p0),r>1&&(s=this.p1);var a=this.project(i.p1);return o<0&&(a=this.p0),o>1&&(a=this.p1),new dn(s,a)}},dn.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},dn.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},dn.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1},dn.prototype.distancePerpendicular=function(t){return at.distancePointLinePerpendicular(t,this.p0,this.p1)},dn.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},dn.prototype.midPoint=function(){return dn.midPoint(this.p0,this.p1)},dn.prototype.projectionFactor=function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?v.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i},dn.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=v.MAX_VALUE,r=null,o=this.closestPoint(t.p0);i=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(r=s.distance(t.p1))<i&&(i=r,n[0]=s,n[1]=t.p1);var a=t.closestPoint(this.p0);(r=a.distance(this.p0))<i&&(i=r,n[0]=this.p0,n[1]=a);var u=t.closestPoint(this.p1);return(r=u.distance(this.p1))<i&&(i=r,n[0]=this.p1,n[1]=u),n},dn.prototype.closestPoint=function(t){var e=this.projectionFactor(t);return e>0&&e<1?this.project(t):this.p0.distance(t)<this.p1.distance(t)?this.p0:this.p1},dn.prototype.maxX=function(){return Math.max(this.p0.x,this.p1.x)},dn.prototype.getLength=function(){return this.p0.distance(this.p1)},dn.prototype.compareTo=function(t){var e=t,n=this.p0.compareTo(e.p0);return 0!==n?n:this.p1.compareTo(e.p1)},dn.prototype.reverse=function(){var t=this.p0;this.p0=this.p1,this.p1=t},dn.prototype.equalsTopo=function(t){return this.p0.equals(t.p0)&&(this.p1.equals(t.p1)||this.p0.equals(t.p1))&&this.p1.equals(t.p0)},dn.prototype.lineIntersection=function(t){try{return Y.intersection(this.p0,this.p1,t.p0,t.p1)}catch(t){if(!(t instanceof k))throw t}return null},dn.prototype.maxY=function(){return Math.max(this.p0.y,this.p1.y)},dn.prototype.pointAlongOffset=function(t,e){var n=this.p0.x+t*(this.p1.x-this.p0.x),i=this.p0.y+t*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y,s=Math.sqrt(r*r+o*o),a=0,u=0;if(0!==e){if(s<=0)throw new Error("Cannot compute offset from zero-length line segment");a=e*r/s,u=e*o/s}return new w(n-u,i+a)},dn.prototype.setCoordinates=function(){if(1===arguments.length){var t=arguments[0];this.setCoordinates(t.p0,t.p1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p0.x=e.x,this.p0.y=e.y,this.p1.x=n.x,this.p1.y=n.y}},dn.prototype.segmentFraction=function(t){var e=this.projectionFactor(t);return e<0?e=0:(e>1||v.isNaN(e))&&(e=1),e},dn.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},dn.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},dn.prototype.distance=function(){if(arguments[0]instanceof dn){var t=arguments[0];return at.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof w)return at.distancePointLine(arguments[0],this.p0,this.p1)},dn.prototype.pointAlong=function(t){var e=new w;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},dn.prototype.hashCode=function(){var t=v.doubleToLongBits(this.p0.x);t^=31*v.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=v.doubleToLongBits(this.p1.x);return n^=31*v.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)},dn.prototype.interfaces_=function(){return[x,e]},dn.prototype.getClass=function(){return dn},dn.midPoint=function(t,e){return new w((t.x+e.x)/2,(t.y+e.y)/2)},yn.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(dn,yn);var _n=function(){this.tempEnv1=new j,this.tempEnv2=new j,this._overlapSeg1=new dn,this._overlapSeg2=new dn};_n.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[2],e=arguments[3];arguments[0].getLineSegment(arguments[1],this._overlapSeg1),t.getLineSegment(e,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}},_n.prototype.interfaces_=function(){return[]},_n.prototype.getClass=function(){return _n};var mn=function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[1],e=arguments[2],n=arguments[3];this._pts=arguments[0],this._start=t,this._end=e,this._context=n};mn.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},mn.prototype.computeSelect=function(t,e,n,i){if(i.tempEnv1.init(this._pts[e],this._pts[n]),n-e==1)return i.select(this,e),null;if(!t.intersects(i.tempEnv1))return null;var r=Math.trunc((e+n)/2);e<r&&this.computeSelect(t,e,r,i),r<n&&this.computeSelect(t,r,n,i)},mn.prototype.getCoordinates=function(){for(var t=new Array(this._end-this._start+1).fill(null),e=0,n=this._start;n<=this._end;n++)t[e++]=this._pts[n];return t},mn.prototype.computeOverlaps=function(t,e){this.computeOverlapsInternal(this._start,this._end,t,t._start,t._end,e)},mn.prototype.setId=function(t){this._id=t},mn.prototype.select=function(t,e){this.computeSelect(t,this._start,this._end,e)},mn.prototype.getEnvelope=function(){return null===this._env&&(this._env=new j(this._pts[this._start],this._pts[this._end])),this._env},mn.prototype.getEndIndex=function(){return this._end},mn.prototype.getStartIndex=function(){return this._start},mn.prototype.getContext=function(){return this._context},mn.prototype.getId=function(){return this._id},mn.prototype.computeOverlapsInternal=function(t,e,n,i,r,o){var s=this._pts[t],a=this._pts[e],u=n._pts[i],l=n._pts[r];if(e-t==1&&r-i==1)return o.overlap(this,t,n,i),null;if(o.tempEnv1.init(s,a),o.tempEnv2.init(u,l),!o.tempEnv1.intersects(o.tempEnv2))return null;var c=Math.trunc((t+e)/2),p=Math.trunc((i+r)/2);t<c&&(i<p&&this.computeOverlapsInternal(t,c,n,i,p,o),p<r&&this.computeOverlapsInternal(t,c,n,p,r,o)),c<e&&(i<p&&this.computeOverlapsInternal(c,e,n,i,p,o),p<r&&this.computeOverlapsInternal(c,e,n,p,r,o))},mn.prototype.interfaces_=function(){return[]},mn.prototype.getClass=function(){return mn};var vn=function(){};vn.prototype.interfaces_=function(){return[]},vn.prototype.getClass=function(){return vn},vn.getChainStartIndices=function(t){var e=0,n=new Nt;n.add(new D(e));do{var i=vn.findChainEnd(t,e);n.add(new D(i)),e=i}while(e<t.length-1);return vn.toIntArray(n)},vn.findChainEnd=function(t,e){for(var n=e;n<t.length-1&&t[n].equals2D(t[n+1]);)n++;if(n>=t.length-1)return t.length-1;for(var i=qe.quadrant(t[n],t[n+1]),r=e+1;r<t.length&&(t[r-1].equals2D(t[r])||qe.quadrant(t[r-1],t[r])===i);)r++;return r-1},vn.getChains=function(){if(1===arguments.length)return vn.getChains(arguments[0],null);if(2===arguments.length){for(var t=arguments[0],e=arguments[1],n=new Nt,i=vn.getChainStartIndices(t),r=0;r<i.length-1;r++){var o=new mn(t,i[r],i[r+1],e);n.add(o)}return n}},vn.toIntArray=function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e};var In=function(){};In.prototype.computeNodes=function(t){},In.prototype.getNodedSubstrings=function(){},In.prototype.interfaces_=function(){return[]},In.prototype.getClass=function(){return In};var xn=function(){this._segInt=null,0===arguments.length||1===arguments.length&&this.setSegmentIntersector(arguments[0])};xn.prototype.setSegmentIntersector=function(t){this._segInt=t},xn.prototype.interfaces_=function(){return[In]},xn.prototype.getClass=function(){return xn};var En=function(t){function e(e){e?t.call(this,e):t.call(this),this._monoChains=new Nt,this._index=new sn,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={SegmentOverlapAction:{configurable:!0}};return e.prototype.getMonotoneChains=function(){return this._monoChains},e.prototype.getNodedSubstrings=function(){return gn.getNodedSubstrings(this._nodedSegStrings)},e.prototype.getIndex=function(){return this._index},e.prototype.add=function(t){for(var e=vn.getChains(t.getCoordinates(),t).iterator();e.hasNext();){var n=e.next();n.setId(this._idCounter++),this._index.insert(n.getEnvelope(),n),this._monoChains.add(n)}},e.prototype.computeNodes=function(t){this._nodedSegStrings=t;for(var e=t.iterator();e.hasNext();)this.add(e.next());this.intersectChains()},e.prototype.intersectChains=function(){for(var t=new Nn(this._segInt),e=this._monoChains.iterator();e.hasNext();)for(var n=e.next(),i=this._index.query(n.getEnvelope()).iterator();i.hasNext();){var r=i.next();if(r.getId()>n.getId()&&(n.computeOverlaps(r,t),this._nOverlaps++),this._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.SegmentOverlapAction.get=function(){return Nn},Object.defineProperties(e,n),e}(xn),Nn=function(t){function e(){t.call(this),this._si=null,this._si=arguments[0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(4!==arguments.length)return t.prototype.overlap.apply(this,arguments);var e=arguments[1],n=arguments[2],i=arguments[3],r=arguments[0].getContext(),o=n.getContext();this._si.processIntersections(r,e,o,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(_n),wn=function t(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length)this.setQuadrantSegments(arguments[0]);else if(2===arguments.length){var e=arguments[1];this.setQuadrantSegments(arguments[0]),this.setEndCapStyle(e)}else if(4===arguments.length){var n=arguments[1],i=arguments[2],r=arguments[3];this.setQuadrantSegments(arguments[0]),this.setEndCapStyle(n),this.setJoinStyle(i),this.setMitreLimit(r)}},Cn={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};wn.prototype.getEndCapStyle=function(){return this._endCapStyle},wn.prototype.isSingleSided=function(){return this._isSingleSided},wn.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=wn.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=wn.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==wn.JOIN_ROUND&&(this._quadrantSegments=wn.DEFAULT_QUADRANT_SEGMENTS)},wn.prototype.getJoinStyle=function(){return this._joinStyle},wn.prototype.setJoinStyle=function(t){this._joinStyle=t},wn.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},wn.prototype.getSimplifyFactor=function(){return this._simplifyFactor},wn.prototype.getQuadrantSegments=function(){return this._quadrantSegments},wn.prototype.setEndCapStyle=function(t){this._endCapStyle=t},wn.prototype.getMitreLimit=function(){return this._mitreLimit},wn.prototype.setMitreLimit=function(t){this._mitreLimit=t},wn.prototype.setSingleSided=function(t){this._isSingleSided=t},wn.prototype.interfaces_=function(){return[]},wn.prototype.getClass=function(){return wn},wn.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},Cn.CAP_ROUND.get=function(){return 1},Cn.CAP_FLAT.get=function(){return 2},Cn.CAP_SQUARE.get=function(){return 3},Cn.JOIN_ROUND.get=function(){return 1},Cn.JOIN_MITRE.get=function(){return 2},Cn.JOIN_BEVEL.get=function(){return 3},Cn.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},Cn.DEFAULT_MITRE_LIMIT.get=function(){return 5},Cn.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(wn,Cn);var Sn=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=at.COUNTERCLOCKWISE,this._inputLine=t||null},bn={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};Sn.prototype.isDeletable=function(t,e,n,i){var r=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(r,o,s)&&!!this.isShallow(r,o,s,i)&&this.isShallowSampled(r,o,t,n,i)},Sn.prototype.deleteShallowConcavities=function(){for(var t=1,e=this.findNextNonDeletedIndex(t),n=this.findNextNonDeletedIndex(e),i=!1;n<this._inputLine.length;){var r=!1;this.isDeletable(t,e,n,this._distanceTol)&&(this._isDeleted[e]=Sn.DELETE,r=!0,i=!0),e=this.findNextNonDeletedIndex(t=r?n:e),n=this.findNextNonDeletedIndex(e)}return i},Sn.prototype.isShallowConcavity=function(t,e,n,i){return at.computeOrientation(t,e,n)===this._angleOrientation&&at.distancePointLine(e,t,n)<i},Sn.prototype.isShallowSampled=function(t,e,n,i,r){var o=Math.trunc((i-n)/Sn.NUM_PTS_TO_CHECK);o<=0&&(o=1);for(var s=n;s<i;s+=o)if(!this.isShallow(t,e,this._inputLine[s],r))return!1;return!0},Sn.prototype.isConcave=function(t,e,n){return at.computeOrientation(t,e,n)===this._angleOrientation},Sn.prototype.simplify=function(t){this._distanceTol=Math.abs(t),t<0&&(this._angleOrientation=at.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var e=!1;do{e=this.deleteShallowConcavities()}while(e);return this.collapseLine()},Sn.prototype.findNextNonDeletedIndex=function(t){for(var e=t+1;e<this._inputLine.length&&this._isDeleted[e]===Sn.DELETE;)e++;return e},Sn.prototype.isShallow=function(t,e,n,i){return at.distancePointLine(e,t,n)<i},Sn.prototype.collapseLine=function(){for(var t=new Ct,e=0;e<this._inputLine.length;e++)this._isDeleted[e]!==Sn.DELETE&&t.add(this._inputLine[e]);return t.toCoordinateArray()},Sn.prototype.interfaces_=function(){return[]},Sn.prototype.getClass=function(){return Sn},Sn.simplify=function(t,e){return new Sn(t).simplify(e)},bn.INIT.get=function(){return 0},bn.DELETE.get=function(){return 1},bn.KEEP.get=function(){return 1},bn.NUM_PTS_TO_CHECK.get=function(){return 10},Object.defineProperties(Sn,bn);var Ln=function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new Nt},On={COORDINATE_ARRAY_TYPE:{configurable:!0}};Ln.prototype.getCoordinates=function(){return this._ptList.toArray(Ln.COORDINATE_ARRAY_TYPE)},Ln.prototype.setPrecisionModel=function(t){this._precisionModel=t},Ln.prototype.addPt=function(t){var e=new w(t);if(this._precisionModel.makePrecise(e),this.isRedundant(e))return null;this._ptList.add(e)},Ln.prototype.revere=function(){},Ln.prototype.addPts=function(t,e){if(e)for(var n=0;n<t.length;n++)this.addPt(t[n]);else for(var i=t.length-1;i>=0;i--)this.addPt(t[i])},Ln.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)<this._minimimVertexDistance},Ln.prototype.toString=function(){return(new _e).createLineString(this.getCoordinates()).toString()},Ln.prototype.closeRing=function(){if(this._ptList.size()<1)return null;var t=new w(this._ptList.get(0)),e=this._ptList.get(this._ptList.size()-1);if(t.equals(e))return null;this._ptList.add(t)},Ln.prototype.setMinimumVertexDistance=function(t){this._minimimVertexDistance=t},Ln.prototype.interfaces_=function(){return[]},Ln.prototype.getClass=function(){return Ln},On.COORDINATE_ARRAY_TYPE.get=function(){return new Array(0).fill(null)},Object.defineProperties(Ln,On);var Tn=function(){},Pn={PI_TIMES_2:{configurable:!0},PI_OVER_2:{configurable:!0},PI_OVER_4:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},CLOCKWISE:{configurable:!0},NONE:{configurable:!0}};Tn.prototype.interfaces_=function(){return[]},Tn.prototype.getClass=function(){return Tn},Tn.toDegrees=function(t){return 180*t/Math.PI},Tn.normalize=function(t){for(;t>Math.PI;)t-=Tn.PI_TIMES_2;for(;t<=-Math.PI;)t+=Tn.PI_TIMES_2;return t},Tn.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return Math.atan2(n.y-e.y,n.x-e.x)}},Tn.isAcute=function(t,e,n){return(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y)>0},Tn.isObtuse=function(t,e,n){return(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y)<0},Tn.interiorAngle=function(t,e,n){var i=Tn.angle(e,t),r=Tn.angle(e,n);return Math.abs(r-i)},Tn.normalizePositive=function(t){if(t<0){for(;t<0;)t+=Tn.PI_TIMES_2;t>=Tn.PI_TIMES_2&&(t=0)}else{for(;t>=Tn.PI_TIMES_2;)t-=Tn.PI_TIMES_2;t<0&&(t=0)}return t},Tn.angleBetween=function(t,e,n){var i=Tn.angle(e,t),r=Tn.angle(e,n);return Tn.diff(i,r)},Tn.diff=function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},Tn.toRadians=function(t){return t*Math.PI/180},Tn.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?Tn.COUNTERCLOCKWISE:n<0?Tn.CLOCKWISE:Tn.NONE},Tn.angleBetweenOriented=function(t,e,n){var i=Tn.angle(e,t),r=Tn.angle(e,n)-i;return r<=-Math.PI?r+Tn.PI_TIMES_2:r>Math.PI?r-Tn.PI_TIMES_2:r},Pn.PI_TIMES_2.get=function(){return 2*Math.PI},Pn.PI_OVER_2.get=function(){return Math.PI/2},Pn.PI_OVER_4.get=function(){return Math.PI/4},Pn.COUNTERCLOCKWISE.get=function(){return at.COUNTERCLOCKWISE},Pn.CLOCKWISE.get=function(){return at.CLOCKWISE},Pn.NONE.get=function(){return at.COLLINEAR},Object.defineProperties(Tn,Pn);var Rn=function t(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new dn,this._seg1=new dn,this._offset0=new dn,this._offset1=new dn,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[1],n=arguments[2];this._precisionModel=arguments[0],this._bufParams=e,this._li=new rt,this._filletAngleQuantum=Math.PI/2/e.getQuadrantSegments(),e.getQuadrantSegments()>=8&&e.getJoinStyle()===wn.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)},Mn={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};Rn.prototype.addNextSegment=function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=at.computeOrientation(this._s0,this._s1,this._s2),i=n===at.CLOCKWISE&&this._side===Ce.LEFT||n===at.COUNTERCLOCKWISE&&this._side===Ce.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},Rn.prototype.addLineEndCap=function(t,e){var n=new dn(t,e),i=new dn;this.computeOffsetSegment(n,Ce.LEFT,this._distance,i);var r=new dn;this.computeOffsetSegment(n,Ce.RIGHT,this._distance,r);var o=Math.atan2(e.y-t.y,e.x-t.x);switch(this._bufParams.getEndCapStyle()){case wn.CAP_ROUND:this._segList.addPt(i.p1),this.addFilletArc(e,o+Math.PI/2,o-Math.PI/2,at.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case wn.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case wn.CAP_SQUARE:var s=new w;s.x=Math.abs(this._distance)*Math.cos(o),s.y=Math.abs(this._distance)*Math.sin(o);var a=new w(i.p1.x+s.x,i.p1.y+s.y),u=new w(r.p1.x+s.x,r.p1.y+s.y);this._segList.addPt(a),this._segList.addPt(u)}},Rn.prototype.getCoordinates=function(){return this._segList.getCoordinates()},Rn.prototype.addMitreJoin=function(t,e,n,i){var r=!0,o=null;try{o=Y.intersection(e.p0,e.p1,n.p0,n.p1),(i<=0?1:o.distance(t)/Math.abs(i))>this._bufParams.getMitreLimit()&&(r=!1)}catch(t){if(!(t instanceof k))throw t;o=new w(0,0),r=!1}r?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,i,this._bufParams.getMitreLimit())},Rn.prototype.addFilletCorner=function(t,e,n,i,r){var o=Math.atan2(e.y-t.y,e.x-t.x),s=Math.atan2(n.y-t.y,n.x-t.x);i===at.CLOCKWISE?o<=s&&(o+=2*Math.PI):o>=s&&(o-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,o,s,i,r),this._segList.addPt(n)},Rn.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*Rn.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===wn.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===wn.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(e&&this._segList.addPt(this._offset0.p1),this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,t,this._distance),this._segList.addPt(this._offset1.p0))},Rn.prototype.createSquare=function(t){this._segList.addPt(new w(t.x+this._distance,t.y+this._distance)),this._segList.addPt(new w(t.x+this._distance,t.y-this._distance)),this._segList.addPt(new w(t.x-this._distance,t.y-this._distance)),this._segList.addPt(new w(t.x-this._distance,t.y+this._distance)),this._segList.closeRing()},Rn.prototype.addSegments=function(t,e){this._segList.addPts(t,e)},Rn.prototype.addFirstSegment=function(){this._segList.addPt(this._offset1.p0)},Rn.prototype.addLastSegment=function(){this._segList.addPt(this._offset1.p1)},Rn.prototype.initSideSegments=function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)},Rn.prototype.addLimitedMitreJoin=function(t,e,n,i){var r=this._seg0.p1,o=Tn.angle(r,this._seg0.p0),s=Tn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=Tn.normalize(o+s),u=Tn.normalize(a+Math.PI),l=i*n,c=n-l*Math.abs(Math.sin(s)),p=r.x+l*Math.cos(u),h=r.y+l*Math.sin(u),f=new w(p,h),g=new dn(r,f),d=g.pointAlongOffset(1,c),y=g.pointAlongOffset(1,-c);this._side===Ce.LEFT?(this._segList.addPt(d),this._segList.addPt(y)):(this._segList.addPt(y),this._segList.addPt(d))},Rn.prototype.computeOffsetSegment=function(t,e,n,i){var r=e===Ce.LEFT?1:-1,o=t.p1.x-t.p0.x,s=t.p1.y-t.p0.y,a=Math.sqrt(o*o+s*s),u=r*n*o/a,l=r*n*s/a;i.p0.x=t.p0.x-l,i.p0.y=t.p0.y+u,i.p1.x=t.p1.x-l,i.p1.y=t.p1.y+u},Rn.prototype.addFilletArc=function(t,e,n,i,r){var o=i===at.CLOCKWISE?-1:1,s=Math.abs(e-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;for(var u=s/a,l=0,c=new w;l<s;){var p=e+o*l;c.x=t.x+r*Math.cos(p),c.y=t.y+r*Math.sin(p),this._segList.addPt(c),l+=u}},Rn.prototype.addInsideTurn=function(t,e){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*Rn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var n=new w((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var i=new w((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(i)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}},Rn.prototype.createCircle=function(t){var e=new w(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},Rn.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},Rn.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Ln,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*Rn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},Rn.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===wn.JOIN_BEVEL||this._bufParams.getJoinStyle()===wn.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,at.CLOCKWISE,this._distance))},Rn.prototype.closeRing=function(){this._segList.closeRing()},Rn.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},Rn.prototype.interfaces_=function(){return[]},Rn.prototype.getClass=function(){return Rn},Mn.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},Mn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},Mn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},Mn.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(Rn,Mn);var Dn=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[1];this._precisionModel=arguments[0],this._bufParams=t};Dn.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var o=r.getCoordinates();return n&&St.reverse(o),o},Dn.prototype.computeSingleSidedBufferCurve=function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var r=Sn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Ce.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{n.addSegments(t,!1);var a=Sn.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],Ce.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment(),n.closeRing()},Dn.prototype.computeRingBufferCurve=function(t,e,n){var i=this.simplifyTolerance(this._distance);e===Ce.RIGHT&&(i=-i);var r=Sn.simplify(t,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],e);for(var s=1;s<=o;s++)n.addNextSegment(r[s],1!==s);n.closeRing()},Dn.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),i=Sn.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],Ce.LEFT);for(var o=2;o<=r;o++)e.addNextSegment(i[o],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var s=Sn.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],Ce.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(s[u],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()},Dn.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case wn.CAP_ROUND:e.createCircle(t);break;case wn.CAP_SQUARE:e.createSquare(t)}},Dn.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),i=this.getSegGen(n);return t.length<=1?this.computePointCurve(t[0],i):this._bufParams.isSingleSided()?this.computeSingleSidedBufferCurve(t,e<0,i):this.computeLineBufferCurve(t,i),i.getCoordinates()},Dn.prototype.getBufferParameters=function(){return this._bufParams},Dn.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},Dn.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return Dn.copyCoordinates(t);var i=this.getSegGen(n);return this.computeRingBufferCurve(t,e,i),i.getCoordinates()},Dn.prototype.computeOffsetCurve=function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){var r=Sn.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],Ce.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{var a=Sn.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],Ce.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment()},Dn.prototype.getSegGen=function(t){return new Rn(this._precisionModel,this._bufParams,t)},Dn.prototype.interfaces_=function(){return[]},Dn.prototype.getClass=function(){return Dn},Dn.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;n<e.length;n++)e[n]=new w(t[n]);return e};var An=function(){this._subgraphs=null,this._seg=new dn,this._cga=new at,this._subgraphs=arguments[0]},Fn={DepthSegment:{configurable:!0}};An.prototype.findStabbedSegments=function(){if(1===arguments.length){for(var t=arguments[0],e=new Nt,n=this._subgraphs.iterator();n.hasNext();){var i=n.next(),r=i.getEnvelope();t.y<r.getMinY()||t.y>r.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(T(arguments[2],Et)&&arguments[0]instanceof w&&arguments[1]instanceof Ue){for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getEdge().getCoordinates(),l=0;l<u.length-1;l++)if(this._seg.p0=u[l],this._seg.p1=u[l+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)<o.x||this._seg.isHorizontal()||o.y<this._seg.p0.y||o.y>this._seg.p1.y||at.computeOrientation(this._seg.p0,this._seg.p1,o)===at.RIGHT)){var c=s.getDepth(Ce.LEFT);this._seg.p0.equals(u[l])||(c=s.getDepth(Ce.RIGHT));var p=new Gn(this._seg,c);a.add(p)}}else if(T(arguments[2],Et)&&arguments[0]instanceof w&&T(arguments[1],Et))for(var h=arguments[0],f=arguments[2],g=arguments[1].iterator();g.hasNext();){var d=g.next();d.isForward()&&this.findStabbedSegments(h,d,f)}},An.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:Ze.min(e)._leftDepth},An.prototype.interfaces_=function(){return[]},An.prototype.getClass=function(){return An},Fn.DepthSegment.get=function(){return Gn},Object.defineProperties(An,Fn);var Gn=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[1];this._upwardSeg=new dn(arguments[0]),this._leftDepth=t};Gn.prototype.compareTo=function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)},Gn.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},Gn.prototype.toString=function(){return this._upwardSeg.toString()},Gn.prototype.interfaces_=function(){return[x]},Gn.prototype.getClass=function(){return Gn};var Vn=function(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null};Vn.prototype.area=function(){return Vn.area(this.p0,this.p1,this.p2)},Vn.prototype.signedArea=function(){return Vn.signedArea(this.p0,this.p1,this.p2)},Vn.prototype.interpolateZ=function(t){if(null===t)throw new m("Supplied point is null.");return Vn.interpolateZ(t,this.p0,this.p1,this.p2)},Vn.prototype.longestSideLength=function(){return Vn.longestSideLength(this.p0,this.p1,this.p2)},Vn.prototype.isAcute=function(){return Vn.isAcute(this.p0,this.p1,this.p2)},Vn.prototype.circumcentre=function(){return Vn.circumcentre(this.p0,this.p1,this.p2)},Vn.prototype.area3D=function(){return Vn.area3D(this.p0,this.p1,this.p2)},Vn.prototype.centroid=function(){return Vn.centroid(this.p0,this.p1,this.p2)},Vn.prototype.inCentre=function(){return Vn.inCentre(this.p0,this.p1,this.p2)},Vn.prototype.interfaces_=function(){return[]},Vn.prototype.getClass=function(){return Vn},Vn.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},Vn.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},Vn.det=function(t,e,n,i){return t*i-e*n},Vn.interpolateZ=function(t,e,n,i){var r=e.x,o=e.y,s=n.x-r,a=i.x-r,u=n.y-o,l=i.y-o,c=s*l-a*u,p=t.x-r,h=t.y-o;return e.z+(l*p-a*h)/c*(n.z-e.z)+(-u*p+s*h)/c*(i.z-e.z)},Vn.longestSideLength=function(t,e,n){var i=t.distance(e),r=e.distance(n),o=n.distance(t),s=i;return r>s&&(s=r),o>s&&(s=o),s},Vn.isAcute=function(t,e,n){return!!Tn.isAcute(t,e,n)&&!!Tn.isAcute(e,n,t)&&!!Tn.isAcute(n,t,e)},Vn.circumcentre=function(t,e,n){var i=n.x,r=n.y,o=t.x-i,s=t.y-r,a=e.x-i,u=e.y-r,l=2*Vn.det(o,s,a,u),c=Vn.det(s,o*o+s*s,u,a*a+u*u),p=Vn.det(o,o*o+s*s,a,a*a+u*u);return new w(i-c/l,r+p/l)},Vn.perpendicularBisector=function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new Y(t.x+n/2,t.y+i/2,1),o=new Y(t.x-i+n/2,t.y+n+i/2,1);return new Y(r,o)},Vn.angleBisector=function(t,e,n){var i=e.distance(t),r=i/(i+e.distance(n));return new w(t.x+r*(n.x-t.x),t.y+r*(n.y-t.y))},Vn.area3D=function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=e.z-t.z,s=n.x-t.x,a=n.y-t.y,u=n.z-t.z,l=r*u-o*a,c=o*s-i*u,p=i*a-r*s;return Math.sqrt(l*l+c*c+p*p)/2},Vn.centroid=function(t,e,n){return new w((t.x+e.x+n.x)/3,(t.y+e.y+n.y)/3)},Vn.inCentre=function(t,e,n){var i=e.distance(n),r=t.distance(n),o=t.distance(e),s=i+r+o;return new w((i*t.x+r*e.x+o*n.x)/s,(i*t.y+r*e.y+o*n.y)/s)};var qn=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new Nt;var t=arguments[1],e=arguments[2];this._inputGeom=arguments[0],this._distance=t,this._curveBuilder=e};qn.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,L.EXTERIOR,L.INTERIOR)},qn.prototype.addPolygon=function(t){var e=this._distance,n=Ce.LEFT;this._distance<0&&(e=-this._distance,n=Ce.RIGHT);var i=t.getExteriorRing(),r=St.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addPolygonRing(r,e,n,L.EXTERIOR,L.INTERIOR);for(var o=0;o<t.getNumInteriorRing();o++){var s=t.getInteriorRingN(o),a=St.removeRepeatedPoints(s.getCoordinates());this._distance>0&&this.isErodedCompletely(s,-this._distance)||this.addPolygonRing(a,e,Ce.opposite(n),L.INTERIOR,L.EXTERIOR)}},qn.prototype.isTriangleErodedCompletely=function(t,e){var n=new Vn(t[0],t[1],t[2]),i=n.inCentre();return at.distancePointLine(i,n.p0,n.p1)<Math.abs(e)},qn.prototype.addLineString=function(t){if(this._distance<=0&&!this._curveBuilder.getBufferParameters().isSingleSided())return null;var e=St.removeRepeatedPoints(t.getCoordinates()),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,L.EXTERIOR,L.INTERIOR)},qn.prototype.addCurve=function(t,e,n){if(null===t||t.length<2)return null;var i=new gn(t,new Re(0,L.BOUNDARY,e,n));this._curveList.add(i)},qn.prototype.getCurves=function(){return this.add(this._inputGeom),this._curveList},qn.prototype.addPolygonRing=function(t,e,n,i,r){if(0===e&&t.length<ee.MINIMUM_VALID_SIZE)return null;var o=i,s=r;t.length>=ee.MINIMUM_VALID_SIZE&&at.isCCW(t)&&(o=r,s=i,n=Ce.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)},qn.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Zt?this.addPolygon(t):t instanceof Jt?this.addLineString(t):t instanceof Qt?this.addPoint(t):(t instanceof te||t instanceof kt||t instanceof ne||t instanceof Ut)&&this.addCollection(t)},qn.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r},qn.prototype.addCollection=function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}},qn.prototype.interfaces_=function(){return[]},qn.prototype.getClass=function(){return qn};var Bn=function(){};Bn.prototype.locate=function(t){},Bn.prototype.interfaces_=function(){return[]},Bn.prototype.getClass=function(){return Bn};var zn=function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()};zn.prototype.next=function(){if(this._atStart)return this._atStart=!1,zn.isAtomic(this._parent)&&this._index++,this._parent;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new i;var t=this._parent.getGeometryN(this._index++);return t instanceof Ut?(this._subcollectionIterator=new zn(t),this._subcollectionIterator.next()):t},zn.prototype.remove=function(){throw new Error(this.getClass().getName())},zn.prototype.hasNext=function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)},zn.prototype.interfaces_=function(){return[xt]},zn.prototype.getClass=function(){return zn},zn.isAtomic=function(t){return!(t instanceof Ut)};var Un=function(){this._geom=null,this._geom=arguments[0]};Un.prototype.locate=function(t){return Un.locate(t,this._geom)},Un.prototype.interfaces_=function(){return[Bn]},Un.prototype.getClass=function(){return Un},Un.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&at.isPointInRing(t,e.getCoordinates())},Un.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Un.isPointInRing(t,n))return!1;for(var i=0;i<e.getNumInteriorRing();i++){var r=e.getInteriorRingN(i);if(Un.isPointInRing(t,r))return!1}return!0},Un.containsPoint=function(t,e){if(e instanceof Zt)return Un.containsPointInPolygon(t,e);if(e instanceof Ut)for(var n=new zn(e);n.hasNext();){var i=n.next();if(i!==e&&Un.containsPoint(t,i))return!0}return!1},Un.locate=function(t,e){return e.isEmpty()?L.EXTERIOR:Un.containsPoint(t,e)?L.INTERIOR:L.EXTERIOR};var kn=function(){this._edgeMap=new p,this._edgeList=null,this._ptInAreaLocation=[L.NONE,L.NONE]};kn.prototype.getNextCW=function(t){this.getEdges();var e=this._edgeList.indexOf(t),n=e-1;return 0===e&&(n=this._edgeList.size()-1),this._edgeList.get(n)},kn.prototype.propagateSideLabels=function(t){for(var e=L.NONE,n=this.iterator();n.hasNext();){var i=n.next().getLabel();i.isArea(t)&&i.getLocation(t,Ce.LEFT)!==L.NONE&&(e=i.getLocation(t,Ce.LEFT))}if(e===L.NONE)return null;for(var r=e,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getLabel();if(a.getLocation(t,Ce.ON)===L.NONE&&a.setLocation(t,Ce.ON,r),a.isArea(t)){var u=a.getLocation(t,Ce.LEFT),l=a.getLocation(t,Ce.RIGHT);if(l!==L.NONE){if(l!==r)throw new Le("side location conflict",s.getCoordinate());u===L.NONE&&et.shouldNeverReachHere("found single null side (at "+s.getCoordinate()+")"),r=u}else et.isTrue(a.getLocation(t,Ce.LEFT)===L.NONE,"found single null side"),a.setLocation(t,Ce.RIGHT,r),a.setLocation(t,Ce.LEFT,r)}}},kn.prototype.getCoordinate=function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null},kn.prototype.print=function(t){X.out.println("EdgeEndStar:   "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)},kn.prototype.isAreaLabelsConsistent=function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)},kn.prototype.checkAreaLabelsConsistent=function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,i=e.get(n).getLabel().getLocation(t,Ce.LEFT);et.isTrue(i!==L.NONE,"Found unlabelled area edge");for(var r=i,o=this.iterator();o.hasNext();){var s=o.next().getLabel();et.isTrue(s.isArea(t),"Found non-area edge");var a=s.getLocation(t,Ce.LEFT),u=s.getLocation(t,Ce.RIGHT);if(a===u)return!1;if(u!==r)return!1;r=a}return!0},kn.prototype.findIndex=function(t){this.iterator();for(var e=0;e<this._edgeList.size();e++)if(this._edgeList.get(e)===t)return e;return-1},kn.prototype.iterator=function(){return this.getEdges().iterator()},kn.prototype.getEdges=function(){return null===this._edgeList&&(this._edgeList=new Nt(this._edgeMap.values())),this._edgeList},kn.prototype.getLocation=function(t,e,n){return this._ptInAreaLocation[t]===L.NONE&&(this._ptInAreaLocation[t]=Un.locate(e,n[t].getGeometry())),this._ptInAreaLocation[t]},kn.prototype.toString=function(){var t=new M;t.append("EdgeEndStar:   "+this.getCoordinate()),t.append("\\n");for(var e=this.iterator();e.hasNext();){var n=e.next();t.append(n),t.append("\\n")}return t.toString()},kn.prototype.computeEdgeEndLabels=function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)},kn.prototype.computeLabelling=function(t){this.computeEdgeEndLabels(t[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var e=[!1,!1],n=this.iterator();n.hasNext();)for(var i=n.next().getLabel(),r=0;r<2;r++)i.isLine(r)&&i.getLocation(r)===L.BOUNDARY&&(e[r]=!0);for(var o=this.iterator();o.hasNext();)for(var s=o.next(),a=s.getLabel(),u=0;u<2;u++)if(a.isAnyNull(u)){var l=L.NONE;if(e[u])l=L.EXTERIOR;else{var c=s.getCoordinate();l=this.getLocation(u,c,t)}a.setAllLocationsIfNull(u,l)}},kn.prototype.getDegree=function(){return this._edgeMap.size()},kn.prototype.insertEdgeEnd=function(t,e){this._edgeMap.put(t,e),this._edgeList=null},kn.prototype.interfaces_=function(){return[]},kn.prototype.getClass=function(){return kn};var Xn=function(t){function e(){t.call(this),this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.linkResultDirectedEdges=function(){this.getResultAreaEdges();for(var t=null,e=null,n=this._SCANNING_FOR_INCOMING,i=0;i<this._resultAreaEdgeList.size();i++){var r=this._resultAreaEdgeList.get(i),o=r.getSym();if(r.getLabel().isArea())switch(null===t&&r.isInResult()&&(t=r),n){case this._SCANNING_FOR_INCOMING:if(!o.isInResult())continue;e=o,n=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!r.isInResult())continue;e.setNext(r),n=this._SCANNING_FOR_INCOMING}}if(n===this._LINKING_TO_OUTGOING){if(null===t)throw new Le("no outgoing dirEdge found",this.getCoordinate());et.isTrue(t.isInResult(),"unable to link last incoming dirEdge"),e.setNext(t)}},e.prototype.insert=function(t){this.insertEdgeEnd(t,t)},e.prototype.getRightmostEdge=function(){var t=this.getEdges(),e=t.size();if(e<1)return null;var n=t.get(0);if(1===e)return n;var i=t.get(e-1),r=n.getQuadrant(),o=i.getQuadrant();return qe.isNorthern(r)&&qe.isNorthern(o)?n:qe.isNorthern(r)||qe.isNorthern(o)?0!==n.getDy()?n:0!==i.getDy()?i:(et.shouldNeverReachHere("found two horizontal edges incident on node"),null):i},e.prototype.print=function(t){X.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();){var n=e.next();t.print("out "),n.print(t),t.println(),t.print("in "),n.getSym().print(t),t.println()}},e.prototype.getResultAreaEdges=function(){if(null!==this._resultAreaEdgeList)return this._resultAreaEdgeList;this._resultAreaEdgeList=new Nt;for(var t=this.iterator();t.hasNext();){var e=t.next();(e.isInResult()||e.getSym().isInResult())&&this._resultAreaEdgeList.add(e)}return this._resultAreaEdgeList},e.prototype.updateLabelling=function(t){for(var e=this.iterator();e.hasNext();){var n=e.next().getLabel();n.setAllLocationsIfNull(0,t.getLocation(0)),n.setAllLocationsIfNull(1,t.getLocation(1))}},e.prototype.linkAllDirectedEdges=function(){this.getEdges();for(var t=null,e=null,n=this._edgeList.size()-1;n>=0;n--){var i=this._edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)},e.prototype.computeDepths=function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(Ce.LEFT),i=t.getDepth(Ce.RIGHT),r=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,r)!==i)throw new Le("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a<o;a++){var u=this._edgeList.get(a);u.setEdgeDepths(Ce.RIGHT,s),s=u.getDepth(Ce.LEFT)}return s}},e.prototype.mergeSymLabels=function(){for(var t=this.iterator();t.hasNext();){var e=t.next();e.getLabel().merge(e.getSym().getLabel())}},e.prototype.linkMinimalDirectedEdges=function(t){for(var e=null,n=null,i=this._SCANNING_FOR_INCOMING,r=this._resultAreaEdgeList.size()-1;r>=0;r--){var o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),i){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(et.isTrue(null!==e,"found null for first outgoing dirEdge"),et.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))},e.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();)e.next().isInResult()&&t++;return t}if(1===arguments.length){for(var n=arguments[0],i=0,r=this.iterator();r.hasNext();)r.next().getEdgeRing()===n&&i++;return i}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var t=L.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=L.INTERIOR;break}if(i.isInResult()){t=L.EXTERIOR;break}}}if(t===L.NONE)return null;for(var r=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===L.INTERIOR):(s.isInResult()&&(r=L.EXTERIOR),a.isInResult()&&(r=L.INTERIOR))}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new Re(L.NONE);for(var n=this.iterator();n.hasNext();)for(var i=n.next().getEdge().getLabel(),r=0;r<2;r++){var o=i.getLocation(r);o!==L.INTERIOR&&o!==L.BOUNDARY||this._label.setLocation(r,L.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(kn),Yn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(t){return new Ge(t,new Xn)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ke),jn=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};jn.prototype.compareTo=function(t){return jn.compareOriented(this._pts,this._orientation,t._pts,t._orientation)},jn.prototype.interfaces_=function(){return[x]},jn.prototype.getClass=function(){return jn},jn.orientation=function(t){return 1===St.increasingDirection(t)},jn.compareOriented=function(t,e,n,i){for(var r=e?1:-1,o=i?1:-1,s=e?t.length:-1,a=i?n.length:-1,u=e?0:t.length-1,l=i?0:n.length-1;;){var c=t[u].compareTo(n[l]);if(0!==c)return c;var p=(u+=r)===s,h=(l+=o)===a;if(p&&!h)return-1;if(!p&&h)return 1;if(p&&h)return 0}};var Hn=function(){this._edges=new Nt,this._ocaMap=new p};Hn.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e<this._edges.size();e++){var n=this._edges.get(e);e>0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r<i.length;r++)r>0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(")  ")},Hn.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Hn.prototype.findEdgeIndex=function(t){for(var e=0;e<this._edges.size();e++)if(this._edges.get(e).equals(t))return e;return-1},Hn.prototype.iterator=function(){return this._edges.iterator()},Hn.prototype.getEdges=function(){return this._edges},Hn.prototype.get=function(t){return this._edges.get(t)},Hn.prototype.findEqualEdge=function(t){var e=new jn(t.getCoordinates());return this._ocaMap.get(e)},Hn.prototype.add=function(t){this._edges.add(t);var e=new jn(t.getCoordinates());this._ocaMap.put(e,t)},Hn.prototype.interfaces_=function(){return[]},Hn.prototype.getClass=function(){return Hn};var Wn=function(){};Wn.prototype.processIntersections=function(t,e,n,i){},Wn.prototype.isDone=function(){},Wn.prototype.interfaces_=function(){return[]},Wn.prototype.getClass=function(){return Wn};var Jn=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0,this._li=arguments[0]};Jn.prototype.isTrivialIntersection=function(t,e,n,i){if(t===n&&1===this._li.getIntersectionNum()){if(Jn.isAdjacentSegments(e,i))return!0;if(t.isClosed()){var r=t.size()-1;if(0===e&&i===r||0===i&&e===r)return!0}}return!1},Jn.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Jn.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Jn.prototype.getLineIntersector=function(){return this._li},Jn.prototype.hasProperIntersection=function(){return this._hasProper},Jn.prototype.processIntersections=function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))},Jn.prototype.hasIntersection=function(){return this._hasIntersection},Jn.prototype.isDone=function(){return!1},Jn.prototype.hasInteriorIntersection=function(){return this._hasInterior},Jn.prototype.interfaces_=function(){return[Wn]},Jn.prototype.getClass=function(){return Jn},Jn.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var Kn=function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[1],e=arguments[2];this.coord=new w(arguments[0]),this.segmentIndex=t,this.dist=e};Kn.prototype.getSegmentIndex=function(){return this.segmentIndex},Kn.prototype.getCoordinate=function(){return this.coord},Kn.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex),t.println(" dist = "+this.dist)},Kn.prototype.compareTo=function(t){return this.compare(t.segmentIndex,t.dist)},Kn.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===t},Kn.prototype.toString=function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist},Kn.prototype.getDistance=function(){return this.dist},Kn.prototype.compare=function(t,e){return this.segmentIndex<t?-1:this.segmentIndex>t?1:this.dist<e?-1:this.dist>e?1:0},Kn.prototype.interfaces_=function(){return[x]},Kn.prototype.getClass=function(){return Kn};var Qn=function(){this._nodeMap=new p,this.edge=null,this.edge=arguments[0]};Qn.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},Qn.prototype.iterator=function(){return this._nodeMap.values().iterator()},Qn.prototype.addSplitEdges=function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}},Qn.prototype.addEndpoints=function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)},Qn.prototype.createSplitEdge=function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=e.dist>0||!e.coord.equals2D(this.edge.pts[e.segmentIndex]);i||n--;var r=new Array(n).fill(null),o=0;r[o++]=new w(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)r[o++]=this.edge.pts[s];return i&&(r[o]=e.coord),new ni(r,new Re(this.edge._label))},Qn.prototype.add=function(t,e,n){var i=new Kn(t,e,n),r=this._nodeMap.get(i);return null!==r?r:(this._nodeMap.put(i,i),i)},Qn.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1},Qn.prototype.interfaces_=function(){return[]},Qn.prototype.getClass=function(){return Qn};var $n=function(){};$n.prototype.getChainStartIndices=function(t){var e=0,n=new Nt;n.add(new D(e));do{var i=this.findChainEnd(t,e);n.add(new D(i)),e=i}while(e<t.length-1);return $n.toIntArray(n)},$n.prototype.findChainEnd=function(t,e){for(var n=qe.quadrant(t[e],t[e+1]),i=e+1;i<t.length&&qe.quadrant(t[i-1],t[i])===n;)i++;return i-1},$n.prototype.interfaces_=function(){return[]},$n.prototype.getClass=function(){return $n},$n.toIntArray=function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e};var Zn=function(){this.e=null,this.pts=null,this.startIndex=null,this.env1=new j,this.env2=new j;var t=arguments[0];this.e=t,this.pts=t.getCoordinates();var e=new $n;this.startIndex=e.getChainStartIndices(this.pts)};Zn.prototype.getCoordinates=function(){return this.pts},Zn.prototype.getMaxX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e>n?e:n},Zn.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e<n?e:n},Zn.prototype.computeIntersectsForChain=function(){if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];this.computeIntersectsForChain(this.startIndex[t],this.startIndex[t+1],e,e.startIndex[n],e.startIndex[n+1],arguments[3])}else if(6===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4],u=arguments[5],l=this.pts[i],c=this.pts[r],p=o.pts[s],h=o.pts[a];if(r-i==1&&a-s==1)return u.addIntersections(this.e,i,o.e,s),null;if(this.env1.init(l,c),this.env2.init(p,h),!this.env1.intersects(this.env2))return null;var f=Math.trunc((i+r)/2),g=Math.trunc((s+a)/2);i<f&&(s<g&&this.computeIntersectsForChain(i,f,o,s,g,u),g<a&&this.computeIntersectsForChain(i,f,o,g,a,u)),f<r&&(s<g&&this.computeIntersectsForChain(f,r,o,s,g,u),g<a&&this.computeIntersectsForChain(f,r,o,g,a,u))}},Zn.prototype.getStartIndexes=function(){return this.startIndex},Zn.prototype.computeIntersects=function(t,e){for(var n=0;n<this.startIndex.length-1;n++)for(var i=0;i<t.startIndex.length-1;i++)this.computeIntersectsForChain(n,t,i,e)},Zn.prototype.interfaces_=function(){return[]},Zn.prototype.getClass=function(){return Zn};var ti=function t(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var e=0;e<2;e++)for(var n=0;n<3;n++)this._depth[e][n]=t.NULL_VALUE},ei={NULL_VALUE:{configurable:!0}};ti.prototype.getDepth=function(t,e){return this._depth[t][e]},ti.prototype.setDepth=function(t,e,n){this._depth[t][e]=n},ti.prototype.isNull=function(){if(0===arguments.length){for(var t=0;t<2;t++)for(var e=0;e<3;e++)if(this._depth[t][e]!==ti.NULL_VALUE)return!1;return!0}return 1===arguments.length?this._depth[arguments[0]][1]===ti.NULL_VALUE:2===arguments.length?this._depth[arguments[0]][arguments[1]]===ti.NULL_VALUE:void 0},ti.prototype.normalize=function(){for(var t=0;t<2;t++)if(!this.isNull(t)){var e=this._depth[t][1];this._depth[t][2]<e&&(e=this._depth[t][2]),e<0&&(e=0);for(var n=1;n<3;n++){var i=0;this._depth[t][n]>e&&(i=1),this._depth[t][n]=i}}},ti.prototype.getDelta=function(t){return this._depth[t][Ce.RIGHT]-this._depth[t][Ce.LEFT]},ti.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?L.EXTERIOR:L.INTERIOR},ti.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},ti.prototype.add=function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<2;e++)for(var n=1;n<3;n++){var i=t.getLocation(e,n);i!==L.EXTERIOR&&i!==L.INTERIOR||(this.isNull(e,n)?this._depth[e][n]=ti.depthAtLocation(i):this._depth[e][n]+=ti.depthAtLocation(i))}else 3===arguments.length&&arguments[2]===L.INTERIOR&&this._depth[arguments[0]][arguments[1]]++},ti.prototype.interfaces_=function(){return[]},ti.prototype.getClass=function(){return ti},ti.depthAtLocation=function(t){return t===L.EXTERIOR?0:t===L.INTERIOR?1:ti.NULL_VALUE},ei.NULL_VALUE.get=function(){return-1},Object.defineProperties(ti,ei);var ni=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Qn(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new ti,this._depthDelta=0,1===arguments.length)e.call(this,arguments[0],null);else if(2===arguments.length){var n=arguments[1];this.pts=arguments[0],this._label=n}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getDepth=function(){return this._depth},e.prototype.getCollapsedEdge=function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new e(t,Re.toLineLabel(this._label))},e.prototype.isIsolated=function(){return this._isIsolated},e.prototype.getCoordinates=function(){return this.pts},e.prototype.setIsolated=function(t){this._isIsolated=t},e.prototype.setName=function(t){this._name=t},e.prototype.equals=function(t){if(!(t instanceof e))return!1;var n=t;if(this.pts.length!==n.pts.length)return!1;for(var i=!0,r=!0,o=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(n.pts[s])||(i=!1),this.pts[s].equals2D(n.pts[--o])||(r=!1),!i&&!r)return!1;return!0},e.prototype.getCoordinate=function(){return 0===arguments.length?this.pts.length>0?this.pts[0]:null:1===arguments.length?this.pts[arguments[0]]:void 0},e.prototype.print=function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(")  "+this._label+" "+this._depthDelta)},e.prototype.computeIM=function(t){e.updateIM(this._label,t)},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},e.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])},e.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1},e.prototype.getDepthDelta=function(){return this._depthDelta},e.prototype.getNumPoints=function(){return this.pts.length},e.prototype.printReverse=function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},e.prototype.getMonotoneChainEdge=function(){return null===this._mce&&(this._mce=new Zn(this)),this._mce},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new j;for(var t=0;t<this.pts.length;t++)this._env.expandToInclude(this.pts[t])}return this._env},e.prototype.addIntersection=function(t,e,n,i){var r=new w(t.getIntersection(i)),o=e,s=t.getEdgeDistance(n,i),a=o+1;a<this.pts.length&&r.equals2D(this.pts[a])&&(o=a,s=0),this.eiList.add(r,o,s)},e.prototype.toString=function(){var t=new M;t.append("edge "+this._name+": "),t.append("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(")  "+this._label+" "+this._depthDelta),t.toString()},e.prototype.isPointwiseEqual=function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e<this.pts.length;e++)if(!this.pts[e].equals2D(t.pts[e]))return!1;return!0},e.prototype.setDepthDelta=function(t){this._depthDelta=t},e.prototype.getEdgeIntersectionList=function(){return this.eiList},e.prototype.addIntersections=function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++)this.addIntersection(t,e,n,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.updateIM=function(){if(2!==arguments.length)return t.prototype.updateIM.apply(this,arguments);var e=arguments[0],n=arguments[1];n.setAtLeastIfValid(e.getLocation(0,Ce.ON),e.getLocation(1,Ce.ON),1),e.isArea()&&(n.setAtLeastIfValid(e.getLocation(0,Ce.LEFT),e.getLocation(1,Ce.LEFT),2),n.setAtLeastIfValid(e.getLocation(0,Ce.RIGHT),e.getLocation(1,Ce.RIGHT),2))},e}(Fe),ii=function(t){this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Hn,this._bufParams=t||null};ii.prototype.setWorkingPrecisionModel=function(t){this._workingPrecisionModel=t},ii.prototype.insertUniqueEdge=function(t){var e=this._edgeList.findEqualEdge(t);if(null!==e){var n=e.getLabel(),i=t.getLabel();e.isPointwiseEqual(t)||(i=new Re(t.getLabel())).flip(),n.merge(i);var r=ii.depthDelta(i),o=e.getDepthDelta()+r;e.setDepthDelta(o)}else this._edgeList.add(t),t.setDepthDelta(ii.depthDelta(t.getLabel()))},ii.prototype.buildSubgraphs=function(t,e){for(var n=new Nt,i=t.iterator();i.hasNext();){var r=i.next(),o=r.getRightmostCoordinate(),s=new An(n).getDepth(o);r.computeDepth(s),r.findResultEdges(),n.add(r),e.add(r.getDirectedEdges(),r.getNodes())}},ii.prototype.createSubgraphs=function(t){for(var e=new Nt,n=t.getNodes().iterator();n.hasNext();){var i=n.next();if(!i.isVisited()){var r=new Te;r.create(i),e.add(r)}}return Ze.sort(e,Ze.reverseOrder()),e},ii.prototype.createEmptyResultGeometry=function(){return this._geomFact.createPolygon()},ii.prototype.getNoder=function(t){if(null!==this._workingNoder)return this._workingNoder;var e=new En,n=new rt;return n.setPrecisionModel(t),e.setSegmentIntersector(new Jn(n)),e},ii.prototype.buffer=function(t,e){var n=this._workingPrecisionModel;null===n&&(n=t.getPrecisionModel()),this._geomFact=t.getFactory();var i=new Dn(n,this._bufParams),r=new qn(t,e,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this._graph=new Xe(new Yn),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),s=new Ye(this._geomFact);this.buildSubgraphs(o,s);var a=s.getPolygons();return a.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(a)},ii.prototype.computeNodedEdges=function(t,e){var n=this.getNoder(e);n.computeNodes(t);for(var i=n.getNodedSubstrings().iterator();i.hasNext();){var r=i.next(),o=r.getCoordinates();if(2!==o.length||!o[0].equals2D(o[1])){var s=r.getData(),a=new ni(r.getCoordinates(),new Re(s));this.insertUniqueEdge(a)}}},ii.prototype.setNoder=function(t){this._workingNoder=t},ii.prototype.interfaces_=function(){return[]},ii.prototype.getClass=function(){return ii},ii.depthDelta=function(t){var e=t.getLocation(0,Ce.LEFT),n=t.getLocation(0,Ce.RIGHT);return e===L.INTERIOR&&n===L.EXTERIOR?1:e===L.EXTERIOR&&n===L.INTERIOR?-1:0},ii.convertSegStrings=function(t){for(var e=new _e,n=new Nt;t.hasNext();){var i=t.next(),r=e.createLineString(i.getCoordinates());n.add(r)}return e.buildGeometry(n)};var ri=function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){var t=arguments[1];this._noder=arguments[0],this._scaleFactor=t,this._offsetX=0,this._offsetY=0,this._isScaled=!this.isIntegerPrecision()}else if(4===arguments.length){var e=arguments[1],n=arguments[2],i=arguments[3];this._noder=arguments[0],this._scaleFactor=e,this._offsetX=n,this._offsetY=i,this._isScaled=!this.isIntegerPrecision()}};ri.prototype.rescale=function(){if(T(arguments[0],It))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.rescale(e.getCoordinates())}else if(arguments[0]instanceof Array){for(var n=arguments[0],i=0;i<n.length;i++)n[i].x=n[i].x/this._scaleFactor+this._offsetX,n[i].y=n[i].y/this._scaleFactor+this._offsetY;2===n.length&&n[0].equals2D(n[1])&&X.out.println(n)}},ri.prototype.scale=function(){if(T(arguments[0],It)){for(var t=arguments[0],e=new Nt,n=t.iterator();n.hasNext();){var i=n.next();e.add(new gn(this.scale(i.getCoordinates()),i.getData()))}return e}if(arguments[0]instanceof Array){for(var r=arguments[0],o=new Array(r.length).fill(null),s=0;s<r.length;s++)o[s]=new w(Math.round((r[s].x-this._offsetX)*this._scaleFactor),Math.round((r[s].y-this._offsetY)*this._scaleFactor),r[s].z);return St.removeRepeatedPoints(o)}},ri.prototype.isIntegerPrecision=function(){return 1===this._scaleFactor},ri.prototype.getNodedSubstrings=function(){var t=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(t),t},ri.prototype.computeNodes=function(t){var e=t;this._isScaled&&(e=this.scale(t)),this._noder.computeNodes(e)},ri.prototype.interfaces_=function(){return[In]},ri.prototype.getClass=function(){return ri};var oi=function(){this._li=new rt,this._segStrings=null,this._segStrings=arguments[0]},si={fact:{configurable:!0}};oi.prototype.checkEndPtVertexIntersections=function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next().getCoordinates();this.checkEndPtVertexIntersections(e[0],this._segStrings),this.checkEndPtVertexIntersections(e[e.length-1],this._segStrings)}else if(2===arguments.length)for(var n=arguments[0],i=arguments[1].iterator();i.hasNext();)for(var r=i.next().getCoordinates(),o=1;o<r.length-1;o++)if(r[o].equals(n))throw new Z("found endpt/interior pt intersection at index "+o+" :pt "+n)},oi.prototype.checkInteriorIntersections=function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();)for(var e=t.next(),n=this._segStrings.iterator();n.hasNext();){var i=n.next();this.checkInteriorIntersections(e,i)}else if(2===arguments.length)for(var r=arguments[0],o=arguments[1],s=r.getCoordinates(),a=o.getCoordinates(),u=0;u<s.length-1;u++)for(var l=0;l<a.length-1;l++)this.checkInteriorIntersections(r,u,o,l);else if(4===arguments.length){var c=arguments[0],p=arguments[1],h=arguments[2],f=arguments[3];if(c===h&&p===f)return null;var g=c.getCoordinates()[p],d=c.getCoordinates()[p+1],y=h.getCoordinates()[f],_=h.getCoordinates()[f+1];if(this._li.computeIntersection(g,d,y,_),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,g,d)||this.hasInteriorIntersection(this._li,y,_)))throw new Z("found non-noded intersection at "+g+"-"+d+" and "+y+"-"+_)}},oi.prototype.checkValid=function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()},oi.prototype.checkCollapses=function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next();this.checkCollapses(e)}else if(1===arguments.length)for(var n=arguments[0].getCoordinates(),i=0;i<n.length-2;i++)this.checkCollapse(n[i],n[i+1],n[i+2])},oi.prototype.hasInteriorIntersection=function(t,e,n){for(var i=0;i<t.getIntersectionNum();i++){var r=t.getIntersection(i);if(!r.equals(e)&&!r.equals(n))return!0}return!1},oi.prototype.checkCollapse=function(t,e,n){if(t.equals(n))throw new Z("found non-noded collapse at "+oi.fact.createLineString([t,e,n]))},oi.prototype.interfaces_=function(){return[]},oi.prototype.getClass=function(){return oi},si.fact.get=function(){return new _e},Object.defineProperties(oi,si);var ai=function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new m("Scale factor must be non-zero");1!==e&&(this._pt=new w(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new w,this._p1Scaled=new w),this.initCorners(this._pt)},ui={SAFE_ENV_EXPANSION_FACTOR:{configurable:!0}};ai.prototype.intersectsScaled=function(t,e){var n=Math.min(t.x,e.x),i=Math.max(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.y,e.y),s=this._maxx<n||this._minx>i||this._maxy<r||this._miny>o;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return et.isTrue(!(s&&a),"Found bad envelope test"),a},ai.prototype.initCorners=function(t){this._minx=t.x-.5,this._maxx=t.x+.5,this._miny=t.y-.5,this._maxy=t.y+.5,this._corner[0]=new w(this._maxx,this._maxy),this._corner[1]=new w(this._minx,this._maxy),this._corner[2]=new w(this._minx,this._miny),this._corner[3]=new w(this._maxx,this._miny)},ai.prototype.intersects=function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))},ai.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},ai.prototype.getCoordinate=function(){return this._originalPt},ai.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},ai.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=ai.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new j(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},ai.prototype.intersectsPixelClosure=function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))},ai.prototype.intersectsToleranceSquare=function(t,e){var n=!1,i=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&i||t.equals(this._pt)||e.equals(this._pt)))))},ai.prototype.addSnappedNode=function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!0)},ai.prototype.interfaces_=function(){return[]},ai.prototype.getClass=function(){return ai},ui.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(ai,ui);var li=function(){this.tempEnv1=new j,this.selectedSegment=new dn};li.prototype.select=function(){1===arguments.length||2===arguments.length&&(arguments[0].getLineSegment(arguments[1],this.selectedSegment),this.select(this.selectedSegment))},li.prototype.interfaces_=function(){return[]},li.prototype.getClass=function(){return li};var ci=function(){this._index=null,this._index=arguments[0]},pi={HotPixelSnapAction:{configurable:!0}};ci.prototype.snap=function(){if(1===arguments.length)return this.snap(arguments[0],null,-1);if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=t.getSafeEnvelope(),r=new hi(t,e,n);return this._index.query(i,{interfaces_:function(){return[Je]},visitItem:function(t){t.select(i,r)}}),r.isNodeAdded()}},ci.prototype.interfaces_=function(){return[]},ci.prototype.getClass=function(){return ci},pi.HotPixelSnapAction.get=function(){return hi},Object.defineProperties(ci,pi);var hi=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[1],n=arguments[2];this._hotPixel=arguments[0],this._parentEdge=e,this._hotPixelVertexIndex=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isNodeAdded=function(){return this._isNodeAdded},e.prototype.select=function(){if(2!==arguments.length)return t.prototype.select.apply(this,arguments);var e=arguments[1],n=arguments[0].getContext();if(null!==this._parentEdge&&n===this._parentEdge&&e===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(n,e)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(li),fi=function(){this._li=null,this._interiorIntersections=null,this._li=arguments[0],this._interiorIntersections=new Nt};fi.prototype.processIntersections=function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u<this._li.getIntersectionNum();u++)this._interiorIntersections.add(this._li.getIntersection(u));t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1)}},fi.prototype.isDone=function(){return!1},fi.prototype.getInteriorIntersections=function(){return this._interiorIntersections},fi.prototype.interfaces_=function(){return[Wn]},fi.prototype.getClass=function(){return fi};var gi=function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var t=arguments[0];this._pm=t,this._li=new rt,this._li.setPrecisionModel(t),this._scaleFactor=t.getScale()};gi.prototype.checkCorrectness=function(t){var e=gn.getNodedSubstrings(t),n=new oi(e);try{n.checkValid()}catch(t){if(!(t instanceof U))throw t;t.printStackTrace()}},gi.prototype.getNodedSubstrings=function(){return gn.getNodedSubstrings(this._nodedSegStrings)},gi.prototype.snapRound=function(t,e){var n=this.findInteriorIntersections(t,e);this.computeIntersectionSnaps(n),this.computeVertexSnaps(t)},gi.prototype.findInteriorIntersections=function(t,e){var n=new fi(e);return this._noder.setSegmentIntersector(n),this._noder.computeNodes(t),n.getInteriorIntersections()},gi.prototype.computeVertexSnaps=function(){if(T(arguments[0],It))for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.computeVertexSnaps(e)}else if(arguments[0]instanceof gn)for(var n=arguments[0],i=n.getCoordinates(),r=0;r<i.length;r++){var o=new ai(i[r],this._scaleFactor,this._li);this._pointSnapper.snap(o,n,r)&&n.addIntersection(i[r],r)}},gi.prototype.computeNodes=function(t){this._nodedSegStrings=t,this._noder=new En,this._pointSnapper=new ci(this._noder.getIndex()),this.snapRound(t,this._li)},gi.prototype.computeIntersectionSnaps=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=new ai(n,this._scaleFactor,this._li);this._pointSnapper.snap(i)}},gi.prototype.interfaces_=function(){return[In]},gi.prototype.getClass=function(){return gi};var di=function(){if(this._argGeom=null,this._distance=null,this._bufParams=new wn,this._resultGeometry=null,this._saveException=null,1===arguments.length)this._argGeom=arguments[0];else if(2===arguments.length){var t=arguments[1];this._argGeom=arguments[0],this._bufParams=t}},yi={CAP_ROUND:{configurable:!0},CAP_BUTT:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},MAX_PRECISION_DIGITS:{configurable:!0}};di.prototype.bufferFixedPrecision=function(t){var e=new ri(new gi(new fe(1)),t.getScale()),n=new ii(this._bufParams);n.setWorkingPrecisionModel(t),n.setNoder(e),this._resultGeometry=n.buffer(this._argGeom,this._distance)},di.prototype.bufferReducedPrecision=function(){var t=this;if(0===arguments.length){for(var e=di.MAX_PRECISION_DIGITS;e>=0;e--){try{t.bufferReducedPrecision(e)}catch(e){if(!(e instanceof Le))throw e;t._saveException=e}if(null!==t._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=di.precisionScaleFactor(this._argGeom,this._distance,arguments[0]),i=new fe(n);this.bufferFixedPrecision(i)}},di.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===fe.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},di.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},di.prototype.bufferOriginalPrecision=function(){try{var t=new ii(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof Z))throw t;this._saveException=t}},di.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},di.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},di.prototype.interfaces_=function(){return[]},di.prototype.getClass=function(){return di},di.bufferOp=function(){if(2===arguments.length){var t=arguments[1];return new di(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof ct&&"number"==typeof arguments[1]){var e=arguments[1],n=arguments[2],i=new di(arguments[0]);return i.setQuadrantSegments(n),i.getResultGeometry(e)}if(arguments[2]instanceof wn&&arguments[0]instanceof ct&&"number"==typeof arguments[1]){var r=arguments[1];return new di(arguments[0],arguments[2]).getResultGeometry(r)}}else if(4===arguments.length){var o=arguments[1],s=arguments[2],a=arguments[3],u=new di(arguments[0]);return u.setQuadrantSegments(s),u.setEndCapStyle(a),u.getResultGeometry(o)}},di.precisionScaleFactor=function(t,e,n){var i=t.getEnvelopeInternal(),r=P.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)},yi.CAP_ROUND.get=function(){return wn.CAP_ROUND},yi.CAP_BUTT.get=function(){return wn.CAP_FLAT},yi.CAP_FLAT.get=function(){return wn.CAP_FLAT},yi.CAP_SQUARE.get=function(){return wn.CAP_SQUARE},yi.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(di,yi);var _i=function(){this._pt=[new w,new w],this._distance=v.NaN,this._isNull=!0};_i.prototype.getCoordinates=function(){return this._pt},_i.prototype.getCoordinate=function(t){return this._pt[t]},_i.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var i=e.distance(n);i<this._distance&&this.initialize(e,n,i)}},_i.prototype.initialize=function(){if(0===arguments.length)this._isNull=!0;else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._pt[0].setCoordinate(t),this._pt[1].setCoordinate(e),this._distance=t.distance(e),this._isNull=!1}else if(3===arguments.length){var n=arguments[1],i=arguments[2];this._pt[0].setCoordinate(arguments[0]),this._pt[1].setCoordinate(n),this._distance=i,this._isNull=!1}},_i.prototype.getDistance=function(){return this._distance},_i.prototype.setMaximum=function(){if(1===arguments.length){var t=arguments[0];this.setMaximum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var i=e.distance(n);i>this._distance&&this.initialize(e,n,i)}},_i.prototype.interfaces_=function(){return[]},_i.prototype.getClass=function(){return _i};var mi=function(){};mi.prototype.interfaces_=function(){return[]},mi.prototype.getClass=function(){return mi},mi.computeDistance=function(){if(arguments[2]instanceof _i&&arguments[0]instanceof Jt&&arguments[1]instanceof w)for(var t=arguments[1],e=arguments[2],n=arguments[0].getCoordinates(),i=new dn,r=0;r<n.length-1;r++){i.setCoordinates(n[r],n[r+1]);var o=i.closestPoint(t);e.setMinimum(o,t)}else if(arguments[2]instanceof _i&&arguments[0]instanceof Zt&&arguments[1]instanceof w){var s=arguments[0],a=arguments[1],u=arguments[2];mi.computeDistance(s.getExteriorRing(),a,u);for(var l=0;l<s.getNumInteriorRing();l++)mi.computeDistance(s.getInteriorRingN(l),a,u)}else if(arguments[2]instanceof _i&&arguments[0]instanceof ct&&arguments[1]instanceof w){var c=arguments[0],p=arguments[1],h=arguments[2];if(c instanceof Jt)mi.computeDistance(c,p,h);else if(c instanceof Zt)mi.computeDistance(c,p,h);else if(c instanceof Ut)for(var f=c,g=0;g<f.getNumGeometries();g++){var d=f.getGeometryN(g);mi.computeDistance(d,p,h)}else h.setMinimum(c.getCoordinate(),p)}else if(arguments[2]instanceof _i&&arguments[0]instanceof dn&&arguments[1]instanceof w){var y=arguments[1],_=arguments[2],m=arguments[0].closestPoint(y);_.setMinimum(m,y)}};var vi=function(t){this._maxPtDist=new _i,this._inputGeom=t||null},Ii={MaxPointDistanceFilter:{configurable:!0},MaxMidpointDistanceFilter:{configurable:!0}};vi.prototype.computeMaxMidpointDistance=function(t){var e=new Ei(this._inputGeom);t.apply(e),this._maxPtDist.setMaximum(e.getMaxPointDistance())},vi.prototype.computeMaxVertexDistance=function(t){var e=new xi(this._inputGeom);t.apply(e),this._maxPtDist.setMaximum(e.getMaxPointDistance())},vi.prototype.findDistance=function(t){return this.computeMaxVertexDistance(t),this.computeMaxMidpointDistance(t),this._maxPtDist.getDistance()},vi.prototype.getDistancePoints=function(){return this._maxPtDist},vi.prototype.interfaces_=function(){return[]},vi.prototype.getClass=function(){return vi},Ii.MaxPointDistanceFilter.get=function(){return xi},Ii.MaxMidpointDistanceFilter.get=function(){return Ei},Object.defineProperties(vi,Ii);var xi=function(t){this._maxPtDist=new _i,this._minPtDist=new _i,this._geom=t||null};xi.prototype.filter=function(t){this._minPtDist.initialize(),mi.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},xi.prototype.getMaxPointDistance=function(){return this._maxPtDist},xi.prototype.interfaces_=function(){return[ft]},xi.prototype.getClass=function(){return xi};var Ei=function(t){this._maxPtDist=new _i,this._minPtDist=new _i,this._geom=t||null};Ei.prototype.filter=function(t,e){if(0===e)return null;var n=t.getCoordinate(e-1),i=t.getCoordinate(e),r=new w((n.x+i.x)/2,(n.y+i.y)/2);this._minPtDist.initialize(),mi.computeDistance(this._geom,r,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},Ei.prototype.isDone=function(){return!1},Ei.prototype.isGeometryChanged=function(){return!1},Ei.prototype.getMaxPointDistance=function(){return this._maxPtDist},Ei.prototype.interfaces_=function(){return[zt]},Ei.prototype.getClass=function(){return Ei};var Ni=function(t){this._comps=t||null};Ni.prototype.filter=function(t){t instanceof Zt&&this._comps.add(t)},Ni.prototype.interfaces_=function(){return[Bt]},Ni.prototype.getClass=function(){return Ni},Ni.getPolygons=function(){if(1===arguments.length)return Ni.getPolygons(arguments[0],new Nt);if(2===arguments.length){var t=arguments[0],e=arguments[1];return t instanceof Zt?e.add(t):t instanceof Ut&&t.apply(new Ni(e)),e}};var wi=function(){if(this._lines=null,this._isForcedToLineString=!1,1===arguments.length)this._lines=arguments[0];else if(2===arguments.length){var t=arguments[1];this._lines=arguments[0],this._isForcedToLineString=t}};wi.prototype.filter=function(t){if(this._isForcedToLineString&&t instanceof ee){var e=t.getFactory().createLineString(t.getCoordinateSequence());return this._lines.add(e),null}t instanceof Jt&&this._lines.add(t)},wi.prototype.setForceToLineString=function(t){this._isForcedToLineString=t},wi.prototype.interfaces_=function(){return[lt]},wi.prototype.getClass=function(){return wi},wi.getGeometry=function(){if(1===arguments.length){var t=arguments[0];return t.getFactory().buildGeometry(wi.getLines(t))}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e.getFactory().buildGeometry(wi.getLines(e,n))}},wi.getLines=function(){if(1===arguments.length)return wi.getLines(arguments[0],!1);if(2===arguments.length){if(T(arguments[0],It)&&T(arguments[1],It)){for(var t=arguments[1],e=arguments[0].iterator();e.hasNext();){var n=e.next();wi.getLines(n,t)}return t}if(arguments[0]instanceof ct&&"boolean"==typeof arguments[1]){var i=arguments[0],r=arguments[1],o=new Nt;return i.apply(new wi(o,r)),o}if(arguments[0]instanceof ct&&T(arguments[1],It)){var s=arguments[0],a=arguments[1];return s instanceof Jt?a.add(s):s.apply(new wi(a)),a}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&T(arguments[0],It)&&T(arguments[1],It)){for(var u=arguments[1],l=arguments[2],c=arguments[0].iterator();c.hasNext();){var p=c.next();wi.getLines(p,u,l)}return u}if("boolean"==typeof arguments[2]&&arguments[0]instanceof ct&&T(arguments[1],It)){var h=arguments[1];return arguments[0].apply(new wi(h,arguments[2])),h}}};var Ci=function(){if(this._boundaryRule=gt.OGC_SFS_BOUNDARY_RULE,this._isIn=null,this._numBoundaries=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];if(null===t)throw new m("Rule must be non-null");this._boundaryRule=t}};Ci.prototype.locateInternal=function(){if(arguments[0]instanceof w&&arguments[1]instanceof Zt){var t=arguments[0],e=arguments[1];if(e.isEmpty())return L.EXTERIOR;var n=e.getExteriorRing(),i=this.locateInPolygonRing(t,n);if(i===L.EXTERIOR)return L.EXTERIOR;if(i===L.BOUNDARY)return L.BOUNDARY;for(var r=0;r<e.getNumInteriorRing();r++){var o=e.getInteriorRingN(r),s=this.locateInPolygonRing(t,o);if(s===L.INTERIOR)return L.EXTERIOR;if(s===L.BOUNDARY)return L.BOUNDARY}return L.INTERIOR}if(arguments[0]instanceof w&&arguments[1]instanceof Jt){var a=arguments[0],u=arguments[1];if(!u.getEnvelopeInternal().intersects(a))return L.EXTERIOR;var l=u.getCoordinates();return u.isClosed()||!a.equals(l[0])&&!a.equals(l[l.length-1])?at.isOnLine(a,l)?L.INTERIOR:L.EXTERIOR:L.BOUNDARY}if(arguments[0]instanceof w&&arguments[1]instanceof Qt){var c=arguments[0];return arguments[1].getCoordinate().equals2D(c)?L.INTERIOR:L.EXTERIOR}},Ci.prototype.locateInPolygonRing=function(t,e){return e.getEnvelopeInternal().intersects(t)?at.locatePointInRing(t,e.getCoordinates()):L.EXTERIOR},Ci.prototype.intersects=function(t,e){return this.locate(t,e)!==L.EXTERIOR},Ci.prototype.updateLocationInfo=function(t){t===L.INTERIOR&&(this._isIn=!0),t===L.BOUNDARY&&this._numBoundaries++},Ci.prototype.computeLocation=function(t,e){if(e instanceof Qt&&this.updateLocationInfo(this.locateInternal(t,e)),e instanceof Jt)this.updateLocationInfo(this.locateInternal(t,e));else if(e instanceof Zt)this.updateLocationInfo(this.locateInternal(t,e));else if(e instanceof kt)for(var n=e,i=0;i<n.getNumGeometries();i++){var r=n.getGeometryN(i);this.updateLocationInfo(this.locateInternal(t,r))}else if(e instanceof ne)for(var o=e,s=0;s<o.getNumGeometries();s++){var a=o.getGeometryN(s);this.updateLocationInfo(this.locateInternal(t,a))}else if(e instanceof Ut)for(var u=new zn(e);u.hasNext();){var l=u.next();l!==e&&this.computeLocation(t,l)}},Ci.prototype.locate=function(t,e){return e.isEmpty()?L.EXTERIOR:e instanceof Jt||e instanceof Zt?this.locateInternal(t,e):(this._isIn=!1,this._numBoundaries=0,this.computeLocation(t,e),this._boundaryRule.isInBoundary(this._numBoundaries)?L.BOUNDARY:this._numBoundaries>0||this._isIn?L.INTERIOR:L.EXTERIOR)},Ci.prototype.interfaces_=function(){return[]},Ci.prototype.getClass=function(){return Ci};var Si=function t(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length)t.call(this,arguments[0],t.INSIDE_AREA,arguments[1]);else if(3===arguments.length){var e=arguments[1],n=arguments[2];this._component=arguments[0],this._segIndex=e,this._pt=n}},bi={INSIDE_AREA:{configurable:!0}};Si.prototype.isInsideArea=function(){return this._segIndex===Si.INSIDE_AREA},Si.prototype.getCoordinate=function(){return this._pt},Si.prototype.getGeometryComponent=function(){return this._component},Si.prototype.getSegmentIndex=function(){return this._segIndex},Si.prototype.interfaces_=function(){return[]},Si.prototype.getClass=function(){return Si},bi.INSIDE_AREA.get=function(){return-1},Object.defineProperties(Si,bi);var Li=function(t){this._pts=t||null};Li.prototype.filter=function(t){t instanceof Qt&&this._pts.add(t)},Li.prototype.interfaces_=function(){return[Bt]},Li.prototype.getClass=function(){return Li},Li.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof Qt?Ze.singletonList(t):Li.getPoints(t,new Nt)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Qt?n.add(e):e instanceof Ut&&e.apply(new Li(n)),n}};var Oi=function(){this._locations=null,this._locations=arguments[0]};Oi.prototype.filter=function(t){(t instanceof Qt||t instanceof Jt||t instanceof Zt)&&this._locations.add(new Si(t,0,t.getCoordinate()))},Oi.prototype.interfaces_=function(){return[Bt]},Oi.prototype.getClass=function(){return Oi},Oi.getLocations=function(t){var e=new Nt;return t.apply(new Oi(e)),e};var Ti=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new Ci,this._minDistanceLocation=null,this._minDistance=v.MAX_VALUE,2===arguments.length)this._geom=[arguments[0],arguments[1]],this._terminateDistance=0;else if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e,this._terminateDistance=n}};Ti.prototype.computeContainmentDistance=function(){if(0===arguments.length){var t=new Array(2).fill(null);if(this.computeContainmentDistance(0,t),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=1-e,r=Ni.getPolygons(this._geom[e]);if(r.size()>0){var o=Oi.getLocations(this._geom[i]);if(this.computeContainmentDistance(o,r,n),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[i]=n[0],this._minDistanceLocation[e]=n[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&T(arguments[0],Et)&&T(arguments[1],Et)){for(var s=arguments[0],a=arguments[1],u=arguments[2],l=0;l<s.size();l++)for(var c=s.get(l),p=0;p<a.size();p++)if(this.computeContainmentDistance(c,a.get(p),u),this._minDistance<=this._terminateDistance)return null}else if(arguments[2]instanceof Array&&arguments[0]instanceof Si&&arguments[1]instanceof Zt){var h=arguments[0],f=arguments[1],g=arguments[2],d=h.getCoordinate();if(L.EXTERIOR!==this._ptLocator.locate(d,f))return this._minDistance=0,g[0]=h,g[1]=new Si(f,d),null}},Ti.prototype.computeMinDistanceLinesPoints=function(t,e,n){for(var i=0;i<t.size();i++)for(var r=t.get(i),o=0;o<e.size();o++){var s=e.get(o);if(this.computeMinDistance(r,s,n),this._minDistance<=this._terminateDistance)return null}},Ti.prototype.computeFacetDistance=function(){var t=new Array(2).fill(null),e=wi.getLines(this._geom[0]),n=wi.getLines(this._geom[1]),i=Li.getPoints(this._geom[0]),r=Li.getPoints(this._geom[1]);return this.computeMinDistanceLines(e,n,t),this.updateMinDistance(t,!1),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistanceLinesPoints(e,r,t),this.updateMinDistance(t,!1),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistanceLinesPoints(n,i,t),this.updateMinDistance(t,!0),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistancePoints(i,r,t),void this.updateMinDistance(t,!1))))},Ti.prototype.nearestLocations=function(){return this.computeMinDistance(),this._minDistanceLocation},Ti.prototype.updateMinDistance=function(t,e){if(null===t[0])return null;e?(this._minDistanceLocation[0]=t[1],this._minDistanceLocation[1]=t[0]):(this._minDistanceLocation[0]=t[0],this._minDistanceLocation[1]=t[1])},Ti.prototype.nearestPoints=function(){return this.computeMinDistance(),[this._minDistanceLocation[0].getCoordinate(),this._minDistanceLocation[1].getCoordinate()]},Ti.prototype.computeMinDistance=function(){if(0===arguments.length){if(null!==this._minDistanceLocation)return null;if(this._minDistanceLocation=new Array(2).fill(null),this.computeContainmentDistance(),this._minDistance<=this._terminateDistance)return null;this.computeFacetDistance()}else if(3===arguments.length)if(arguments[2]instanceof Array&&arguments[0]instanceof Jt&&arguments[1]instanceof Qt){var t=arguments[0],e=arguments[1],n=arguments[2];if(t.getEnvelopeInternal().distance(e.getEnvelopeInternal())>this._minDistance)return null;for(var i=t.getCoordinates(),r=e.getCoordinate(),o=0;o<i.length-1;o++){var s=at.distancePointLine(r,i[o],i[o+1]);if(s<this._minDistance){this._minDistance=s;var a=new dn(i[o],i[o+1]).closestPoint(r);n[0]=new Si(t,o,a),n[1]=new Si(e,0,r)}if(this._minDistance<=this._terminateDistance)return null}}else if(arguments[2]instanceof Array&&arguments[0]instanceof Jt&&arguments[1]instanceof Jt){var u=arguments[0],l=arguments[1],c=arguments[2];if(u.getEnvelopeInternal().distance(l.getEnvelopeInternal())>this._minDistance)return null;for(var p=u.getCoordinates(),h=l.getCoordinates(),f=0;f<p.length-1;f++)for(var g=0;g<h.length-1;g++){var d=at.distanceLineLine(p[f],p[f+1],h[g],h[g+1]);if(d<this._minDistance){this._minDistance=d;var y=new dn(p[f],p[f+1]),_=new dn(h[g],h[g+1]),m=y.closestPoints(_);c[0]=new Si(u,f,m[0]),c[1]=new Si(l,g,m[1])}if(this._minDistance<=this._terminateDistance)return null}}},Ti.prototype.computeMinDistancePoints=function(t,e,n){for(var i=0;i<t.size();i++)for(var r=t.get(i),o=0;o<e.size();o++){var s=e.get(o),a=r.getCoordinate().distance(s.getCoordinate());if(a<this._minDistance&&(this._minDistance=a,n[0]=new Si(r,0,r.getCoordinate()),n[1]=new Si(s,0,s.getCoordinate())),this._minDistance<=this._terminateDistance)return null}},Ti.prototype.distance=function(){if(null===this._geom[0]||null===this._geom[1])throw new m("null geometries are not supported");return this._geom[0].isEmpty()||this._geom[1].isEmpty()?0:(this.computeMinDistance(),this._minDistance)},Ti.prototype.computeMinDistanceLines=function(t,e,n){for(var i=0;i<t.size();i++)for(var r=t.get(i),o=0;o<e.size();o++){var s=e.get(o);if(this.computeMinDistance(r,s,n),this._minDistance<=this._terminateDistance)return null}},Ti.prototype.interfaces_=function(){return[]},Ti.prototype.getClass=function(){return Ti},Ti.distance=function(t,e){return new Ti(t,e).distance()},Ti.isWithinDistance=function(t,e,n){return new Ti(t,e,n).distance()<=n},Ti.nearestPoints=function(t,e){return new Ti(t,e).nearestPoints()};var Pi=function(){this._pt=[new w,new w],this._distance=v.NaN,this._isNull=!0};Pi.prototype.getCoordinates=function(){return this._pt},Pi.prototype.getCoordinate=function(t){return this._pt[t]},Pi.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var i=e.distance(n);i<this._distance&&this.initialize(e,n,i)}},Pi.prototype.initialize=function(){if(0===arguments.length)this._isNull=!0;else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._pt[0].setCoordinate(t),this._pt[1].setCoordinate(e),this._distance=t.distance(e),this._isNull=!1}else if(3===arguments.length){var n=arguments[1],i=arguments[2];this._pt[0].setCoordinate(arguments[0]),this._pt[1].setCoordinate(n),this._distance=i,this._isNull=!1}},Pi.prototype.toString=function(){return $.toLineString(this._pt[0],this._pt[1])},Pi.prototype.getDistance=function(){return this._distance},Pi.prototype.setMaximum=function(){if(1===arguments.length){var t=arguments[0];this.setMaximum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var i=e.distance(n);i>this._distance&&this.initialize(e,n,i)}},Pi.prototype.interfaces_=function(){return[]},Pi.prototype.getClass=function(){return Pi};var Ri=function(){};Ri.prototype.interfaces_=function(){return[]},Ri.prototype.getClass=function(){return Ri},Ri.computeDistance=function(){if(arguments[2]instanceof Pi&&arguments[0]instanceof Jt&&arguments[1]instanceof w)for(var t=arguments[0],e=arguments[1],n=arguments[2],i=new dn,r=t.getCoordinates(),o=0;o<r.length-1;o++){i.setCoordinates(r[o],r[o+1]);var s=i.closestPoint(e);n.setMinimum(s,e)}else if(arguments[2]instanceof Pi&&arguments[0]instanceof Zt&&arguments[1]instanceof w){var a=arguments[0],u=arguments[1],l=arguments[2];Ri.computeDistance(a.getExteriorRing(),u,l);for(var c=0;c<a.getNumInteriorRing();c++)Ri.computeDistance(a.getInteriorRingN(c),u,l)}else if(arguments[2]instanceof Pi&&arguments[0]instanceof ct&&arguments[1]instanceof w){var p=arguments[0],h=arguments[1],f=arguments[2];if(p instanceof Jt)Ri.computeDistance(p,h,f);else if(p instanceof Zt)Ri.computeDistance(p,h,f);else if(p instanceof Ut)for(var g=p,d=0;d<g.getNumGeometries();d++){var y=g.getGeometryN(d);Ri.computeDistance(y,h,f)}else f.setMinimum(p.getCoordinate(),h)}else if(arguments[2]instanceof Pi&&arguments[0]instanceof dn&&arguments[1]instanceof w){var _=arguments[1],m=arguments[2],v=arguments[0].closestPoint(_);m.setMinimum(v,_)}};var Mi=function(){this._g0=null,this._g1=null,this._ptDist=new Pi,this._densifyFrac=0;var t=arguments[1];this._g0=arguments[0],this._g1=t},Di={MaxPointDistanceFilter:{configurable:!0},MaxDensifiedByFractionDistanceFilter:{configurable:!0}};Mi.prototype.getCoordinates=function(){return this._ptDist.getCoordinates()},Mi.prototype.setDensifyFraction=function(t){if(t>1||t<=0)throw new m("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},Mi.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},Mi.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},Mi.prototype.computeOrientedDistance=function(t,e,n){var i=new Ai(e);if(t.apply(i),n.setMaximum(i.getMaxPointDistance()),this._densifyFrac>0){var r=new Fi(e,this._densifyFrac);t.apply(r),n.setMaximum(r.getMaxPointDistance())}},Mi.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},Mi.prototype.interfaces_=function(){return[]},Mi.prototype.getClass=function(){return Mi},Mi.distance=function(){if(2===arguments.length)return new Mi(arguments[0],arguments[1]).distance();if(3===arguments.length){var t=arguments[2],e=new Mi(arguments[0],arguments[1]);return e.setDensifyFraction(t),e.distance()}},Di.MaxPointDistanceFilter.get=function(){return Ai},Di.MaxDensifiedByFractionDistanceFilter.get=function(){return Fi},Object.defineProperties(Mi,Di);var Ai=function(){this._maxPtDist=new Pi,this._minPtDist=new Pi,this._euclideanDist=new Ri,this._geom=null,this._geom=arguments[0]};Ai.prototype.filter=function(t){this._minPtDist.initialize(),Ri.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},Ai.prototype.getMaxPointDistance=function(){return this._maxPtDist},Ai.prototype.interfaces_=function(){return[ft]},Ai.prototype.getClass=function(){return Ai};var Fi=function(){this._maxPtDist=new Pi,this._minPtDist=new Pi,this._geom=null,this._numSubSegs=0;var t=arguments[1];this._geom=arguments[0],this._numSubSegs=Math.trunc(Math.round(1/t))};Fi.prototype.filter=function(t,e){if(0===e)return null;for(var n=t.getCoordinate(e-1),i=t.getCoordinate(e),r=(i.x-n.x)/this._numSubSegs,o=(i.y-n.y)/this._numSubSegs,s=0;s<this._numSubSegs;s++){var a=new w(n.x+s*r,n.y+s*o);this._minPtDist.initialize(),Ri.computeDistance(this._geom,a,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)}},Fi.prototype.isDone=function(){return!1},Fi.prototype.isGeometryChanged=function(){return!1},Fi.prototype.getMaxPointDistance=function(){return this._maxPtDist},Fi.prototype.interfaces_=function(){return[zt]},Fi.prototype.getClass=function(){return Fi};var Gi=function(t,e,n){this._minValidDistance=null,this._maxValidDistance=null,this._minDistanceFound=null,this._maxDistanceFound=null,this._isValid=!0,this._errMsg=null,this._errorLocation=null,this._errorIndicator=null,this._input=t||null,this._bufDistance=e||null,this._result=n||null},Vi={VERBOSE:{configurable:!0},MAX_DISTANCE_DIFF_FRAC:{configurable:!0}};Gi.prototype.checkMaximumDistance=function(t,e,n){var i=new Mi(e,t);if(i.setDensifyFraction(.25),this._maxDistanceFound=i.orientedDistance(),this._maxDistanceFound>n){this._isValid=!1;var r=i.getCoordinates();this._errorLocation=r[1],this._errorIndicator=t.getFactory().createLineString(r),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+$.toLineString(r[0],r[1])+")"}},Gi.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=Gi.MAX_DISTANCE_DIFF_FRAC*t;return this._minValidDistance=t-e,this._maxValidDistance=t+e,!(!this._input.isEmpty()&&!this._result.isEmpty())||(this._bufDistance>0?this.checkPositiveValid():this.checkNegativeValid(),Gi.VERBOSE&&X.out.println("Min Dist= "+this._minDistanceFound+"  err= "+(1-this._minDistanceFound/this._bufDistance)+"  Max Dist= "+this._maxDistanceFound+"  err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},Gi.prototype.checkNegativeValid=function(){if(!(this._input instanceof Zt||this._input instanceof ne||this._input instanceof Ut))return null;var t=this.getPolygonLines(this._input);if(this.checkMinimumDistance(t,this._result,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(t,this._result,this._maxValidDistance)},Gi.prototype.getErrorIndicator=function(){return this._errorIndicator},Gi.prototype.checkMinimumDistance=function(t,e,n){var i=new Ti(t,e,n);if(this._minDistanceFound=i.distance(),this._minDistanceFound<n){this._isValid=!1;var r=i.nearestPoints();this._errorLocation=i.nearestPoints()[1],this._errorIndicator=t.getFactory().createLineString(r),this._errMsg="Distance between buffer curve and input is too small ("+this._minDistanceFound+" at "+$.toLineString(r[0],r[1])+" )"}},Gi.prototype.checkPositiveValid=function(){var t=this._result.getBoundary();if(this.checkMinimumDistance(this._input,t,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(this._input,t,this._maxValidDistance)},Gi.prototype.getErrorLocation=function(){return this._errorLocation},Gi.prototype.getPolygonLines=function(t){for(var e=new Nt,n=new wi(e),i=Ni.getPolygons(t).iterator();i.hasNext();)i.next().apply(n);return t.getFactory().buildGeometry(e)},Gi.prototype.getErrorMessage=function(){return this._errMsg},Gi.prototype.interfaces_=function(){return[]},Gi.prototype.getClass=function(){return Gi},Vi.VERBOSE.get=function(){return!1},Vi.MAX_DISTANCE_DIFF_FRAC.get=function(){return.012},Object.defineProperties(Gi,Vi);var qi=function(t,e,n){this._isValid=!0,this._errorMsg=null,this._errorLocation=null,this._errorIndicator=null,this._input=t||null,this._distance=e||null,this._result=n||null},Bi={VERBOSE:{configurable:!0},MAX_ENV_DIFF_FRAC:{configurable:!0}};qi.prototype.isValid=function(){return this.checkPolygonal(),this._isValid?(this.checkExpectedEmpty(),this._isValid?(this.checkEnvelope(),this._isValid?(this.checkArea(),this._isValid?(this.checkDistance(),this._isValid):this._isValid):this._isValid):this._isValid):this._isValid},qi.prototype.checkEnvelope=function(){if(this._distance<0)return null;var t=this._distance*qi.MAX_ENV_DIFF_FRAC;0===t&&(t=.001);var e=new j(this._input.getEnvelopeInternal());e.expandBy(this._distance);var n=new j(this._result.getEnvelopeInternal());n.expandBy(t),n.contains(e)||(this._isValid=!1,this._errorMsg="Buffer envelope is incorrect",this._errorIndicator=this._input.getFactory().toGeometry(n)),this.report("Envelope")},qi.prototype.checkDistance=function(){var t=new Gi(this._input,this._distance,this._result);t.isValid()||(this._isValid=!1,this._errorMsg=t.getErrorMessage(),this._errorLocation=t.getErrorLocation(),this._errorIndicator=t.getErrorIndicator()),this.report("Distance")},qi.prototype.checkArea=function(){var t=this._input.getArea(),e=this._result.getArea();this._distance>0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t<e&&(this._isValid=!1,this._errorMsg="Area of negative buffer is larger than input",this._errorIndicator=this._result),this.report("Area")},qi.prototype.checkPolygonal=function(){this._result instanceof Zt||this._result instanceof ne||(this._isValid=!1),this._errorMsg="Result is not polygonal",this._errorIndicator=this._result,this.report("Polygonal")},qi.prototype.getErrorIndicator=function(){return this._errorIndicator},qi.prototype.getErrorLocation=function(){return this._errorLocation},qi.prototype.checkExpectedEmpty=function(){return this._input.getDimension()>=2||this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"))},qi.prototype.report=function(t){if(!qi.VERBOSE)return null;X.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},qi.prototype.getErrorMessage=function(){return this._errorMsg},qi.prototype.interfaces_=function(){return[]},qi.prototype.getClass=function(){return qi},qi.isValidMsg=function(t,e,n){var i=new qi(t,e,n);return i.isValid()?null:i.getErrorMessage()},qi.isValid=function(t,e,n){return!!new qi(t,e,n).isValid()},Bi.VERBOSE.get=function(){return!1},Bi.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(qi,Bi);var zi=function(){this._pts=null,this._data=null;var t=arguments[1];this._pts=arguments[0],this._data=t};zi.prototype.getCoordinates=function(){return this._pts},zi.prototype.size=function(){return this._pts.length},zi.prototype.getCoordinate=function(t){return this._pts[t]},zi.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},zi.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:pn.octant(this.getCoordinate(t),this.getCoordinate(t+1))},zi.prototype.setData=function(t){this._data=t},zi.prototype.getData=function(){return this._data},zi.prototype.toString=function(){return $.toLineString(new ue(this._pts))},zi.prototype.interfaces_=function(){return[hn]},zi.prototype.getClass=function(){return zi};var Ui=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new Nt,this._intersectionCount=0,this._keepIntersections=!0,this._li=arguments[0],this._interiorIntersection=null};Ui.prototype.getInteriorIntersection=function(){return this._interiorIntersection},Ui.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},Ui.prototype.getIntersectionSegments=function(){return this._intSegments},Ui.prototype.count=function(){return this._intersectionCount},Ui.prototype.getIntersections=function(){return this._intersections},Ui.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Ui.prototype.setKeepIntersections=function(t){this._keepIntersections=t},Ui.prototype.processIntersections=function(t,e,n,i){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===i)return null;if(this._isCheckEndSegmentsOnly&&!this.isEndSegment(t,e)&&!this.isEndSegment(n,i))return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=r,this._intSegments[1]=o,this._intSegments[2]=s,this._intSegments[3]=a,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)},Ui.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2},Ui.prototype.hasIntersection=function(){return null!==this._interiorIntersection},Ui.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection},Ui.prototype.interfaces_=function(){return[Wn]},Ui.prototype.getClass=function(){return Ui},Ui.createAllIntersectionsFinder=function(t){var e=new Ui(t);return e.setFindAllIntersections(!0),e},Ui.createAnyIntersectionFinder=function(t){return new Ui(t)},Ui.createIntersectionCounter=function(t){var e=new Ui(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var ki=function(){this._li=new rt,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0,this._segStrings=arguments[0]};ki.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},ki.prototype.getIntersections=function(){return this._segInt.getIntersections()},ki.prototype.isValid=function(){return this.execute(),this._isValid},ki.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},ki.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new Ui(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new En;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},ki.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new Le(this.getErrorMessage(),this._segInt.getInteriorIntersection())},ki.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+$.toLineString(t[0],t[1])+" and "+$.toLineString(t[2],t[3])},ki.prototype.interfaces_=function(){return[]},ki.prototype.getClass=function(){return ki},ki.computeIntersections=function(t){var e=new ki(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Xi=function t(){this._nv=null,this._nv=new ki(t.toSegmentStrings(arguments[0]))};Xi.prototype.checkValid=function(){this._nv.checkValid()},Xi.prototype.interfaces_=function(){return[]},Xi.prototype.getClass=function(){return Xi},Xi.toSegmentStrings=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next();e.add(new zi(i.getCoordinates(),i))}return e},Xi.checkValid=function(t){new Xi(t).checkValid()};var Yi=function(t){this._mapOp=t};Yi.prototype.map=function(t){for(var e=new Nt,n=0;n<t.getNumGeometries();n++){var i=this._mapOp.map(t.getGeometryN(n));i.isEmpty()||e.add(i)}return t.getFactory().createGeometryCollection(_e.toGeometryArray(e))},Yi.prototype.interfaces_=function(){return[]},Yi.prototype.getClass=function(){return Yi},Yi.map=function(t,e){return new Yi(e).map(t)};var ji=function(){this._op=null,this._geometryFactory=null,this._ptLocator=null,this._lineEdgesList=new Nt,this._resultLineList=new Nt;var t=arguments[1],e=arguments[2];this._op=arguments[0],this._geometryFactory=t,this._ptLocator=e};ji.prototype.collectLines=function(t){for(var e=this._op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next();this.collectLineEdge(n,t,this._lineEdgesList),this.collectBoundaryTouchEdge(n,t,this._lineEdgesList)}},ji.prototype.labelIsolatedLine=function(t,e){var n=this._ptLocator.locate(t.getCoordinate(),this._op.getArgGeometry(e));t.getLabel().setLocation(e,n)},ji.prototype.build=function(t){return this.findCoveredLineEdges(),this.collectLines(t),this.buildLines(t),this._resultLineList},ji.prototype.collectLineEdge=function(t,e,n){var i=t.getLabel(),r=t.getEdge();t.isLineEdge()&&(t.isVisited()||!Sr.isResultOfOp(i,e)||r.isCovered()||(n.add(r),t.setVisitedEdge(!0)))},ji.prototype.findCoveredLineEdges=function(){for(var t=this._op.getGraph().getNodes().iterator();t.hasNext();)t.next().getEdges().findCoveredLineEdges();for(var e=this._op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next(),i=n.getEdge();if(n.isLineEdge()&&!i.isCoveredSet()){var r=this._op.isCoveredByA(n.getCoordinate());i.setCovered(r)}}},ji.prototype.labelIsolatedLines=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getLabel();n.isIsolated()&&(i.isNull(0)?this.labelIsolatedLine(n,0):this.labelIsolatedLine(n,1))}},ji.prototype.buildLines=function(t){for(var e=this._lineEdgesList.iterator();e.hasNext();){var n=e.next(),i=this._geometryFactory.createLineString(n.getCoordinates());this._resultLineList.add(i),n.setInResult(!0)}},ji.prototype.collectBoundaryTouchEdge=function(t,e,n){var i=t.getLabel();return t.isLineEdge()||t.isVisited()||t.isInteriorAreaEdge()||t.getEdge().isInResult()?null:(et.isTrue(!(t.isInResult()||t.getSym().isInResult())||!t.getEdge().isInResult()),void(Sr.isResultOfOp(i,e)&&e===Sr.INTERSECTION&&(n.add(t.getEdge()),t.setVisitedEdge(!0))))},ji.prototype.interfaces_=function(){return[]},ji.prototype.getClass=function(){return ji};var Hi=function(){this._op=null,this._geometryFactory=null,this._resultPointList=new Nt;var t=arguments[1];this._op=arguments[0],this._geometryFactory=t};Hi.prototype.filterCoveredNodeToPoint=function(t){var e=t.getCoordinate();if(!this._op.isCoveredByLA(e)){var n=this._geometryFactory.createPoint(e);this._resultPointList.add(n)}},Hi.prototype.extractNonCoveredResultNodes=function(t){for(var e=this._op.getGraph().getNodes().iterator();e.hasNext();){var n=e.next();if(!(n.isInResult()||n.isIncidentEdgeInResult()||0!==n.getEdges().getDegree()&&t!==Sr.INTERSECTION)){var i=n.getLabel();Sr.isResultOfOp(i,t)&&this.filterCoveredNodeToPoint(n)}}},Hi.prototype.build=function(t){return this.extractNonCoveredResultNodes(t),this._resultPointList},Hi.prototype.interfaces_=function(){return[]},Hi.prototype.getClass=function(){return Hi};var Wi=function(){this._inputGeom=null,this._factory=null,this._pruneEmptyGeometry=!0,this._preserveGeometryCollectionType=!0,this._preserveCollections=!1,this._preserveType=!1};Wi.prototype.transformPoint=function(t,e){return this._factory.createPoint(this.transformCoordinates(t.getCoordinateSequence(),t))},Wi.prototype.transformPolygon=function(t,e){var n=!0,i=this.transformLinearRing(t.getExteriorRing(),t);null!==i&&i instanceof ee&&!i.isEmpty()||(n=!1);for(var r=new Nt,o=0;o<t.getNumInteriorRing();o++){var s=this.transformLinearRing(t.getInteriorRingN(o),t);null===s||s.isEmpty()||(s instanceof ee||(n=!1),r.add(s))}if(n)return this._factory.createPolygon(i,r.toArray([]));var a=new Nt;return null!==i&&a.add(i),a.addAll(r),this._factory.buildGeometry(a)},Wi.prototype.createCoordinateSequence=function(t){return this._factory.getCoordinateSequenceFactory().create(t)},Wi.prototype.getInputGeometry=function(){return this._inputGeom},Wi.prototype.transformMultiLineString=function(t,e){for(var n=new Nt,i=0;i<t.getNumGeometries();i++){var r=this.transformLineString(t.getGeometryN(i),t);null!==r&&(r.isEmpty()||n.add(r))}return this._factory.buildGeometry(n)},Wi.prototype.transformCoordinates=function(t,e){return this.copy(t)},Wi.prototype.transformLineString=function(t,e){return this._factory.createLineString(this.transformCoordinates(t.getCoordinateSequence(),t))},Wi.prototype.transformMultiPoint=function(t,e){for(var n=new Nt,i=0;i<t.getNumGeometries();i++){var r=this.transformPoint(t.getGeometryN(i),t);null!==r&&(r.isEmpty()||n.add(r))}return this._factory.buildGeometry(n)},Wi.prototype.transformMultiPolygon=function(t,e){for(var n=new Nt,i=0;i<t.getNumGeometries();i++){var r=this.transformPolygon(t.getGeometryN(i),t);null!==r&&(r.isEmpty()||n.add(r))}return this._factory.buildGeometry(n)},Wi.prototype.copy=function(t){return t.copy()},Wi.prototype.transformGeometryCollection=function(t,e){for(var n=new Nt,i=0;i<t.getNumGeometries();i++){var r=this.transform(t.getGeometryN(i));null!==r&&(this._pruneEmptyGeometry&&r.isEmpty()||n.add(r))}return this._preserveGeometryCollectionType?this._factory.createGeometryCollection(_e.toGeometryArray(n)):this._factory.buildGeometry(n)},Wi.prototype.transform=function(t){if(this._inputGeom=t,this._factory=t.getFactory(),t instanceof Qt)return this.transformPoint(t,null);if(t instanceof te)return this.transformMultiPoint(t,null);if(t instanceof ee)return this.transformLinearRing(t,null);if(t instanceof Jt)return this.transformLineString(t,null);if(t instanceof kt)return this.transformMultiLineString(t,null);if(t instanceof Zt)return this.transformPolygon(t,null);if(t instanceof ne)return this.transformMultiPolygon(t,null);if(t instanceof Ut)return this.transformGeometryCollection(t,null);throw new m("Unknown Geometry subtype: "+t.getClass().getName())},Wi.prototype.transformLinearRing=function(t,e){var n=this.transformCoordinates(t.getCoordinateSequence(),t);if(null===n)return this._factory.createLinearRing(null);var i=n.size();return i>0&&i<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)},Wi.prototype.interfaces_=function(){return[]},Wi.prototype.getClass=function(){return Wi};var Ji=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new dn,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Jt&&"number"==typeof arguments[1]){var e=arguments[1];t.call(this,arguments[0].getCoordinates(),e)}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this._srcPts=n,this._isClosed=t.isClosed(n),this._snapTolerance=i}};Ji.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),i=0;i<n;i++){var r=t.get(i),o=this.findSnapForVertex(r,e);null!==o&&(t.set(i,new w(o)),0===i&&this._isClosed&&t.set(t.size()-1,new w(o)))}},Ji.prototype.findSnapForVertex=function(t,e){for(var n=0;n<e.length;n++){if(t.equals2D(e[n]))return null;if(t.distance(e[n])<this._snapTolerance)return e[n]}return null},Ji.prototype.snapTo=function(t){var e=new Ct(this._srcPts);return this.snapVertices(e,t),this.snapSegments(e,t),e.toCoordinateArray()},Ji.prototype.snapSegments=function(t,e){if(0===e.length)return null;var n=e.length;e[0].equals2D(e[e.length-1])&&(n=e.length-1);for(var i=0;i<n;i++){var r=e[i],o=this.findSegmentIndexToSnap(r,t);o>=0&&t.add(o+1,new w(r),!1)}},Ji.prototype.findSegmentIndexToSnap=function(t,e){for(var n=v.MAX_VALUE,i=-1,r=0;r<e.size()-1;r++){if(this._seg.p0=e.get(r),this._seg.p1=e.get(r+1),this._seg.p0.equals2D(t)||this._seg.p1.equals2D(t)){if(this._allowSnappingToSourceVertices)continue;return-1}var o=this._seg.distance(t);o<this._snapTolerance&&o<n&&(n=o,i=r)}return i},Ji.prototype.setAllowSnappingToSourceVertices=function(t){this._allowSnappingToSourceVertices=t},Ji.prototype.interfaces_=function(){return[]},Ji.prototype.getClass=function(){return Ji},Ji.isClosed=function(t){return!(t.length<=1)&&t[0].equals2D(t[t.length-1])};var Ki=function(t){this._srcGeom=t||null},Qi={SNAP_PRECISION_FACTOR:{configurable:!0}};Ki.prototype.snapTo=function(t,e){var n=this.extractTargetCoordinates(t);return new $i(e,n).transform(this._srcGeom)},Ki.prototype.snapToSelf=function(t,e){var n=this.extractTargetCoordinates(this._srcGeom),i=new $i(t,n,!0).transform(this._srcGeom),r=i;return e&&T(r,$t)&&(r=i.buffer(0)),r},Ki.prototype.computeSnapTolerance=function(t){return this.computeMinimumSegmentLength(t)/10},Ki.prototype.extractTargetCoordinates=function(t){for(var e=new f,n=t.getCoordinates(),i=0;i<n.length;i++)e.add(n[i]);return e.toArray(new Array(0).fill(null))},Ki.prototype.computeMinimumSegmentLength=function(t){for(var e=v.MAX_VALUE,n=0;n<t.length-1;n++){var i=t[n].distance(t[n+1]);i<e&&(e=i)}return e},Ki.prototype.interfaces_=function(){return[]},Ki.prototype.getClass=function(){return Ki},Ki.snap=function(t,e,n){var i=new Array(2).fill(null),r=new Ki(t);i[0]=r.snapTo(e,n);var o=new Ki(e);return i[1]=o.snapTo(i[0],n),i},Ki.computeOverlaySnapTolerance=function(){if(1===arguments.length){var t=arguments[0],e=Ki.computeSizeBasedSnapTolerance(t),n=t.getPrecisionModel();if(n.getType()===fe.FIXED){var i=1/n.getScale()*2/1.415;i>e&&(e=i)}return e}if(2===arguments.length){var r=arguments[1];return Math.min(Ki.computeOverlaySnapTolerance(arguments[0]),Ki.computeOverlaySnapTolerance(r))}},Ki.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*Ki.SNAP_PRECISION_FACTOR},Ki.snapToSelf=function(t,e,n){return new Ki(t).snapToSelf(e,n)},Qi.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Ki,Qi);var $i=function(t){function e(e,n,i){t.call(this),this._snapTolerance=e||null,this._snapPts=n||null,this._isSelfSnap=void 0!==i&&i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var n=new Ji(t,this._snapTolerance);return n.setAllowSnappingToSourceVertices(this._isSelfSnap),n.snapTo(e)},e.prototype.transformCoordinates=function(t,e){var n=t.toCoordinateArray(),i=this.snapLine(n,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Wi),Zi=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};Zi.prototype.getCommon=function(){return v.longBitsToDouble(this._commonBits)},Zi.prototype.add=function(t){var e=v.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=Zi.signExpBits(this._commonBits),this._isFirst=!1,null):Zi.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=Zi.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=Zi.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))))},Zi.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=v.longBitsToDouble(t),n="0000000000000000000000000000000000000000000000000000000000000000"+v.toBinaryString(t),i=n.substring(n.length-64);return i.substring(0,1)+"  "+i.substring(1,12)+"(exp) "+i.substring(12)+" [ "+e+" ]"}},Zi.prototype.interfaces_=function(){return[]},Zi.prototype.getClass=function(){return Zi},Zi.getBit=function(t,e){return t&1<<e?1:0},Zi.signExpBits=function(t){return t>>52},Zi.zeroLowerBits=function(t,e){return t&~((1<<e)-1)},Zi.numCommonMostSigMantissaBits=function(t,e){for(var n=0,i=52;i>=0;i--){if(Zi.getBit(t,i)!==Zi.getBit(e,i))return n;n++}return 52};var tr=function(){this._commonCoord=null,this._ccFilter=new nr},er={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};tr.prototype.addCommonBits=function(t){var e=new ir(this._commonCoord);t.apply(e),t.geometryChanged()},tr.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new w(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new ir(e);return t.apply(n),t.geometryChanged(),t},tr.prototype.getCommonCoordinate=function(){return this._commonCoord},tr.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},tr.prototype.interfaces_=function(){return[]},tr.prototype.getClass=function(){return tr},er.CommonCoordinateFilter.get=function(){return nr},er.Translater.get=function(){return ir},Object.defineProperties(tr,er);var nr=function(){this._commonBitsX=new Zi,this._commonBitsY=new Zi};nr.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},nr.prototype.getCommonCoordinate=function(){return new w(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},nr.prototype.interfaces_=function(){return[ft]},nr.prototype.getClass=function(){return nr};var ir=function(){this.trans=null,this.trans=arguments[0]};ir.prototype.filter=function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,i=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,i)},ir.prototype.isDone=function(){return!1},ir.prototype.isGeometryChanged=function(){return!0},ir.prototype.interfaces_=function(){return[zt]},ir.prototype.getClass=function(){return ir};var rr=function(t,e){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null,this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance()};rr.prototype.selfSnap=function(t){return new Ki(t).snapTo(t,this._snapTolerance)},rr.prototype.removeCommonBits=function(t){this._cbr=new tr,this._cbr.add(t[0]),this._cbr.add(t[1]);var e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e},rr.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},rr.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=Sr.overlayOp(e[0],e[1],t);return this.prepareResult(n)},rr.prototype.checkValid=function(t){t.isValid()||X.out.println("Snapped geometry is invalid")},rr.prototype.computeSnapTolerance=function(){this._snapTolerance=Ki.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},rr.prototype.snap=function(t){var e=this.removeCommonBits(t);return Ki.snap(e[0],e[1],this._snapTolerance)},rr.prototype.interfaces_=function(){return[]},rr.prototype.getClass=function(){return rr},rr.overlayOp=function(t,e,n){return new rr(t,e).getResultGeometry(n)},rr.union=function(t,e){return rr.overlayOp(t,e,Sr.UNION)},rr.intersection=function(t,e){return rr.overlayOp(t,e,Sr.INTERSECTION)},rr.symDifference=function(t,e){return rr.overlayOp(t,e,Sr.SYMDIFFERENCE)},rr.difference=function(t,e){return rr.overlayOp(t,e,Sr.DIFFERENCE)};var or=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};or.prototype.getResultGeometry=function(t){var e=null,n=!1,i=null;try{e=Sr.overlayOp(this._geom[0],this._geom[1],t),n=!0}catch(t){if(!(t instanceof Z))throw t;i=t}if(!n)try{e=rr.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof Z?i:t}return e},or.prototype.interfaces_=function(){return[]},or.prototype.getClass=function(){return or},or.overlayOp=function(t,e,n){return new or(t,e).getResultGeometry(n)},or.union=function(t,e){return or.overlayOp(t,e,Sr.UNION)},or.intersection=function(t,e){return or.overlayOp(t,e,Sr.INTERSECTION)},or.symDifference=function(t,e){return or.overlayOp(t,e,Sr.SYMDIFFERENCE)},or.difference=function(t,e){return or.overlayOp(t,e,Sr.DIFFERENCE)};var sr=function(){this.mce=null,this.chainIndex=null;var t=arguments[1];this.mce=arguments[0],this.chainIndex=t};sr.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},sr.prototype.interfaces_=function(){return[]},sr.prototype.getClass=function(){return sr};var ar=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=i,this._xValue=r,this._obj=o}},ur={INSERT:{configurable:!0},DELETE:{configurable:!0}};ar.prototype.isDelete=function(){return this._eventType===ar.DELETE},ar.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},ar.prototype.getObject=function(){return this._obj},ar.prototype.compareTo=function(t){return this._xValue<t._xValue?-1:this._xValue>t._xValue?1:this._eventType<t._eventType?-1:this._eventType>t._eventType?1:0},ar.prototype.getInsertEvent=function(){return this._insertEvent},ar.prototype.isInsert=function(){return this._eventType===ar.INSERT},ar.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label},ar.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},ar.prototype.interfaces_=function(){return[x]},ar.prototype.getClass=function(){return ar},ur.INSERT.get=function(){return 1},ur.DELETE.get=function(){return 2},Object.defineProperties(ar,ur);var lr=function(){};lr.prototype.interfaces_=function(){return[]},lr.prototype.getClass=function(){return lr};var cr=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;var t=arguments[1],e=arguments[2];this._li=arguments[0],this._includeProper=t,this._recordIsolated=e};cr.prototype.isTrivialIntersection=function(t,e,n,i){if(t===n&&1===this._li.getIntersectionNum()){if(cr.isAdjacentSegments(e,i))return!0;if(t.isClosed()){var r=t.getNumPoints()-1;if(0===e&&i===r||0===i&&e===r)return!0}}return!1},cr.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},cr.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},cr.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},cr.prototype.isBoundaryPointInternal=function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next().getCoordinate();if(t.isIntersection(i))return!0}return!1},cr.prototype.hasProperIntersection=function(){return this._hasProper},cr.prototype.hasIntersection=function(){return this._hasIntersection},cr.prototype.isDone=function(){return this._isDone},cr.prototype.isBoundaryPoint=function(t,e){return!(null===e||!this.isBoundaryPointInternal(t,e[0])&&!this.isBoundaryPointInternal(t,e[1]))},cr.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},cr.prototype.addIntersections=function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),n.addIntersections(this._li,i,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))))},cr.prototype.interfaces_=function(){return[]},cr.prototype.getClass=function(){return cr},cr.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var pr=function(t){function e(){t.call(this),this.events=new Nt,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){Ze.sort(this.events);for(var t=0;t<this.events.size();t++){var e=this.events.get(t);e.isDelete()&&e.getInsertEvent().setDeleteEventIndex(t)}},e.prototype.computeIntersections=function(){if(1===arguments.length){var t=arguments[0];this.nOverlaps=0,this.prepareEvents();for(var e=0;e<this.events.size();e++){var n=this.events.get(e);if(n.isInsert()&&this.processOverlaps(e,n.getDeleteEventIndex(),n,t),t.isDone())break}}else if(3===arguments.length)if(arguments[2]instanceof cr&&T(arguments[0],Et)&&T(arguments[1],Et)){var i=arguments[0],r=arguments[1],o=arguments[2];this.addEdges(i,i),this.addEdges(r,r),this.computeIntersections(o)}else if("boolean"==typeof arguments[2]&&T(arguments[0],Et)&&arguments[1]instanceof cr){var s=arguments[0],a=arguments[1];arguments[2]?this.addEdges(s,null):this.addEdges(s),this.computeIntersections(a)}},e.prototype.addEdge=function(t,e){for(var n=t.getMonotoneChainEdge(),i=n.getStartIndexes(),r=0;r<i.length-1;r++){var o=new sr(n,r),s=new ar(e,n.getMinX(r),o);this.events.add(s),this.events.add(new ar(n.getMaxX(r),s))}},e.prototype.processOverlaps=function(t,e,n,i){for(var r=n.getObject(),o=t;o<e;o++){var s=this.events.get(o);if(s.isInsert()){var a=s.getObject();n.isSameLabel(s)||(r.computeIntersections(a,i),this.nOverlaps++)}}},e.prototype.addEdges=function(){if(1===arguments.length)for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.addEdge(e,e)}else if(2===arguments.length)for(var n=arguments[1],i=arguments[0].iterator();i.hasNext();){var r=i.next();this.addEdge(r,n)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(lr),hr=function(){this._min=v.POSITIVE_INFINITY,this._max=v.NEGATIVE_INFINITY},fr={NodeComparator:{configurable:!0}};hr.prototype.getMin=function(){return this._min},hr.prototype.intersects=function(t,e){return!(this._min>e||this._max<t)},hr.prototype.getMax=function(){return this._max},hr.prototype.toString=function(){return $.toLineString(new w(this._min,0),new w(this._max,0))},hr.prototype.interfaces_=function(){return[]},hr.prototype.getClass=function(){return hr},fr.NodeComparator.get=function(){return gr},Object.defineProperties(hr,fr);var gr=function(){};gr.prototype.compare=function(t,e){var n=(t._min+t._max)/2,i=(e._min+e._max)/2;return n<i?-1:n>i?1:0},gr.prototype.interfaces_=function(){return[N]},gr.prototype.getClass=function(){return gr};var dr=function(t){function e(){t.call(this),this._item=null;var e=arguments[1],n=arguments[2];this._min=arguments[0],this._max=e,this._item=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;n.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(hr),yr=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[1];this._node1=arguments[0],this._node2=e,this.buildExtent(this._node1,this._node2)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildExtent=function(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max)},e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,n),null!==this._node2&&this._node2.query(t,e,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(hr),_r=function(){this._leaves=new Nt,this._root=null,this._level=0};_r.prototype.buildTree=function(){Ze.sort(this._leaves,new hr.NodeComparator);for(var t=this._leaves,e=null,n=new Nt;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},_r.prototype.insert=function(t,e,n){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new dr(t,e,n))},_r.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n)},_r.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree()},_r.prototype.printNode=function(t){X.out.println($.toLineString(new w(t._min,this._level),new w(t._max,this._level)))},_r.prototype.init=function(){if(null!==this._root)return null;this.buildRoot()},_r.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n<t.size();n+=2){var i=t.get(n);if(null===(n+1<t.size()?t.get(n):null))e.add(i);else{var r=new yr(t.get(n),t.get(n+1));e.add(r)}}},_r.prototype.interfaces_=function(){return[]},_r.prototype.getClass=function(){return _r};var mr=function(){this._items=new Nt};mr.prototype.visitItem=function(t){this._items.add(t)},mr.prototype.getItems=function(){return this._items},mr.prototype.interfaces_=function(){return[Je]},mr.prototype.getClass=function(){return mr};var vr=function(){this._index=null;var t=arguments[0];if(!T(t,$t))throw new m("Argument must be Polygonal");this._index=new Er(t)},Ir={SegmentVisitor:{configurable:!0},IntervalIndexedGeometry:{configurable:!0}};vr.prototype.locate=function(t){var e=new st(t),n=new xr(e);return this._index.query(t.y,t.y,n),e.getLocation()},vr.prototype.interfaces_=function(){return[Bn]},vr.prototype.getClass=function(){return vr},Ir.SegmentVisitor.get=function(){return xr},Ir.IntervalIndexedGeometry.get=function(){return Er},Object.defineProperties(vr,Ir);var xr=function(){this._counter=null,this._counter=arguments[0]};xr.prototype.visitItem=function(t){var e=t;this._counter.countSegment(e.getCoordinate(0),e.getCoordinate(1))},xr.prototype.interfaces_=function(){return[Je]},xr.prototype.getClass=function(){return xr};var Er=function(){this._index=new _r,this.init(arguments[0])};Er.prototype.init=function(t){for(var e=wi.getLines(t).iterator();e.hasNext();){var n=e.next().getCoordinates();this.addLine(n)}},Er.prototype.addLine=function(t){for(var e=1;e<t.length;e++){var n=new dn(t[e-1],t[e]),i=Math.min(n.p0.y,n.p1.y),r=Math.max(n.p0.y,n.p1.y);this._index.insert(i,r,n)}},Er.prototype.query=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new mr;return this._index.query(t,e,n),n.getItems()}3===arguments.length&&this._index.query(arguments[0],arguments[1],arguments[2])},Er.prototype.interfaces_=function(){return[]},Er.prototype.getClass=function(){return Er};var Nr=function(t){function e(){if(t.call(this),this._parentGeom=null,this._lineEdgeMap=new he,this._boundaryNodeRule=null,this._useBoundaryDeterminationRule=!0,this._argIndex=null,this._boundaryNodes=null,this._hasTooFewPoints=!1,this._invalidPoint=null,this._areaPtLocator=null,this._ptLocator=new Ci,2===arguments.length){var e=arguments[1],n=gt.OGC_SFS_BOUNDARY_RULE;this._argIndex=arguments[0],this._parentGeom=e,this._boundaryNodeRule=n,null!==e&&this.add(e)}else if(3===arguments.length){var i=arguments[1],r=arguments[2];this._argIndex=arguments[0],this._parentGeom=i,this._boundaryNodeRule=r,null!==i&&this.add(i)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.insertBoundaryPoint=function(t,n){var i=this._nodes.addNode(n).getLabel(),r=1;i.getLocation(t,Ce.ON)===L.BOUNDARY&&r++;var o=e.determineBoundary(this._boundaryNodeRule,r);i.setLocation(t,o)},e.prototype.computeSelfNodes=function(){if(2===arguments.length)return this.computeSelfNodes(arguments[0],arguments[1],!1);if(3===arguments.length){var t=arguments[1],e=arguments[2],n=new cr(arguments[0],!0,!1);return n.setIsDoneIfProperInt(e),this.createEdgeSetIntersector().computeIntersections(this._edges,n,t||!(this._parentGeom instanceof ee||this._parentGeom instanceof Zt||this._parentGeom instanceof ne)),this.addSelfIntersectionNodes(this._argIndex),n}},e.prototype.computeSplitEdges=function(t){for(var e=this._edges.iterator();e.hasNext();)e.next().eiList.addSplitEdges(t)},e.prototype.computeEdgeIntersections=function(t,e,n){var i=new cr(e,n,!0);return i.setBoundaryNodes(this.getBoundaryNodes(),t.getBoundaryNodes()),this.createEdgeSetIntersector().computeIntersections(this._edges,t._edges,i),i},e.prototype.getGeometry=function(){return this._parentGeom},e.prototype.getBoundaryNodeRule=function(){return this._boundaryNodeRule},e.prototype.hasTooFewPoints=function(){return this._hasTooFewPoints},e.prototype.addPoint=function(){if(arguments[0]instanceof Qt){var t=arguments[0].getCoordinate();this.insertPoint(this._argIndex,t,L.INTERIOR)}else arguments[0]instanceof w&&this.insertPoint(this._argIndex,arguments[0],L.INTERIOR)},e.prototype.addPolygon=function(t){this.addPolygonRing(t.getExteriorRing(),L.EXTERIOR,L.INTERIOR);for(var e=0;e<t.getNumInteriorRing();e++){var n=t.getInteriorRingN(e);this.addPolygonRing(n,L.INTERIOR,L.EXTERIOR)}},e.prototype.addEdge=function(t){this.insertEdge(t);var e=t.getCoordinates();this.insertPoint(this._argIndex,e[0],L.BOUNDARY),this.insertPoint(this._argIndex,e[e.length-1],L.BOUNDARY)},e.prototype.addLineString=function(t){var e=St.removeRepeatedPoints(t.getCoordinates());if(e.length<2)return this._hasTooFewPoints=!0,this._invalidPoint=e[0],null;var n=new ni(e,new Re(this._argIndex,L.INTERIOR));this._lineEdgeMap.put(t,n),this.insertEdge(n),et.isTrue(e.length>=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1])},e.prototype.getInvalidPoint=function(){return this._invalidPoint},e.prototype.getBoundaryPoints=function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,i=t.iterator();i.hasNext();){var r=i.next();e[n++]=r.getCoordinate().copy()}return e},e.prototype.getBoundaryNodes=function(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes},e.prototype.addSelfIntersectionNode=function(t,e,n){if(this.isBoundaryNode(t,e))return null;n===L.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n)},e.prototype.addPolygonRing=function(t,e,n){if(t.isEmpty())return null;var i=St.removeRepeatedPoints(t.getCoordinates());if(i.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=i[0],null;var r=e,o=n;at.isCCW(i)&&(r=n,o=e);var s=new ni(i,new Re(this._argIndex,L.BOUNDARY,r,o));this._lineEdgeMap.put(t,s),this.insertEdge(s),this.insertPoint(this._argIndex,i[0],L.BOUNDARY)},e.prototype.insertPoint=function(t,e,n){var i=this._nodes.addNode(e),r=i.getLabel();null===r?i._label=new Re(t,n):r.setLocation(t,n)},e.prototype.createEdgeSetIntersector=function(){return new pr},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.eiList.iterator();r.hasNext();){var o=r.next();this.addSelfIntersectionNode(t,o.coord,i)}},e.prototype.add=function(){if(1!==arguments.length)return t.prototype.add.apply(this,arguments);var e=arguments[0];if(e.isEmpty())return null;if(e instanceof ne&&(this._useBoundaryDeterminationRule=!1),e instanceof Zt)this.addPolygon(e);else if(e instanceof Jt)this.addLineString(e);else if(e instanceof Qt)this.addPoint(e);else if(e instanceof te)this.addCollection(e);else if(e instanceof kt)this.addCollection(e);else if(e instanceof ne)this.addCollection(e);else{if(!(e instanceof Ut))throw new Error(e.getClass().getName());this.addCollection(e)}},e.prototype.addCollection=function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}},e.prototype.locate=function(t){return T(this._parentGeom,$t)&&this._parentGeom.getNumGeometries()>50?(null===this._areaPtLocator&&(this._areaPtLocator=new vr(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom)},e.prototype.findEdge=function(){return 1===arguments.length?this._lineEdgeMap.get(arguments[0]):t.prototype.findEdge.apply(this,arguments)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.determineBoundary=function(t,e){return t.isInBoundary(e)?L.BOUNDARY:L.INTERIOR},e}(Xe),wr=function(){if(this._li=new rt,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new Nr(0,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=gt.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Nr(0,e,i),this._arg[1]=new Nr(1,n,i)}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];r.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(r.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Nr(0,r,s),this._arg[1]=new Nr(1,o,s)}};wr.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},wr.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},wr.prototype.interfaces_=function(){return[]},wr.prototype.getClass=function(){return wr};var Cr=function(){};Cr.prototype.interfaces_=function(){return[]},Cr.prototype.getClass=function(){return Cr},Cr.map=function(){if(arguments[0]instanceof ct&&T(arguments[1],Cr.MapOp)){for(var t=arguments[0],e=arguments[1],n=new Nt,i=0;i<t.getNumGeometries();i++){var r=e.map(t.getGeometryN(i));null!==r&&n.add(r)}return t.getFactory().buildGeometry(n)}if(T(arguments[0],It)&&T(arguments[1],Cr.MapOp)){for(var o=arguments[0],s=arguments[1],a=new Nt,u=o.iterator();u.hasNext();){var l=u.next(),c=s.map(l);null!==c&&a.add(c)}return a}},Cr.MapOp=function(){};var Sr=function(t){function e(){var e=arguments[0];t.call(this,e,arguments[1]),this._ptLocator=new Ci,this._geomFact=null,this._resultGeom=null,this._graph=null,this._edgeList=new Hn,this._resultPolyList=new Nt,this._resultLineList=new Nt,this._resultPointList=new Nt,this._graph=new Xe(new Yn),this._geomFact=e.getFactory()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.insertUniqueEdge=function(t){var e=this._edgeList.findEqualEdge(t);if(null!==e){var n=e.getLabel(),i=t.getLabel();e.isPointwiseEqual(t)||(i=new Re(t.getLabel())).flip();var r=e.getDepth();r.isNull()&&r.add(n),r.add(i),n.merge(i)}else this._edgeList.add(t)},e.prototype.getGraph=function(){return this._graph},e.prototype.cancelDuplicateResultEdges=function(){for(var t=this._graph.getEdgeEnds().iterator();t.hasNext();){var e=t.next(),n=e.getSym();e.isInResult()&&n.isInResult()&&(e.setInResult(!1),n.setInResult(!1))}},e.prototype.isCoveredByLA=function(t){return!!this.isCovered(t,this._resultLineList)||!!this.isCovered(t,this._resultPolyList)},e.prototype.computeGeometry=function(t,n,i,r){var o=new Nt;return o.addAll(t),o.addAll(n),o.addAll(i),o.isEmpty()?e.createEmptyResult(r,this._arg[0].getGeometry(),this._arg[1].getGeometry(),this._geomFact):this._geomFact.buildGeometry(o)},e.prototype.mergeSymLabels=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();)t.next().getEdges().mergeSymLabels()},e.prototype.isCovered=function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();if(this._ptLocator.locate(t,i)!==L.EXTERIOR)return!0}return!1},e.prototype.replaceCollapsedEdges=function(){for(var t=new Nt,e=this._edgeList.iterator();e.hasNext();){var n=e.next();n.isCollapsed()&&(e.remove(),t.add(n.getCollapsedEdge()))}this._edgeList.addAll(t)},e.prototype.updateNodeLabelling=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();){var e=t.next(),n=e.getEdges().getLabel();e.getLabel().merge(n)}},e.prototype.getResultGeometry=function(t){return this.computeOverlay(t),this._resultGeom},e.prototype.insertUniqueEdges=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.insertUniqueEdge(n)}},e.prototype.computeOverlay=function(t){this.copyPoints(0),this.copyPoints(1),this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1),this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!0);var e=new Nt;this._arg[0].computeSplitEdges(e),this._arg[1].computeSplitEdges(e),this.insertUniqueEdges(e),this.computeLabelsFromDepths(),this.replaceCollapsedEdges(),Xi.checkValid(this._edgeList.getEdges()),this._graph.addEdges(this._edgeList.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(t),this.cancelDuplicateResultEdges();var n=new Ye(this._geomFact);n.add(this._graph),this._resultPolyList=n.getPolygons();var i=new ji(this,this._geomFact,this._ptLocator);this._resultLineList=i.build(t);var r=new Hi(this,this._geomFact,this._ptLocator);this._resultPointList=r.build(t),this._resultGeom=this.computeGeometry(this._resultPointList,this._resultLineList,this._resultPolyList,t)},e.prototype.labelIncompleteNode=function(t,e){var n=this._ptLocator.locate(t.getCoordinate(),this._arg[e].getGeometry());t.getLabel().setLocation(e,n)},e.prototype.copyPoints=function(t){for(var e=this._arg[t].getNodeIterator();e.hasNext();){var n=e.next();this._graph.addNode(n.getCoordinate()).setLabel(t,n.getLabel().getLocation(t))}},e.prototype.findResultAreaEdges=function(t){for(var n=this._graph.getEdgeEnds().iterator();n.hasNext();){var i=n.next(),r=i.getLabel();r.isArea()&&!i.isInteriorAreaEdge()&&e.isResultOfOp(r.getLocation(0,Ce.RIGHT),r.getLocation(1,Ce.RIGHT),t)&&i.setInResult(!0)}},e.prototype.computeLabelsFromDepths=function(){for(var t=this._edgeList.iterator();t.hasNext();){var e=t.next(),n=e.getLabel(),i=e.getDepth();if(!i.isNull()){i.normalize();for(var r=0;r<2;r++)n.isNull(r)||!n.isArea()||i.isNull(r)||(0===i.getDelta(r)?n.toLine(r):(et.isTrue(!i.isNull(r,Ce.LEFT),"depth of LEFT side has not been initialized"),n.setLocation(r,Ce.LEFT,i.getLocation(r,Ce.LEFT)),et.isTrue(!i.isNull(r,Ce.RIGHT),"depth of RIGHT side has not been initialized"),n.setLocation(r,Ce.RIGHT,i.getLocation(r,Ce.RIGHT))))}}},e.prototype.computeLabelling=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();)t.next().getEdges().computeLabelling(this._arg);this.mergeSymLabels(),this.updateNodeLabelling()},e.prototype.labelIncompleteNodes=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();){var e=t.next(),n=e.getLabel();e.isIsolated()&&(n.isNull(0)?this.labelIncompleteNode(e,0):this.labelIncompleteNode(e,1)),e.getEdges().updateLabelling(n)}},e.prototype.isCoveredByA=function(t){return!!this.isCovered(t,this._resultPolyList)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(wr);Sr.overlayOp=function(t,e,n){return new Sr(t,e).getResultGeometry(n)},Sr.intersection=function(t,e){if(t.isEmpty()||e.isEmpty())return Sr.createEmptyResult(Sr.INTERSECTION,t,e,t.getFactory());if(t.isGeometryCollection()){var n=e;return Yi.map(t,{interfaces_:function(){return[Cr.MapOp]},map:function(t){return t.intersection(n)}})}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),or.overlayOp(t,e,Sr.INTERSECTION)},Sr.symDifference=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Sr.createEmptyResult(Sr.SYMDIFFERENCE,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),or.overlayOp(t,e,Sr.SYMDIFFERENCE)},Sr.resultDimension=function(t,e,n){var i=e.getDimension(),r=n.getDimension(),o=-1;switch(t){case Sr.INTERSECTION:o=Math.min(i,r);break;case Sr.UNION:o=Math.max(i,r);break;case Sr.DIFFERENCE:o=i;break;case Sr.SYMDIFFERENCE:o=Math.max(i,r)}return o},Sr.createEmptyResult=function(t,e,n,i){var r=null;switch(Sr.resultDimension(t,e,n)){case-1:r=i.createGeometryCollection(new Array(0).fill(null));break;case 0:r=i.createPoint();break;case 1:r=i.createLineString();break;case 2:r=i.createPolygon()}return r},Sr.difference=function(t,e){return t.isEmpty()?Sr.createEmptyResult(Sr.DIFFERENCE,t,e,t.getFactory()):e.isEmpty()?t.copy():(t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),or.overlayOp(t,e,Sr.DIFFERENCE))},Sr.isResultOfOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=t.getLocation(0),i=t.getLocation(1);return Sr.isResultOfOp(n,i,e)}if(3===arguments.length){var r=arguments[0],o=arguments[1];switch(r===L.BOUNDARY&&(r=L.INTERIOR),o===L.BOUNDARY&&(o=L.INTERIOR),arguments[2]){case Sr.INTERSECTION:return r===L.INTERIOR&&o===L.INTERIOR;case Sr.UNION:return r===L.INTERIOR||o===L.INTERIOR;case Sr.DIFFERENCE:return r===L.INTERIOR&&o!==L.INTERIOR;case Sr.SYMDIFFERENCE:return r===L.INTERIOR&&o!==L.INTERIOR||r!==L.INTERIOR&&o===L.INTERIOR}return!1}},Sr.INTERSECTION=1,Sr.UNION=2,Sr.DIFFERENCE=3,Sr.SYMDIFFERENCE=4;var br=function(){this._g=null,this._boundaryDistanceTolerance=null,this._linework=null,this._ptLocator=new Ci,this._seg=new dn;var t=arguments[0],e=arguments[1];this._g=t,this._boundaryDistanceTolerance=e,this._linework=this.extractLinework(t)};br.prototype.isWithinToleranceOfBoundary=function(t){for(var e=0;e<this._linework.getNumGeometries();e++)for(var n=this._linework.getGeometryN(e).getCoordinateSequence(),i=0;i<n.size()-1;i++)if(n.getCoordinate(i,this._seg.p0),n.getCoordinate(i+1,this._seg.p1),this._seg.distance(t)<=this._boundaryDistanceTolerance)return!0;return!1},br.prototype.getLocation=function(t){return this.isWithinToleranceOfBoundary(t)?L.BOUNDARY:this._ptLocator.locate(t,this._g)},br.prototype.extractLinework=function(t){var e=new Lr;t.apply(e);var n=e.getLinework(),i=_e.toLineStringArray(n);return t.getFactory().createMultiLineString(i)},br.prototype.interfaces_=function(){return[]},br.prototype.getClass=function(){return br};var Lr=function(){this._linework=null,this._linework=new Nt};Lr.prototype.getLinework=function(){return this._linework},Lr.prototype.filter=function(t){if(t instanceof Zt){var e=t;this._linework.add(e.getExteriorRing());for(var n=0;n<e.getNumInteriorRing();n++)this._linework.add(e.getInteriorRingN(n))}},Lr.prototype.interfaces_=function(){return[Bt]},Lr.prototype.getClass=function(){return Lr};var Or=function(){this._g=null,this._doLeft=!0,this._doRight=!0,this._g=arguments[0]};Or.prototype.extractPoints=function(t,e,n){for(var i=t.getCoordinates(),r=0;r<i.length-1;r++)this.computeOffsetPoints(i[r],i[r+1],e,n)},Or.prototype.setSidesToGenerate=function(t,e){this._doLeft=t,this._doRight=e},Or.prototype.getPoints=function(t){for(var e=new Nt,n=wi.getLines(this._g).iterator();n.hasNext();){var i=n.next();this.extractPoints(i,t,e)}return e},Or.prototype.computeOffsetPoints=function(t,e,n,i){var r=e.x-t.x,o=e.y-t.y,s=Math.sqrt(r*r+o*o),a=n*r/s,u=n*o/s,l=(e.x+t.x)/2,c=(e.y+t.y)/2;if(this._doLeft){var p=new w(l-u,c+a);i.add(p)}if(this._doRight){var h=new w(l+u,c-a);i.add(h)}},Or.prototype.interfaces_=function(){return[]},Or.prototype.getClass=function(){return Or};var Tr=function t(){this._geom=null,this._locFinder=null,this._location=new Array(3).fill(null),this._invalidLocation=null,this._boundaryDistanceTolerance=t.TOLERANCE,this._testCoords=new Nt;var e=arguments[0],n=arguments[1],i=arguments[2];this._boundaryDistanceTolerance=t.computeBoundaryDistanceTolerance(e,n),this._geom=[e,n,i],this._locFinder=[new br(this._geom[0],this._boundaryDistanceTolerance),new br(this._geom[1],this._boundaryDistanceTolerance),new br(this._geom[2],this._boundaryDistanceTolerance)]},Pr={TOLERANCE:{configurable:!0}};Tr.prototype.reportResult=function(t,e,n){X.out.println("Overlay result invalid - A:"+L.toLocationSymbol(e[0])+" B:"+L.toLocationSymbol(e[1])+" expected:"+(n?"i":"e")+" actual:"+L.toLocationSymbol(e[2]))},Tr.prototype.isValid=function(t){return this.addTestPts(this._geom[0]),this.addTestPts(this._geom[1]),this.checkValid(t)},Tr.prototype.checkValid=function(){if(1===arguments.length){for(var t=arguments[0],e=0;e<this._testCoords.size();e++){var n=this._testCoords.get(e);if(!this.checkValid(t,n))return this._invalidLocation=n,!1}return!0}if(2===arguments.length){var i=arguments[0],r=arguments[1];return this._location[0]=this._locFinder[0].getLocation(r),this._location[1]=this._locFinder[1].getLocation(r),this._location[2]=this._locFinder[2].getLocation(r),!!Tr.hasLocation(this._location,L.BOUNDARY)||this.isValidResult(i,this._location)}},Tr.prototype.addTestPts=function(t){var e=new Or(t);this._testCoords.addAll(e.getPoints(5*this._boundaryDistanceTolerance))},Tr.prototype.isValidResult=function(t,e){var n=Sr.isResultOfOp(e[0],e[1],t),i=!(n^e[2]===L.INTERIOR);return i||this.reportResult(t,e,n),i},Tr.prototype.getInvalidLocation=function(){return this._invalidLocation},Tr.prototype.interfaces_=function(){return[]},Tr.prototype.getClass=function(){return Tr},Tr.hasLocation=function(t,e){for(var n=0;n<3;n++)if(t[n]===e)return!0;return!1},Tr.computeBoundaryDistanceTolerance=function(t,e){return Math.min(Ki.computeSizeBasedSnapTolerance(t),Ki.computeSizeBasedSnapTolerance(e))},Tr.isValid=function(t,e,n,i){return new Tr(t,e,i).isValid(n)},Pr.TOLERANCE.get=function(){return 1e-6},Object.defineProperties(Tr,Pr);var Rr=function t(e){this._geomFactory=null,this._skipEmpty=!1,this._inputGeoms=null,this._geomFactory=t.extractFactory(e),this._inputGeoms=e};Rr.prototype.extractElements=function(t,e){if(null===t)return null;for(var n=0;n<t.getNumGeometries();n++){var i=t.getGeometryN(n);this._skipEmpty&&i.isEmpty()||e.add(i)}},Rr.prototype.combine=function(){for(var t=new Nt,e=this._inputGeoms.iterator();e.hasNext();){var n=e.next();this.extractElements(n,t)}return 0===t.size()?null!==this._geomFactory?this._geomFactory.createGeometryCollection(null):null:this._geomFactory.buildGeometry(t)},Rr.prototype.interfaces_=function(){return[]},Rr.prototype.getClass=function(){return Rr},Rr.combine=function(){return 1===arguments.length?new Rr(arguments[0]).combine():2===arguments.length?new Rr(Rr.createList(arguments[0],arguments[1])).combine():3===arguments.length?new Rr(Rr.createList(arguments[0],arguments[1],arguments[2])).combine():void 0},Rr.extractFactory=function(t){return t.isEmpty()?null:t.iterator().next().getFactory()},Rr.createList=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new Nt;return n.add(t),n.add(e),n}if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=new Nt;return s.add(i),s.add(r),s.add(o),s}};var Mr=function(){this._inputPolys=null,this._geomFactory=null,this._inputPolys=arguments[0],null===this._inputPolys&&(this._inputPolys=new Nt)},Dr={STRTREE_NODE_CAPACITY:{configurable:!0}};Mr.prototype.reduceToGeometries=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next(),r=null;T(i,Et)?r=this.unionTree(i):i instanceof ct&&(r=i),e.add(r)}return e},Mr.prototype.extractByEnvelope=function(t,e,n){for(var i=new Nt,r=0;r<e.getNumGeometries();r++){var o=e.getGeometryN(r);o.getEnvelopeInternal().intersects(t)?i.add(o):n.add(o)}return this._geomFactory.buildGeometry(i)},Mr.prototype.unionOptimized=function(t,e){var n=t.getEnvelopeInternal(),i=e.getEnvelopeInternal();if(!n.intersects(i))return Rr.combine(t,e);if(t.getNumGeometries()<=1&&e.getNumGeometries()<=1)return this.unionActual(t,e);var r=n.intersection(i);return this.unionUsingEnvelopeIntersection(t,e,r)},Mr.prototype.union=function(){if(null===this._inputPolys)throw new Error("union() method cannot be called twice");if(this._inputPolys.isEmpty())return null;this._geomFactory=this._inputPolys.iterator().next().getFactory();for(var t=new sn(Mr.STRTREE_NODE_CAPACITY),e=this._inputPolys.iterator();e.hasNext();){var n=e.next();t.insert(n.getEnvelopeInternal(),n)}this._inputPolys=null;var i=t.itemsTree();return this.unionTree(i)},Mr.prototype.binaryUnion=function(){if(1===arguments.length){var t=arguments[0];return this.binaryUnion(t,0,t.size())}if(3===arguments.length){var e=arguments[0],n=arguments[1],i=arguments[2];if(i-n<=1){var r=Mr.getGeometry(e,n);return this.unionSafe(r,null)}if(i-n==2)return this.unionSafe(Mr.getGeometry(e,n),Mr.getGeometry(e,n+1));var o=Math.trunc((i+n)/2),s=this.binaryUnion(e,n,o),a=this.binaryUnion(e,o,i);return this.unionSafe(s,a)}},Mr.prototype.repeatedUnion=function(t){for(var e=null,n=t.iterator();n.hasNext();){var i=n.next();e=null===e?i.copy():e.union(i)}return e},Mr.prototype.unionSafe=function(t,e){return null===t&&null===e?null:null===t?e.copy():null===e?t.copy():this.unionOptimized(t,e)},Mr.prototype.unionActual=function(t,e){return Mr.restrictToPolygons(t.union(e))},Mr.prototype.unionTree=function(t){var e=this.reduceToGeometries(t);return this.binaryUnion(e)},Mr.prototype.unionUsingEnvelopeIntersection=function(t,e,n){var i=new Nt,r=this.extractByEnvelope(n,t,i),o=this.extractByEnvelope(n,e,i),s=this.unionActual(r,o);return i.add(s),Rr.combine(i)},Mr.prototype.bufferUnion=function(){if(1===arguments.length){var t=arguments[0];return t.get(0).getFactory().buildGeometry(t).buffer(0)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e.getFactory().createGeometryCollection([e,n]).buffer(0)}},Mr.prototype.interfaces_=function(){return[]},Mr.prototype.getClass=function(){return Mr},Mr.restrictToPolygons=function(t){if(T(t,$t))return t;var e=Ni.getPolygons(t);return 1===e.size()?e.get(0):t.getFactory().createMultiPolygon(_e.toPolygonArray(e))},Mr.getGeometry=function(t,e){return e>=t.size()?null:t.get(e)},Mr.union=function(t){return new Mr(t).union()},Dr.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(Mr,Dr);var Ar=function(){};Ar.prototype.interfaces_=function(){return[]},Ar.prototype.getClass=function(){return Ar},Ar.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Sr.createEmptyResult(Sr.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),or.overlayOp(t,e,Sr.UNION)},t.GeoJSONReader=Ne,t.GeoJSONWriter=we,t.OverlayOp=Sr,t.UnionOp=Ar,t.BufferOp=di,Object.defineProperty(t,"__esModule",{value:!0})}(_.exports)),_.exports);function v(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return I(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"features":return;default:e[n]=t[n]}}),e.features=t.features.map(function(t){return I(t)}),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return E(t);default:throw new Error("unknown GeoJSON type")}}function I(t){var e={type:"Feature"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}),e.properties=x(t.properties),e.geometry=E(t.geometry),e}function x(t){var e={};return t?(Object.keys(t).forEach(function(n){var i=t[n];e[n]="object"==typeof i?null===i?null:i.length?i.map(function(t){return t}):x(i):i}),e):e}function E(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(function(t){return E(t)}),e):(e.coordinates=N(t.coordinates),e)}function N(t){return"object"!=typeof t[0]?t.slice():t.map(function(t){return N(t)})}function w(t,e,n){if(!l(n=n||{}))throw new Error("options is invalid");var i=n.mutate;if(!t)throw new Error("geojson is required");return Array.isArray(t)&&u(t[0])?t="mercator"===e?C(t):S(t):(!0!==i&&(t=v(t)),h(t,function(t){var n="mercator"===e?C(t):S(t);t[0]=n[0],t[1]=n[1]})),t}function C(t){var e=Math.PI/180,n=6378137,i=20037508.342789244,r=Math.abs(t[0])<=180?t[0]:t[0]-360*function(t){return t<0?-1:t>0?1:0}(t[0]),o=[n*r*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return o[0]>i&&(o[0]=i),o[0]<-i&&(o[0]=-i),o[1]>i&&(o[1]=i),o[1]<-i&&(o[1]=-i),o}function S(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e]}function b(){return new L}function L(){this.reset()}L.prototype={constructor:L,reset:function(){this.s=this.t=0},add:function(t){T(O,t,this.t),T(this,O.s,this.s),this.s?this.t+=O.t:this.s=O.t},valueOf:function(){return this.s}};var O=new L;function T(t,e,n){var i=t.s=e+n,r=i-e;t.t=e-(i-r)+(n-r)}var P=1e-6,R=Math.PI,M=R/2,D=R/4,A=2*R,F=180/R,G=R/180,V=Math.abs,q=Math.atan,B=Math.atan2,z=Math.cos,U=Math.exp,k=Math.log,X=Math.sin,Y=Math.sqrt,j=Math.tan;function H(t){return t>1?M:t<-1?-M:Math.asin(t)}function W(){}function J(t,e){t&&Z.hasOwnProperty(t.type)&&Z[t.type](t,e)}var K,Q,$={Feature:function(t,e){J(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i<r;)J(n[i].geometry,e)}},Z={Sphere:function(t,e){e.sphere()},Point:function(t,e){e.point((t=t.coordinates)[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)e.point((t=n[i])[0],t[1],t[2])},LineString:function(t,e){tt(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)tt(n[i],e,0)},Polygon:function(t,e){et(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)et(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,r=n.length;++i<r;)J(n[i],e)}};function tt(t,e,n){var i,r=-1,o=t.length-n;for(e.lineStart();++r<o;)e.point((i=t[r])[0],i[1],i[2]);e.lineEnd()}function et(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)tt(t[n],e,1);e.polygonEnd()}function nt(t){return[B(t[1],t[0]),H(t[2])]}function it(t){var e=t[0],n=t[1],i=z(n);return[i*z(e),i*X(e),X(n)]}function rt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ot(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function st(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function at(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function ut(t){var e=Y(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function lt(t,e){function n(n,i){return n=t(n,i),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,i){return(n=e.invert(n,i))&&t.invert(n[0],n[1])}),n}function ct(t,e){return[t>R?t-A:t<-R?t+A:t,e]}function pt(t,e,n){return(t%=A)?e||n?lt(ft(t),gt(e,n)):ft(t):e||n?gt(e,n):ct}function ht(t){return function(e,n){return[(e+=t)>R?e-A:e<-R?e+A:e,n]}}function ft(t){var e=ht(t);return e.invert=ht(-t),e}function gt(t,e){var n=z(t),i=X(t),r=z(e),o=X(e);function s(t,e){var s=z(e),a=z(t)*s,u=X(t)*s,l=X(e),c=l*n+a*i;return[B(u*r-c*o,a*n-l*i),H(c*r+u*o)]}return s.invert=function(t,e){var s=z(e),a=z(t)*s,u=X(t)*s,l=X(e),c=l*r-u*o;return[B(u*r+l*o,a*n+c*i),H(c*n-a*i)]},s}function dt(t,e){(e=it(e))[0]-=t,ut(e);var n=function(t){return t>1?0:t<-1?R:Math.acos(t)}(-e[1]);return((-e[2]<0?-n:n)+A-P)%A}function yt(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:W,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function _t(t,e){return V(t[0]-e[0])<P&&V(t[1]-e[1])<P}function mt(t,e,n,i){this.x=t,this.z=e,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function vt(t,e,n,i,r){var o,s,a=[],u=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,i=t[0],s=t[e];if(_t(i,s)){for(r.lineStart(),o=0;o<e;++o)r.point((i=t[o])[0],i[1]);r.lineEnd()}else a.push(n=new mt(i,t,null,!0)),u.push(n.o=new mt(i,null,n,!1)),a.push(n=new mt(s,t,null,!1)),u.push(n.o=new mt(s,null,n,!0))}}),a.length){for(u.sort(e),It(a),It(u),o=0,s=u.length;o<s;++o)u[o].e=n=!n;for(var l,c,p=a[0];;){for(var h=p,f=!0;h.v;)if((h=h.n)===p)return;l=h.z,r.lineStart();do{if(h.v=h.o.v=!0,h.e){if(f)for(o=0,s=l.length;o<s;++o)r.point((c=l[o])[0],c[1]);else i(h.x,h.n.x,1,r);h=h.n}else{if(f)for(o=(l=h.p.z).length-1;o>=0;--o)r.point((c=l[o])[0],c[1]);else i(h.x,h.p.x,-1,r);h=h.p}l=(h=h.o).z,f=!f}while(!h.v);r.lineEnd()}}}function It(t){if(e=t.length){for(var e,n,i=0,r=t[0];++i<e;)r.n=n=t[i],n.p=r,r=n;r.n=n=t[0],n.p=r}}function xt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Et(t){for(var e,n,i,r=t.length,o=-1,s=0;++o<r;)s+=t[o].length;for(n=new Array(s);--r>=0;)for(e=(i=t[r]).length;--e>=0;)n[--s]=i[e];return n}b(),b(),b(),ct.invert=ct,1===(K=xt).length&&(Q=K,K=function(t,e){return xt(Q(t),e)});var Nt=1e9,wt=-Nt;function Ct(t,e,n,i){function r(r,o){return t<=r&&r<=n&&e<=o&&o<=i}function o(r,o,a,l){var c=0,p=0;if(null==r||(c=s(r,a))!==(p=s(o,a))||u(r,o)<0^a>0)do{l.point(0===c||3===c?t:n,c>1?i:e)}while((c=(c+a+4)%4)!==p);else l.point(o[0],o[1])}function s(i,r){return V(i[0]-t)<P?r>0?0:3:V(i[0]-n)<P?r>0?2:1:V(i[1]-e)<P?r>0?1:0:r>0?3:2}function a(t,e){return u(t.x,e.x)}function u(t,e){var n=s(t,1),i=s(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(s){var u,l,c,p,h,f,g,d,y,_,m,v=s,I=yt(),x={point:E,lineStart:function(){x.point=N,l&&l.push(c=[]);_=!0,y=!1,g=d=NaN},lineEnd:function(){u&&(N(p,h),f&&y&&I.rejoin(),u.push(I.result()));x.point=E,y&&v.lineEnd()},polygonStart:function(){v=I,u=[],l=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,r=l.length;n<r;++n)for(var o,s,a=l[n],u=1,c=a.length,p=a[0],h=p[0],f=p[1];u<c;++u)o=h,s=f,h=(p=a[u])[0],f=p[1],s<=i?f>i&&(h-o)*(i-s)>(f-s)*(t-o)&&++e:f<=i&&(h-o)*(i-s)<(f-s)*(t-o)&&--e;return e}(),n=m&&e,r=(u=Et(u)).length;(n||r)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&vt(u,a,e,o,s),s.polygonEnd());v=s,u=l=c=null}};function E(t,e){r(t,e)&&v.point(t,e)}function N(o,s){var a=r(o,s);if(l&&c.push([o,s]),_)p=o,h=s,f=a,_=!1,a&&(v.lineStart(),v.point(o,s));else if(a&&y)v.point(o,s);else{var u=[g=Math.max(wt,Math.min(Nt,g)),d=Math.max(wt,Math.min(Nt,d))],I=[o=Math.max(wt,Math.min(Nt,o)),s=Math.max(wt,Math.min(Nt,s))];!function(t,e,n,i,r,o){var s,a=t[0],u=t[1],l=0,c=1,p=e[0]-a,h=e[1]-u;if(s=n-a,p||!(s>0)){if(s/=p,p<0){if(s<l)return;s<c&&(c=s)}else if(p>0){if(s>c)return;s>l&&(l=s)}if(s=r-a,p||!(s<0)){if(s/=p,p<0){if(s>c)return;s>l&&(l=s)}else if(p>0){if(s<l)return;s<c&&(c=s)}if(s=i-u,h||!(s>0)){if(s/=h,h<0){if(s<l)return;s<c&&(c=s)}else if(h>0){if(s>c)return;s>l&&(l=s)}if(s=o-u,h||!(s<0)){if(s/=h,h<0){if(s>c)return;s>l&&(l=s)}else if(h>0){if(s<l)return;s<c&&(c=s)}return l>0&&(t[0]=a+l*p,t[1]=u+l*h),c<1&&(e[0]=a+c*p,e[1]=u+c*h),!0}}}}}(u,I,t,e,n,i)?a&&(v.lineStart(),v.point(o,s),m=!1):(y||(v.lineStart(),v.point(u[0],u[1])),v.point(I[0],I[1]),a||v.lineEnd(),m=!1)}g=o,d=s,y=a}return x}}var St=b();function bt(t){return t}b(),b(),b();var Lt=1/0,Ot=Lt,Tt=-Lt,Pt=Tt,Rt={point:function(t,e){t<Lt&&(Lt=t);t>Tt&&(Tt=t);e<Ot&&(Ot=e);e>Pt&&(Pt=e)},lineStart:W,lineEnd:W,polygonStart:W,polygonEnd:W,result:function(){var t=[[Lt,Ot],[Tt,Pt]];return Tt=Pt=-(Ot=Lt=1/0),t}};function Mt(t,e,n,i){return function(r,o){var s,a,u,l=e(o),c=r.invert(i[0],i[1]),p=yt(),h=e(p),f=!1,g={point:d,lineStart:_,lineEnd:m,polygonStart:function(){g.point=v,g.lineStart=I,g.lineEnd=x,a=[],s=[]},polygonEnd:function(){g.point=d,g.lineStart=_,g.lineEnd=m,a=Et(a);var t=function(t,e){var n=e[0],i=e[1],r=[X(n),-z(n),0],o=0,s=0;St.reset();for(var a=0,u=t.length;a<u;++a)if(c=(l=t[a]).length)for(var l,c,p=l[c-1],h=p[0],f=p[1]/2+D,g=X(f),d=z(f),y=0;y<c;++y,h=m,g=I,d=x,p=_){var _=l[y],m=_[0],v=_[1]/2+D,I=X(v),x=z(v),E=m-h,N=E>=0?1:-1,w=N*E,C=w>R,S=g*I;if(St.add(B(S*N*X(w),d*x+S*z(w))),o+=C?E+N*A:E,C^h>=n^m>=n){var b=ot(it(p),it(_));ut(b);var L=ot(r,b);ut(L);var O=(C^E>=0?-1:1)*H(L[2]);(i>O||i===O&&(b[0]||b[1]))&&(s+=C^E>=0?1:-1)}}return(o<-P||o<P&&St<-P)^1&s}(s,c);a.length?(f||(o.polygonStart(),f=!0),vt(a,At,t,n,o)):t&&(f||(o.polygonStart(),f=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),f&&(o.polygonEnd(),f=!1),a=s=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function d(e,n){var i=r(e,n);t(e=i[0],n=i[1])&&o.point(e,n)}function y(t,e){var n=r(t,e);l.point(n[0],n[1])}function _(){g.point=y,l.lineStart()}function m(){g.point=d,l.lineEnd()}function v(t,e){u.push([t,e]);var n=r(t,e);h.point(n[0],n[1])}function I(){h.lineStart(),u=[]}function x(){v(u[0][0],u[0][1]),h.lineEnd();var t,e,n,i,r=h.clean(),l=p.result(),c=l.length;if(u.pop(),s.push(u),u=null,c)if(1&r){if((e=(n=l[0]).length-1)>0){for(f||(o.polygonStart(),f=!0),o.lineStart(),t=0;t<e;++t)o.point((i=n[t])[0],i[1]);o.lineEnd()}}else c>1&&2&r&&l.push(l.pop().concat(l.shift())),a.push(l.filter(Dt))}return g}}function Dt(t){return t.length>1}function At(t,e){return((t=t.x)[0]<0?t[1]-M-P:M-t[1])-((e=e.x)[0]<0?e[1]-M-P:M-e[1])}b();var Ft=Mt(function(){return!0},function(t){var e,n=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?R:-R,u=V(o-n);V(u-R)<P?(t.point(n,i=(i+s)/2>0?M:-M),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),e=0):r!==a&&u>=R&&(V(n-r)<P&&(n-=r*P),V(o-a)<P&&(o-=a*P),i=function(t,e,n,i){var r,o,s=X(t-n);return V(s)>P?q((X(e)*(o=z(i))*X(n)-X(i)*(r=z(e))*X(t))/(r*o*s)):(e+i)/2}(n,i,o,s),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),e=0),t.point(n=o,i=s),r=a},lineEnd:function(){t.lineEnd(),n=i=NaN},clean:function(){return 2-e}}},function(t,e,n,i){var r;if(null==t)i.point(-R,r=n*M),i.point(0,r),i.point(R,r),i.point(R,0),i.point(R,-r),i.point(0,-r),i.point(-R,-r),i.point(-R,0),i.point(-R,r);else if(V(t[0]-e[0])>P){var o=t[0]<e[0]?R:-R;i.point(-o,r=n*o/2),i.point(0,r),i.point(o,r)}else i.point(e[0],e[1])},[-R,-M]);function Gt(t,e){var n=z(t),i=n>0,r=V(n)>P;function o(t,e){return z(t)*z(e)>n}function s(t,e,i){var r=[1,0,0],o=ot(it(t),it(e)),s=rt(o,o),a=o[0],u=s-a*a;if(!u)return!i&&t;var l=n*s/u,c=-n*a/u,p=ot(r,o),h=at(r,l);st(h,at(o,c));var f=p,g=rt(h,f),d=rt(f,f),y=g*g-d*(rt(h,h)-1);if(!(y<0)){var _=Y(y),m=at(f,(-g-_)/d);if(st(m,h),m=nt(m),!i)return m;var v,I=t[0],x=e[0],E=t[1],N=e[1];x<I&&(v=I,I=x,x=v);var w=x-I,C=V(w-R)<P;if(!C&&N<E&&(v=E,E=N,N=v),C||w<P?C?E+N>0^m[1]<(V(m[0]-I)<P?E:N):E<=m[1]&&m[1]<=N:w>R^(I<=m[0]&&m[0]<=x)){var S=at(f,(-g+_)/d);return st(S,h),[m,nt(S)]}}}function a(e,n){var r=i?t:R-t,o=0;return e<-r?o|=1:e>r&&(o|=2),n<-r?o|=4:n>r&&(o|=8),o}return Mt(o,function(t){var e,n,u,l,c;return{lineStart:function(){l=u=!1,c=1},point:function(p,h){var f,g=[p,h],d=o(p,h),y=i?d?0:a(p,h):d?a(p+(p<0?R:-R),h):0;if(!e&&(l=u=d)&&t.lineStart(),d!==u&&(!(f=s(e,g))||_t(e,f)||_t(g,f))&&(g[0]+=P,g[1]+=P,d=o(g[0],g[1])),d!==u)c=0,d?(t.lineStart(),f=s(g,e),t.point(f[0],f[1])):(f=s(e,g),t.point(f[0],f[1]),t.lineEnd()),e=f;else if(r&&e&&i^d){var _;y&n||!(_=s(g,e,!0))||(c=0,i?(t.lineStart(),t.point(_[0][0],_[0][1]),t.point(_[1][0],_[1][1]),t.lineEnd()):(t.point(_[1][0],_[1][1]),t.lineEnd(),t.lineStart(),t.point(_[0][0],_[0][1])))}!d||e&&_t(e,g)||t.point(g[0],g[1]),e=g,u=d,n=y},lineEnd:function(){u&&t.lineEnd(),e=null},clean:function(){return c|(l&&u)<<1}}},function(n,i,r,o){!function(t,e,n,i,r,o){if(n){var s=z(e),a=X(e),u=i*n;null==r?(r=e+i*A,o=e-u/2):(r=dt(s,r),o=dt(s,o),(i>0?r<o:r>o)&&(r+=i*A));for(var l,c=r;i>0?c>o:c<o;c-=u)l=nt([s,-a*z(c),-a*X(c)]),t.point(l[0],l[1])}}(o,t,e,r,n,i)},i?[0,-t]:[-R,t-R])}function Vt(t){return function(e){var n=new qt;for(var i in t)n[i]=t[i];return n.stream=e,n}}function qt(){}function Bt(t,e,n){var i=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),null!=o&&t.clipExtent(null),function(t,e){t&&$.hasOwnProperty(t.type)?$[t.type](t,e):J(t,e)}(n,t.stream(Rt));var s=Rt.result(),a=Math.min(i/(s[1][0]-s[0][0]),r/(s[1][1]-s[0][1])),u=+e[0][0]+(i-a*(s[1][0]+s[0][0]))/2,l=+e[0][1]+(r-a*(s[1][1]+s[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*a).translate([u,l])}qt.prototype={constructor:qt,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var zt=z(30*G);function Ut(t,e){return+e?function(t,e){function n(i,r,o,s,a,u,l,c,p,h,f,g,d,y){var _=l-i,m=c-r,v=_*_+m*m;if(v>4*e&&d--){var I=s+h,x=a+f,E=u+g,N=Y(I*I+x*x+E*E),w=H(E/=N),C=V(V(E)-1)<P||V(o-p)<P?(o+p)/2:B(x,I),S=t(C,w),b=S[0],L=S[1],O=b-i,T=L-r,R=m*O-_*T;(R*R/v>e||V((_*O+m*T)/v-.5)>.3||s*h+a*f+u*g<zt)&&(n(i,r,o,s,a,u,b,L,C,I/=N,x/=N,E,d,y),y.point(b,L),n(b,L,C,I,x,E,l,c,p,h,f,g,d,y))}}return function(e){var i,r,o,s,a,u,l,c,p,h,f,g,d={point:y,lineStart:_,lineEnd:v,polygonStart:function(){e.polygonStart(),d.lineStart=I},polygonEnd:function(){e.polygonEnd(),d.lineStart=_}};function y(n,i){n=t(n,i),e.point(n[0],n[1])}function _(){c=NaN,d.point=m,e.lineStart()}function m(i,r){var o=it([i,r]),s=t(i,r);n(c,p,l,h,f,g,c=s[0],p=s[1],l=i,h=o[0],f=o[1],g=o[2],16,e),e.point(c,p)}function v(){d.point=y,e.lineEnd()}function I(){_(),d.point=x,d.lineEnd=E}function x(t,e){m(i=t,e),r=c,o=p,s=h,a=f,u=g,d.point=m}function E(){n(c,p,l,h,f,g,r,o,i,s,a,u,16,e),d.lineEnd=v,v()}return d}}(t,e):function(t){return Vt({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var kt=Vt({point:function(t,e){this.stream.point(t*G,e*G)}});function Xt(t){return function(t){var e,n,i,r,o,s,a,u,l,c,p=150,h=480,f=250,g=0,d=0,y=0,_=0,m=0,v=null,I=Ft,x=null,E=bt,N=.5,w=Ut(b,N);function C(t){return[(t=o(t[0]*G,t[1]*G))[0]*p+n,i-t[1]*p]}function S(t){return(t=o.invert((t[0]-n)/p,(i-t[1])/p))&&[t[0]*F,t[1]*F]}function b(t,r){return[(t=e(t,r))[0]*p+n,i-t[1]*p]}function L(){o=lt(r=pt(y,_,m),e);var t=e(g,d);return n=h-t[0]*p,i=f+t[1]*p,O()}function O(){return l=c=null,C}return C.stream=function(t){return l&&c===t?l:l=kt(I(r,w(E(c=t))))},C.clipAngle=function(t){return arguments.length?(I=+t?Gt(v=t*G,6*G):(v=null,Ft),O()):v*F},C.clipExtent=function(t){return arguments.length?(E=null==t?(x=s=a=u=null,bt):Ct(x=+t[0][0],s=+t[0][1],a=+t[1][0],u=+t[1][1]),O()):null==x?null:[[x,s],[a,u]]},C.scale=function(t){return arguments.length?(p=+t,L()):p},C.translate=function(t){return arguments.length?(h=+t[0],f=+t[1],L()):[h,f]},C.center=function(t){return arguments.length?(g=t[0]%360*G,d=t[1]%360*G,L()):[g*F,d*F]},C.rotate=function(t){return arguments.length?(y=t[0]%360*G,_=t[1]%360*G,m=t.length>2?t[2]%360*G:0,L()):[y*F,_*F,m*F]},C.precision=function(t){return arguments.length?(w=Ut(b,N=t*t),O()):Y(N)},C.fitExtent=function(t,e){return Bt(C,t,e)},C.fitSize=function(t,e){return function(t,e,n){return Bt(t,[[0,0],e],n)}(C,t,e)},function(){return e=t.apply(this,arguments),C.invert=e.invert&&S,L()}}(function(){return t})()}function Yt(t,e){return[t,k(j((M+e)/2))]}function jt(t){var e,n,i,r=Xt(t),o=r.center,s=r.scale,a=r.translate,u=r.clipExtent,l=null;function c(){var o=R*s(),a=r(function(t){function e(e){return(e=t(e[0]*G,e[1]*G))[0]*=F,e[1]*=F,e}return t=pt(t[0]*G,t[1]*G,t.length>2?t[2]*G:0),e.invert=function(e){return(e=t.invert(e[0]*G,e[1]*G))[0]*=F,e[1]*=F,e},e}(r.rotate()).invert([0,0]));return u(null==l?[[a[0]-o,a[1]-o],[a[0]+o,a[1]+o]]:t===Yt?[[Math.max(a[0]-o,l),e],[Math.min(a[0]+o,n),i]]:[[l,Math.max(a[1]-o,e)],[n,Math.min(a[1]+o,i)]])}return r.scale=function(t){return arguments.length?(s(t),c()):s()},r.translate=function(t){return arguments.length?(a(t),c()):a()},r.center=function(t){return arguments.length?(o(t),c()):o()},r.clipExtent=function(t){return arguments.length?(null==t?l=e=n=i=null:(l=+t[0][0],e=+t[0][1],n=+t[1][0],i=+t[1][1]),c()):null==l?null:[[l,e],[n,i]]},c()}function Ht(t,e){return[t,e]}function Wt(t,e){return[k(j((M+e)/2)),-t]}function Jt(t,e,n){var i=(n=n||{}).units,r=n.steps||64;if(!t)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");r=r||64,i=i||"kilometers";var s=[];switch(t.type){case"GeometryCollection":return g(t,function(t){var n=Kt(t,e,i);n&&s.push(n)}),o(s);case"FeatureCollection":return f(t,function(t){var n=Kt(t,e,i);n&&f(n,function(t){t&&s.push(t)})}),o(s)}return Kt(t,e,i)}function Kt(t,i,r,a){var u,l=t.properties||{},c="Feature"===t.type?t.geometry:t;if("GeometryCollection"===c.type){var p=[];return g(t,function(t){var e=Kt(t,i,r);e&&p.push(e)}),o(p)}var h=d(t),f=h[1]>50&&h[3]>50;u=f?{type:c.type,coordinates:$t(c.coordinates,te(c))}:function(t,e){return w(t,"mercator",e)}(c);var y,_=(new m.GeoJSONReader).read(u),v=s(function(t,n){if(null==t)throw new Error("distance is required");if(n&&"string"!=typeof n)throw new Error("units must be a string");var i=e[n||"kilometers"];if(!i)throw new Error(n+" units is invalid");return t/i}(i,r),"meters"),I=m.BufferOp.bufferOp(_,v);if(!Qt((I=(new m.GeoJSONWriter).write(I)).coordinates))return y=f?{type:I.type,coordinates:Zt(I.coordinates,te(c))}:function(t,e){return w(t,"wgs84",e)}(I),y.geometry?y:n(y,l)}function Qt(t){return Array.isArray(t[0])?Qt(t[0]):isNaN(t[0])}function $t(t,e){return"object"!=typeof t[0]?e(t):t.map(function(t){return $t(t,e)})}function Zt(t,e){return"object"!=typeof t[0]?e.invert(t):t.map(function(t){return Zt(t,e)})}function te(e){var n=function(t,e){if(!l(e=e||{}))throw new Error("options is invalid");var n=e.properties;if(!t)throw new Error("geojson is required");var r=d(t);return i([(r[0]+r[2])/2,(r[1]+r[3])/2],n)}(e).geometry.coordinates.reverse(),r=n.map(function(t){return-t});return function(){var t=jt(Wt),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90]).scale(159.155)}().center(n).rotate(r).scale(t)}function ee(){for(var t=new m.GeoJSONReader,e=t.read(JSON.stringify(arguments[0].geometry)),n=1;n<arguments.length;n++)e=m.UnionOp.union(e,t.read(JSON.stringify(arguments[n].geometry)));return{type:"Feature",geometry:e=(new m.GeoJSONWriter).write(e),properties:arguments[0].properties}}\n/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */Yt.invert=function(t,e){return[t,2*q(U(e))-M]},Ht.invert=Ht,Wt.invert=function(t,e){return[-e,2*q(U(t))-M]};const ne=Symbol("Comlink.proxy"),ie=Symbol("Comlink.endpoint"),re=Symbol("Comlink.releaseProxy"),oe=Symbol("Comlink.finalizer"),se=Symbol("Comlink.thrown"),ae=t=>"object"==typeof t&&null!==t||"function"==typeof t,ue={canHandle:t=>ae(t)&&t[ne],serialize(t){const{port1:e,port2:n}=new MessageChannel;return ce(t,e),[n,[n]]},deserialize:t=>(t.start(),function(t,e){const n=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const i=n.get(e.id);if(i)try{i(e)}finally{n.delete(e.id)}}),ye(t,n,[],e)}(t))},le=new Map([["proxy",ue],["throw",{canHandle:t=>ae(t)&&se in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function ce(t,e=globalThis,n=["*"]){e.addEventListener("message",function i(r){if(!r||!r.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,r.origin))return void console.warn(`Invalid origin \'${r.origin}\' for comlink proxy`);const{id:o,type:s,path:a}=Object.assign({path:[]},r.data),u=(r.data.argumentList||[]).map(xe);let l;try{const e=a.slice(0,-1).reduce((t,e)=>t[e],t),n=a.reduce((t,e)=>t[e],t);switch(s){case"GET":l=n;break;case"SET":e[a.slice(-1)[0]]=xe(r.data.value),l=!0;break;case"APPLY":l=n.apply(e,u);break;case"CONSTRUCT":l=function(t){return Object.assign(t,{[ne]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;ce(t,n),l=ve(e,[e])}break;case"RELEASE":l=void 0;break;default:return}}catch(t){l={value:t,[se]:0}}Promise.resolve(l).catch(t=>({value:t,[se]:0})).then(n=>{const[r,a]=Ie(n);e.postMessage(Object.assign(Object.assign({},r),{id:o}),a),"RELEASE"===s&&(e.removeEventListener("message",i),pe(e),oe in t&&"function"==typeof t[oe]&&t[oe]())}).catch(t=>{const[n,i]=Ie({value:new TypeError("Unserializable return value"),[se]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),i)})}),e.start&&e.start()}function pe(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function he(t){if(t)throw new Error("Proxy has been released and is not useable")}function fe(t){return Ee(t,new Map,{type:"RELEASE"}).then(()=>{pe(t)})}const ge=new WeakMap,de="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(ge.get(t)||0)-1;ge.set(t,e),0===e&&fe(t)});function ye(t,e,n=[],i=function(){}){let r=!1;const o=new Proxy(i,{get(i,s){if(he(r),s===re)return()=>{!function(t){de&&de.unregister(t)}(o),fe(t),e.clear(),r=!0};if("then"===s){if(0===n.length)return{then:()=>o};const i=Ee(t,e,{type:"GET",path:n.map(t=>t.toString())}).then(xe);return i.then.bind(i)}return ye(t,e,[...n,s])},set(i,o,s){he(r);const[a,u]=Ie(s);return Ee(t,e,{type:"SET",path:[...n,o].map(t=>t.toString()),value:a},u).then(xe)},apply(i,o,s){he(r);const a=n[n.length-1];if(a===ie)return Ee(t,e,{type:"ENDPOINT"}).then(xe);if("bind"===a)return ye(t,e,n.slice(0,-1));const[u,l]=_e(s);return Ee(t,e,{type:"APPLY",path:n.map(t=>t.toString()),argumentList:u},l).then(xe)},construct(i,o){he(r);const[s,a]=_e(o);return Ee(t,e,{type:"CONSTRUCT",path:n.map(t=>t.toString()),argumentList:s},a).then(xe)}});return function(t,e){const n=(ge.get(e)||0)+1;ge.set(e,n),de&&de.register(t,e,t)}(o,t),o}function _e(t){const e=t.map(Ie);return[e.map(t=>t[0]),(n=e.map(t=>t[1]),Array.prototype.concat.apply([],n))];var n}const me=new WeakMap;function ve(t,e){return me.set(t,e),t}function Ie(t){for(const[e,n]of le)if(n.canHandle(t)){const[i,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},r]}return[{type:"RAW",value:t},me.get(t)||[]]}function xe(t){switch(t.type){case"HANDLER":return le.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Ee(t,e,n,i){return new Promise(r=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(o,r),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),i)})}var Ne=Uint8Array,we=Uint16Array,Ce=Int32Array,Se=new Ne([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),be=new Ne([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Le=new Ne([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Oe=function(t,e){for(var n=new we(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new Ce(n[30]);for(i=1;i<30;++i)for(var o=n[i];o<n[i+1];++o)r[o]=o-n[i]<<5|i;return{b:n,r:r}},Te=Oe(Se,2),Pe=Te.b,Re=Te.r;Pe[28]=258,Re[258]=28;for(var Me=Oe(be,0).b,De=new we(32768),Ae=0;Ae<32768;++Ae){var Fe=(43690&Ae)>>1|(21845&Ae)<<1;De[Ae]=((65280&(Fe=(61680&(Fe=(52428&Fe)>>2|(13107&Fe)<<2))>>4|(3855&Fe)<<4))>>8|(255&Fe)<<8)>>1}var Ge=function(t,e,n){for(var i=t.length,r=0,o=new we(e);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new we(e);for(r=1;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;if(n){s=new we(1<<e);var u=15-e;for(r=0;r<i;++r)if(t[r])for(var l=r<<4|t[r],c=e-t[r],p=a[t[r]-1]++<<c,h=p|(1<<c)-1;p<=h;++p)s[De[p]>>u]=l}else for(s=new we(i),r=0;r<i;++r)t[r]&&(s[r]=De[a[t[r]-1]++]>>15-t[r]);return s},Ve=new Ne(288);for(Ae=0;Ae<144;++Ae)Ve[Ae]=8;for(Ae=144;Ae<256;++Ae)Ve[Ae]=9;for(Ae=256;Ae<280;++Ae)Ve[Ae]=7;for(Ae=280;Ae<288;++Ae)Ve[Ae]=8;var qe=new Ne(32);for(Ae=0;Ae<32;++Ae)qe[Ae]=5;var Be=Ge(Ve,9,1),ze=Ge(qe,5,1),Ue=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},ke=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},Xe=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Ye=function(t){return(t+7)/8|0},je=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new Ne(t.subarray(e,n))},He=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],We=function(t,e,n){var i=new Error(e||He[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,We),!n)throw i;return i},Je=new Ne(0),Ke=function(t,e){return t[e]|t[e+1]<<8},Qe=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},$e=function(t,e){return Qe(t,e)+4294967296*Qe(t,e+4)},Ze=function(){function t(t,e){"function"==typeof t&&(e=t,t={}),this.ondata=e;var n=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new Ne(32768),this.p=new Ne(0),n&&this.o.set(n)}return t.prototype.e=function(t){if(this.ondata||We(5),this.d&&We(4),this.p.length){if(t.length){var e=new Ne(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length),this.p=e}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var e=this.s.b,n=function(t,e,n,i){var r=t.length;if(!r||e.f&&!e.l)return n||new Ne(0);var o=!n,s=o||2!=e.i,a=e.i;o&&(n=new Ne(3*r));var u=function(t){var e=n.length;if(t>e){var i=new Ne(Math.max(2*e,t));i.set(n),n=i}},l=e.f||0,c=e.p||0,p=e.b||0,h=e.l,f=e.d,g=e.m,d=e.n,y=8*r;do{if(!h){l=ke(t,c,1);var _=ke(t,c+1,3);if(c+=3,!_){var m=t[(O=Ye(c)+4)-4]|t[O-3]<<8,v=O+m;if(v>r){a&&We(0);break}s&&u(p+m),n.set(t.subarray(O,v),p),e.b=p+=m,e.p=c=8*v,e.f=l;continue}if(1==_)h=Be,f=ze,g=9,d=5;else if(2==_){var I=ke(t,c,31)+257,x=ke(t,c+10,15)+4,E=I+ke(t,c+5,31)+1;c+=14;for(var N=new Ne(E),w=new Ne(19),C=0;C<x;++C)w[Le[C]]=ke(t,c+3*C,7);c+=3*x;var S=Ue(w),b=(1<<S)-1,L=Ge(w,S,1);for(C=0;C<E;){var O,T=L[ke(t,c,b)];if(c+=15&T,(O=T>>4)<16)N[C++]=O;else{var P=0,R=0;for(16==O?(R=3+ke(t,c,3),c+=2,P=N[C-1]):17==O?(R=3+ke(t,c,7),c+=3):18==O&&(R=11+ke(t,c,127),c+=7);R--;)N[C++]=P}}var M=N.subarray(0,I),D=N.subarray(I);g=Ue(M),d=Ue(D),h=Ge(M,g,1),f=Ge(D,d,1)}else We(1);if(c>y){a&&We(0);break}}s&&u(p+131072);for(var A=(1<<g)-1,F=(1<<d)-1,G=c;;G=c){var V=(P=h[Xe(t,c)&A])>>4;if((c+=15&P)>y){a&&We(0);break}if(P||We(2),V<256)n[p++]=V;else{if(256==V){G=c,h=null;break}var q=V-254;V>264&&(q=ke(t,c,(1<<(U=Se[C=V-257]))-1)+Pe[C],c+=U);var B=f[Xe(t,c)&F],z=B>>4;if(B||We(3),c+=15&B,D=Me[z],z>3){var U=be[z];D+=Xe(t,c)&(1<<U)-1,c+=U}if(c>y){a&&We(0);break}s&&u(p+131072);var k=p+q;if(p<D){var X=0-D,Y=Math.min(D,k);for(X+p<0&&We(3);p<Y;++p)n[p]=i[X+p]}for(;p<k;++p)n[p]=n[p-D]}}e.l=h,e.p=G,e.b=p,e.f=l,h&&(l=1,e.m=g,e.d=f,e.n=d)}while(!l);return p!=n.length&&o?je(n,0,p):n.subarray(0,p)}(this.p,this.s,this.o);this.ondata(je(n,e,this.s.b),this.d),this.o=je(n,this.s.b-32768),this.s.b=this.o.length,this.p=je(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),tn="undefined"!=typeof TextDecoder&&new TextDecoder,en=0;try{tn.decode(Je,{stream:!0}),en=1}catch(pn){}var nn=function(t){for(var e="",n=0;;){var i=t[n++],r=(i>127)+(i>223)+(i>239);if(n+r>t.length)return{s:e,r:je(t,n-1)};r?3==r?(i=((15&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|i>>10,56320|1023&i)):e+=String.fromCharCode(1&r?(31&i)<<6|63&t[n++]:(15&i)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(i)}},rn=function(){function t(t){this.ondata=t,en?this.t=new TextDecoder:this.p=Je}return t.prototype.push=function(t,e){if(this.ondata||We(5),e=!!e,this.t)return this.ondata(this.t.decode(t,{stream:!0}),e),void(e&&(this.t.decode().length&&We(8),this.t=null));this.p||We(4);var n=new Ne(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=nn(n),r=i.s,o=i.r;e?(o.length&&We(8),this.p=null):this.p=o,this.ondata(r,e)},t}();var on=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),sn=function(){function t(){var t=this;this.i=new Ze(function(e,n){t.ondata(null,e,n)})}return t.prototype.push=function(t,e){try{this.i.push(t,e)}catch(t){this.ondata(t,null,e)}},t.compression=8,t}(),an=function(){function t(t){this.onfile=t,this.k=[],this.o={0:on},this.p=Je}return t.prototype.push=function(t,e){var n=this;if(this.onfile||We(5),this.p||We(4),this.c>0){var i=Math.min(this.c,t.length),r=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(i)).length)return this.push(t,e)}else{var o=0,s=0,a=void 0,u=void 0;this.p.length?t.length?((u=new Ne(this.p.length+t.length)).set(this.p),u.set(t,this.p.length)):u=this.p:u=t;for(var l=u.length,c=this.c,p=c&&this.d,h=function(){var t=Qe(u,s);if(67324752==t){o=1,a=s,f.d=null,f.c=0;var e=Ke(u,s+6),i=Ke(u,s+8),r=2048&e,p=8&e,h=Ke(u,s+26),g=Ke(u,s+28);if(l>s+30+h+g){var d=[];f.k.unshift(d),o=2;var y,_=Qe(u,s+18),m=Qe(u,s+22),v=function(t,e){if(e){for(var n="",i=0;i<t.length;i+=16384)n+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return n}if(tn)return tn.decode(t);var r=nn(t),o=r.s;return(n=r.r).length&&We(8),o}(u.subarray(s+30,s+=30+h),!r),I=function(t,e,n,i,r,o,s){var a=4294967295==r,u=4294967295==o,l=e+n;if(a+u+(4294967295==s))for(;e+4<l;e+=4+Ke(t,e+2))if(1==Ke(t,e))return[a?$e(t,e+4+8*u):r,u?$e(t,e+4):o,s,1];return[r,o,s,0]}(u,s,g,0,_,m,0),x=I[0],E=I[1];p&&(x=-1-I[3]),s+=g,f.c=x;var N={name:v,compression:i,start:function(){if(N.ondata||We(5),x){var t=n.o[i];t||N.ondata(We(14,"unknown compression type "+i,1),null,!1),(y=x<0?new t(v):new t(v,x,E)).ondata=function(t,e,n){N.ondata(t,e,n)};for(var e=0,r=d;e<r.length;e++){y.push(r[e],!1)}n.k[0]==d&&n.c?n.d=y:y.push(Je,!0)}else N.ondata(null,Je,!0)},terminate:function(){y&&y.terminate&&y.terminate()}};x>=0&&(N.size=x,N.originalSize=E),f.onfile(N)}return"break"}if(c){if(134695760==t)return a=s+=12+(-2==c&&8),o=3,f.c=0,"break";if(33639248==t)return a=s-=4,o=3,f.c=0,"break"}},f=this;s<l-4;++s){if("break"===h())break}if(this.p=Je,c<0){var g=u.subarray(0,o?a-12-(-2==c&&8)-(134695760==Qe(u,a-16)&&4):s);p?p.push(g,!!o):this.k[+(2==o)].push(g)}if(2&o)return this.push(u.subarray(s),e);this.p=u.subarray(s)}e&&(this.c&&We(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}();let un,ln,cn,pn;const hn=1e6,fn={Point:0,MultiPoint:1,LineString:2,MultiLineString:3,Polygon:4,MultiPolygon:5,GeometryCollection:6};function gn(t,e){un={},ln=[],cn=0,pn=1,dn(t),pn=Math.min(pn,hn);const n=Math.ceil(Math.log(pn)/Math.LN10);for(const t of ln)e.writeStringField(1,t);return 2!==cn&&e.writeVarintField(2,cn),6!==n&&e.writeVarintField(3,n),"FeatureCollection"===t.type?e.writeMessage(4,In,t):"Feature"===t.type?e.writeMessage(5,xn,t):e.writeMessage(6,En,t),un=null,e.finish()}function dn(t){if("FeatureCollection"===t.type)for(const e of t.features)dn(e);else if("Feature"===t.type){null!==t.geometry&&dn(t.geometry);for(const e in t.properties)vn(e)}else if("Point"===t.type)mn(t.coordinates);else if("MultiPoint"===t.type)_n(t.coordinates);else if("GeometryCollection"===t.type)for(const e of t.geometries)dn(e);else if("LineString"===t.type)_n(t.coordinates);else if("Polygon"===t.type||"MultiLineString"===t.type)yn(t.coordinates);else if("MultiPolygon"===t.type)for(const e of t.coordinates)yn(e);for(const e in t)Ln(e,t.type)||vn(e)}function yn(t){for(const e of t)_n(e)}function _n(t){for(const e of t)mn(e)}function mn(t){cn=Math.max(cn,t.length);for(const e of t)for(;Math.round(e*pn)/pn!==e&&pn<hn;)pn*=10}function vn(t){void 0===un[t]&&(un[t]=ln.push(t)-1)}function In(t,e){for(const n of t.features)e.writeMessage(1,xn,n);Nn(t,e,!0)}function xn(t,e){null!==t.geometry&&e.writeMessage(1,En,t.geometry),void 0!==t.id&&("number"==typeof t.id&&t.id%1==0?e.writeSVarintField(12,t.id):e.writeStringField(11,t.id)),t.properties&&Nn(t.properties,e),Nn(t,e,!0)}function En(t,e){e.writeVarintField(1,fn[t.type]);const n=t.coordinates;if("Point"===t.type)!function(t,e){const n=[];for(let e=0;e<cn;e++)n.push(Math.round(t[e]*pn));e.writePackedSVarint(3,n)}(n,e);else if("MultiPoint"===t.type)Cn(n,e);else if("LineString"===t.type)Cn(n,e);else if("MultiLineString"===t.type)Sn(n,e);else if("Polygon"===t.type)Sn(n,e,!0);else if("MultiPolygon"===t.type)!function(t,e){const n=t.length;if(1!==n||1!==t[0].length){const i=[n];for(const e of t){i.push(e.length);for(const t of e)i.push(t.length-1)}e.writePackedVarint(2,i)}const i=[];for(const e of t)for(const t of e)bn(i,t,!0);e.writePackedSVarint(3,i)}(n,e);else if("GeometryCollection"===t.type)for(const n of t.geometries)e.writeMessage(4,En,n);Nn(t,e,!0)}function Nn(t,e,n){const i=[];let r=0;for(const o in t)n&&Ln(o,t.type)||(e.writeMessage(13,wn,t[o]),i.push(un[o]),i.push(r++));e.writePackedVarint(n?15:14,i)}function wn(t,e){if(null===t)return;const n=typeof t;"string"===n?e.writeStringField(1,t):"boolean"===n?e.writeBooleanField(5,t):"object"===n?e.writeStringField(6,JSON.stringify(t)):"number"===n&&(t%1!=0?e.writeDoubleField(2,t):t>=0?e.writeVarintField(3,t):e.writeVarintField(4,-t))}function Cn(t,e){const n=[];bn(n,t),e.writePackedSVarint(3,n)}function Sn(t,e,n){if(1!==t.length){const i=[];for(const e of t)i.push(e.length-(n?1:0));e.writePackedVarint(2,i)}const i=[];for(const e of t)bn(i,e,n);e.writePackedSVarint(3,i)}function bn(t,e,n){const i=e.length-(n?1:0),r=new Array(cn).fill(0);for(let n=0;n<i;n++)for(let i=0;i<cn;i++){const o=Math.round(e[n][i]*pn)-r[i];t.push(o),r[i]+=o}}function Ln(t,e){return"type"===t||("FeatureCollection"===e?"features"===t:"Feature"===e?"id"===t||"properties"===t||"geometry"===t:"GeometryCollection"===e?"geometries"===t:"coordinates"===t)}const On=1/4294967296;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8");class Tn{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*On),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*On),!0),this.pos+=8}writeVarint(t){if((t=+t||0)>=0&&t<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=t);t>268435455||t<0?function(t,e){let n,i;t>=0?(n=t%4294967296|0,i=t/4294967296|0):(n=~(-t%4294967296),i=~(-t/4294967296),4294967295^n?n=n+1|0:(n=0,i=i+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn\'t fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){const n=(7&t)<<4;if(e.buf[e.pos++]|=n|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(i,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,n){for(let i,r,o=0;o<e.length;o++){if(i=e.charCodeAt(o),i>55295&&i<57344){if(!r){i>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):r=i;continue}if(i<56320){t[n++]=239,t[n++]=191,t[n++]=189,r=i;continue}i=r-55296<<10|i-56320|65536,r=null}else r&&(t[n++]=239,t[n++]=191,t[n++]=189,r=null);i<128?t[n++]=i:(i<2048?t[n++]=i>>6|192:(i<65536?t[n++]=i>>12|224:(t[n++]=i>>18|240,t[n++]=i>>12&63|128),t[n++]=i>>6&63|128),t[n++]=63&i|128)}return n}(this.buf,t,this.pos);const n=this.pos-e;n>=128&&Pn(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e),this.buf.set(t,this.pos),this.pos+=e}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const i=this.pos-n;i>=128&&Pn(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeMessage(t,e,n){this.writeTag(t,2),this.writeRawMessage(e,n)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Rn,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Mn,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Fn,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Dn,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,An,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Gn,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Vn,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,qn,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Bn,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Pn(t,e,n){const i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(i),n.buf.copyWithin(t+i,t,n.pos)}function Rn(t,e){const n=t.length;let i=e.buf,r=e.pos,o=e.length;for(let s=0;s<n;s++){let n=t[s];if(n<0||r+10>o)e.pos=r,e.writeVarint(n),i=e.buf,r=e.pos,o=e.length;else{for(;n>127;)i[r++]=n%128|128,n=Math.floor(n/128);i[r++]=n}}e.pos=r}function Mn(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n])}function Dn(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n])}function An(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n])}function Fn(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n])}function Gn(t,e){for(let n=0;n<t.length;n++)e.writeFixed32(t[n])}function Vn(t,e){for(let n=0;n<t.length;n++)e.writeSFixed32(t[n])}function qn(t,e){for(let n=0;n<t.length;n++)e.writeFixed64(t[n])}function Bn(t,e){for(let n=0;n<t.length;n++)e.writeSFixed64(t[n])}const zn={defaultTimezone:"Asia/Tokyo",langs:["de","en","es","fr","ja","ko","ne","pt-BR","th","zh-Hans","zh-Hant"]};function Un(t,e){let n,i;if(!Array.isArray(t)&&"string"!=typeof t)return!1;if(!Array.isArray(e))return-1!==t.indexOf(e);for(n=0,i=e.length;n<i;n++)if(-1===t.indexOf(e[n]))return!1;return!0}function kn(...t){const e=new Map;for(const n of t)for(const[t,i]of n)e.set(t,i);return e}function Xn(t){return Un(zn.langs.map(t=>t.replace("pt-BR","pt")),t=t.match(/^zh-(Hant|TW|HK|MO)/)?"zh-Hant":t.match(/^zh/)?"zh-Hans":t.substring(0,2))?t:void 0}function Yn(t){if(!t)throw new Error("coord is required");if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates;if(Array.isArray(t)&&t.length>=2&&void 0===t[0].length&&void 0===t[1].length)return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function jn(t,e,n){if(!l(n=n||{}))throw new Error("options is invalid");if(!0===n.final)return function(t,e){var n=jn(e,t);return n=(n+180)%360}(t,e);var i=Yn(t),r=Yn(e),o=a(i[0]),s=a(r[0]),u=a(i[1]),c=a(r[1]),p=Math.sin(s-o)*Math.cos(c),h=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-o);return function(t){if(null==t)throw new Error("radians is required");return t%(2*Math.PI)*180/Math.PI}(Math.atan2(p,h))}"undefined"!=typeof window&&window.addEventListener("touchstart",()=>{},{once:!0});var Hn,Wn,Jn,Kn,Qn,$n={exports:{}};function Zn(t,e,n){if(!l(n=n||{}))throw new Error("options is invalid");var i=n.units,r=Yn(t),o=Yn(e),u=a(o[1]-r[1]),c=a(o[0]-r[0]),p=a(r[1]),h=a(o[1]),f=Math.pow(Math.sin(u/2),2)+Math.pow(Math.sin(c/2),2)*Math.cos(p)*Math.cos(h);return s(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),i)}function ti(t){const e=function(t){if(!t)throw new Error("coords is required");if("Feature"===t.type&&null!==t.geometry)return t.geometry.coordinates;if(t.coordinates)return t.coordinates;if(Array.isArray(t))return t;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(t),n=t.properties.distances=[];let i,r,o,s=0,a=e[0];for(let t=0,u=e.length;t<u-1;t++){const u=a;a=e[t+1];const l=Zn(u,a);i=jn(u,a),r=((a[2]||0)-(u[2]||0))/l,o=Math.atan(r/1e3),n.push([s,i,r,o]),s+=l}n.push([s,i,r,o])}function ei(t,e){e.writeStringField(1,t.agency);for(const n of t.stops)e.writeMessage(2,(t,e)=>{e.writeStringField(1,t.id),e.writeStringField(2,t.name),e.writePackedDouble(3,t.coord)},n);for(const n of t.routes)e.writeMessage(3,(t,e)=>{e.writeStringField(1,t.id),t.shortName&&e.writeStringField(2,t.shortName),t.longName&&e.writeStringField(3,t.longName),t.color&&e.writeStringField(4,t.color),t.textColor&&e.writeStringField(5,t.textColor);for(const n of t.shapes)e.writeStringField(6,n)},n);for(const n of t.trips)e.writeMessage(4,(t,e)=>{e.writeStringField(1,t.id),e.writeStringField(2,t.route),e.writeStringField(3,t.shape),e.writePackedVarint(4,t.departureTimes);for(const n of t.stops)e.writeStringField(5,n);e.writePackedVarint(6,t.stopSequences);for(const n of t.headsigns)e.writeStringField(7,n)},n);return e.writeStringField(5,t.version),t.timezone&&e.writeStringField(6,t.timezone),e.finish()}function ni(t){const e=[""];let n=0,i="",r=!0;for(const o of t)\'"\'===o?(r&&o===i&&(e[n]+=o),r=!r):","===o&&r?e[++n]="":e[n]+=o,i=o;return e}!function(){if(Qn)return $n.exports;Qn=1;var t=(Wn||(Wn=1,Hn=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=(i-n)/2,u=0,l=a-1;u<a;l=u++){var c=e[n+2*u+0],p=e[n+2*u+1],h=e[n+2*l+1];p>o!=h>o&&r<(e[n+2*l+0]-c)*(o-p)/(h-p)+c&&(s=!s)}return s}),Hn),e=(Kn||(Kn=1,Jn=function(t,e,n,i){var r=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=i-n,u=0,l=a-1;u<a;l=u++){var c=e[u+n][0],p=e[u+n][1],h=e[l+n][1];p>o!=h>o&&r<(e[l+n][0]-c)*(o-p)/(h-p)+c&&(s=!s)}return s}),Jn);$n.exports=function(n,i,r,o){return i.length>0&&Array.isArray(i[0])?e(n,i,r,o):t(n,i,r,o)},$n.exports.nested=e,$n.exports.flat=t}();const ii=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];const ri={agency:class{read(t){const e=this,n=ni(t);if(void 0===e.agencyNameIndex)e.agencyNameIndex=n.indexOf("agency_name"),e.agencyTimezoneIndex=n.indexOf("agency_timezone");else{const t=n[e.agencyTimezoneIndex];void 0===e.name&&(e.name=n[e.agencyNameIndex],e.timezone=t)}}get result(){return{name:this.name,timezone:this.timezone}}},calendar:class{constructor(){this.rows=[]}read(t){const e=this,n=ni(t);void 0===e.serviceIdIndex?(e.serviceIdIndex=n.indexOf("service_id"),e.dayIndexes=ii.map(t=>n.indexOf(t)),e.startDateIndex=n.indexOf("start_date"),e.endDateIndex=n.indexOf("end_date")):e.rows.push({service:n[e.serviceIdIndex],days:e.dayIndexes.map(t=>n[t]),start:n[e.startDateIndex],end:n[e.endDateIndex]})}get result(){return this.rows}},calendar_dates:class{constructor(){this.rows=[]}read(t){const e=this,n=ni(t);void 0===e.serviceIdIndex?(e.serviceIdIndex=n.indexOf("service_id"),e.dateIndex=n.indexOf("date"),e.exceptionTypeIndex=n.indexOf("exception_type")):e.rows.push({service:n[e.serviceIdIndex],date:n[e.dateIndex],type:n[e.exceptionTypeIndex]})}get result(){return this.rows}},feed_info:class{constructor({lang:t}){this.lang=t}read(t){const e=this,n=ni(t);void 0===e.feedLangIndex?(e.feedLangIndex=n.indexOf("feed_lang"),e.feedVersionIndex=n.indexOf("feed_version")):(e.feedLang=n[e.feedLangIndex],e.feedVersion=n[e.feedVersionIndex])}get result(){const t=this;return{needTranslation:Xn(t.feedLang)!==t.lang,version:t.feedVersion}}},routes:class{constructor(){this.array=[]}read(t){const e=this,n=ni(t);if(void 0===e.routeIdIndex)e.routeIdIndex=n.indexOf("route_id"),e.routeShortNameIndex=n.indexOf("route_short_name"),e.routeLongNameIndex=n.indexOf("route_long_name"),e.routeColorIndex=n.indexOf("route_color"),e.routeTextColorIndex=n.indexOf("route_text_color");else{const t=n[e.routeColorIndex],i=n[e.routeTextColorIndex];e.array.push({id:n[e.routeIdIndex],shortName:n[e.routeShortNameIndex],longName:n[e.routeLongNameIndex],color:t?`#${t}`:void 0,textColor:i?`#${i}`:void 0})}}get result(){return this.array}},shapes:class{constructor({color:t}){this.color=t,this.lookup=new Map}read(t){const e=this,n=ni(t),i=e.lookup;if(void 0===e.shapeIdIndex)e.shapeIdIndex=n.indexOf("shape_id"),e.shapePtLatIdIndex=n.indexOf("shape_pt_lat"),e.shapePtLonIdIndex=n.indexOf("shape_pt_lon"),e.shapePtSequenceIndex=n.indexOf("shape_pt_sequence");else if(n.length>1){const t=n[e.shapeIdIndex];let r;i.has(t)?r=i.get(t):(r=[],i.set(t,r)),r.push([+n[e.shapePtLonIdIndex],+n[e.shapePtLatIdIndex],+n[e.shapePtSequenceIndex]])}}get result(){const t=this,e=[];for(const[n,i]of t.lookup.entries()){const o=r(i.sort((t,e)=>t[2]-e[2]),{id:n,type:0,color:t.color,width:2});for(const t of i)t.pop();ti(o),e.push(o)}return e}},stops:class{constructor(){this.array=[]}read(t){const e=this,n=ni(t);void 0===e.stopIdIndex?(e.stopIdIndex=n.indexOf("stop_id"),e.stopNameIndex=n.indexOf("stop_name"),e.stopLatIndex=n.indexOf("stop_lat"),e.stopLonIndex=n.indexOf("stop_lon")):e.array.push({id:n[e.stopIdIndex],name:n[e.stopNameIndex],coord:[+n[e.stopLonIndex],+n[e.stopLatIndex]]})}get result(){return this.array}},stop_times:class{constructor(){this.lookup=new Map}read(t){const e=this,n=ni(t),i=e.lookup;if(void 0===e.tripIdIndex)e.tripIdIndex=n.indexOf("trip_id"),e.departureTimeIndex=n.indexOf("departure_time"),e.stopIdIndex=n.indexOf("stop_id"),e.stopSequenceIndex=n.indexOf("stop_sequence"),e.stopHeadsignIndex=n.indexOf("stop_headsign");else{const t=function(t){const e=t.split(":");return 1e3*(60*(60*(+e[0]-3)+ +e[1])+ +e[2])}(n[e.departureTimeIndex]);if(!Number.isFinite(t))return;const r=n[e.tripIdIndex];let o;i.has(r)?o=i.get(r):(o=[],i.set(r,o)),o.push([t,n[e.stopIdIndex],+n[e.stopSequenceIndex],n[e.stopHeadsignIndex]])}}get result(){const t=new Map;for(const[e,n]of this.lookup.entries())n.sort((t,e)=>t[2]-e[2]),t.set(e,{departureTimes:n.map(t=>t[0]),stops:n.map(t=>t[1]),stopSequences:n.map(t=>t[2]),stopHeadsigns:n.map(t=>t[3])});return t}},translations:class{constructor({lang:t}){this.lang=t,this.lookup=new Map}read(t){const e=this,n=ni(t),i=e.lookup;if(void 0===e.tableNameIndex)e.tableNameIndex=n.indexOf("table_name"),e.fieldNameIndex=n.indexOf("field_name"),e.recordIdIndex=n.indexOf("record_id"),e.fieldValueIndex=n.indexOf("field_value"),e.languageIndex=n.indexOf("language"),e.translationIndex=n.indexOf("translation");else{const t=n[e.languageIndex];let r;i.has(t)?r=i.get(t):(r=new Map,i.set(t,r)),r.set(`${n[e.tableNameIndex]}.${n[e.fieldNameIndex]}.${n[e.recordIdIndex]||n[e.fieldValueIndex]}`,n[e.translationIndex])}}get result(){const t=this,e=t.lookup,n=e.get("en")||new Map;if("en"===t.lang)return n;if(e.has(t.lang))return kn(n,e.get(t.lang));for(const[i,r]of e){const e=Xn(i);if(e===t.lang||"zh-Hans"===e&&"zh-Hant"===t.lang)return kn(n,r)}return n}},trips:class{constructor(){this.array=[]}read(t){const e=this,n=ni(t);void 0===e.tripIdIndex?(e.tripIdIndex=n.indexOf("trip_id"),e.serviceIdIndex=n.indexOf("service_id"),e.routeIdIndex=n.indexOf("route_id"),e.shapeIdIndex=n.indexOf("shape_id"),e.headsignIndex=n.indexOf("trip_headsign")):e.array.push({id:n[e.tripIdIndex],service:n[e.serviceIdIndex],route:n[e.routeIdIndex],shape:n[e.shapeIdIndex],headsign:n[e.headsignIndex]})}get result(){return this.array}}},oi=Object.keys(ri);function si(t,e,n){const r=t,s=new Map;for(const{id:t,name:o,coord:a}of e)r.push(i(a,{type:2,name:n&&(n.get(`stops.stop_name.${t}`)||n.get(`stops.stop_name.${o}`))||o})),s.has(o)?s.get(o).push(a):s.set(o,[a]);for(const t of[14,15,16,17,18]){const e=.1*Math.pow(2,14-t);for(const n of s.values()){const o=ee(...n.map(t=>Jt(i(t),e/4)));o.properties={type:1,outlineColor:"#000000",width:2,color:"#FFFFFF",zoom:t},r.push(o)}}return o(r)}function ai(t,e){return t.map(({id:t,name:n,coord:i})=>({id:t,name:e&&(e.get(`stops.stop_name.${t}`)||e.get(`stops.stop_name.${n}`))||n,coord:i}))}function ui(t,e,n){const i=new Map;for(const{route:t,shape:n}of e)i.has(t)?i.get(t).add(n):i.set(t,new Set([n]));return t.map(({id:t,shortName:e,longName:r,color:o,textColor:s})=>({id:t,shortName:n&&(n.get(`routes.route_short_name.${t}`)||n.get(`routes.route_short_name.${e}`))||e,longName:n&&(n.get(`routes.route_long_name.${t}`)||n.get(`routes.route_long_name.${r}`))||r,color:o,textColor:s,shapes:Array.from((i.get(t)||new Set).values())}))}function li(t,e=new Set,n=[new Set,new Set],i,r){const o=e.union(n[0]).difference(n[1]),s=[];for(const{id:e,service:n,route:a,shape:u,headsign:l}of t)if(o.has(n)){const{departureTimes:t,stops:n,stopSequences:o,stopHeadsigns:c}=i.get(e),p=[];if(new Set(c).size>1)for(const t of c)p.push(r&&r.get(`stop_times.stop_headsign.${t}`)||t);else l?p.push(r&&(r.get(`trips.trip_headsign.${e}`)||r.get(`trips.trip_headsign.${l}`))||l):c[0]&&p.push(r&&r.get(`stop_times.stop_headsign.${c[0]}`)||c[0]);s.push({id:e,route:a,shape:u,departureTimes:t,stops:n,stopSequences:o,headsigns:p})}return s}function ci(t,e,n){return new Promise((e,i)=>{fetch(t.gtfsUrl).then(r=>{const o={},s=r.body.getReader(),a=new an(e=>{const r=e.name.split(".")[0];if(Un(oi,r)){let s="";const a=new ri[r]({lang:n,color:t.color}),u=new rn((t,e)=>{const n=t.split(/\\r?\\n/);n.length>1&&(a.read(s+n[0]),s="");for(let t=1;t<n.length-1;t++)a.read(n[t]);s+=n[n.length-1],e&&(s&&a.read(s),o[r]=a.result)});e.ondata=(t,e,n)=>{if(t)i(t);else try{u.push(e,n)}catch(t){i(t)}},e.start()}});return a.register(sn),s.read().then(function t({done:n,value:i}){if(n)return a.push(new Uint8Array(0),!0),void e(o);a.push(i),s.read().then(t)})})}).then(t=>{const n=t.agency||{},i=function(t){if(t)try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).resolvedOptions().timeZone}catch(t){}return zn.defaultTimezone}(n.timezone),{date:r,day:o}=function(t,e){const n=new Date(new Date(t).toLocaleString("en-US",{timeZone:e})),i=n.getHours();return i<3&&n.setHours(i-24),{date:`${n.getFullYear()}${`0${n.getMonth()+1}`.slice(-2)}${`0${n.getDate()}`.slice(-2)}`,day:n.getDay()}}(e,i),s=function(t=[],e,n){const i=new Set;for(const r of t)e>=r.start&&e<=r.end&&"1"===r.days[n]&&i.add(r.service);return i}(t.calendar,r,o),a=function(t=[],e){const n=new Set,i=new Set;for(const r of t)r.date===e&&("1"===r.type?n:i).add(r.service);return[n,i]}(t.calendar_dates,r),u=t.feed_info&&t.feed_info.needTranslation&&t.translations,l=si(t.shapes,t.stops,u),c={agency:n.name,timezone:i,version:t.feed_info?t.feed_info.version:"N/A",stops:ai(t.stops,u),routes:ui(t.routes,t.trips,u),trips:li(t.trips,s,a,t.stop_times,u)};return[gn(l,new Tn),ei(c,new Tn)]})}ce({load:(t,e,n,i)=>ci(t,e,n).then(t=>i(ve(t,t.map(({buffer:t})=>t))))})});\n'],{type:"text/javascript"})),r=new Worker(n),s=mG(r);return new Promise(n=>{s.load(e,t,i,TG(e=>{s[lG](),r.terminate(),n(Object.assign({featureCollection:OG(new UH(e[0]))},new UH(e[1]).readFields((e,t,i)=>{1===e&&(t.agency=i.readString()),2===e&&t.stops.push(i.readFields((e,t,i)=>{1===e?t.id=i.readString():2===e?t.name=i.readString():3===e&&(t.coord=i.readPackedDouble())},{},i.readVarint()+i.pos)),3===e&&t.routes.push(i.readFields((e,t,i)=>{1===e?t.id=i.readString():2===e?t.shortName=i.readString():3===e?t.longName=i.readString():4===e?t.color=i.readString():5===e?t.textColor=i.readString():6===e&&t.shapes.push(i.readString())},{shapes:[]},i.readVarint()+i.pos)),4===e&&t.trips.push(i.readFields((e,t,i)=>{1===e?t.id=i.readString():2===e?t.route=i.readString():3===e?t.shape=i.readString():4===e?i.readPackedVarint(t.departureTimes,!0):5===e?t.stops.push(i.readString()):6===e?i.readPackedVarint(t.stopSequences,!0):7===e&&t.headsigns.push(i.readString())},{departureTimes:[],stops:[],stopSequences:[],headsigns:[]},i.readVarint()+i.pos)),5===e&&(t.version=i.readString()),6===e&&(t.timezone=i.readString())},{stops:[],routes:[],trips:[]})))}))})}function XH(e){return fetch(e).then(e=>e.arrayBuffer()).then(e=>NH.transit_realtime.FeedMessage.decode(new Uint8Array(e)))}function $H(e,t){if(!("string"==typeof(i=e)||i instanceof String)||e.match(/acl:consumerKey/))return e;var i;const n=t&&t[s.odptHosts[new URL(e).host]];return n?`${e}${e.match(/\?/)?"&":"?"}acl:consumerKey=${n}`:e}const ZH=H(navigator.userAgent,"Windows");class YH{constructor(e){this._options=Object.assign({modal:!1},e)}setTitle(e){const t=this,i=t._container;return t._title=e,i&&(i.querySelector("#panel-title").innerHTML=e),t}setHTML(e){const t=this,i=t._container;return t._html=e,i&&(i.querySelector("#panel-content").innerHTML=e),t}setButtons(e){const t=this,i=t._container;if(t._buttons=e,i){const t=i.querySelector("#panel-button-group"),n=t.children;for(let e=n.length-1;e>0;e--)t.removeChild(n[e]);for(const i of e||[])t.appendChild(i)}return t}addTo(e){const t=this,i=t._options;if(t._map=e,i.modal){(t._background=Q("div",{className:"modal-panel-background closed"},e.container)).addEventListener("click",()=>{t.remove()})}const n=t._container=Q("div",{className:`panel closed ${i.className||""}`,innerHTML:['<div id="panel-header">','<div id="panel-title"></div>','<div id="panel-button-group" class="panel-button-group">',`<div id="panel-button" class="${i.modal?"close-button":"slide-button"}"></div>`,"</div>","</div>",`<div id="panel-body"${ZH?' class="windows"':""}>`,'<div id="panel-content"></div>',"</div>"].join("")},e.container);return t._title&&t.setTitle(t._title),t._html&&t.setHTML(t._html),t._buttons&&t.setButtons(t._buttons),i.modal?n.querySelector("#panel-button").addEventListener("click",()=>{t.remove()}):(n.querySelector("#panel-header").addEventListener("click",()=>{const e=n.classList;e.contains("collapsed")?e.remove("collapsed"):e.add("collapsed")}),n.querySelector("#panel-header").style.cursor="pointer"),requestAnimationFrame(()=>{i.modal&&(t._background.classList.remove("closed"),n.style.height=`min(calc(100% - 10px), ${n.querySelector("#panel-content").offsetHeight+50}px)`),n.classList.remove("closed")}),t}remove(){const e=this,t=e._options,i=e._background,n=e._container;return t.modal&&i.classList.add("closed"),n.style.removeProperty("height"),n.classList.add("closed"),setTimeout(()=>{t.modal&&(i.parentNode.removeChild(i),delete e._background),n.parentNode.removeChild(n),delete e._container,delete e._map},300),e}isOpen(){return!!this._map}}class JH extends YH{constructor(e){super(Object.assign({className:"about-panel",modal:!0},e))}addTo(e){return super.addTo(e).setTitle(e.dict.about).updateContent()}updateContent(){const e=this;if(e.isOpen()){const{dict:t,gtfs:i,lastDynamicUpdate:n}=e._map,r=[...i.values()];e.setHTML([t.description.replace(/<h3>.*<\/h3>/,""),`<p>${s.copyright}</p>`,`<div class="card-title">${t["static-update"]}</div>`,`<div class="card-body">${s.lastStaticUpdate}</div>`,`<div class="card-title">${t["dynamic-update"]}</div>`,`<div class="card-body">${[...Object.entries(n).filter(([e,i])=>i&&t[e.toLowerCase()]).map(([e,i])=>`${i} (${t[e.toLowerCase()]})`),...r.filter(({date:e})=>e).map(({date:e,agency:t})=>`${e} (${t})`)].join("<br>")}</div>`,r.length>0?[`<div class="card-title">${t["gtfs-feed-version"]}</div>`,'<div class="card-body">',r.map(({version:e,agency:t})=>`${e} (${t})`).join("<br>"),"</div>"].join(""):""].join(""))}return e}}class KH extends YH{constructor(e){super(Object.assign({className:"bus-panel"},e))}addTo(e){const t=this,i=[],n=[],r=t._options.object,s=e.gtfs.get(r.gtfsId),o=r.trip,{route:a,stops:l,departureTimes:c}=o,u=s.routes.get(a).color,h=s.stops;for(let e=0,t=l.length;e<t;e++){const t=h.get(l[e]),n=X(c[e]);i.push(['<div class="busstop-row">',`<div class="busstop-title-box">${t.name}</div>`,`<div class="busstop-time-box">${n}</div>`,"</div>"].join(""))}super.addTo(e),t.updateHeader(),t.setHTML(['<div id="timetable-content">',...i,"</div>",'<svg id="busroute-mark"></svg>','<svg id="bus-mark"></svg>'].join(""));const d=t._container,p=d.querySelector("#panel-body");for(const e of d.querySelector("#timetable-content").children)n.push(e.offsetTop+e.getBoundingClientRect().height/2);return d.querySelector("#busroute-mark").innerHTML=[`<line stroke="${u||s.color}" stroke-width="10" x1="12" y1="${n[0]}" x2="12" y2="${n[n.length-1]}" stroke-linecap="round" />`].concat(n.map(e=>`<circle cx="12" cy="${e}" r="3" fill="#ffffff" />`)).join(""),function e(){const i=p.getBoundingClientRect().height,s=r.sectionIndex+r.sectionLength,o=j(n[Math.max(0,s-1)],n[s],r._t),a=performance.now()%1500/1500;d.querySelector("#bus-mark").innerHTML=`<circle cx="22" cy="${o}" r="${7+15*a}" fill="#ffffff" opacity="${1-a}" /><circle cx="22" cy="${o}" r="7" fill="#ffffff" />`,void 0!==t._scrollTop&&t._scrollTop!==p.scrollTop||(t._scrollTop=p.scrollTop=Math.round(o-i/2+4)),t._container&&requestAnimationFrame(e)}(),t}updateHeader(){const e=this._options.object,t=this._map.gtfs.get(e.gtfsId),{route:i,headsigns:n}=e.trip,{shortName:r,longName:s,color:o,textColor:a}=t.routes.get(i),l=[a?`color: ${a};`:"",o?`background-color: ${o};`:""].join(" ");this.setTitle(['<div class="desc-header">',`<div style="background-color: ${t.color};"></div>`,'<div><div class="desc-first-row">',t.agency,void 0!==e.stop?'<span class="realtime-icon"></span>':"",'</div><div class="desc-second-row">',r||s?` <span class="bus-route-label" style="${l}">${r||s}</span> `:"",0===n.length?s:n[1===n.length?0:e.sectionIndex],"</div></div></div>"].join(""))}reset(){delete this._scrollTop}}class QH extends YH{constructor(e){super(Object.assign({className:"layer-panel",modal:!0},e))}addTo(e){const t=this,i=t._options.layers;super.addTo(e).setTitle(e.dict.layers).setHTML(i.map(t=>[`<div id="${t.getId()}-layer" class="layer-row">`,'<div class="layer-icon"></div>',`<div>${t.getName(e.lang)}</div>`,"</div>"].join("")).join(""));for(const e of i){const i=t._container.querySelector(`#${e.getId()}-layer .layer-icon`),n=i.classList;Object.assign(i.style,e.getIconStyle()),e.isEnabled()&&n.add("layer-icon-enabled"),i.addEventListener("click",()=>{e.isEnabled()?(n.remove("layer-icon-enabled"),e.disable()):(n.add("layer-icon-enabled"),e.enable())})}return t}}class eW{constructor(e){this._object=e.object}addTo(e){const t=this,i=e.dict,n=t._object,r="station"===n.type,o=n instanceof nt?"train":"flight",a=r?function(e){const t="underground"===e.layer,i=e.stations.find(({altitude:e})=>t?e<0:!(e<0));return(i||e.stations[0]).id}(n):n.id,l=t._container=Q("div",{className:"share-panel closed"},e.container);return(t._button=Q("button",{className:"share-button",innerHTML:r?i["share-station"]:i["share-this"].replace("$1",i[o])},l)).onclick=()=>{window.navigator.share({title:r?i["my-station"]:i.my.replace("$1",i[o]),text:r?i["on-station"]:i["on-this"].replace("$1",i[o]),url:`${s.shareUrl}?selection=${a}`}).then(()=>{ee(e.container,i.shared)}).catch(()=>{})},t._map=e,requestAnimationFrame(()=>{l.classList.remove("closed")}),t}remove(){const e=this,t=e._container;return t.classList.add("closed"),setTimeout(()=>{t.parentNode.removeChild(t),delete e._container,delete e._map},300),e}}function tW(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function iW(e={},t={}){const i=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>i.indexOf(e)<0).forEach(i=>{void 0===e[i]?e[i]=t[i]:tW(t[i])&&tW(e[i])&&Object.keys(t[i]).length>0&&iW(e[i],t[i])})}const nW={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function rW(){const e="undefined"!=typeof document?document:{};return iW(e,nW),e}const sW={document:nW,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function oW(){const e="undefined"!=typeof window?window:{};return iW(e,sW),e}function aW(e,t=0){return setTimeout(e,t)}function lW(){return Date.now()}function cW(e,t="x"){const i=oW();let n,r,s;const o=function(e){const t=oW();let i;return t.getComputedStyle&&(i=t.getComputedStyle(e,null)),!i&&e.currentStyle&&(i=e.currentStyle),i||(i=e.style),i}(e);return i.WebKitCSSMatrix?(r=o.transform||o.webkitTransform,r.split(",").length>6&&(r=r.split(", ").map(e=>e.replace(",",".")).join(", ")),s=new i.WebKitCSSMatrix("none"===r?"":r)):(s=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),n=s.toString().split(",")),"x"===t&&(r=i.WebKitCSSMatrix?s.m41:16===n.length?parseFloat(n[12]):parseFloat(n[4])),"y"===t&&(r=i.WebKitCSSMatrix?s.m42:16===n.length?parseFloat(n[13]):parseFloat(n[5])),r||0}function uW(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function hW(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function dW(...e){const t=Object(e[0]);for(let i=1;i<e.length;i+=1){const n=e[i];if(null!=n&&!hW(n)){const e=Object.keys(Object(n)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e);for(let i=0,r=e.length;i<r;i+=1){const r=e[i],s=Object.getOwnPropertyDescriptor(n,r);void 0!==s&&s.enumerable&&(uW(t[r])&&uW(n[r])?n[r].__swiper__?t[r]=n[r]:dW(t[r],n[r]):!uW(t[r])&&uW(n[r])?(t[r]={},n[r].__swiper__?t[r]=n[r]:dW(t[r],n[r])):t[r]=n[r])}}}return t}function pW(e,t,i){e.style.setProperty(t,i)}function fW({swiper:e,targetPosition:t,side:i}){const n=oW(),r=-e.translate;let s,o=null;const a=e.params.speed;e.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(e.cssModeFrameID);const l=t>r?"next":"prev",c=(e,t)=>"next"===l&&e>=t||"prev"===l&&e<=t,u=()=>{s=(new Date).getTime(),null===o&&(o=s);const l=Math.max(Math.min((s-o)/a,1),0),h=.5-Math.cos(l*Math.PI)/2;let d=r+h*(t-r);if(c(d,t)&&(d=t),e.wrapperEl.scrollTo({[i]:d}),c(d,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:d})}),void n.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=n.requestAnimationFrame(u)};u()}function mW(e,t=""){const i=oW(),n=[...e.children];return i.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function gW(e){try{return void console.warn(e)}catch(e){}}function _W(e,t=[]){const i=document.createElement(e);return i.classList.add(...Array.isArray(t)?t:function(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}(t)),i}function yW(e,t){return oW().getComputedStyle(e,null).getPropertyValue(t)}function vW(e){let t,i=e;if(i){for(t=0;null!==(i=i.previousSibling);)1===i.nodeType&&(t+=1);return t}}function xW(e,t){const i=[];let n=e.parentElement;for(;n;)t?n.matches(t)&&i.push(n):i.push(n),n=n.parentElement;return i}function bW(e,t,i){const n=oW();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function wW(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function TW(e,t=""){e.innerHTML="undefined"!=typeof trustedTypes?trustedTypes.createPolicy("html",{createHTML:e=>e}).createHTML(t):t}let SW,EW,AW;function MW(){return SW||(SW=function(){const e=oW(),t=rW();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),SW}function IW(e={}){return EW||(EW=function({userAgent:e}={}){const t=MW(),i=oW(),n=i.navigator.platform,r=e||i.navigator.userAgent,s={ios:!1,android:!1},o=i.screen.width,a=i.screen.height,l=r.match(/(Android);?[\s\/]+([\d.]+)?/);let c=r.match(/(iPad)(?!\1).*OS\s([\d_]+)/);const u=r.match(/(iPod)(.*OS\s([\d_]+))?/),h=!c&&r.match(/(iPhone\sOS|iOS)\s([\d_]+)/),d="Win32"===n;let p="MacIntel"===n;return!c&&p&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${a}`)>=0&&(c=r.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),p=!1),l&&!d&&(s.os="android",s.android=!0),(c||h||u)&&(s.os="ios",s.ios=!0),s}(e)),EW}function CW(){return AW||(AW=function(){const e=oW(),t=IW();let i=!1;function n(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(n()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,n]=t.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e));i=e<16||16===e&&n<2}}const r=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),s=n();return{isSafari:i||s,needPerspectiveFix:i,need3dFix:s||r&&t.ios,isWebView:r}}()),AW}var PW={on(e,t,i){const n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;const r=i?"unshift":"push";return e.split(" ").forEach(e=>{n.eventsListeners[e]||(n.eventsListeners[e]=[]),n.eventsListeners[e][r](t)}),n},once(e,t,i){const n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;function r(...i){n.off(e,r),r.__emitterProxy&&delete r.__emitterProxy,t.apply(n,i)}return r.__emitterProxy=t,n.on(e,r,i)},onAny(e,t){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;const n=t?"unshift":"push";return i.eventsAnyListeners.indexOf(e)<0&&i.eventsAnyListeners[n](e),i},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const i=t.eventsAnyListeners.indexOf(e);return i>=0&&t.eventsAnyListeners.splice(i,1),t},off(e,t){const i=this;return!i.eventsListeners||i.destroyed?i:i.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?i.eventsListeners[e]=[]:i.eventsListeners[e]&&i.eventsListeners[e].forEach((n,r)=>{(n===t||n.__emitterProxy&&n.__emitterProxy===t)&&i.eventsListeners[e].splice(r,1)})}),i):i},emit(...e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsListeners)return t;let i,n,r;"string"==typeof e[0]||Array.isArray(e[0])?(i=e[0],n=e.slice(1,e.length),r=t):(i=e[0].events,n=e[0].data,r=e[0].context||t),n.unshift(r);return(Array.isArray(i)?i:i.split(" ")).forEach(e=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach(t=>{t.apply(r,[e,...n])}),t.eventsListeners&&t.eventsListeners[e]&&t.eventsListeners[e].forEach(e=>{e.apply(r,n)})}),t}};const LW=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};const RW=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};const OW=(e,t)=>{if(!e||e.destroyed||!e.params)return;const i=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(i){let t=i.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(i.shadowRoot?t=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(t=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&!t.lazyPreloaderManaged&&t.remove())})),t&&!t.lazyPreloaderManaged&&t.remove()}},DW=(e,t)=>{if(!e.slides[t])return;const i=e.slides[t].querySelector('[loading="lazy"]');i&&i.removeAttribute("loading")},BW=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const i=e.slides.length;if(!i||!t||t<0)return;t=Math.min(t,i);const n="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),r=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const i=r,s=[i-t];return s.push(...Array.from({length:t}).map((e,t)=>i+n+t)),void e.slides.forEach((t,i)=>{s.includes(t.column)&&DW(e,i)})}const s=r+n-1;if(e.params.rewind||e.params.loop)for(let n=r-t;n<=s+t;n+=1){const t=(n%i+i)%i;(t<r||t>s)&&DW(e,t)}else for(let n=Math.max(r-t,0);n<=Math.min(s+t,i-1);n+=1)n!==r&&(n>s||n<r)&&DW(e,n)};var FW={updateSize:function(){const e=this;let t,i;const n=e.el;t=null!=e.params.width?e.params.width:n.clientWidth,i=null!=e.params.height?e.params.height:n.clientHeight,0===t&&e.isHorizontal()||0===i&&e.isVertical()||(t=t-parseInt(yW(n,"padding-left")||0,10)-parseInt(yW(n,"padding-right")||0,10),i=i-parseInt(yW(n,"padding-top")||0,10)-parseInt(yW(n,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(i)&&(i=0),Object.assign(e,{width:t,height:i,size:e.isHorizontal()?t:i}))},updateSlides:function(){const e=this;function t(t,i){return parseFloat(t.getPropertyValue(e.getDirectionLabel(i))||0)}const i=e.params,{wrapperEl:n,slidesEl:r,rtlTranslate:s,wrongRTL:o}=e,a=e.virtual&&i.virtual.enabled,l=a?e.virtual.slides.length:e.slides.length,c=mW(r,`.${e.params.slideClass}, swiper-slide`),u=a?e.virtual.slides.length:c.length;let h=[];const d=[],p=[];let f=i.slidesOffsetBefore;"function"==typeof f&&(f=i.slidesOffsetBefore.call(e));let m=i.slidesOffsetAfter;"function"==typeof m&&(m=i.slidesOffsetAfter.call(e));const g=e.snapGrid.length,_=e.slidesGrid.length,y=e.size-f-m;let v=i.spaceBetween,x=-f,b=0,w=0;if(void 0===y)return;"string"==typeof v&&v.indexOf("%")>=0?v=parseFloat(v.replace("%",""))/100*y:"string"==typeof v&&(v=parseFloat(v)),e.virtualSize=-v-f-m,c.forEach(e=>{s?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),i.centeredSlides&&i.cssMode&&(pW(n,"--swiper-centered-offset-before",""),pW(n,"--swiper-centered-offset-after","")),i.cssMode&&(pW(n,"--swiper-slides-offset-before",`${f}px`),pW(n,"--swiper-slides-offset-after",`${m}px`));const T=i.grid&&i.grid.rows>1&&e.grid;let S;T?e.grid.initSlides(c):e.grid&&e.grid.unsetSlides();const E="auto"===i.slidesPerView&&i.breakpoints&&Object.keys(i.breakpoints).filter(e=>void 0!==i.breakpoints[e].slidesPerView).length>0;for(let n=0;n<u;n+=1){S=0;const r=c[n];if(!r||(T&&e.grid.updateSlide(n,r,c),"none"!==yW(r,"display"))){if(a&&"auto"===i.slidesPerView)i.virtual.slidesPerViewAutoSlideSize&&(S=i.virtual.slidesPerViewAutoSlideSize),S&&r&&(i.roundLengths&&(S=Math.floor(S)),r.style[e.getDirectionLabel("width")]=`${S}px`);else if("auto"===i.slidesPerView){E&&(r.style[e.getDirectionLabel("width")]="");const n=getComputedStyle(r),s=r.style.transform,o=r.style.webkitTransform;if(s&&(r.style.transform="none"),o&&(r.style.webkitTransform="none"),i.roundLengths)S=e.isHorizontal()?bW(r,"width"):bW(r,"height");else{const e=t(n,"width"),i=t(n,"padding-left"),s=t(n,"padding-right"),o=t(n,"margin-left"),a=t(n,"margin-right"),l=n.getPropertyValue("box-sizing");if(l&&"border-box"===l)S=e+o+a;else{const{clientWidth:t,offsetWidth:n}=r;S=e+i+s+o+a+(n-t)}}s&&(r.style.transform=s),o&&(r.style.webkitTransform=o),i.roundLengths&&(S=Math.floor(S))}else S=(y-(i.slidesPerView-1)*v)/i.slidesPerView,i.roundLengths&&(S=Math.floor(S)),r&&(r.style[e.getDirectionLabel("width")]=`${S}px`);r&&(r.swiperSlideSize=S),p.push(S),i.centeredSlides?(x=x+S/2+b/2+v,0===b&&0!==n&&(x=x-y/2-v),0===n&&(x=x-y/2-v),Math.abs(x)<.001&&(x=0),i.roundLengths&&(x=Math.floor(x)),w%i.slidesPerGroup===0&&h.push(x),d.push(x)):(i.roundLengths&&(x=Math.floor(x)),(w-Math.min(e.params.slidesPerGroupSkip,w))%e.params.slidesPerGroup===0&&h.push(x),d.push(x),x=x+S+v),e.virtualSize+=S+v,b=S,w+=1}}if(e.virtualSize=Math.max(e.virtualSize,y)+m,s&&o&&("slide"===i.effect||"coverflow"===i.effect)&&(n.style.width=`${e.virtualSize+v}px`),i.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+v}px`),T&&e.grid.updateWrapperSize(S,h),!i.centeredSlides){const t=i.snapToSlideEdge&&!i.loop&&("auto"===i.slidesPerView||"auto"!==i.slidesPerView&&i.slidesPerView%1!=0);let n=h.length;if(t){let e;if("auto"===i.slidesPerView){e=1;let t=0;for(let i=p.length-1;i>=0&&(t+=p[i]+(i<p.length-1?v:0),t<=y);i-=1)e=p.length-i}else e=Math.floor(i.slidesPerView);n=Math.max(u-e,0)}const r=[];for(let s=0;s<h.length;s+=1){let o=h[s];i.roundLengths&&(o=Math.floor(o)),t?s<=n&&r.push(o):h[s]<=e.virtualSize-y&&r.push(o)}h=r,Math.floor(e.virtualSize-y)-Math.floor(h[h.length-1])>1&&(t||h.push(e.virtualSize-y))}if(a&&i.loop){const t=p[0]+v;if(i.slidesPerGroup>1){const n=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/i.slidesPerGroup),r=t*i.slidesPerGroup;for(let e=0;e<n;e+=1)h.push(h[h.length-1]+r)}for(let n=0;n<e.virtual.slidesBefore+e.virtual.slidesAfter;n+=1)1===i.slidesPerGroup&&h.push(h[h.length-1]+t),d.push(d[d.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==v){const t=e.isHorizontal()&&s?"marginLeft":e.getDirectionLabel("marginRight");c.filter((e,t)=>!(i.cssMode&&!i.loop)||t!==c.length-1).forEach(e=>{e.style[t]=`${v}px`})}if(i.centeredSlides&&i.centeredSlidesBounds){let e=0;p.forEach(t=>{e+=t+(v||0)}),e-=v;const t=e>y?e-y:0;h=h.map(e=>e<=0?-f:e>t?t+m:e)}if(i.centerInsufficientSlides){let e=0;if(p.forEach(t=>{e+=t+(v||0)}),e-=v,e<y){const t=(y-e)/2;h.forEach((e,i)=>{h[i]=e-t}),d.forEach((e,i)=>{d[i]=e+t})}}if(Object.assign(e,{slides:c,snapGrid:h,slidesGrid:d,slidesSizesGrid:p}),i.centeredSlides&&i.cssMode&&!i.centeredSlidesBounds){pW(n,"--swiper-centered-offset-before",-h[0]+"px"),pW(n,"--swiper-centered-offset-after",e.size/2-p[p.length-1]/2+"px");const t=-e.snapGrid[0],i=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+t),e.slidesGrid=e.slidesGrid.map(e=>e+i)}if(u!==l&&e.emit("slidesLengthChange"),h.length!==g&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),d.length!==_&&e.emit("slidesGridLengthChange"),i.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(a||i.cssMode||"slide"!==i.effect&&"fade"!==i.effect)){const t=`${i.containerModifierClass}backface-hidden`,n=e.el.classList.contains(t);u<=i.maxBackfaceHiddenSlides?n||e.el.classList.add(t):n&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,i=[],n=t.virtual&&t.params.virtual.enabled;let r,s=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const o=e=>n?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(e=>{i.push(e)});else for(r=0;r<Math.ceil(t.params.slidesPerView);r+=1){const e=t.activeIndex+r;if(e>t.slides.length&&!n)break;i.push(o(e))}else i.push(o(t.activeIndex));for(r=0;r<i.length;r+=1)if(void 0!==i[r]){const e=i[r].offsetHeight;s=e>s?e:s}(s||0===s)&&(t.wrapperEl.style.height=`${s}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,i=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-i-e.cssOverflowAdjustment()},updateSlidesProgress:function(e=this&&this.translate||0){const t=this,i=t.params,{slides:n,rtlTranslate:r,snapGrid:s}=t;if(0===n.length)return;void 0===n[0].swiperSlideOffset&&t.updateSlidesOffset();let o=-e;r&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let a=i.spaceBetween;"string"==typeof a&&a.indexOf("%")>=0?a=parseFloat(a.replace("%",""))/100*t.size:"string"==typeof a&&(a=parseFloat(a));for(let e=0;e<n.length;e+=1){const l=n[e];let c=l.swiperSlideOffset;i.cssMode&&i.centeredSlides&&(c-=n[0].swiperSlideOffset);const u=(o+(i.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+a),h=(o-s[0]+(i.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+a),d=-(o-c),p=d+t.slidesSizesGrid[e],f=d>=0&&d<=t.size-t.slidesSizesGrid[e],m=d>=0&&d<t.size-1||p>1&&p<=t.size||d<=0&&p>=t.size;m&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e)),LW(l,m,i.slideVisibleClass),LW(l,f,i.slideFullyVisibleClass),l.progress=r?-u:u,l.originalProgress=r?-h:h}},updateProgress:function(e){const t=this;if(void 0===e){e=t&&t.translate&&t.translate*(t.rtlTranslate?-1:1)||0}const i=t.params,n=t.maxTranslate()-t.minTranslate();let{progress:r,isBeginning:s,isEnd:o,progressLoop:a}=t;const l=s,c=o;if(0===n)r=0,s=!0,o=!0;else{r=(e-t.minTranslate())/n;const i=Math.abs(e-t.minTranslate())<1,a=Math.abs(e-t.maxTranslate())<1;s=i||r<=0,o=a||r>=1,i&&(r=0),a&&(r=1)}if(i.loop){const i=t.getSlideIndexByData(0),n=t.getSlideIndexByData(t.slides.length-1),r=t.slidesGrid[i],s=t.slidesGrid[n],o=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);a=l>=r?(l-r)/o:(l+o-s)/o,a>1&&(a-=1)}Object.assign(t,{progress:r,progressLoop:a,isBeginning:s,isEnd:o}),(i.watchSlidesProgress||i.centeredSlides&&i.autoHeight)&&t.updateSlidesProgress(e),s&&!l&&t.emit("reachBeginning toEdge"),o&&!c&&t.emit("reachEnd toEdge"),(l&&!s||c&&!o)&&t.emit("fromEdge"),t.emit("progress",r)},updateSlidesClasses:function(){const e=this,{slides:t,params:i,slidesEl:n,activeIndex:r}=e,s=e.grid&&i.grid&&i.grid.rows>1,o=e=>mW(n,`.${i.slideClass}${e}, swiper-slide${e}`)[0];let a,l,c;if(e.virtual&&i.virtual.enabled)if(i.loop){let t=r-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),a=o(`[data-swiper-slide-index="${t}"]`)}else a=o(`[data-swiper-slide-index="${r}"]`);else s?(a=t.find(e=>e.column===r),c=t.find(e=>e.column===r+1),l=t.find(e=>e.column===r-1)):a=t[r];a&&(s||(c=function(e,t){const i=[];for(;e.nextElementSibling;){const n=e.nextElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(a,`.${i.slideClass}, swiper-slide`)[0],i.loop&&!c&&(c=t[0]),l=function(e,t){const i=[];for(;e.previousElementSibling;){const n=e.previousElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(a,`.${i.slideClass}, swiper-slide`)[0],i.loop&&0===!l&&(l=t[t.length-1]))),t.forEach(e=>{RW(e,e===a,i.slideActiveClass),RW(e,e===c,i.slideNextClass),RW(e,e===l,i.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,i=t.rtlTranslate?t.translate:-t.translate,{snapGrid:n,params:r,activeIndex:s,realIndex:o,snapIndex:a}=t;let l,c=e;const u=e=>{let i=e-t.virtual.slidesBefore;return i<0&&(i=t.virtual.slides.length+i),i>=t.virtual.slides.length&&(i-=t.virtual.slides.length),i};if(void 0===c&&(c=function(e){const{slidesGrid:t,params:i}=e,n=e.rtlTranslate?e.translate:-e.translate;let r;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?n>=t[e]&&n<t[e+1]-(t[e+1]-t[e])/2?r=e:n>=t[e]&&n<t[e+1]&&(r=e+1):n>=t[e]&&(r=e);return i.normalizeSlideIndex&&(r<0||void 0===r)&&(r=0),r}(t)),n.indexOf(i)>=0)l=n.indexOf(i);else{const e=Math.min(r.slidesPerGroupSkip,c);l=e+Math.floor((c-e)/r.slidesPerGroup)}if(l>=n.length&&(l=n.length-1),c===s&&!t.params.loop)return void(l!==a&&(t.snapIndex=l,t.emit("snapIndexChange")));if(c===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=u(c));const h=t.grid&&r.grid&&r.grid.rows>1;let d;if(t.virtual&&r.virtual.enabled)d=r.loop?u(c):c;else if(h){const e=t.slides.find(e=>e.column===c);let i=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(i)&&(i=Math.max(t.slides.indexOf(e),0)),d=Math.floor(i/r.grid.rows)}else if(t.slides[c]){const e=t.slides[c].getAttribute("data-swiper-slide-index");d=e?parseInt(e,10):c}else d=c;Object.assign(t,{previousSnapIndex:a,snapIndex:l,previousRealIndex:o,realIndex:d,previousIndex:s,activeIndex:c}),t.initialized&&BW(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(o!==d&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const i=this,n=i.params;let r=e.closest(`.${n.slideClass}, swiper-slide`);!r&&i.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!r&&e.matches&&e.matches(`.${n.slideClass}, swiper-slide`)&&(r=e)});let s,o=!1;if(r)for(let e=0;e<i.slides.length;e+=1)if(i.slides[e]===r){o=!0,s=e;break}if(!r||!o)return i.clickedSlide=void 0,void(i.clickedIndex=void 0);i.clickedSlide=r,i.clickedIndex=i.virtual&&i.params.virtual.enabled?parseInt(r.getAttribute("data-swiper-slide-index"),10):s,n.slideToClickedSlide&&void 0!==i.clickedIndex&&i.clickedIndex!==i.activeIndex&&i.slideToClickedSlide()}};var NW={getTranslate:function(e=(this.isHorizontal()?"x":"y")){const{params:t,rtlTranslate:i,translate:n,wrapperEl:r}=this;if(t.virtualTranslate)return i?-n:n;if(t.cssMode)return n;let s=cW(r,e);return s+=this.cssOverflowAdjustment(),i&&(s=-s),s||0},setTranslate:function(e,t){const i=this,{rtlTranslate:n,params:r,wrapperEl:s,progress:o}=i;let a,l=0,c=0;i.isHorizontal()?l=n?-e:e:c=e,r.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),i.previousTranslate=i.translate,i.translate=i.isHorizontal()?l:c,r.cssMode?s[i.isHorizontal()?"scrollLeft":"scrollTop"]=i.isHorizontal()?-l:-c:r.virtualTranslate||(i.isHorizontal()?l-=i.cssOverflowAdjustment():c-=i.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const u=i.maxTranslate()-i.minTranslate();a=0===u?0:(e-i.minTranslate())/u,a!==o&&i.updateProgress(e),i.emit("setTranslate",i.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e=0,t=this.params.speed,i=!0,n=!0,r){const s=this,{params:o,wrapperEl:a}=s;if(s.animating&&o.preventInteractionOnTransition)return!1;const l=s.minTranslate(),c=s.maxTranslate();let u;if(u=n&&e>l?l:n&&e<c?c:e,s.updateProgress(u),o.cssMode){const e=s.isHorizontal();if(0===t)a[e?"scrollLeft":"scrollTop"]=-u;else{if(!s.support.smoothScroll)return fW({swiper:s,targetPosition:-u,side:e?"left":"top"}),!0;a.scrollTo({[e?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(u),i&&(s.emit("beforeTransitionStart",t,r),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(u),i&&(s.emit("beforeTransitionStart",t,r),s.emit("transitionStart")),s.animating||(s.animating=!0,s.onTranslateToWrapperTransitionEnd||(s.onTranslateToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onTranslateToWrapperTransitionEnd),s.onTranslateToWrapperTransitionEnd=null,delete s.onTranslateToWrapperTransitionEnd,s.animating=!1,i&&s.emit("transitionEnd"))}),s.wrapperEl.addEventListener("transitionend",s.onTranslateToWrapperTransitionEnd))),!0}};function kW({swiper:e,runCallbacks:t,direction:i,step:n}){const{activeIndex:r,previousIndex:s}=e;let o=i;o||(o=r>s?"next":r<s?"prev":"reset"),e.emit(`transition${n}`),t&&"reset"===o?e.emit(`slideResetTransition${n}`):t&&r!==s&&(e.emit(`slideChangeTransition${n}`),e.emit("next"===o?`slideNextTransition${n}`:`slidePrevTransition${n}`))}var zW={slideTo:function(e=0,t,i=!0,n,r){"string"==typeof e&&(e=parseInt(e,10));const s=this;let o=e;o<0&&(o=0);const{params:a,snapGrid:l,slidesGrid:c,previousIndex:u,activeIndex:h,rtlTranslate:d,wrapperEl:p,enabled:f}=s;if(!f&&!n&&!r||s.destroyed||s.animating&&a.preventInteractionOnTransition)return!1;void 0===t&&(t=s.params.speed);const m=Math.min(s.params.slidesPerGroupSkip,o);let g=m+Math.floor((o-m)/s.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const _=-l[g];if(a.normalizeSlideIndex)for(let e=0;e<c.length;e+=1){const t=-Math.floor(100*_),i=Math.floor(100*c[e]),n=Math.floor(100*c[e+1]);void 0!==c[e+1]?t>=i&&t<n-(n-i)/2?o=e:t>=i&&t<n&&(o=e+1):t>=i&&(o=e)}if(s.initialized&&o!==h){if(!s.allowSlideNext&&(d?_>s.translate&&_>s.minTranslate():_<s.translate&&_<s.minTranslate()))return!1;if(!s.allowSlidePrev&&_>s.translate&&_>s.maxTranslate()&&(h||0)!==o)return!1}let y;o!==(u||0)&&i&&s.emit("beforeSlideChangeStart"),s.updateProgress(_),y=o>h?"next":o<h?"prev":"reset";const v=s.virtual&&s.params.virtual.enabled;if(!(v&&r)&&(d&&-_===s.translate||!d&&_===s.translate))return s.updateActiveIndex(o),a.autoHeight&&s.updateAutoHeight(),s.updateSlidesClasses(),"slide"!==a.effect&&s.setTranslate(_),"reset"!==y&&(s.transitionStart(i,y),s.transitionEnd(i,y)),!1;if(a.cssMode){const e=s.isHorizontal(),i=d?_:-_;if(0===t)v&&(s.wrapperEl.style.scrollSnapType="none",s._immediateVirtual=!0),v&&!s._cssModeVirtualInitialSet&&s.params.initialSlide>0?(s._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{p[e?"scrollLeft":"scrollTop"]=i})):p[e?"scrollLeft":"scrollTop"]=i,v&&requestAnimationFrame(()=>{s.wrapperEl.style.scrollSnapType="",s._immediateVirtual=!1});else{if(!s.support.smoothScroll)return fW({swiper:s,targetPosition:i,side:e?"left":"top"}),!0;p.scrollTo({[e?"left":"top"]:i,behavior:"smooth"})}return!0}const x=CW();return v&&!r&&x.isSafari&&s.isElement&&s.virtual.update(!1,!1,o),s.setTransition(t),s.setTranslate(_),s.updateActiveIndex(o),s.updateSlidesClasses(),s.emit("beforeTransitionStart",t,n),s.transitionStart(i,y),0===t?s.transitionEnd(i,y):s.animating||(s.animating=!0,s.onSlideToWrapperTransitionEnd||(s.onSlideToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onSlideToWrapperTransitionEnd),s.onSlideToWrapperTransitionEnd=null,delete s.onSlideToWrapperTransitionEnd,s.transitionEnd(i,y))}),s.wrapperEl.addEventListener("transitionend",s.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t,i=!0,n){if("string"==typeof e){e=parseInt(e,10)}const r=this;if(r.destroyed)return;void 0===t&&(t=r.params.speed);const s=r.grid&&r.params.grid&&r.params.grid.rows>1;let o=e;if(r.params.loop)if(r.virtual&&r.params.virtual.enabled)o+=r.virtual.slidesBefore;else{let e;if(s){const t=o*r.params.grid.rows;e=r.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===t).column}else e=r.getSlideIndexByData(o);const t=s?Math.ceil(r.slides.length/r.params.grid.rows):r.slides.length,{centeredSlides:i,slidesOffsetBefore:a,slidesOffsetAfter:l}=r.params,c=i||!!a||!!l;let u=r.params.slidesPerView;"auto"===u?u=r.slidesPerViewDynamic():(u=Math.ceil(parseFloat(r.params.slidesPerView,10)),c&&u%2==0&&(u+=1));let h=t-e<u;if(c&&(h=h||e<Math.ceil(u/2)),n&&c&&"auto"!==r.params.slidesPerView&&!s&&(h=!1),h){const i=c?e<r.activeIndex?"prev":"next":e-r.activeIndex-1<r.params.slidesPerView?"next":"prev";r.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?r.realIndex:void 0})}if(s){const e=o*r.params.grid.rows;o=r.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e).column}else o=r.getSlideIndexByData(o)}return requestAnimationFrame(()=>{r.slideTo(o,t,i,n)}),r},slideNext:function(e,t=!0,i){const n=this,{enabled:r,params:s,animating:o}=n;if(!r||n.destroyed)return n;void 0===e&&(e=n.params.speed);let a=s.slidesPerGroup;"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(a=Math.max(n.slidesPerViewDynamic("current",!0),1));const l=n.activeIndex<s.slidesPerGroupSkip?1:a;if(s.loop){if(o&&!(n.virtual&&s.virtual.enabled)&&s.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&s.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+l,e,t,i)}),!0}return n.slideTo(s.rewind&&n.isEnd?0:n.activeIndex+l,e,t,i)},slidePrev:function(e,t=!0,i){const n=this,{params:r,snapGrid:s,slidesGrid:o,rtlTranslate:a,enabled:l,animating:c}=n;if(!l||n.destroyed)return n;if(void 0===e&&(e=n.params.speed),r.loop){if(c&&!(n.virtual&&r.virtual.enabled)&&r.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}function u(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=u(a?n.translate:-n.translate),d=s.map(e=>u(e)),p=r.freeMode&&r.freeMode.enabled;let f=s[d.indexOf(h)-1];if(void 0===f&&(r.cssMode||p)){let e;s.forEach((t,i)=>{h>=t&&(e=i)}),void 0!==e&&(f=p?s[e]:s[e>0?e-1:e])}let m=0;if(void 0!==f&&(m=o.indexOf(f),m<0&&(m=n.activeIndex-1),"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(m=m-n.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),r.rewind&&n.isBeginning){return n.slideTo(n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1,e,t,i)}return r.loop&&0===n.activeIndex&&r.cssMode?(requestAnimationFrame(()=>{n.slideTo(m,e,t,i)}),!0):n.slideTo(m,e,t,i)},slideReset:function(e,t=!0,i){const n=this;if(!n.destroyed)return void 0===e&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,i)},slideToClosest:function(e,t=!0,i,n=.5){const r=this;if(r.destroyed)return;void 0===e&&(e=r.params.speed);let s=r.activeIndex;const o=Math.min(r.params.slidesPerGroupSkip,s),a=o+Math.floor((s-o)/r.params.slidesPerGroup),l=r.rtlTranslate?r.translate:-r.translate;if(l>=r.snapGrid[a]){const e=r.snapGrid[a];l-e>(r.snapGrid[a+1]-e)*n&&(s+=r.params.slidesPerGroup)}else{const e=r.snapGrid[a-1];l-e<=(r.snapGrid[a]-e)*n&&(s-=r.params.slidesPerGroup)}return s=Math.max(s,0),s=Math.min(s,r.slidesGrid.length-1),r.slideTo(s,e,t,i)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:i}=e,n="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let r,s=e.getSlideIndexWhenGrid(e.clickedIndex);const o=e.isElement?"swiper-slide":`.${t.slideClass}`,a=e.grid&&e.params.grid&&e.params.grid.rows>1;if(t.loop){if(e.animating)return;r=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?e.slideToLoop(r):s>(a?(e.slides.length-n)/2-(e.params.grid.rows-1):e.slides.length-n)?(e.loopFix(),s=e.getSlideIndex(mW(i,`${o}[data-swiper-slide-index="${r}"]`)[0]),aW(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var UW={loopCreate:function(e,t){const i=this,{params:n,slidesEl:r}=i;if(!n.loop||i.virtual&&i.params.virtual.enabled)return;const s=()=>{mW(r,`.${n.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},o=i.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||o)&&(()=>{const e=mW(r,`.${n.slideBlankClass}`);e.forEach(e=>{e.remove()}),e.length>0&&(i.recalcSlides(),i.updateSlides())})();const a=n.slidesPerGroup*(o?n.grid.rows:1),l=o&&i.slides.length%n.grid.rows!==0,c=e=>{for(let t=0;t<e;t+=1){const e=i.isElement?_W("swiper-slide",[n.slideBlankClass]):_W("div",[n.slideClass,n.slideBlankClass]);i.slidesEl.append(e)}};if(i.slides.length%a!==0){if(n.loopAddBlankSlides){c(a-i.slides.length%a),i.recalcSlides(),i.updateSlides()}else gW("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else if(l){if(n.loopAddBlankSlides){c(n.grid.rows-i.slides.length%n.grid.rows),i.recalcSlides(),i.updateSlides()}else gW("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else s();i.loopFix({slideRealIndex:e,direction:n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter?void 0:"next",initial:t})},loopFix:function({slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:n,activeSlideIndex:r,initial:s,byController:o,byMousewheel:a}={}){const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:u,allowSlideNext:h,slidesEl:d,params:p}=l,{centeredSlides:f,slidesOffsetBefore:m,slidesOffsetAfter:g,initialSlide:_}=p,y=f||!!m||!!g;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&p.virtual.enabled)return t&&(y||0!==l.snapIndex?y&&l.snapIndex<p.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=u,l.allowSlideNext=h,void l.emit("loopFix");let v=p.slidesPerView;"auto"===v?v=l.slidesPerViewDynamic():(v=Math.ceil(parseFloat(p.slidesPerView,10)),y&&v%2==0&&(v+=1));const x=p.slidesPerGroupAuto?v:p.slidesPerGroup;let b=y?Math.max(x,Math.ceil(v/2)):x;b%x!==0&&(b+=x-b%x),b+=p.loopAdditionalSlides,l.loopedSlides=b;const w=l.grid&&p.grid&&p.grid.rows>1;c.length<v+b||"cards"===l.params.effect&&c.length<v+2*b?gW("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):w&&"row"===p.grid.fill&&gW("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const T=[],S=[],E=w?Math.ceil(c.length/p.grid.rows):c.length,A=s&&E-_<v&&!y;let M=A?_:l.activeIndex;void 0===r?r=l.getSlideIndex(c.find(e=>e.classList.contains(p.slideActiveClass))):M=r;const I="next"===i||!i,C="prev"===i||!i;let P=0,L=0;const R=(w?c[r].column:r)+(y&&void 0===n?-v/2+.5:0);if(R<b){P=Math.max(b-R,x);for(let e=0;e<b-R;e+=1){const t=e-Math.floor(e/E)*E;if(w){const e=E-t-1;for(let t=c.length-1;t>=0;t-=1)c[t].column===e&&T.push(t)}else T.push(E-t-1)}}else if(R+v>E-b){L=Math.max(R-(E-2*b),x),A&&(L=Math.max(L,v-E+_+1));for(let e=0;e<L;e+=1){const t=e-Math.floor(e/E)*E;w?c.forEach((e,i)=>{e.column===t&&S.push(i)}):S.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),"cards"===l.params.effect&&c.length<v+2*b&&(S.includes(r)&&S.splice(S.indexOf(r),1),T.includes(r)&&T.splice(T.indexOf(r),1)),C&&T.forEach(e=>{c[e].swiperLoopMoveDOM=!0,d.prepend(c[e]),c[e].swiperLoopMoveDOM=!1}),I&&S.forEach(e=>{c[e].swiperLoopMoveDOM=!0,d.append(c[e]),c[e].swiperLoopMoveDOM=!1}),l.recalcSlides(),"auto"===p.slidesPerView?l.updateSlides():w&&(T.length>0&&C||S.length>0&&I)&&l.slides.forEach((e,t)=>{l.grid.updateSlide(t,e,l.slides)}),p.watchSlidesProgress&&l.updateSlidesOffset(),t)if(T.length>0&&C){if(void 0===e){const e=l.slidesGrid[M+P]-l.slidesGrid[M];a?l.setTranslate(l.translate-e):(l.slideTo(M+Math.ceil(P),0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-e,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-e))}else if(n){l.slideTo(l.activeIndex+(w?T.length/p.grid.rows:T.length),0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(S.length>0&&I)if(void 0===e){const e=l.slidesGrid[M-L]-l.slidesGrid[M];a?l.setTranslate(l.translate-e):(l.slideTo(M-L,0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-e,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-e))}else{l.slideTo(l.activeIndex-(w?S.length/p.grid.rows:S.length),0,!1,!0)}if(l.allowSlidePrev=u,l.allowSlideNext=h,l.controller&&l.controller.control&&!o){const s={slideRealIndex:e,direction:i,setTranslate:n,activeSlideIndex:r,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(e=>{!e.destroyed&&e.params.loop&&e.loopFix({...s,slideTo:e.params.slidesPerView===p.slidesPerView&&t})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...s,slideTo:l.controller.control.params.slidesPerView===p.slidesPerView&&t})}l.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:i}=e;if(!t.loop||!i||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const n=[];e.slides.forEach(e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;n[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),n.forEach(e=>{i.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}};function VW(e,t,i){const n=oW(),{params:r}=e,s=r.edgeSwipeDetection,o=r.edgeSwipeThreshold;return!s||!(i<=o||i>=n.innerWidth-o)||"prevent"===s&&(t.preventDefault(),!0)}function jW(e){const t=this;if(t.destroyed)return;const i=rW();let n=e;n.originalEvent&&(n=n.originalEvent);const r=t.touchEventsData;if("pointerdown"===n.type){if(null!==r.pointerId&&r.pointerId!==n.pointerId)return;r.pointerId=n.pointerId}else"touchstart"===n.type&&1===n.targetTouches.length&&(r.touchId=n.targetTouches[0].identifier);if("touchstart"===n.type)return void VW(t,n,n.targetTouches[0].pageX);const{params:s,touches:o,enabled:a}=t;if(!a)return;if(!s.simulateTouch&&"mouse"===n.pointerType)return;if(t.animating&&s.preventInteractionOnTransition)return;!t.animating&&s.cssMode&&s.loop&&t.loopFix();let l=n.target;if("wrapper"===s.touchEventsTarget&&!function(e,t){const i=oW();let n=t.contains(e);!n&&i.HTMLSlotElement&&t instanceof HTMLSlotElement&&(n=[...t.assignedElements()].includes(e),n||(n=function(e,t){const i=[t];for(;i.length>0;){const t=i.shift();if(e===t)return!0;i.push(...t.children,...t.shadowRoot?t.shadowRoot.children:[],...t.assignedElements?t.assignedElements():[])}}(e,t)));return n}(l,t.wrapperEl))return;if("which"in n&&3===n.which)return;if("button"in n&&n.button>0)return;if(r.isTouched&&r.isMoved)return;const c=!!s.noSwipingClass&&""!==s.noSwipingClass,u=n.composedPath?n.composedPath():n.path;c&&n.target&&n.target.shadowRoot&&u&&(l=u[0]);const h=s.noSwipingSelector?s.noSwipingSelector:`.${s.noSwipingClass}`;if(s.noSwiping&&(!(!n.target||!n.target.shadowRoot)?function(e,t=this){return function t(i){if(!i||i===rW()||i===oW())return null;i.assignedSlot&&(i=i.assignedSlot);const n=i.closest(e);return n||i.getRootNode?n||t(i.getRootNode().host):null}(t)}(h,l):l.closest(h)))return void(t.allowClick=!0);if(s.swipeHandler&&!l.closest(s.swipeHandler))return;o.currentX=n.pageX,o.currentY=n.pageY;const d=o.currentX,p=o.currentY;if(!VW(t,n,d))return;Object.assign(r,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=d,o.startY=p,r.touchStartTime=lW(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,s.threshold>0&&(r.allowThresholdMove=!1);let f=!0;l.matches(r.focusableElements)&&(f=!1,"SELECT"===l.nodeName&&(r.isTouched=!1)),i.activeElement&&i.activeElement.matches(r.focusableElements)&&i.activeElement!==l&&("mouse"===n.pointerType||"mouse"!==n.pointerType&&!l.matches(r.focusableElements))&&i.activeElement.blur();!s.touchStartForcePreventDefault&&!(f&&t.allowTouchMove&&s.touchStartPreventDefault)||l.isContentEditable||n.preventDefault(),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.animating&&!s.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}function GW(e){const t=rW(),i=this;if(i.destroyed)return;const n=i.touchEventsData,{params:r,touches:s,rtlTranslate:o,enabled:a}=i;if(!a)return;if(!r.simulateTouch&&"mouse"===e.pointerType)return;let l,c=e;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==n.touchId)return;if(c.pointerId!==n.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].find(e=>e.identifier===n.touchId),!l||l.identifier!==n.touchId)return}else l=c;if(!n.isTouched)return void(n.startMoving&&n.isScrolling&&i.emit("touchMoveOpposite",c));const u=l.pageX,h=l.pageY;if(c.preventedByNestedSwiper)return s.startX=u,void(s.startY=h);if(!i.allowTouchMove)return c.target.matches(n.focusableElements)||(i.allowClick=!1),void(n.isTouched&&(Object.assign(s,{startX:u,startY:h,currentX:u,currentY:h}),n.touchStartTime=lW()));if(r.touchReleaseOnEdges&&!r.loop)if(i.isVertical()){if(h<s.startY&&i.translate<=i.maxTranslate()||h>s.startY&&i.translate>=i.minTranslate())return n.isTouched=!1,void(n.isMoved=!1)}else{if(o&&(u>s.startX&&-i.translate<=i.maxTranslate()||u<s.startX&&-i.translate>=i.minTranslate()))return;if(!o&&(u<s.startX&&i.translate<=i.maxTranslate()||u>s.startX&&i.translate>=i.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==c.target&&"mouse"!==c.pointerType&&t.activeElement.blur(),t.activeElement&&c.target===t.activeElement&&c.target.matches(n.focusableElements))return n.isMoved=!0,void(i.allowClick=!1);n.allowTouchCallbacks&&i.emit("touchMove",c),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=u,s.currentY=h;const d=s.currentX-s.startX,p=s.currentY-s.startY;if(i.params.threshold&&Math.sqrt(d**2+p**2)<i.params.threshold)return;if(void 0===n.isScrolling){let e;i.isHorizontal()&&s.currentY===s.startY||i.isVertical()&&s.currentX===s.startX?n.isScrolling=!1:d*d+p*p>=25&&(e=180*Math.atan2(Math.abs(p),Math.abs(d))/Math.PI,n.isScrolling=i.isHorizontal()?e>r.touchAngle:90-e>r.touchAngle)}if(n.isScrolling&&i.emit("touchMoveOpposite",c),void 0===n.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(n.startMoving=!0)),n.isScrolling||"touchmove"===c.type&&n.preventTouchMoveFromPointerMove)return void(n.isTouched=!1);if(!n.startMoving)return;i.allowClick=!1,!r.cssMode&&c.cancelable&&c.preventDefault(),r.touchMoveStopPropagation&&!r.nested&&c.stopPropagation();let f=i.isHorizontal()?d:p,m=i.isHorizontal()?s.currentX-s.previousX:s.currentY-s.previousY;r.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),m=Math.abs(m)*(o?1:-1)),s.diff=f,f*=r.touchRatio,o&&(f=-f,m=-m);const g=i.touchesDirection;i.swipeDirection=f>0?"prev":"next",i.touchesDirection=m>0?"prev":"next";const _=i.params.loop&&!r.cssMode,y="next"===i.touchesDirection&&i.allowSlideNext||"prev"===i.touchesDirection&&i.allowSlidePrev;if(!n.isMoved){if(_&&y&&i.loopFix({direction:i.swipeDirection}),n.startTranslate=i.getTranslate(),i.setTransition(0),i.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});i.wrapperEl.dispatchEvent(e)}n.allowMomentumBounce=!1,!r.grabCursor||!0!==i.allowSlideNext&&!0!==i.allowSlidePrev||i.setGrabCursor(!0),i.emit("sliderFirstMove",c)}if((new Date).getTime(),!1!==r._loopSwapReset&&n.isMoved&&n.allowThresholdMove&&g!==i.touchesDirection&&_&&y&&Math.abs(f)>=1)return Object.assign(s,{startX:u,startY:h,currentX:u,currentY:h,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,void(n.startTranslate=n.currentTranslate);i.emit("sliderMove",c),n.isMoved=!0,n.currentTranslate=f+n.startTranslate;let v=!0,x=r.resistanceRatio;if(r.touchReleaseOnEdges&&(x=0),f>0?(_&&y&&n.allowThresholdMove&&n.currentTranslate>(r.centeredSlides?i.minTranslate()-i.slidesSizesGrid[i.activeIndex+1]-("auto"!==r.slidesPerView&&i.slides.length-r.slidesPerView>=2?i.slidesSizesGrid[i.activeIndex+1]+i.params.spaceBetween:0)-i.params.spaceBetween:i.minTranslate())&&i.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>i.minTranslate()&&(v=!1,r.resistance&&(n.currentTranslate=i.minTranslate()-1+(-i.minTranslate()+n.startTranslate+f)**x))):f<0&&(_&&y&&n.allowThresholdMove&&n.currentTranslate<(r.centeredSlides?i.maxTranslate()+i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween+("auto"!==r.slidesPerView&&i.slides.length-r.slidesPerView>=2?i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween:0):i.maxTranslate())&&i.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:i.slides.length-("auto"===r.slidesPerView?i.slidesPerViewDynamic():Math.ceil(parseFloat(r.slidesPerView,10)))}),n.currentTranslate<i.maxTranslate()&&(v=!1,r.resistance&&(n.currentTranslate=i.maxTranslate()+1-(i.maxTranslate()-n.startTranslate-f)**x))),v&&(c.preventedByNestedSwiper=!0),!i.allowSlideNext&&"next"===i.swipeDirection&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!i.allowSlidePrev&&"prev"===i.swipeDirection&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),i.allowSlidePrev||i.allowSlideNext||(n.currentTranslate=n.startTranslate),r.threshold>0){if(!(Math.abs(f)>r.threshold||n.allowThresholdMove))return void(n.currentTranslate=n.startTranslate);if(!n.allowThresholdMove)return n.allowThresholdMove=!0,s.startX=s.currentX,s.startY=s.currentY,n.currentTranslate=n.startTranslate,void(s.diff=i.isHorizontal()?s.currentX-s.startX:s.currentY-s.startY)}r.followFinger&&!r.cssMode&&((r.freeMode&&r.freeMode.enabled&&i.freeMode||r.watchSlidesProgress)&&(i.updateActiveIndex(),i.updateSlidesClasses()),r.freeMode&&r.freeMode.enabled&&i.freeMode&&i.freeMode.onTouchMove(),i.updateProgress(n.currentTranslate),i.setTranslate(n.currentTranslate))}function HW(e){const t=this;if(t.destroyed)return;const i=t.touchEventsData;let n,r=e;r.originalEvent&&(r=r.originalEvent);if("touchend"===r.type||"touchcancel"===r.type){if(n=[...r.changedTouches].find(e=>e.identifier===i.touchId),!n||n.identifier!==i.touchId)return}else{if(null!==i.touchId)return;if(r.pointerId!==i.pointerId)return;n=r}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(r.type)){if(!(["pointercancel","contextmenu"].includes(r.type)&&(t.browser.isSafari||t.browser.isWebView)))return}i.pointerId=null,i.touchId=null;const{params:s,touches:o,rtlTranslate:a,slidesGrid:l,enabled:c}=t;if(!c)return;if(!s.simulateTouch&&"mouse"===r.pointerType)return;if(i.allowTouchCallbacks&&t.emit("touchEnd",r),i.allowTouchCallbacks=!1,!i.isTouched)return i.isMoved&&s.grabCursor&&t.setGrabCursor(!1),i.isMoved=!1,void(i.startMoving=!1);s.grabCursor&&i.isMoved&&i.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const u=lW(),h=u-i.touchStartTime;if(t.allowClick){const e=r.path||r.composedPath&&r.composedPath();t.updateClickedSlide(e&&e[0]||r.target,e),t.emit("tap click",r),h<300&&u-i.lastClickTime<300&&t.emit("doubleTap doubleClick",r)}if(i.lastClickTime=lW(),aW(()=>{t.destroyed||(t.allowClick=!0)}),!i.isTouched||!i.isMoved||!t.swipeDirection||0===o.diff&&!i.loopSwapReset||i.currentTranslate===i.startTranslate&&!i.loopSwapReset)return i.isTouched=!1,i.isMoved=!1,void(i.startMoving=!1);let d;if(i.isTouched=!1,i.isMoved=!1,i.startMoving=!1,d=s.followFinger?a?t.translate:-t.translate:-i.currentTranslate,s.cssMode)return;if(s.freeMode&&s.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:d});const p=d>=-t.maxTranslate()&&!t.params.loop;let f=0,m=t.slidesSizesGrid[0];for(let e=0;e<l.length;e+=e<s.slidesPerGroupSkip?1:s.slidesPerGroup){const t=e<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;void 0!==l[e+t]?(p||d>=l[e]&&d<l[e+t])&&(f=e,m=l[e+t]-l[e]):(p||d>=l[e])&&(f=e,m=l[l.length-1]-l[l.length-2])}let g=null,_=null;s.rewind&&(t.isBeginning?_=s.virtual&&s.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(g=0));const y=(d-l[f])/m,v=f<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(h>s.longSwipesMs){if(!s.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&t.slideTo(y>=s.longSwipesRatio?s.rewind&&t.isEnd?g:f+v:f),"prev"===t.swipeDirection&&(y>1-s.longSwipesRatio?t.slideTo(f+v):null!==_&&y<0&&Math.abs(y)>s.longSwipesRatio?t.slideTo(_):t.slideTo(f))}else{if(!s.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(r.target===t.navigation.nextEl||r.target===t.navigation.prevEl)?t.slideTo(r.target===t.navigation.nextEl?f+v:f):("next"===t.swipeDirection&&t.slideTo(null!==g?g:f+v),"prev"===t.swipeDirection&&t.slideTo(null!==_?_:f))}}function WW(){const e=this,{params:t,el:i}=e;if(i&&0===i.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:n,allowSlidePrev:r,snapGrid:s}=e,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();if(!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||o&&t.loop)e.params.loop&&!o?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);else{e.slideTo((o?e.virtual.slides:e.slides).length-1,0,!1,!0)}e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=r,e.allowSlideNext=n,e.params.watchOverflow&&s!==e.snapGrid&&e.checkOverflow()}function qW(e){const t=this;t.destroyed||t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function XW(){const e=this;if(e.destroyed)return;const{wrapperEl:t,rtlTranslate:i,enabled:n}=e;if(!n)return;let r;e.previousTranslate=e.translate,e.translate=e.isHorizontal()?-t.scrollLeft:-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const s=e.maxTranslate()-e.minTranslate();r=0===s?0:(e.translate-e.minTranslate())/s,r!==e.progress&&e.updateProgress(i?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function $W(e){const t=this;t.destroyed||(OW(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update())}function ZW(){const e=this;e.destroyed||e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const YW=(e,t)=>{const i=rW(),{params:n,el:r,wrapperEl:s,device:o}=e,a=!!n.nested,l="on"===t?"addEventListener":"removeEventListener",c=t;r&&"string"!=typeof r&&(i[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:a}),r[l]("touchstart",e.onTouchStart,{passive:!1}),r[l]("pointerdown",e.onTouchStart,{passive:!1}),i[l]("touchmove",e.onTouchMove,{passive:!1,capture:a}),i[l]("pointermove",e.onTouchMove,{passive:!1,capture:a}),i[l]("touchend",e.onTouchEnd,{passive:!0}),i[l]("pointerup",e.onTouchEnd,{passive:!0}),i[l]("pointercancel",e.onTouchEnd,{passive:!0}),i[l]("touchcancel",e.onTouchEnd,{passive:!0}),i[l]("pointerout",e.onTouchEnd,{passive:!0}),i[l]("pointerleave",e.onTouchEnd,{passive:!0}),i[l]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&r[l]("click",e.onClick,!0),n.cssMode&&s[l]("scroll",e.onScroll),e[c](n.updateOnWindowResize?o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate":"observerUpdate",WW,!0),r[l]("load",e.onLoad,{capture:!0}))};const JW=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var KW={setBreakpoint:function(){const e=this,{realIndex:t,initialized:i,params:n,el:r}=e,s=n.breakpoints;if(!s||s&&0===Object.keys(s).length)return;const o=rW(),a="window"!==n.breakpointsBase&&n.breakpointsBase?"container":n.breakpointsBase,l=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:o.querySelector(n.breakpointsBase),c=e.getBreakpoint(s,a,l);if(!c||e.currentBreakpoint===c)return;const u=(c in s?s[c]:void 0)||e.originalParams,h=JW(e,n),d=JW(e,u),p=e.params.grabCursor,f=u.grabCursor,m=n.enabled;h&&!d?(r.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!h&&d&&(r.classList.add(`${n.containerModifierClass}grid`),(u.grid.fill&&"column"===u.grid.fill||!u.grid.fill&&"column"===n.grid.fill)&&r.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),p&&!f?e.unsetGrabCursor():!p&&f&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===u[t])return;const i=n[t]&&n[t].enabled,r=u[t]&&u[t].enabled;i&&!r&&e[t].disable(),!i&&r&&e[t].enable()});const g=u.direction&&u.direction!==n.direction,_=n.loop&&(u.slidesPerView!==n.slidesPerView||g),y=n.loop;g&&i&&e.changeDirection(),dW(e.params,u);const v=e.params.enabled,x=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),m&&!v?e.disable():!m&&v&&e.enable(),e.currentBreakpoint=c,e.emit("_beforeBreakpoint",u),i&&(_?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!y&&x?(e.loopCreate(t),e.updateSlides()):y&&!x&&e.loopDestroy()),e.emit("breakpoint",u)},getBreakpoint:function(e,t="window",i){if(!e||"container"===t&&!i)return;let n=!1;const r=oW(),s="window"===t?r.innerHeight:i.clientHeight,o=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:s*t,point:e}}return{value:e,point:e}});o.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(let e=0;e<o.length;e+=1){const{point:s,value:a}=o[e];"window"===t?r.matchMedia(`(min-width: ${a}px)`).matches&&(n=s):a<=i.clientWidth&&(n=s)}return n||"max"}};var QW={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function eq(e,t){return function(i={}){const n=Object.keys(i)[0],r=i[n];"object"==typeof r&&null!==r?(!0===e[n]&&(e[n]={enabled:!0}),"navigation"===n&&e[n]&&e[n].enabled&&!e[n].prevEl&&!e[n].nextEl&&(e[n].auto=!0),["pagination","scrollbar"].indexOf(n)>=0&&e[n]&&e[n].enabled&&!e[n].el&&(e[n].auto=!0),n in e&&"enabled"in r?("object"!=typeof e[n]||"enabled"in e[n]||(e[n].enabled=!0),e[n]||(e[n]={enabled:!1}),dW(t,i)):dW(t,i)):dW(t,i)}}const tq={eventsEmitter:PW,update:FW,translate:NW,transition:{setTransition:function(e,t){const i=this;i.params.cssMode||(i.wrapperEl.style.transitionDuration=`${e}ms`,i.wrapperEl.style.transitionDelay=0===e?"0ms":""),i.emit("setTransition",e,t)},transitionStart:function(e=!0,t){const i=this,{params:n}=i;n.cssMode||(n.autoHeight&&i.updateAutoHeight(),kW({swiper:i,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e=!0,t){const i=this,{params:n}=i;i.animating=!1,n.cssMode||(i.setTransition(0),kW({swiper:i,runCallbacks:e,direction:t,step:"End"}))}},slide:zW,loop:UW,grabCursor:{setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const i="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),i.style.cursor="move",i.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})},unsetGrabCursor:function(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}},events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=jW.bind(e),e.onTouchMove=GW.bind(e),e.onTouchEnd=HW.bind(e),e.onDocumentTouchStart=ZW.bind(e),t.cssMode&&(e.onScroll=XW.bind(e)),e.onClick=qW.bind(e),e.onLoad=$W.bind(e),YW(e,"on")},detachEvents:function(){YW(this,"off")}},breakpoints:KW,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:i}=e,{slidesOffsetBefore:n}=i;if(n){const t=e.slides.length-1;e.isLocked=e.size>e.slidesGrid[t]+e.slidesSizesGrid[t]+2*n}else e.isLocked=1===e.snapGrid.length;!0===i.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===i.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:i,rtl:n,el:r,device:s}=e,o=function(e,t){const i=[];return e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(n=>{e[n]&&i.push(t+n)}):"string"==typeof e&&i.push(t+e)}),i}(["initialized",i.direction,{"free-mode":e.params.freeMode&&i.freeMode.enabled},{autoheight:i.autoHeight},{rtl:n},{grid:i.grid&&i.grid.rows>1},{"grid-column":i.grid&&i.grid.rows>1&&"column"===i.grid.fill},{android:s.android},{ios:s.ios},{"css-mode":i.cssMode},{centered:i.cssMode&&i.centeredSlides},{"watch-progress":i.watchSlidesProgress}],i.containerModifierClass);t.push(...o),r.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},iq={};class nq{constructor(...e){let t,i;1===e.length&&e[0].constructor&&"Object"===Object.prototype.toString.call(e[0]).slice(8,-1)?i=e[0]:[t,i]=e,i||(i={}),i=dW({},i),t&&!i.el&&(i.el=t);const n=rW();if(i.el&&"string"==typeof i.el&&n.querySelectorAll(i.el).length>1){const e=[];return n.querySelectorAll(i.el).forEach(t=>{const n=dW({},i,{el:t});e.push(new nq(n))}),e}const r=this;r.__swiper__=!0,r.support=MW(),r.device=IW({userAgent:i.userAgent}),r.browser=CW(),r.eventsListeners={},r.eventsAnyListeners=[],r.modules=[...r.__modules__],i.modules&&Array.isArray(i.modules)&&i.modules.forEach(e=>{"function"==typeof e&&r.modules.indexOf(e)<0&&r.modules.push(e)});const s={};r.modules.forEach(e=>{e({params:i,swiper:r,extendParams:eq(i,s),on:r.on.bind(r),once:r.once.bind(r),off:r.off.bind(r),emit:r.emit.bind(r)})});const o=dW({},QW,s);return r.params=dW({},o,iq,i),r.originalParams=dW({},r.params),r.passedParams=dW({},i),r.params&&r.params.on&&Object.keys(r.params.on).forEach(e=>{r.on(e,r.params.on[e])}),r.params&&r.params.onAny&&r.onAny(r.params.onAny),Object.assign(r,{enabled:r.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===r.params.direction,isVertical:()=>"vertical"===r.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:r.params.allowSlideNext,allowSlidePrev:r.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:r.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:r.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),r.emit("_swiper"),r.params.init&&r.init(),r}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:i}=this,n=vW(mW(t,`.${i.slideClass}, swiper-slide`)[0]);return vW(e)-n}getSlideIndexByData(e){return this.getSlideIndex(this.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e))}getSlideIndexWhenGrid(e){return this.grid&&this.params.grid&&this.params.grid.rows>1&&("column"===this.params.grid.fill?e=Math.floor(e/this.params.grid.rows):"row"===this.params.grid.fill&&(e%=Math.ceil(this.slides.length/this.params.grid.rows))),e}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=mW(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const i=this;e=Math.min(Math.max(e,0),1);const n=i.minTranslate(),r=i.maxTranslate();i.translateTo((r-n)*e+n,void 0===t?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(i=>{const n=e.getSlideClasses(i);t.push({slideEl:i,classNames:n}),e.emit("_slideClass",i,n)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e="current",t=!1){const{params:i,slides:n,slidesGrid:r,slidesSizesGrid:s,size:o,activeIndex:a}=this;let l=1;if("number"==typeof i.slidesPerView)return i.slidesPerView;if(i.centeredSlides){let e,t=n[a]?Math.ceil(n[a].swiperSlideSize):0;for(let i=a+1;i<n.length;i+=1)n[i]&&!e&&(t+=Math.ceil(n[i].swiperSlideSize),l+=1,t>o&&(e=!0));for(let i=a-1;i>=0;i-=1)n[i]&&!e&&(t+=n[i].swiperSlideSize,l+=1,t>o&&(e=!0))}else if("current"===e)for(let e=a+1;e<n.length;e+=1){(t?r[e]+s[e]-r[a]<o:r[e]-r[a]<o)&&(l+=1)}else for(let e=a-1;e>=0;e-=1){r[a]-r[e]<o&&(l+=1)}return l}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:i}=e;function n(){const t=Math.min(Math.max(e.rtlTranslate?-1*e.translate:e.translate,e.maxTranslate()),e.minTranslate());e.setTranslate(t),e.updateActiveIndex(),e.updateSlidesClasses()}let r;if(i.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&OW(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),i.freeMode&&i.freeMode.enabled&&!i.cssMode)n(),i.autoHeight&&e.updateAutoHeight();else{if(("auto"===i.slidesPerView||i.slidesPerView>1)&&e.isEnd&&!i.centeredSlides){r=e.slideTo((e.virtual&&i.virtual.enabled?e.virtual.slides:e.slides).length-1,0,!1,!0)}else r=e.slideTo(e.activeIndex,0,!1,!0);r||n()}i.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t=!0){const i=this,n=i.params.direction;return e||(e="horizontal"===n?"vertical":"horizontal"),e===n||"horizontal"!==e&&"vertical"!==e||(i.el.classList.remove(`${i.params.containerModifierClass}${n}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}changeLanguageDirection(e){const t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let i=e||t.params.el;if("string"==typeof i&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const n=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let r=(()=>{if(i&&i.shadowRoot&&i.shadowRoot.querySelector){return i.shadowRoot.querySelector(n())}return mW(i,n())[0]})();return!r&&t.params.createElements&&(r=_W("div",t.params.wrapperClass),i.append(r),mW(i,`.${t.params.slideClass}`).forEach(e=>{r.append(e)})),Object.assign(t,{el:i,wrapperEl:r,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:r,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:"rtl"===i.dir.toLowerCase()||"rtl"===yW(i,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===i.dir.toLowerCase()||"rtl"===yW(i,"direction")),wrongRTL:"-webkit-box"===yW(r,"display")}),!0}init(e){const t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.slideTo(t.params.loop&&t.virtual&&t.params.virtual.enabled?t.params.initialSlide+t.virtual.slidesBefore:t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(void 0,!0),t.attachEvents();const i=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&i.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),i.forEach(e=>{e.complete?OW(t,e):e.addEventListener("load",e=>{OW(t,e.target)})}),BW(t),t.initialized=!0,BW(t),t.emit("init"),t.emit("afterInit"),t}destroy(e=!0,t=!0){const i=this,{params:n,el:r,wrapperEl:s,slides:o}=i;return void 0===i.params||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),n.loop&&i.loopDestroy(),t&&(i.removeClasses(),r&&"string"!=typeof r&&r.removeAttribute("style"),s&&s.removeAttribute("style"),o&&o.length&&o.forEach(e=>{e.classList.remove(n.slideVisibleClass,n.slideFullyVisibleClass,n.slideActiveClass,n.slideNextClass,n.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(e=>{i.off(e)}),!1!==e&&(i.el&&"string"!=typeof i.el&&(i.el.swiper=null),function(e){const t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(i)),i.destroyed=!0),null}static extendDefaults(e){dW(iq,e)}static get extendedDefaults(){return iq}static get defaults(){return QW}static installModule(e){nq.prototype.__modules__||(nq.prototype.__modules__=[]);const t=nq.prototype.__modules__;"function"==typeof e&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach(e=>nq.installModule(e)),nq):(nq.installModule(e),nq)}}function rq(e=""){return`.${e.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g,"\\$1").replace(/ /g,".")}`}function sq({swiper:e,extendParams:t,on:i,emit:n}){const r="swiper-pagination";let s;t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${r}-bullet`,bulletActiveClass:`${r}-bullet-active`,modifierClass:`${r}-`,currentClass:`${r}-current`,totalClass:`${r}-total`,hiddenClass:`${r}-hidden`,progressbarFillClass:`${r}-progressbar-fill`,progressbarOppositeClass:`${r}-progressbar-opposite`,clickableClass:`${r}-clickable`,lockClass:`${r}-lock`,horizontalClass:`${r}-horizontal`,verticalClass:`${r}-vertical`,paginationDisabledClass:`${r}-disabled`}}),e.pagination={el:null,bullets:[]};let o=0;function a(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function l(t,i){const{bulletActiveClass:n}=e.params.pagination;t&&(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${n}-${i}`),(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&t.classList.add(`${n}-${i}-${i}`))}function c(t){const i=t.target.closest(rq(e.params.pagination.bulletClass));if(!i)return;t.preventDefault();const n=vW(i)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===n)return;const t=function(e,t,i){return(t%=i)===1+(e%=i)?"next":t===e-1?"previous":void 0}(e.realIndex,n,e.slides.length);"next"===t?e.slideNext():"previous"===t?e.slidePrev():e.slideToLoop(n)}else e.slideTo(n)}function u(){const t=e.rtl,i=e.params.pagination;if(a())return;let r,c,u=e.pagination.el;u=wW(u);const h=e.params.loop?Math.ceil((e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length)/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(c=e.previousRealIndex||0,r=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(r=e.snapIndex,c=e.previousSnapIndex):(c=e.previousIndex||0,r=e.activeIndex||0),"bullets"===i.type&&e.pagination.bullets&&e.pagination.bullets.length>0){const n=e.pagination.bullets;let a,h,d;if(i.dynamicBullets&&(s=bW(n[0],e.isHorizontal()?"width":"height"),u.forEach(t=>{t.style[e.isHorizontal()?"width":"height"]=s*(i.dynamicMainBullets+4)+"px"}),i.dynamicMainBullets>1&&void 0!==c&&(o+=r-(c||0),o>i.dynamicMainBullets-1?o=i.dynamicMainBullets-1:o<0&&(o=0)),a=Math.max(r-o,0),h=a+(Math.min(n.length,i.dynamicMainBullets)-1),d=(h+a)/2),n.forEach(e=>{const t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map(e=>`${i.bulletActiveClass}${e}`)].map(e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e).flat();e.classList.remove(...t)}),u.length>1)n.forEach(t=>{const n=vW(t);n===r?t.classList.add(...i.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),i.dynamicBullets&&(n>=a&&n<=h&&t.classList.add(...`${i.bulletActiveClass}-main`.split(" ")),n===a&&l(t,"prev"),n===h&&l(t,"next"))});else{const t=n[r];if(t&&t.classList.add(...i.bulletActiveClass.split(" ")),e.isElement&&n.forEach((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")}),i.dynamicBullets){const e=n[a],t=n[h];for(let e=a;e<=h;e+=1)n[e]&&n[e].classList.add(...`${i.bulletActiveClass}-main`.split(" "));l(e,"prev"),l(t,"next")}}if(i.dynamicBullets){const r=Math.min(n.length,i.dynamicMainBullets+4),o=(s*r-s)/2-d*s,a=t?"right":"left";n.forEach(t=>{t.style[e.isHorizontal()?a:"top"]=`${o}px`})}}u.forEach((t,s)=>{if("fraction"===i.type&&(t.querySelectorAll(rq(i.currentClass)).forEach(e=>{e.textContent=i.formatFractionCurrent(r+1)}),t.querySelectorAll(rq(i.totalClass)).forEach(e=>{e.textContent=i.formatFractionTotal(h)})),"progressbar"===i.type){let n;n=i.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";const s=(r+1)/h;let o=1,a=1;"horizontal"===n?o=s:a=s,t.querySelectorAll(rq(i.progressbarFillClass)).forEach(t=>{t.style.transform=`translate3d(0,0,0) scaleX(${o}) scaleY(${a})`,t.style.transitionDuration=`${e.params.speed}ms`})}"custom"===i.type&&i.renderCustom?(TW(t,i.renderCustom(e,r+1,h)),0===s&&n("paginationRender",t)):(0===s&&n("paginationRender",t),n("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](i.lockClass)})}function h(){const t=e.params.pagination;if(a())return;const i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.grid&&e.params.grid.rows>1?e.slides.length/Math.ceil(e.params.grid.rows):e.slides.length;let r=e.pagination.el;r=wW(r);let s="";if("bullets"===t.type){let n=e.params.loop?Math.ceil(i/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&n>i&&(n=i);for(let i=0;i<n;i+=1)s+=t.renderBullet?t.renderBullet.call(e,i,t.bulletClass):`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(s=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(s=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],r.forEach(i=>{"custom"!==t.type&&TW(i,s||""),"bullets"===t.type&&e.pagination.bullets.push(...i.querySelectorAll(rq(t.bulletClass)))}),"custom"!==t.type&&n("paginationRender",r[0])}function d(){e.params.pagination=function(e,t,i,n){return e.params.createElements&&Object.keys(n).forEach(r=>{if(!i[r]&&!0===i.auto){let s=mW(e.el,`.${n[r]}`)[0];s||(s=_W("div",n[r]),s.className=n[r],e.el.append(s)),i[r]=s,t[r]=s}}),i}(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});const t=e.params.pagination;if(!t.el)return;let i;"string"==typeof t.el&&e.isElement&&(i=e.el.querySelector(t.el)),i||"string"!=typeof t.el||(i=[...document.querySelectorAll(t.el)]),i||(i=t.el),i&&0!==i.length&&(e.params.uniqueNavElements&&"string"==typeof t.el&&Array.isArray(i)&&i.length>1&&(i=[...e.el.querySelectorAll(t.el)],i.length>1&&(i=i.find(t=>xW(t,".swiper")[0]===e.el))),Array.isArray(i)&&1===i.length&&(i=i[0]),Object.assign(e.pagination,{el:i}),i=wW(i),i.forEach(i=>{"bullets"===t.type&&t.clickable&&i.classList.add(...(t.clickableClass||"").split(" ")),i.classList.add(t.modifierClass+t.type),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass),"bullets"===t.type&&t.dynamicBullets&&(i.classList.add(`${t.modifierClass}${t.type}-dynamic`),o=0,t.dynamicMainBullets<1&&(t.dynamicMainBullets=1)),"progressbar"===t.type&&t.progressbarOpposite&&i.classList.add(t.progressbarOppositeClass),t.clickable&&i.addEventListener("click",c),e.enabled||i.classList.add(t.lockClass)}))}function p(){const t=e.params.pagination;if(a())return;let i=e.pagination.el;i&&(i=wW(i),i.forEach(i=>{i.classList.remove(t.hiddenClass),i.classList.remove(t.modifierClass+t.type),i.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(i.classList.remove(...(t.clickableClass||"").split(" ")),i.removeEventListener("click",c))})),e.pagination.bullets&&e.pagination.bullets.forEach(e=>e.classList.remove(...t.bulletActiveClass.split(" ")))}i("changeDirection",()=>{if(!e.pagination||!e.pagination.el)return;const t=e.params.pagination;let{el:i}=e.pagination;i=wW(i),i.forEach(i=>{i.classList.remove(t.horizontalClass,t.verticalClass),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)})}),i("init",()=>{!1===e.params.pagination.enabled?f():(d(),h(),u())}),i("activeIndexChange",()=>{void 0===e.snapIndex&&u()}),i("snapIndexChange",()=>{u()}),i("snapGridLengthChange",()=>{h(),u()}),i("destroy",()=>{p()}),i("enable disable",()=>{let{el:t}=e.pagination;t&&(t=wW(t),t.forEach(t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass)))}),i("lock unlock",()=>{u()}),i("click",(t,i)=>{const r=i.target,s=wW(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&s&&s.length>0&&!r.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&r===e.navigation.nextEl||e.navigation.prevEl&&r===e.navigation.prevEl))return;const t=s[0].classList.contains(e.params.pagination.hiddenClass);n(!0===t?"paginationShow":"paginationHide"),s.forEach(t=>t.classList.toggle(e.params.pagination.hiddenClass))}});const f=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);let{el:t}=e.pagination;t&&(t=wW(t),t.forEach(t=>t.classList.add(e.params.pagination.paginationDisabledClass))),p()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);let{el:t}=e.pagination;t&&(t=wW(t),t.forEach(t=>t.classList.remove(e.params.pagination.paginationDisabledClass))),d(),h(),u()},disable:f,render:h,update:u,init:d,destroy:p})}Object.keys(tq).forEach(e=>{Object.keys(tq[e]).forEach(t=>{nq.prototype[t]=tq[e][t]})}),nq.use([function({swiper:e,on:t,emit:i}){const n=oW();let r=null,s=null;const o=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},a=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};t("init",()=>{e.params.resizeObserver&&void 0!==n.ResizeObserver?e&&!e.destroyed&&e.initialized&&(r=new ResizeObserver(t=>{s=n.requestAnimationFrame(()=>{const{width:i,height:n}=e;let r=i,s=n;t.forEach(({contentBoxSize:t,contentRect:i,target:n})=>{n&&n!==e.el||(r=i?i.width:(t[0]||t).inlineSize,s=i?i.height:(t[0]||t).blockSize)}),r===i&&s===n||o()})}),r.observe(e.el)):(n.addEventListener("resize",o),n.addEventListener("orientationchange",a))}),t("destroy",()=>{s&&n.cancelAnimationFrame(s),r&&r.unobserve&&e.el&&(r.unobserve(e.el),r=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",a)})},function({swiper:e,extendParams:t,on:i,emit:n}){const r=[],s=oW(),o=(t,i={})=>{const o=new(s.MutationObserver||s.WebkitMutationObserver)(t=>{if(e.__preventObserver__)return;if(1===t.length)return void n("observerUpdate",t[0]);const i=function(){n("observerUpdate",t[0])};s.requestAnimationFrame?s.requestAnimationFrame(i):s.setTimeout(i,0)});o.observe(t,{attributes:void 0===i.attributes||i.attributes,childList:e.isElement||(void 0===i.childList||i).childList,characterData:void 0===i.characterData||i.characterData}),r.push(o)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(e.params.observer){if(e.params.observeParents){const t=xW(e.hostEl);for(let e=0;e<t.length;e+=1)o(t[e])}o(e.hostEl,{childList:e.params.observeSlideChildren}),o(e.wrapperEl,{attributes:!1})}}),i("destroy",()=>{r.forEach(e=>{e.disconnect()}),r.splice(0,r.length)})}]);const oq=["station-departure","station-to","station-from","station-exits","station-searching","station-routes","station-noroute"];class aq extends YH{constructor(e){super(Object.assign({className:"station-panel"},e))}addTo(e){const t=this,i=t._options,n=i.object,r=[],o={},a=i.mode||"departure",l=t._departures=[],c=t._exits=[].concat(...n.map(e=>e.exit||[])),u=e.getPitch(),{lang:h,dict:d,clock:p}=e,f=p.getDate(),m=f.getMonth()+1,g=f.getDate(),_=f.getHours(),y=f.getMinutes();for(const t of n){const i=e.getLocalizedStationTitle(t),n=t.railway.id;H(r,i)||r.push(i),o[n]||(o[n]=[]),H(o[n],i)||o[n].push(i)}for(const t of n){const{railway:i,alternate:n,ascending:r,descending:s}=t,{stations:a,ascending:c,descending:u,color:h}=i;for(const{direction:d,altDirection:p}of[{direction:c,altDirection:r},{direction:u,altDirection:s}])if(null!==p)if(n){for(const{railways:e}of l)if(e[0].station===n&&e[0].direction===p){e.push({railway:i,station:t,direction:d});break}}else{let n;if(a[0]!==a[a.length-1])for(let e=0,t=a.length;e<t;e++){const i=a[d===c?t-1-e:e];if(!i.alternate){n=i;break}}t!==n&&l.push({railways:[{railway:i,station:t,direction:d}],color:h,label:[e.getLocalizedRailwayTitle(i),o[i.id].length>1?`(${e.getLocalizedStationTitle(t)})`:"",e.getLocalizedRailDirectionTitle(p||d)].join(" ")})}}super.addTo(e).setTitle(['<div id="station-title-name">',`<div>${r.join(d.and)}</div>`,'<div class="station-content-selector">',"<span>",'<input id="station-departure-button" type="radio" name="station">',`<label for="station-departure-button">${d.departures}</label>`,"</span>","<span>",'<input id="station-to-button" type="radio" name="station">',`<label for="station-to-button">${d["to-here"]}</label>`,"</span>","<span>",'<input id="station-from-button" type="radio" name="station">',`<label for="station-from-button">${d["from-here"]}</label>`,"</span>",c.length?["<span>",'<input id="station-exits-button" type="radio" name="station">',`<label for="station-exits-button">${d.exits}</label>`,"</span>"].join(""):"","</div>","</div>",`<div id="station-title-searching">${d["route-search"]}</div>`,'<div id="station-title-routes"></div>'].join("")).setHTML(['<div id="station-departure"></div>','<div id="station-to">',`<div class="search-form-element">${d["from-station"]} <input id="origin" class="search-input search-focus" type="text" list="stations" placeholder="${d["enter-station-name"]}"></div>`,'<div class="search-form-element">','<select id="to-type" class="search-select">',`<option value="departure" selected>${d["depart-at"]}</option>`,"</select>",'<select id="to-month" class="search-select">',`<option value="${m}" selected>${f.toLocaleDateString(h,{month:"short"})}</option>`,"</select>",'<select id="to-date" class="search-select">',`<option value="${g}" selected>${f.toLocaleDateString(h,{day:"numeric"})}</option>`,"</select>",'<select id="to-hours" class="search-select"></select>','<select id="to-minutes" class="search-select"></select>',"</div>",`<div class="search-form-element"><button id="to-search-button" class="search-button" disabled>${d["search-route"]}</button></div>`,"</div>",'<div id="station-from">',`<div class="search-form-element">${d["to-station"]} <input id="destination" class="search-input search-focus" type="text" list="stations" placeholder="${d["enter-station-name"]}"></div>`,'<div class="search-form-element">','<select id="from-type" class="search-select">',`<option value="departure" selected>${d["depart-at"]}</option>`,"</select>",'<select id="from-month" class="search-select">',`<option value="${m}" selected>${f.toLocaleDateString(h,{month:"short"})}</option>`,"</select>",'<select id="from-date" class="search-select">',`<option value="${g}" selected>${f.toLocaleDateString(h,{day:"numeric"})}</option>`,"</select>",'<select id="from-hours" class="search-select"></select>','<select id="from-minutes" class="search-select"></select>',"</div>",`<div class="search-form-element"><button id="from-search-button" class="search-button" disabled>${d["search-route"]}</button></div>`,"</div>",'<div id="station-exits"></div>','<div id="station-searching">','<div class="ball-pulse"><div></div><div></div><div></div></div>',"</div>",'<div id="station-routes" class="swiper">','<div class="swiper-wrapper"></div>','<div class="swiper-pagination"></div>',"</div>",`<div id="station-noroute">${d["cannot-find-train"]}</div>`].join(""));const v=t._container,x=v.querySelector("#origin"),b=v.querySelector("#destination");v.classList.add(`station-${a}`),v.querySelector(`#station-${a}-button`).checked=!0;for(const t of["station-departure","station-to","station-from","station-exits"]){const i=v.querySelector(`#${t}-button`);i&&i.addEventListener("click",()=>{const i=v.classList;i.contains(t)||(i.remove(...oq),i.add(t),"station-to"===t?x.focus():"station-from"===t&&b.focus(),"station-exits"!==t?(e.hideStationExits(),e.map.flyTo({center:e.lastCameraParams.center,zoom:15.5,pitch:u})):e.showStationExits(n),e._setSearchMode(H(["station-to","station-from"],t)?"edit":"none"))})}t.updateContent();for(const i of["to","from"]){const r=v.querySelector(`#${i}-hours`),o=v.querySelector(`#${i}-minutes`),a="to"===i?x:b,l=v.querySelector(`#${i}-search-button`);for(let e=0;e<24;e++)f.setHours(e),Q("option",{value:e,text:f.toLocaleTimeString(h,{hour:"numeric"}),selected:e===_},r);for(let e=0;e<60;e++)f.setMinutes(e),Q("option",{value:e,text:`${f.toLocaleTimeString(h,{minute:"numeric"})}${d.minute}`,selected:e===y},o);a.addEventListener("input",()=>{const t=e.stationTitleLookup.get(a.value.toUpperCase());l.disabled=!t||H(n,t)}),l.addEventListener("click",()=>{const a=v.classList,l=e.stationTitleLookup,c="to"===i?l.get(x.value.toUpperCase()):n[0],u="from"===i?l.get(b.value.toUpperCase()):n[0],h=v.querySelector(`#${i}-type`).value,d=v.querySelector(`#${i}-month`).value,p=v.querySelector(`#${i}-date`).value,f=r.value,m=o.value;a.remove(...oq),a.add("station-searching"),t.setButtons([t._backButton]),V(`${s.searchUrl}?origin=${c.id}&destination=${u.id}&type=${h}&month=${d}&date=${p}&hours=${f}&minutes=${m}`).then(e=>{const i=v.classList;i.contains("station-searching")&&(i.remove(...oq),t.showResult(e))})})}t.popups=[];const w=t._backButton=Q("div",{innerHTML:['<button id="back-button" class="back-button">','<span class="back-icon"></span>',"</button>"].join("")});return w.addEventListener("click",e=>{e.stopPropagation()}),w.querySelector("#back-button").addEventListener("click",()=>{const i=t._swiper,n=v.classList;i&&(i.destroy(),delete t._swiper,t.hideRoute()),n.remove(...oq),v.querySelector("#station-to-button").checked?(n.add("station-to"),x.focus()):(n.add("station-from"),b.focus()),t.setButtons(),e.map.flyTo({center:e.lastCameraParams.center,zoom:15.5}),e._setSearchMode("edit")}),t}reset(){const e=this,{_map:t,_container:i,_swiper:n}=e,r=i.classList;n&&(n.destroy(),delete e._swiper,e.hideRoute()),r.remove(...oq),r.add("station-departure"),i.querySelector(":checked").checked=!1,i.querySelector("#station-departure-button").checked=!0,e.setButtons(),t.hideStationExits(),t.map.flyTo({center:t.lastCameraParams.center,zoom:15.5}),t._setSearchMode("none")}updateContent(){const{_map:e,_container:t,_exits:i,_departures:n}=this,{dict:r,clock:s,container:o}=e,a=s.getTimeOffset(),l=s.getCalendar(),c=t.querySelector("#station-exits");if(this.isOpen()){for(const t of n){const i=[];for(const{railway:n,station:r,direction:s}of t.railways)for(const t of e.timetables.getByDirectionId(n.id,s.id)){const n=e.activeTrainLookup.get(t.t)||e.standbyTrainLookup.get(t.id),s=n&&n.delay||0,o=t.stations;if(!(t.end+s<=a))for(let e=0,n=o.length-1;e<n;e++)if(o[e]===r){const n=t.departureTimes[e]+s;n>a&&(0===i.length||n<i[0].time?(i.unshift({timetable:t,time:n,delay:s}),i.splice(2,1)):(1===i.length||n<i[1].time)&&i.splice(1,1,{timetable:t,time:n,delay:s}));break}}t.trains=i}t.querySelector("#station-departure").innerHTML=n.map(({color:t,label:i,trains:n})=>['<div class="direction-row">',`<div class="line-strip" style="background-color: ${t};"></div>`,`<div class="direction-label">${i}</div>`,"</div>",'<div class="trains-row">',n.length?n.map(({timetable:t,time:i,delay:n})=>['<div class="train-row">',`<div class="train-time-box${n>=6e4?" desc-caution":""}">${X(i)}</div>`,'<div class="train-title-box">',`<span class="train-type-label">${e.getLocalizedTrainTypeTitle(t.y)}</span> `,t.nm?`${e.getLocalizedTrainNameOrRailwayTitle(t.nm)} `:"",e.getLocalizedDestinationTitle(t.ds,t.d),n>=6e4?` <span class="desc-caution">${r.delay.replace("$1",Math.floor(n/6e4))}</span>`:"","</div>","</div>"].join("")).join(""):`<div class="train-row desc-caution">${r["service-has-ended"]}</div>`,"</div>"].join("")).join(""),c.innerHTML="";for(let t=0,n=i.length;t<n;t++){const n=i[t],r=n.uptime&&n.uptime.reduce((e,t)=>!t.calendar||H(t.calendar,l)?t:e,{}),s=Q("div",{className:"exit-row"+(r&&(a<r.open||a>=r.close||r.open===r.close)?" closed":""),innerHTML:['<div class="exit-icon-box"></div>','<div class="exit-title-box">',e.getLocalizedPOIDescription(n),r&&r.open!==r.close?` (${X(r.open)}-${X(r.close)})`:"","</div>",(n.facilities||[]).map(e=>`<div class="exit-${e}-icon"></div>`).join(""),'<div class="exit-share-button"></div>'].join("")},c);s.addEventListener("click",()=>{e.map.flyTo({center:n.coord,zoom:19,pitch:30})}),s.addEventListener("mouseenter",()=>{const e=o.querySelector(`#exit-${t}`);e&&e.classList.add("highlighted")}),s.addEventListener("mouseleave",()=>{const e=o.querySelector(`#exit-${t}`);e&&e.classList.remove("highlighted")})}}}fillStationName(e){const t=this._container,i=t.classList;if(i.contains("station-to")){const i=t.querySelector("#origin");i.value=e,i.dispatchEvent(new Event("input")),i.focus()}else if(i.contains("station-from")){const i=t.querySelector("#destination");i.value=e,i.dispatchEvent(new Event("input")),i.focus()}}showResult(e){const t=this,{_map:i,_container:n,_backButton:r}=t,s=i.dict,o=n.classList,a=Q("div",{className:"page-controller",innerHTML:['<span><button id="previous-button" class="previous-button">','<span class="previous-icon"></span>',"</button></span>",'<span><button id="next-button" class="next-button">','<span class="next-icon"></span>',"</button></span>"].join("")}),l=n.querySelector(".swiper-wrapper"),c=e.routes;if(t._result=e,i._setSearchMode("route"),a.addEventListener("click",e=>{e.stopPropagation()}),a.querySelector("#previous-button").addEventListener("click",()=>{t._swiper.slidePrev()}),a.querySelector("#next-button").addEventListener("click",()=>{t._swiper.slideNext()}),l.innerHTML="",c){o.add("station-routes"),t.setButtons([r,a]);for(const e of c){const t=Q("div",{className:"swiper-slide",innerHTML:['<div class="swiper-slide-content">','<div id="search-routes"></div>','<svg id="railway-mark"></svg>',"</div>"].join("")},l),n=t.querySelector("#search-routes"),r=t.querySelector("#railway-mark"),o=[],a=[],c=[];let u;for(const{r:t,y:n,ds:r,d:l,tt:c,nm:h,transfer:d,delay:p}of e.trains){const e=c[0],f=c[c.length-1],m=i.getLocalizedTrainNameOrRailwayTitle(h,i.railways.get(t)),g=i.getLocalizedTrainTypeTitle(i.trainTypes.get(n)),_=i.getLocalizedDestinationTitle(r?r.map(e=>i.stations.get(e)):void 0,i.railDirections.get(l)),y={};if(y.start=a.length,a.push(['<div class="station-row">',`<div class="station-title-box">${i.getLocalizedStationTitle(i.stations.get(e.s))}</div>`,`<div class="station-time-box${p?" desc-caution":""}">`,void 0!==u?`${X(u+6e4*p)}<br>`:"",X($(e.d)+6e4*p),"</div></div>"].join("")),a.push(['<div class="station-row">',`<div class="train-title-box">${m} <span class="train-type-label">${g}</span> ${_}`,p?` <span class="desc-caution">${s.delay.replace("$1",p)}</span>`:"","</div></div>"].join("")),y.end=a.length,y.color=i.railways.get(t).color,o.push(y),0===d)u=$(f.a);else{if(a.push(['<div class="station-row">',`<div class="station-title-box">${i.getLocalizedStationTitle(i.stations.get(f.s))}</div>`,`<div class="station-time-box${p?" desc-caution":""}">`,X($(f.a||f.d)+6e4*p),"</div></div>"].join("")),d>0){const e={};e.start=a.length-1,a.push(['<div class="station-row">',`<div class="train-title-box">${s["transfer-and-wait"].replace("$1",d)}</div>`,"</div>"].join("")),e.end=a.length,o.push(e)}u=void 0}}n.innerHTML=a.join("");for(const e of n.children)c.push(e.offsetTop+e.getBoundingClientRect().height/2);r.innerHTML=o.map(({color:e,start:t,end:i})=>e?`<line stroke="${e}" stroke-width="10" x1="12" y1="${c[t]}" x2="12" y2="${c[i]}" stroke-linecap="round" />`:`<line stroke="#7f7f7f" stroke-width="4" x1="12" y1="${c[t]}" x2="12" y2="${c[i]}" stroke-dasharray="4 4" />`).concat(c.map((e,t)=>t%2==0?`<circle cx="12" cy="${e}" r="3" fill="#ffffff" />`:"")).join("")}t._swiper=new nq(".swiper",{modules:[sq],pagination:{el:".swiper-pagination",clickable:!0}}),t._swiper.on("slideChange",()=>{t.hideRoute()}),t._swiper.on("slideChangeTransitionEnd",()=>{t.switchRoute()}),t.switchRoute()}else o.add("station-noroute"),t.setButtons([r]),l.innerHTML=['<div class="swiper-slide">','<div class="swiper-slide-content">',s["cannot-find-train"],"</div></div>"].join("")}switchRoute(){const e=this,{_map:t,_container:i,_swiper:n}=e,{dict:r,map:s,featureCollection:o}=t,a=n.activeIndex,l=e._result.routes[a],c=l.trains,u=[],h=[],d=[];i.querySelector("#station-title-routes").innerHTML=[`${r.route}${a+1} `,r.transfers.replace("$1",l.numTransfers)].join(""),i.querySelector("#previous-button").disabled=n.isBeginning,i.querySelector("#next-button").disabled=n.isEnd;for(const{r:e,tt:i,d:n}of c){const{stations:r,ascending:s}=t.railways.get(e),o=r.map(({id:e})=>e),a=i[0].s,l=i[i.length-1].s;for(const e of i){const i=t.stations.get(e.s);h.push(i.group),d.push(i.coord)}if(n===s.id){const t=o.indexOf(a),i=o.indexOf(l,t);for(let n=t;n<i;n++)u.push(`${e}.${n+1}`)}else{const t=o.lastIndexOf(a),i=o.lastIndexOf(l,t);for(let n=t;n>i;n--)u.push(`${e}.${n}`)}}for(const e of[13,14,15,16,17,18])s.getLayer(`railways-routeug-${e}`).setProps({data:Xg(o,t=>t.zoom===e&&t.altitude<0&&H(u,t.section)),visible:!0}),s.getLayer(`stations-routeug-${e}`).setProps({data:Xg(o,t=>t.zoom===e&&t.altitude<0&&H(h,t.group)),visible:!0}),s.getLayer(`railways-routeog-${e}`).setProps({data:Xg(o,t=>t.zoom===e&&0===t.altitude&&H(u,t.section)),visible:!0}),s.getLayer(`stations-routeog-${e}`).setProps({data:Xg(o,t=>t.zoom===e&&0===t.altitude&&H(h,t.group)),visible:!0});s.fitBounds(P_(d),{bearing:s.getBearing(),pitch:s.getPitch(),offset:[0,-s.transform.height/12],padding:{top:20,bottom:20,left:10,right:60},retainPadding:!1,linear:!0,maxZoom:18}),t.refreshMap();const p=[c[0].tt[0].s];for(const e of c)(e.transfer>0||e===c[c.length-1])&&p.push(e.tt[e.tt.length-1].s);e.popups=p.map((i,n)=>setTimeout(()=>{const o=new Me({className:"popup-route",closeButton:!1,closeOnClick:!1});o.setLngLat(t.stations.get(i).coord).setHTML(0===n?r["from-station"]:n===p.length-1?r["to-station"]:`${r.transfer}${n}`).addTo(s),e.popups[n]=o},n/p.length*1e3+500))}hideRoute(){const e=this,t=e._map.map;for(const e of[13,14,15,16,17,18])for(const i of["routeug","routeog"])for(const n of["railways","stations"])L_(t,`${n}-${i}-${e}`,{data:$g(),visible:!1});for(const t of e.popups)t instanceof Me?t.remove():clearTimeout(t)}remove(){return this.hideRoute(),super.remove()}}const lq=["position","back","topback","front","topfront","helicopter","drone","bird"];class cq extends YH{constructor(e){super(Object.assign({className:"tracking-mode-panel",modal:!0},e));const t=this;t._onModeChanged=e=>{const i=t._container,n=e.mode.replace("heading","topback");i.querySelector(".tracking-mode-icon-enabled").classList.remove("tracking-mode-icon-enabled"),i.querySelector(`#${n}-tracking-mode .tracking-mode-icon`).classList.add("tracking-mode-icon-enabled")}}addTo(e){const t=this,i=e.dict,n=e.getTrackingMode();super.addTo(e).setTitle(i["tracking-modes"]).setHTML(lq.map(e=>[`<div id="${e}-tracking-mode" class="tracking-mode-row">`,'<div class="tracking-mode-icon"></div>',`<div>${i[e]}</div>`,"</div>"].join("")).join(""));for(const i of lq){const r=t._container.querySelector(`#${i}-tracking-mode .tracking-mode-icon`);(i===n||"topback"===i&&"heading"===n)&&r.classList.add("tracking-mode-icon-enabled"),r.addEventListener("click",()=>{e.getTrackingMode()!==i&&e.setTrackingMode(i)})}return e.on("trackingmode",t._onModeChanged),t}remove(){return this._map.off("trackingmode",this._onModeChanged),super.remove()}}class uq extends YH{constructor(e){super(Object.assign({className:"train-panel"},e))}addTo(e){const t=this,i=[],n=[],r=[],s=[],o=t._options.object,{r:a,timetable:l}=o,c=(o.v||a).color,u=o.delay||0;let h,d;for(let e=l;e;e=e.pt&&e.pt[0])i.unshift(e);for(let e=l.nt&&l.nt[0];e;e=e.nt&&e.nt[0])i.push(e);for(const t of i){const i={},s=t.stations;i.start=r.length;for(let i=0,n=s.length;i<n;i++){const o=t.arrivalTimes[i]||d,a=t.departureTimes[i];if(i===n-1&&t.nt){d=o;break}d=void 0,r.push(['<div class="station-row">',`<div class="station-title-box">${e.getLocalizedStationTitle(s[i])}</div>`,'<div class="station-time-box',u>=6e4?" desc-caution":"",'">',void 0!==o?X(o+u):"",void 0!==o&&void 0!==a?"<br>":"",void 0!==a?X(a+u):"","</div></div>"].join(""))}i.end=r.length-(t.nt?0:1),i.color=t.r.color,n.push(i),t===l&&(h=i)}super.addTo(e).setTitle(['<div class="desc-header">',Array.isArray(c)?["<div>",...c.slice(0,3).map(e=>`<div class="line-strip-long" style="background-color: ${e};"></div>`),"</div>"].join(""):`<div style="background-color: ${c};"></div>`,'<div><div class="desc-first-row">',e.getLocalizedTrainNameOrRailwayTitle(o.nm,a),'</div><div class="desc-second-row">',`<span class="train-type-label">${e.getLocalizedTrainTypeTitle(o.y)}</span> `,e.getLocalizedDestinationTitle(o.ds,o.d),"</div></div></div>"].join("")).setHTML(['<div id="timetable-content">',...r,"</div>",'<svg id="railway-mark"></svg>','<svg id="train-mark"></svg>'].join(""));const p=t._container,f=p.querySelector("#panel-body");for(const e of p.querySelector("#timetable-content").children)s.push(e.offsetTop+e.getBoundingClientRect().height/2);p.querySelector("#railway-mark").innerHTML=n.map(({color:e,start:t,end:i})=>`<line stroke="${e}" stroke-width="10" x1="12" y1="${s[t]}" x2="12" y2="${s[i]}" stroke-linecap="round" />`).concat(s.map(e=>`<circle cx="12" cy="${e}" r="3" fill="#ffffff" />`)).join("");const m=s.slice(h.start,h.end+1);return function e(){const i=f.getBoundingClientRect().height,n=o.timetableIndex,r=m[n],s=j(r,o.arrivalStation?m[n+1]:r,o._t),a=performance.now()%1500/1500;p.querySelector("#train-mark").innerHTML=`<circle cx="22" cy="${s}" r="${7+15*a}" fill="#ffffff" opacity="${1-a}" /><circle cx="22" cy="${s}" r="7" fill="#ffffff" />`,void 0!==t._scrollTop&&t._scrollTop!==f.scrollTop||(f.scrollTop=Math.round(s-i/2+4),t._scrollTop=f.scrollTop),t._container&&requestAnimationFrame(e)}(),t}reset(){delete this._scrollTop}}class hq{constructor(e){const t=this;t.implementation=e,t.enabled=!1,t.clockModes=e.clockModes||["realtime","playback"],t.viewModes=e.viewModes||["ground","underground"],t.searchModes=e.searchModes||["none"],t._onModeChanged=()=>{t.setVisibility(!0)}}addTo(e){const t=this,i=t.implementation;return t.map=e,i.onAdd&&i.onAdd(e),q(i.enabled,!0)&&t.enable(),t}remove(){const e=this,t=e.implementation;return e.disable(),t.onRemove&&t.onRemove(e.map),delete e.map,e}enable(){const e=this,{map:t,_onModeChanged:i,implementation:n}=e;return e.enabled||(e.enabled=!0,t.on("clockmode",i),t.on("viewmode",i),n.onEnabled&&n.onEnabled(),e.setVisibility(!0)),e}disable(){const e=this,{map:t,_onModeChanged:i,implementation:n}=e;return e.enabled&&(e.enabled=!1,t.off("clockmode",i),t.off("viewmode",i),e.setVisibility(!1),n.onDisabled&&n.onDisabled()),e}setVisibility(e){const t=this,{map:i,implementation:n}=t;n.onVisibilityChanged&&n.onVisibilityChanged(e&&t.enabled&&H(t.clockModes,i.getClockMode())&&H(t.viewModes,i.getViewMode())&&H(t.searchModes,i.searchMode))}getId(){return this.implementation.id}getName(e){const t=this.implementation.name;return t[e]||t.en}getIconStyle(){return this.implementation.iconStyle}isEnabled(){return this.enabled}}function dq(e,t,i,n){if(!ye(n=n||{}))throw new Error("options is invalid");var r=n.units,s=n.properties,o=jm(e),a=ge(o[0]),l=ge(o[1]),c=ge(i),u=function(e,t){if(null==e)throw new Error("distance is required");if(t&&"string"!=typeof t)throw new Error("units must be a string");var i=ue[t||"kilometers"];if(!i)throw new Error(t+" units is invalid");return e/i}(t,r),h=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c));return de([me(a+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(h))),me(h)],s)}function pq(e,t,i,n,r){fq(e,t,i||0,n||e.length-1,r||gq)}function fq(e,t,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,o=t-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);fq(e,t,Math.max(i,Math.floor(t-o*l/s+c)),Math.min(n,Math.floor(t+(s-o)*l/s+c)),r)}var u=e[t],h=i,d=n;for(mq(e,i,t),r(e[n],u)>0&&mq(e,i,n);h<d;){for(mq(e,h,d),h++,d--;r(e[h],u)<0;)h++;for(;r(e[d],u)>0;)d--}0===r(e[i],u)?mq(e,i,d):mq(e,++d,n),d<=t&&(i=d+1),t<=d&&(n=d-1)}}function mq(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function gq(e,t){return e<t?-1:e>t?1:0}function _q(e,t){if(!(this instanceof _q))return new _q(e,t);this._maxEntries=Math.max(4,e||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),t&&this._initFormat(t),this.clear()}function yq(e,t,i){if(!i)return t.indexOf(e);for(var n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function vq(e,t){xq(e,0,e.children.length,t,e)}function xq(e,t,i,n,r){r||(r=Pq(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var s,o=t;o<i;o++)s=e.children[o],bq(r,e.leaf?n(s):s);return r}function bq(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function wq(e,t){return e.minX-t.minX}function Tq(e,t){return e.minY-t.minY}function Sq(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Eq(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Aq(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Mq(e,t){var i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),s=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function Iq(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Cq(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Pq(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Lq(e,t,i,n,r){for(var s,o=[t,i];o.length;)(i=o.pop())-(t=o.pop())<=n||(pq(e,s=t+Math.ceil((i-t)/n/2)*n,t,i,r),o.push(t,s,s,i))}function Rq(e){var t=[e[0],e[1]];return{type:"Feature",bbox:e,properties:{},geometry:{type:"Polygon",coordinates:[[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]]}}}function Oq(e){var t=[1/0,1/0,-1/0,-1/0];return be(e,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}function Dq(e){if(!e)throw new Error("geojson is required");var t=[];return Te(e,function(e){!function(e,t){var i=[],n=e.geometry;switch(n.type){case"Polygon":i=Gm(n);break;case"LineString":i=[Gm(n)]}i.forEach(function(i){var n=function(e,t){var i=[];return e.reduce(function(e,n){var r,s,o,a,l,c,u=pe([e,n],t);return u.bbox=[(o=(r=e)[0])<(l=(s=n)[0])?o:l,(a=r[1])<(c=s[1])?a:c,o>l?o:l,a>c?a:c],i.push(u),n}),i}(i,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}(e,t)}),fe(t)}function Bq(e,t){var i={},n=[];if("LineString"===e.type&&(e=he(e)),"LineString"===t.type&&(t=he(t)),"Feature"===e.type&&"Feature"===t.type&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var r=Fq(e,t);return r&&n.push(r),fe(n)}var s=function(e){var t=_q(e);return t.insert=function(e){if(Array.isArray(e)){var t=e;(e=Rq(t)).bbox=t}else e.bbox=e.bbox?e.bbox:Oq(e);return _q.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){var i=Rq(e);i.bbox=e,t.push(i)}):we(e,function(e){e.bbox=e.bbox?e.bbox:Oq(e),t.push(e)}),_q.prototype.load.call(this,t)},t.remove=function(e){if(Array.isArray(e)){var t=e;(e=Rq(t)).bbox=t}return _q.prototype.remove.call(this,e)},t.clear=function(){return _q.prototype.clear.call(this)},t.search=function(e){return{type:"FeatureCollection",features:_q.prototype.search.call(this,this.toBBox(e))}},t.collides=function(e){return _q.prototype.collides.call(this,this.toBBox(e))},t.all=function(){return{type:"FeatureCollection",features:_q.prototype.all.call(this)}},t.toJSON=function(){return _q.prototype.toJSON.call(this)},t.fromJSON=function(e){return _q.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;return{minX:(t=e.bbox?e.bbox:Array.isArray(e)&&4===e.length?e:Oq(e))[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}();return s.load(Dq(t)),we(Dq(e),function(e){we(s.search(e),function(t){var r=Fq(e,t);if(r){var s=Gm(r).join(",");i[s]||(i[s]=!0,n.push(r))}})}),fe(n)}function Fq(e,t){var i=Gm(e),n=Gm(t);if(2!==i.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var r=i[0][0],s=i[0][1],o=i[1][0],a=i[1][1],l=n[0][0],c=n[0][1],u=n[1][0],h=n[1][1],d=(h-c)*(o-r)-(u-l)*(a-s),p=(u-l)*(s-c)-(h-c)*(r-l),f=(o-r)*(s-c)-(a-s)*(r-l);if(0===d)return null;var m=p/d,g=f/d;return m>=0&&m<=1&&g>=0&&g<=1?de([r+m*(o-r),s+m*(a-s)]):null}function Nq(e,t,i,n){if(!ye(n=n||{}))throw new Error("options is invalid");const r=e.geometry?e.geometry.type:e.type;if("LineString"!==r&&"MultiLineString"!==r)throw new Error("lines must be LineString or MultiLineString");let s=de([1/0,1/0],{dist:1/0,score:1/0}),o=0;return Te(e,e=>{const r=Gm(e);for(let e=0;e<r.length-1;e++){const a=de(r[e]);a.properties.dist=qg(t,a,n),a.properties.score=a.properties.dist+Math.abs(o-i)/100;const l=de(r[e+1]);l.properties.dist=qg(t,l,n);const c=qg(a,l,n);l.properties.score=l.properties.dist+Math.abs(o+c-i)/100;const u=Math.max(a.properties.dist,l.properties.dist),h=Hm(a,l),d=dq(t,u,h+90,n),p=dq(t,u,h-90,n),f=Bq(pe([d.geometry.coordinates,p.geometry.coordinates]),pe([a.geometry.coordinates,l.geometry.coordinates]));let m=null;f.features.length>0&&(m=f.features[0],m.properties.dist=qg(t,m,n),m.properties.location=o+qg(a,m,n),m.properties.score=m.properties.dist+Math.abs(m.properties.location-i)/100),a.properties.score<s.properties.score&&(s=a,s.properties.index=e,s.properties.location=o),l.properties.score<s.properties.score&&(s=l,s.properties.index=e+1,s.properties.location=o+c),m&&m.properties.score<s.properties.score&&(s=m,s.properties.index=e),o+=c}}),s}_q.prototype={all:function(){return this._all(this.data,[])},search:function(e){var t=this.data,i=[],n=this.toBBox;if(!Cq(e,t))return i;for(var r,s,o,a,l=[];t;){for(r=0,s=t.children.length;r<s;r++)o=t.children[r],Cq(e,a=t.leaf?n(o):o)&&(t.leaf?i.push(o):Iq(e,a)?this._all(o,i):l.push(o));t=l.pop()}return i},collides:function(e){var t=this.data,i=this.toBBox;if(!Cq(e,t))return!1;for(var n,r,s,o,a=[];t;){for(n=0,r=t.children.length;n<r;n++)if(s=t.children[n],Cq(e,o=t.leaf?i(s):s)){if(t.leaf||Iq(e,o))return!0;a.push(s)}t=a.pop()}return!1},load:function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0,i=e.length;t<i;t++)this.insert(e[t]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},insert:function(e){return e&&this._insert(e,this.data.height-1),this},clear:function(){return this.data=Pq([]),this},remove:function(e,t){if(!e)return this;for(var i,n,r,s,o=this.data,a=this.toBBox(e),l=[],c=[];o||l.length;){if(o||(o=l.pop(),n=l[l.length-1],i=c.pop(),s=!0),o.leaf&&-1!==(r=yq(e,o.children,t)))return o.children.splice(r,1),l.push(o),this._condense(l),this;s||o.leaf||!Iq(o,a)?n?(i++,o=n.children[i],s=!1):o=null:(l.push(o),c.push(i),i=0,n=o,o=o.children[0])}return this},toBBox:function(e){return e},compareMinX:wq,compareMinY:Tq,toJSON:function(){return this.data},fromJSON:function(e){return this.data=e,this},_all:function(e,t){for(var i=[];e;)e.leaf?t.push.apply(t,e.children):i.push.apply(i,e.children),e=i.pop();return t},_build:function(e,t,i,n){var r,s=i-t+1,o=this._maxEntries;if(s<=o)return vq(r=Pq(e.slice(t,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),(r=Pq([])).leaf=!1,r.height=n;var a,l,c,u,h=Math.ceil(s/o),d=h*Math.ceil(Math.sqrt(o));for(Lq(e,t,i,d,this.compareMinX),a=t;a<=i;a+=d)for(Lq(e,a,c=Math.min(a+d-1,i),h,this.compareMinY),l=a;l<=c;l+=h)u=Math.min(l+h-1,c),r.children.push(this._build(e,l,u,n-1));return vq(r,this.toBBox),r},_chooseSubtree:function(e,t,i,n){for(var r,s,o,a,l,c,u,h;n.push(t),!t.leaf&&n.length-1!==i;){for(u=h=1/0,r=0,s=t.children.length;r<s;r++)l=Sq(o=t.children[r]),(c=Aq(e,o)-l)<h?(h=c,u=l<u?l:u,a=o):c===h&&l<u&&(u=l,a=o);t=a||t.children[0]}return t},_insert:function(e,t,i){var n=i?e:(0,this.toBBox)(e),r=[],s=this._chooseSubtree(n,this.data,t,r);for(s.children.push(e),bq(s,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)},_split:function(e,t){var i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var s=this._chooseSplitIndex(i,r,n),o=Pq(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,vq(i,this.toBBox),vq(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(i,o)},_splitRoot:function(e,t){this.data=Pq([e,t]),this.data.height=e.height+1,this.data.leaf=!1,vq(this.data,this.toBBox)},_chooseSplitIndex:function(e,t,i){var n,r,s,o,a,l,c,u;for(l=c=1/0,n=t;n<=i-t;n++)o=Mq(r=xq(e,0,n,this.toBBox),s=xq(e,n,i,this.toBBox)),a=Sq(r)+Sq(s),o<l?(l=o,u=n,c=a<c?a:c):o===l&&a<c&&(c=a,u=n);return u},_chooseSplitAxis:function(e,t,i){var n=e.leaf?this.compareMinX:wq,r=e.leaf?this.compareMinY:Tq;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)},_allDistMargin:function(e,t,i,n){e.children.sort(n);var r,s,o=this.toBBox,a=xq(e,0,t,o),l=xq(e,i-t,i,o),c=Eq(a)+Eq(l);for(r=t;r<i-t;r++)s=e.children[r],bq(a,e.leaf?o(s):s),c+=Eq(a);for(r=i-t-1;r>=t;r--)s=e.children[r],bq(l,e.leaf?o(s):s),c+=Eq(l);return c},_adjustParentBBoxes:function(e,t,i){for(var n=i;n>=0;n--)bq(t[n],e)},_condense:function(e){for(var t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children).splice(t.indexOf(e[i]),1):this.clear():vq(e[i],this.toBBox)},_initFormat:function(e){var t=["return a"," - b",";"];this.compareMinX=new Function("a","b",t.join(e[0])),this.compareMinY=new Function("a","b",t.join(e[1])),this.toBBox=new Function("a","return {minX: a"+e[0]+", minY: a"+e[1]+", maxX: a"+e[2]+", maxY: a"+e[3]+"};")}};const kq="Toei.Mita",zq=["ADO","SFJ","SNJ"],Uq=Math.PI/180,Vq=ae.NavigationControl.prototype._updateZoomButtons;ae.NavigationControl.prototype._updateZoomButtons=function(){const{_disabled:e,_zoomInButton:t,_zoomOutButton:i,_compass:n}=this;Vq.apply(this),e&&(t.disabled=i.disabled=!0,t.setAttribute("aria-disabled","true"),i.setAttribute("aria-disabled","true")),n.disabled=!!e,n.setAttribute("aria-disabled",(!!e).toString())},ae.NavigationControl.prototype.enable=function(){delete this._disabled,this._updateZoomButtons()},ae.NavigationControl.prototype.disable=function(){this._disabled=!0,this._updateZoomButtons()};function jq(e,t){return{id:e.id,trainUrl:$H(e.trainUrl,t),trainInfoUrl:$H(e.trainInfoUrl,t),flightUrl:$H(e.flightUrl,t),atisUrl:$H(e.atisUrl,t),gtfsUrl:$H(e.gtfsUrl,t),vehiclePositionUrl:$H(e.vehiclePositionUrl,t),color:e.color,expiresAt:e.expiresAt}}function Gq(e){const t=e.querySelector("#loader");t.style.opacity=0,setTimeout(()=>{t.style.display="none"},1e3)}function Hq(e){const t=e.querySelector("#loader"),i=e.querySelector("#loading-error");t.style.display="none",i.innerHTML="Loading failed. Please reload the page.",i.style.display="block"}function Wq(e,t){const i=e.length,n=[],r=[];for(let s=0;s<i-1;s++){const i=e[s+1]-e[s],o=t[s+1]-t[s];n.push(i),r.push(o/i)}const s=[r[0]];for(let e=0;e<n.length-1;e++){const t=r[e],i=r[e+1];if(t*i<=0)s.push(0);else{const r=n[e],o=n[e+1],a=r+o;s.push(3*a/((a+o)/t+(a+r)/i))}}s.push(r[r.length-1]);const o=[],a=[];for(let e=0;e<s.length-1;e++){const t=s[e],i=r[e],l=1/n[e],c=t+s[e+1]-i-i;o.push((i-t-c)*l),a.push(c*l*l)}return i=>{let n=e.length-1;if(i===e[n])return t[n];let r,l=0,c=a.length-1;for(;l<=c;){r=Math.floor(.5*(l+c));const n=e[r];if(n<i)l=r+1;else{if(!(n>i))return t[r];c=r-1}}n=Math.max(0,c);const u=i-e[n],h=u*u;return t[n]+s[n]*u+o[n]*h+a[n]*u*h}}function qq(e){return G(Math.floor(e),13,18)}function Xq(e){return e&&H(["train","flight","bus"],e.type)}function $q(e){return e&&"station"===e.type}function Zq(e,t){return e===t||!!(e&&e.properties&&t&&t.properties&&e.properties.ids===t.properties.ids)}function Yq(e){const t=new Map,i=new Map,n=e.clone();return Jq(e,n,function(e,n){t.set(n,e),i.set(e,n)}),n.traverse(function(e){if(!e.isSkinnedMesh)return;const n=e,r=t.get(e),s=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=s.map(function(e){return i.get(e)}),n.bind(n.skeleton,n.bindMatrix)}),n}function Jq(e,t,i){i(e,t);for(let n=0;n<e.children.length;n++)Jq(e.children[n],t.children[n],i)}function Kq(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Qq(e,t,i){const n=e.json.materials[t];return n.extensions&&n.extensions[i]?n.extensions[i]:null}const eX={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class tX{constructor(e){this.parser=e,this.name=eX.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const a=new cS(16777215);void 0!==s.color&&a.setRGB(s.color[0],s.color[1],s.color[2],mw);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new _P(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new fP(a),o.distance=l;break;case"spot":o=new dP(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),jX(o,s),void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),n=Promise.resolve(o),t.cache.add(i,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return i._getNodeRef(t.cache,r,e)})}}class iX{constructor(){this.name=eX.KHR_MATERIALS_UNLIT}getMaterialType(){return HE}extendParams(e,t,i){const n=[];e.color=new cS(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],mw),e.opacity=t[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(e,"map",r.baseColorTexture,fw))}return Promise.all(n)}}class nX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);return null===i||void 0!==i.emissiveStrength&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class rX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&n.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new iT(e,e)}return Promise.all(n)}}class sX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_DISPERSION}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);return null===i||(t.dispersion=void 0!==i.dispersion?i.dispersion:0),Promise.resolve()}}class oX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&n.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class aX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_SHEEN}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];if(t.sheenColor=new cS(0,0,0),t.sheenRoughness=0,t.sheen=1,void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],mw)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&n.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,fw)),void 0!==i.sheenRoughnessTexture&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class lX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&n.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class cX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_VOLUME}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&n.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=(new cS).setRGB(r[0],r[1],r[2],mw),Promise.all(n)}}class uX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_IOR}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);return null===i||(t.ior=void 0!==i.ior?i.ior:1.5),Promise.resolve()}}class hX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_SPECULAR}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&n.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=(new cS).setRGB(r[0],r[1],r[2],mw),void 0!==i.specularColorTexture&&n.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,fw)),Promise.all(n)}}class dX{constructor(e){this.parser=e,this.name=eX.EXT_MATERIALS_BUMP}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&n.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(n)}}class pX{constructor(e){this.parser=e,this.name=eX.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return null!==Qq(this.parser,e,this.name)?dC:null}extendMaterialParams(e,t){const i=Qq(this.parser,e,this.name);if(null===i)return Promise.resolve();const n=[];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&n.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class fX{constructor(e){this.parser=e,this.name=eX.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class mX{constructor(e){this.parser=e,this.name=eX.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=n.images[s.source];let a=i.textureLoader;if(o.uri){const e=i.options.manager.getHandler(o.uri);null!==e&&(a=e)}return i.loadTextureImage(e,s.source,a)}}class gX{constructor(e){this.parser=e,this.name=eX.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=n.images[s.source];let a=i.textureLoader;if(o.uri){const e=i.options.manager.getHandler(o.uri);null!==e&&(a=e)}return i.loadTextureImage(e,s.source,a)}}class _X{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(t){const i=e.count,n=e.byteStride,s=new Uint8Array(t,e.byteOffset||0,e.byteLength||0);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,n,s,e.mode,e.filter).then(function(e){return e.buffer}):r.ready.then(function(){const t=new ArrayBuffer(i*n);return r.decodeGltfBuffer(new Uint8Array(t),i,n,s,e.mode,e.filter),t})})}return null}}class yX{constructor(e){this.name=eX.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=t.meshes[i.mesh];for(const e of n.primitives)if(e.mode!==CX.TRIANGLES&&e.mode!==CX.TRIANGLE_STRIP&&e.mode!==CX.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=i.extensions[this.name].attributes,s=[],o={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{const t=e.pop(),i=t.isGroup?t.children:[t],n=e[0].count,r=[];for(const e of i){const t=new IT,i=new rT,s=new nT,a=new rT(1,1,1),l=new MA(e.geometry,e.material,n);for(let e=0;e<n;e++)o.TRANSLATION&&i.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&s.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),l.setMatrixAt(e,t.compose(i,s,a));for(const t in o)if("_COLOR_0"===t){const e=o[t];l.instanceColor=new vA(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);tS.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]}))}}const vX="glTF",xX=1313821514,bX=5130562;class wX{constructor(e){this.name=eX.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==vX)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let s=0;for(;s<n;){const t=r.getUint32(s,!0);s+=4;const n=r.getUint32(s,!0);if(s+=4,n===xX){const n=new Uint8Array(e,12+s,t);this.content=i.decode(n)}else if(n===bX){const i=12+s;this.body=e.slice(i,i+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class TX{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=eX.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=DX[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const n=DX[t]||t.toLowerCase();if(void 0!==s[t]){const r=i.accessors[e.attributes[t]];l[n]=PX[r.componentType].name,a[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then(function(e){return new Promise(function(t,i){n.decodeDracoFile(e,function(e){for(const t in e.attributes){const i=a[t];void 0!==i&&(e.attributes[t].normalized=i)}t(e)},o,l,mw,i)})})}}class SX{constructor(){this.name=eX.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class EX{constructor(){this.name=eX.KHR_MESH_QUANTIZATION}}class AX extends EC{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=i[r+e];return t}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=n-t,u=(i-t)/c,h=u*u,d=h*u,p=e*l,f=p-l,m=-2*d+3*h,g=d-h,_=1-m,y=g-h+u;for(let e=0;e!==o;e++){r[e]=_*s[f+e+o]+y*(s[f+e+a]*c)+m*s[p+e+o]+g*(s[p+e]*c)}return r}}const MX=new nT;class IX extends AX{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return MX.fromArray(r).normalize().toArray(r),r}}const CX={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},PX={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},LX={9728:Xx,9729:Yx,9984:$x,9985:Jx,9986:Zx,9987:Kx},RX={33071:Wx,33648:qx,10497:Hx},OX={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},DX={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},BX={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},FX={CUBICSPLINE:void 0,LINEAR:sw,STEP:rw},NX="OPAQUE",kX="MASK",zX="BLEND";function UX(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new hC({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function VX(e,t,i){for(const n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function jX(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function GX(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i<n;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){const i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,n=i.length;t<n;t++)e.morphTargetDictionary[i[t]]=t}}}function HX(e){let t;const i=e.extensions&&e.extensions[eX.KHR_DRACO_MESH_COMPRESSION];if(t=i?"draco:"+i.bufferView+":"+i.indices+":"+WX(i.attributes):e.indices+":"+WX(e.attributes)+":"+e.mode,void 0!==e.targets)for(let i=0,n=e.targets.length;i<n;i++)t+=":"+WX(e.targets[i]);return t}function WX(e){let t="";const i=Object.keys(e).sort();for(let n=0,r=i.length;n<r;n++)t+=i[n]+":"+e[i[n]]+";";return t}function qX(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const XX=new IT;class $X{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Kq,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,s=-1;if("undefined"!=typeof navigator&&void 0!==navigator.userAgent){const e=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);n=i&&t?parseInt(t[1],10):-1,r=e.indexOf("Firefox")>-1,s=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader="undefined"==typeof createImageBitmap||i&&n<17||r&&s<98?new YC(this.options.manager):new PP(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new XC(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(t){const s={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:i,userData:{}};return VX(r,s,n),jX(s,n),Promise.all(i._invokeAll(function(e){return e.afterRoot&&e.afterRoot(s)})).then(function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i].joints;for(let t=0,i=n.length;t<i;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone(),r=(e,t)=>{const i=this.associations.get(e);null!=i&&this.associations.set(t,i);for(const[i,n]of e.children.entries())r(n,t.children[i])};return r(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this;t=Promise.all((this.json[e+("mesh"===e?"es":"s")]||[]).map(function(t,n){return i.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[eX.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(e,r){i.load(TP.resolveURL(t.uri,n.path),e,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const i=t.byteOffset||0;return e.slice(i,i+(t.byteLength||0))})}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){const e=OX[n.type],t=!0===n.normalized,i=new(0,PX[n.componentType])(n.count*e);return Promise.resolve(new YS(i,e,t))}const r=[];return r.push(void 0!==n.bufferView?this.getDependency("bufferView",n.bufferView):null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(e){const r=e[0],s=OX[n.type],o=PX[n.componentType],a=o.BYTES_PER_ELEMENT,l=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,u=!0===n.normalized;let h,d;if(c&&c!==a*s){const e=Math.floor(l/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count;let p=t.cache.get(i);p||(h=new o(r,e*c,n.count*c/a),p=new dE(h,c/a),t.cache.add(i,p)),d=new fE(p,s,l%c/a,u)}else h=null===r?new o(n.count*s):new o(r,l,n.count*s),d=new YS(h,s,u);if(void 0!==n.sparse){const t=n.sparse.values.byteOffset||0,i=new(0,PX[n.sparse.indices.componentType])(e[1],n.sparse.indices.byteOffset||0,n.sparse.count*OX.SCALAR),a=new o(e[2],t,n.sparse.count*s);null!==r&&(d=new YS(d.array.slice(),d.itemSize,d.normalized)),d.normalized=!1;for(let e=0,t=i.length;e<t;e++){const t=i[e];if(d.setX(t,a[e*s]),s>=2&&d.setY(t,a[e*s+1]),s>=3&&d.setZ(t,a[e*s+2]),s>=4&&d.setW(t,a[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}d.normalized=u}return d})}loadTexture(e){const t=this.json,i=t.textures[e].source,n=t.images[i];let r=this.textureLoader;if(n.uri){const e=this.options.manager.getHandler(n.uri);null!==e&&(r=e)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,i){const n=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,i).then(function(t){t.flipY=!1,t.name=s.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const i=(r.samplers||{})[s.sampler]||{};return t.magFilter=LX[i.magFilter]||Yx,t.minFilter=LX[i.minFilter]||Kx,t.wrapS=RX[i.wrapS]||Hx,t.wrapT=RX[i.wrapT]||Hx,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==Xx&&t.minFilter!==Yx,n.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const s=n.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=i.getDependency("bufferView",s.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a});else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(e){return new Promise(function(i,n){let s=i;!0===t.isImageBitmapLoader&&(s=function(e){const t=new wT(e);t.needsUpdate=!0,i(t)}),t.load(TP.resolveURL(e,r.path),s,void 0,n)})}).then(function(e){var t;return!0===l&&o.revokeObjectURL(a),jX(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw e});return this.sourceCache[e]=c,c}assignTexture(e,t,i,n){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),r.extensions[eX.KHR_TEXTURE_TRANSFORM]){const e=void 0!==i.extensions?i.extensions[eX.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[eX.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==n&&(s.colorSpace=n),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new yM,_E.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new rM,_E.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,this.cache.add(e,t)),i=t}if(n||r||s){let e="ClonedMaterial:"+i.uuid+":";n&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}e.material=i}getMaterialType(){return hC}loadMaterial(e){const t=this,i=this.extensions,n=this.json.materials[e];let r;const s={},o=[];if((n.extensions||{})[eX.KHR_MATERIALS_UNLIT]){const e=i[eX.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),o.push(e.extendParams(s,n,t))}else{const i=n.pbrMetallicRoughness||{};if(s.color=new cS(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],mw),s.opacity=e[3]}void 0!==i.baseColorTexture&&o.push(t.assignTexture(s,"map",i.baseColorTexture,fw)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),r=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),o.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}!0===n.doubleSided&&(s.side=2);const a=n.alphaMode||NX;if(a===zX?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,a===kX&&(s.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&r!==HE&&(o.push(t.assignTexture(s,"normalMap",n.normalTexture)),s.normalScale=new iT(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==n.occlusionTexture&&r!==HE&&(o.push(t.assignTexture(s,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(s.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&r!==HE){const e=n.emissiveFactor;s.emissive=(new cS).setRGB(e[0],e[1],e[2],mw)}return void 0!==n.emissiveTexture&&r!==HE&&o.push(t.assignTexture(s,"emissiveMap",n.emissiveTexture,fw)),Promise.all(o).then(function(){const o=new r(s);return n.name&&(o.name=n.name),jX(o,n),t.associations.set(o,{materials:e}),n.extensions&&VX(i,o,n),o})}createUniqueName(e){const t=rL.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function r(e){return i[eX.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(i){return ZX(i,e,t)})}const s=[];for(let i=0,o=e.length;i<o;i++){const o=e[i],a=HX(o),l=n[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[eX.KHR_DRACO_MESH_COMPRESSION]?r(o):ZX(new hE,o,t),n[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.extensions,n=this.json.meshes[e],r=n.primitives,s=[];for(let e=0,t=r.length;e<t;e++){const t=void 0===r[e].material?UX(this.cache):this.getDependency("material",r[e].material);s.push(t)}return s.push(t.loadGeometries(r)),Promise.all(s).then(function(s){const o=s.slice(0,s.length-1),a=s[s.length-1],l=[];for(let s=0,c=a.length;s<c;s++){const c=a[s],u=r[s];let h;const d=o[s];if(u.mode===CX.TRIANGLES||u.mode===CX.TRIANGLE_STRIP||u.mode===CX.TRIANGLE_FAN||void 0===u.mode)h=!0===n.isSkinnedMesh?new pA(c,d):new iA(c,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===CX.TRIANGLE_STRIP?h.geometry=Qj(h.geometry,1):u.mode===CX.TRIANGLE_FAN&&(h.geometry=Qj(h.geometry,2));else if(u.mode===CX.LINES)h=new gM(c,d);else if(u.mode===CX.LINE_STRIP)h=new dM(c,d);else if(u.mode===CX.LINE_LOOP)h=new _M(c,d);else{if(u.mode!==CX.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new TM(c,d)}Object.keys(h.geometry.morphAttributes).length>0&&GX(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),jX(h,n),u.extensions&&VX(i,h,u),t.assignFinalMaterial(h),l.push(h)}for(let i=0,n=l.length;i<n;i++)t.associations.set(l[i],{meshes:e,primitives:i});if(1===l.length)return n.extensions&&VX(i,l[0],n),l[0];const c=new iS;n.extensions&&VX(i,c,n),t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c})}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(n)return"perspective"===i.type?t=new uP(tT.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(t=new mP(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),jX(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let e=0,n=t.joints.length;e<n;e++)i.push(this._loadNodeShallow(t.joints[e]));return i.push(void 0!==t.inverseBindMatrices?this.getDependency("accessor",t.inverseBindMatrices):null),Promise.all(i).then(function(e){const t=e.pop(),i=e,n=[],r=[];for(let e=0,s=i.length;e<s;e++){const s=i[e];if(s){n.push(s);const i=new IT;null!==t&&i.fromArray(t.array,16*e),r.push(i)}}return new yA(n,r)})}loadAnimation(e){const t=this,i=this.json.animations[e],n=i.name?i.name:"animation_"+e,r=[],s=[],o=[],a=[],l=[];for(let e=0,t=i.channels.length;e<t;e++){const t=i.channels[e],n=i.samplers[t.sampler],c=t.target,u=void 0!==i.parameters?i.parameters[n.input]:n.input,h=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==c.node&&(r.push(this.getDependency("node",c.node)),s.push(this.getDependency("accessor",u)),o.push(this.getDependency("accessor",h)),a.push(n),l.push(c))}return Promise.all([Promise.all(r),Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(e){const r=e[0],s=e[1],o=e[2],a=e[3],l=e[4],c=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=s[e],u=o[e],h=a[e],d=l[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=t._createAnimationTracks(i,n,u,h,d);if(p)for(let e=0;e<p.length;e++)c.push(p[e])}const u=new kC(n,void 0,c);return jX(u,i),u})}createNodeMesh(e){const t=this,i=this.json.nodes[e];return void 0===i.mesh?null:t.getDependency("mesh",i.mesh).then(function(e){const n=t._getNodeRef(t.meshCache,i.mesh,e);return void 0!==i.weights&&n.traverse(function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]}),n})}loadNode(e){const t=this,i=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],s=i.children||[];for(let e=0,i=s.length;e<i;e++)r.push(t.getDependency("node",s[e]));const o=void 0===i.skin?Promise.resolve(null):t.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),o]).then(function(e){const t=e[0],i=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,XX)});for(let e=0,n=i.length;e<n;e++)t.add(i[e]);if(void 0!==t.userData.pivot&&i.length>0){const e=t.userData.pivot,n=i[0];t.pivot=(new rT).fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],n.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){const t=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const n=this.json.nodes[e],r=n.name?i.createUniqueName(n.name):"",s=[],o=i._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return o&&s.push(o),void 0!==n.camera&&s.push(i.getDependency("camera",n.camera).then(function(e){return i._getNodeRef(i.cameraCache,n.camera,e)})),i._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){s.push(e)}),this.nodeCache[e]=Promise.all(s).then(function(s){let o;if(o=!0===n.isBone?new fA:s.length>1?new iS:1===s.length?s[0]:new tS,o!==s[0])for(let e=0,t=s.length;e<t;e++)o.add(s[e]);if(n.name&&(o.userData.name=n.name,o.name=r),jX(o,n),n.extensions&&VX(t,o,n),void 0!==n.matrix){const e=new IT;e.fromArray(n.matrix),o.applyMatrix4(e)}else void 0!==n.translation&&o.position.fromArray(n.translation),void 0!==n.rotation&&o.quaternion.fromArray(n.rotation),void 0!==n.scale&&o.scale.fromArray(n.scale);if(i.associations.has(o)){if(void 0!==n.mesh&&i.meshCache.refs[n.mesh]>1){const e=i.associations.get(o);i.associations.set(o,{...e})}}else i.associations.set(o,{});return i.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,r=new iS;i.name&&(r.name=n.createUniqueName(i.name)),jX(r,i),i.extensions&&VX(t,r,i);const s=i.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(n.getDependency("node",s[e]));return Promise.all(o).then(function(e){for(let t=0,i=e.length;t<i;t++){const i=e[t];r.add(null!==i.parent?Yq(i):i)}return n.associations=(e=>{const t=new Map;for(const[e,i]of n.associations)(e instanceof _E||e instanceof wT)&&t.set(e,i);return e.traverse(e=>{const i=n.associations.get(e);null!=i&&t.set(e,i)}),t})(r),r})}_createAnimationTracks(e,t,i,n,r){const s=[],o=e.name?e.name:e.uuid,a=[];let l;switch(BX[r.path]===BX.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(o),BX[r.path]){case BX.weights:l=OC;break;case BX.rotation:l=BC;break;case BX.translation:case BX.scale:l=NC;break;default:if(1===i.itemSize)l=OC;else l=NC}const c=void 0!==n.interpolation?FX[n.interpolation]:sw,u=this._getArrayFromAccessor(i);for(let e=0,i=a.length;e<i;e++){const i=new l(a[e]+"."+BX[r.path],t.array,u,c);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(i),s.push(i)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=qX(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*e;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof BC?IX:AX)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ZX(e,t,i){const n=t.attributes,r=[];function s(t,n){return i.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in n){const i=DX[t]||t.toLowerCase();i in e.attributes||r.push(s(n[t],i))}if(void 0!==t.indices&&!e.index){const n=i.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});r.push(n)}return jX(e,t),function(e,t,i){const n=t.attributes,r=new IS;if(void 0===n.POSITION)return;{const e=i.json.accessors[n.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return;if(r.set(new rT(t[0],t[1],t[2]),new rT(s[0],s[1],s[2])),e.normalized){const t=qX(PX[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new rT,t=new rT;for(let n=0,r=s.length;n<r;n++){const r=s[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],s=n.min,o=n.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),n.normalized){const e=qX(PX[n.componentType]);t.multiplyScalar(e)}e.max(t)}}}r.expandByVector(e)}e.boundingBox=r;const o=new nE;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,i),Promise.all(r).then(function(){return void 0!==t.targets?function(e,t,i){let n=!1,r=!1,s=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(n){const t=void 0!==u.POSITION?i.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?i.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==u.COLOR_0?i.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(t){const i=t[1],o=t[2];return n&&(e.morphAttributes.position=t[0]),r&&(e.morphAttributes.normal=i),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e})}(e,t.targets,i):e})}const YX=Object.assign({GLTFLoader:class extends HC{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new rX(e)}),this.register(function(e){return new sX(e)}),this.register(function(e){return new fX(e)}),this.register(function(e){return new mX(e)}),this.register(function(e){return new gX(e)}),this.register(function(e){return new aX(e)}),this.register(function(e){return new lX(e)}),this.register(function(e){return new cX(e)}),this.register(function(e){return new uX(e)}),this.register(function(e){return new nX(e)}),this.register(function(e){return new hX(e)}),this.register(function(e){return new oX(e)}),this.register(function(e){return new pX(e)}),this.register(function(e){return new dX(e)}),this.register(function(e){return new tX(e)}),this.register(function(e){return new _X(e,eX.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new _X(e,eX.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new yX(e)})}load(e,t,i,n){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=TP.extractUrlBase(e);s=TP.resolveURL(t,this.path)}else s=TP.extractUrlBase(e);this.manager.itemStart(e);const o=function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new XC(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(i){try{r.parse(i,s,function(i){t(i),r.manager.itemEnd(e)},o)}catch(e){o(e)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let r;const s={},o={},a=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===vX){try{s[eX.KHR_BINARY_GLTF]=new wX(e)}catch(e){return void(n&&n(e))}r=JSON.parse(s[eX.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new $X(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],i=r.extensionsRequired||[];switch(t){case eX.KHR_MATERIALS_UNLIT:s[t]=new iX;break;case eX.KHR_DRACO_MESH_COMPRESSION:s[t]=new TX(r,this.dracoLoader);break;case eX.KHR_TEXTURE_TRANSFORM:s[t]=new SX;break;case eX.KHR_MESH_QUANTIZATION:s[t]=new EX;break;default:i.indexOf(t)}}l.setExtensions(s),l.setPlugins(o),l.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,r){i.parse(e,t,n,r)})}}},DD);e.Map=class extends ae.Evented{constructor(e){super();const t=this;var i,n,r;e=function(e,...t){const i=lt,n={};n[i("0x0","6xIJ")]=i("0x1","%ou1"),n[i("0x2","2Hem")]=i("0x3","u^fZ");const r={};r[i("0x4","WMIj")]=i("0x5","x15a"),r[i("0x6","zx#t")]=n;const s=r;for(const i of[s,...t])for(const t in i)e[t]=i[t];return e}({hash:!1,useWebGL2:!0,center:s.defaultCenter,zoom:s.defaultZoom,bearing:s.defaultBearing,pitch:s.defaultPitch,dataUrl:s.dataUrl,dataSources:s.dataSources,clockControl:!0,searchControl:!0,navigationControl:!0,fullscreenControl:!0,modeControl:!0,configControl:!0,trackingMode:s.defaultTrackingMode,ecoMode:s.defaultEcoMode,ecoFrameRate:s.defaultEcoFrameRate},e),t.lang=te(e.lang),t.dataUrl=e.dataUrl,t.dataSources=e.dataSources.map(t=>jq(t,e.secrets)),t.container="string"==typeof e.container?document.getElementById(e.container):e.container,t.secrets=e.secrets,t.modelOrigin=ae.MercatorCoordinate.fromLngLat(e.center),t.exitPopups=[],t.clockControl=e.clockControl,t.searchControl=e.searchControl,t.navigationControl=e.navigationControl,t.fullscreenControl=e.fullscreenControl,t.modeControl=e.modeControl,t.configControl=e.configControl,t.clock=new Ne,t.plugins=(e.plugins||[]).map(e=>new hq(e)),t.searchMode="none",t.viewMode=s.defaultViewMode,t.trackingMode=e.trackingMode,t.trackingParams={zoom:{},bearing:{},pitch:{}},t.lastCameraParams={},t.initialSelection=e.selection,t.clockMode=s.defaultClockMode,t.isEditingTime=!1,t.ecoMode=e.ecoMode,t.ecoFrameRate=e.ecoFrameRate,t.lastDynamicUpdate={},t.lastRepaint=0,t.frameRateFactor=1,e.container=function(e){const t=Q("div",{id:"map"},e);return Q("div",{id:"loader",className:"loader-inner ball-pulse",innerHTML:"<div></div><div></div><div></div>"},e),Q("div",{id:"loading-error"},e),e.classList.add("mini-tokyo-3d"),t}(t.container),e.style=U("assets/style.json"),e.configControl||(e.customAttribution=[e.customAttribution,s.customAttribution].reduce((e,t)=>e.concat(t),[])),t.map=new ae.Map(e);for(const e of s.events)t.map.on(e,t.fire.bind(t));t.map.once("idle",()=>{new Promise(e=>{let t=0;const i=performance.now(),n=()=>{t++<60?requestAnimationFrame(n):e(1e3/((performance.now()-i)/60))};n()}).then(e=>{t.frameRateFactor=Math.min(60/e,2)})}),t.timezone=t.dataUrl?t.clock.getTimezone():void 0,t.gtfs=new Map,t.gtfsLoading=new Set,Promise.all([(r=t.lang,V(U(`assets/dictionary-${r}.json`))).then(e=>t.dict=e).catch(e=>{throw Hq(t.container),e}),(i=t.dataUrl,n=t.clock,Promise.all(i?[...["railways.json.gz","stations.json.gz","features.json.gz","rail-directions.json.gz","train-types.json.gz","train-vehicles.json.gz","operators.json.gz","airports.json.gz","flight-statuses.json.gz","poi.json.gz"].map(e=>`${i}/${e}`).map(V),Promise.all([jH(n),...GH(n)].map(e=>`${i}/${e}`).map(V))]:[...Array(11)].map(()=>[])).then(e=>({railwayData:e[0],stationData:e[1],featureCollection:e[2],railDirectionData:e[3],trainTypeData:e[4],trainVehicleData:e[5],operatorData:e[6],airportData:e[7],flightStatusData:e[8],poiData:e[9],timetableData:[].concat(...e[10])}))).then(t.initData.bind(t)).catch(e=>{throw Hq(t.container),e}),new Promise(e=>{t.map.once("styledata",()=>{Promise.resolve().then(()=>{const i=t.clock.getTime();k_(t.map,i,"ground"===t.viewMode?1:0),t.lastSunlightCenter=t.map.getCenter(),t.lastSunlightTime=i,t.lastSunlightRefresh=Date.now(),e()})})})]).then(t.initialize.bind(t)),t.refreshBusData()}getMapboxMap(){return this.map}getCenter(){return this.map.getCenter()}setCenter(e){const t=this;return t.trackObject(),t.map.setCenter(e),t}getZoom(){return this.map.getZoom()}setZoom(e){return this.map.setZoom(e),this}getBearing(){return this.map.getBearing()}setBearing(e){const t=this;return t.trackObject(),t.map.setBearing(e),t}getPitch(){return this.map.getPitch()}setPitch(e){return this.map.setPitch(e),this}easeTo(e){const t=this;return void 0===e.center&&void 0===e.bearing||t.trackObject(),t.map.easeTo(e),t}flyTo(e){const t=this;return void 0===e.center&&void 0===e.bearing||t.trackObject(),t.map.flyTo(e),t}jumpTo(e){const t=this;return void 0===e.center&&void 0===e.bearing||t.trackObject(),t.map.jumpTo(e),t}getViewMode(){return this.viewMode}setViewMode(e){const t=this;return t.initialized&&t._setViewMode(e),t}getTrackingMode(){return this.trackingMode}setTrackingMode(e){return this._setTrackingMode(e),this}getSelection(){const e=this.trackedObject;return Xq(e)?e.id:$q(e)?e.stations:void 0}setSelection(e){const t=this,i=Z(e),n=t.stations.get(i);if(n)t.trackObject(t.stationGroupLookup.get(n.group)),delete t.initialSelection;else if(i.match(/NRT|HND/))if(t.flightLoaded){const e=t.activeFlightLookup.get(i);e?t.trackObject(e):ee(t.container,t.dict["flight-terminated"]),delete t.initialSelection}else t.initialSelection=i;else if(t.trainLoaded){let e;for(const n of t.timetables.getConnectingTrainIds(i))if(e=t.activeTrainLookup.get(n))break;e?t.trackObject(e):ee(t.container,t.dict["train-terminated"]),delete t.initialSelection}else t.initialSelection=i;return t}getClockMode(){return this.clockMode}setClockMode(e){const t=this;return t.initialized&&t._setClockMode(e),t}getEcoMode(){return this.ecoMode}setEcoMode(e){return this._setEcoMode(e),this}addLayer(e,t){const i=this,n=e.type;return"three"===n?new ND(e).onAdd(i,t):"geojson"===n?new Xv(e).onAdd(i,t):"tile-3d"===n?(new jj(e).onAdd(i,t),i.layerVisibility.tile3d.set(e.id,"visible"),i.updateLayerVisibility()):i.map.addLayer(e,t||"poi"),i}removeLayer(e){const t=this,i=t.layerVisibility.tile3d;return t.map.removeLayer(e),i.has(e)&&(i.delete(e),t.updateLayerVisibility()),t}setLayerVisibility(e,t){const i=this,{model:n,tile3d:r}=i.layerVisibility;let s=t;return n.has(e)?(n.set(e,t),r.values().some(e=>"visible"===e)&&(s="none")):r.has(e)&&(r.set(e,t),i.updateLayerVisibility()),i.map.setLayoutProperty(e,"visibility",s),i}getModelOrigin(){return this.modelOrigin}getModelScale(){return this.modelOrigin.meterInMercatorCoordinateUnits()}getModelPosition(e,t){const i=this,n=ae.MercatorCoordinate.fromLngLat(e,t);return{x:n.x-i.modelOrigin.x,y:-(n.y-i.modelOrigin.y),z:n.z-i.modelOrigin.z}}hasDarkBackground(){return z_(this.map)}addDataSource(e){const t=this,i=jq(e,t.secrets),n=t.dataSources.findIndex(({id:e})=>e===i.id);return n>=0?t.dataSources[n]=i:t.dataSources.push(i),t.refreshDataSource(i),t}removeDataSource(e){const t=this,i=t.dataSources.findIndex(t=>t.id===e);if(i>=0){const[e]=t.dataSources.splice(i,1);t.refreshDataSource(e)}return t}refreshDataSource(e){const t=this;e.gtfsUrl&&t.refreshBusData(),t.initialized&&((e.trainUrl||e.trainInfoUrl)&&t.refreshRealtimeTrainData(),(e.flightUrl||e.atisUrl)&&t.refreshRealtimeFlightData())}initData(e){const t=this,i=t.featureLookup=new Map,n=t.stationGroupLookup=new Map;t.featureCollection=e.featureCollection,t.stations=new Ge(tt),t.railDirections=new Ge(Qe,e.railDirectionData),t.railways=new Ge(et,e.railwayData,{stations:t.stations,railDirections:t.railDirections}),t.pois=new Ge(Ke,e.poiData),t.stations.load(e.stationData,{stations:t.stations,railways:t.railways,railDirections:t.railDirections,pois:t.pois}),we(t.featureCollection,e=>{const r=e.properties,{group:s,altitude:o}=r;1===r.type?(i.set(`${s}.${r.zoom}`,e),n.has(s)||n.set(s,{id:s,type:"station",stations:r.ids.map(e=>t.stations.get(e)),layer:0===o?"ground":"underground"})):o<=0||(i.set(r.id,e),function(e){const t=Gm(e),i=e.properties.distances=[];let n,r,s,o=0,a=t[0];for(let e=0,l=t.length;e<l-1;e++){const l=a;a=t[e+1];const c=qg(l,a);n=Hm(l,a),r=((a[2]||0)-(l[2]||0))/c,s=Math.atan(r/1e3),i.push([o,n,r,s]),o+=c}i.push([o,n,r,s])}(e))});for(const e of t.stations.getAll())if(e.alternate)for(const t of["og","ug"]){const i=e.group.replace(/.g$/,t),r=n.get(i);r&&(r.hidden||(r.hidden=[]),r.hidden.push(e))}t.trainTypes=new Ge(st,e.trainTypeData),t.trainVehicleTypes=new Ge(ot,e.trainVehicleData),t.lastTimetableRefresh=t.clock.getTime("03:00"),t.dataReferences={railways:t.railways,stations:t.stations,railDirections:t.railDirections,trainTypes:t.trainTypes,trainVehicleTypes:t.trainVehicleTypes},t.timetables=new rt(e.timetableData,t.dataReferences),t.operators=new Ge(Je,e.operatorData),t.airports=new Ge(He,e.airportData),t.flightStatuses=new Ge(Xe,e.flightStatusData),t.activeTrainLookup=new Map,t.standbyTrainLookup=new Map,t.realtimeTrains=new Set,t.adTrains=new Set,t.activeFlightLookup=new Map,t.flightLookup=new Map}initialize(){const e=this,{lang:t,dict:i,clock:n,map:r,container:o,featureCollection:a}=e,l=r.getZoom(),c=e.layerZoom=qq(l);r.loaded()?Gq(o):r.once("load",()=>{Gq(o)}),e.trafficLayer=new sG({id:"traffic"}),r.setLayoutProperty("poi","text-field",["coalesce",["get",`name_${t}`],["get","name_en"],["get","name"]]);for(const t of[13,14,15,16,17,18]){const i={type:"geojson",lineWidthUnits:"pixels",lineWidthScale:13===t?G(Math.pow(2,l-12),.125,1):18===t?G(Math.pow(2,l-19),1,8):1,parameters:{depthTest:!1},minzoom:t<=13?0:t,maxzoom:t>=18?24:t+1};for(const n of["marked","selected"])e.addLayer(Object.assign({},i,{id:`stations-${n}-${t}`,getLineWidth:12,getLineColor:[255,255,255],getFillColor:[255,255,255],visible:!1}),"trees");for(const n of["ug","routeug","routeog"])for(const r of["railways","stations"]){const s="railways"===r?0:1;e.addLayer(Object.assign({},i,{id:`${r}-${n}-${t}`,data:"ug"===n?Xg(a,e=>e.zoom===t&&e.type===s&&e.altitude<0):$g()},{railways:{filled:!1,getLineWidth:e=>e.properties.width,getLineColor:e=>K(e.properties.color)},stations:{getLineWidth:4,getFillColor:[255,255,255,179]}}[r],{ug:{opacity:.0625,pickable:"stations"===r,metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":.0625,"mt3d:opacity-route":.005,"mt3d:opacity-underground":1,"mt3d:opacity-underground-route":.005}},routeug:{opacity:.0625,visible:!1,metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":.125,"mt3d:opacity-underground":1}},routeog:{visible:!1,metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-underground":.25}}}[n]),"trees")}}var u;(u=r.__deck).setProps({getCursor:()=>u.getCanvas().style.cursor}),r.addSource("odpt",{type:"geojson",data:Xg(a,e=>0===e.altitude)});for(const e of[13,14,15,16,17,18]){const t=["interpolate",["exponential",2],["zoom"]],i=["get","width"],n=["get","color"],s=13===e?[...t,9,["/",i,8],12,i]:18===e?[...t,19,i,22,["*",i,8]]:i;for(const t of["railways","stations","stations-outline"])r.addLayer({id:`${t}-og-${e}`,type:"stations"===t?"fill":"line",source:"odpt",filter:["all",["==",["get","zoom"],e],["==",["get","type"],"railways"===t?0:1]],layout:{visibility:e===c?"visible":"none"},paint:{railways:{"line-color":n,"line-width":s,"line-emissive-strength":1},stations:{"fill-color":n,"fill-opacity":.7,"fill-emissive-strength":1},"stations-outline":{"line-color":["get","outlineColor"],"line-width":s,"line-emissive-strength":1}}[t],metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-route":.1,"mt3d:opacity-underground":.25,"mt3d:opacity-underground-route":.1}},"trees")}e.addLayer(e.trafficLayer,"trees");const h=[],d=[];for(const{id:t,color:i}of e.railways.getAll())h.push({id:t,feature:[13,14,15,16,17,18].map(i=>e.featureLookup.get(`${t}.${i}`))}),d.push({id:t,color:i});for(const[t,i]of e.featureLookup)i.properties.altitude>0&&h.push({id:t,feature:i});for(const{id:t,color:i}of e.trainVehicleTypes.getAll())d.push({id:t,color:i});for(const{id:t,color:i,tailcolor:n}of e.operators.getAll())d.push({id:t,color:[i,n]});e.trafficLayer.addRouteGroup(h),e.trafficLayer.addColorGroup(d),e.styleOpacities=U_(r,"mt3d:opacity-effect"),e.layerVisibility={model:new Map,tile3d:new Map};for(const{id:t,type:i}of r.getStyle().layers)("model"===i||"fill-extrusion"===i||t.startsWith("hd-"))&&e.layerVisibility.model.set(t,"visible");const p=Q("datalist",{id:"stations"},document.body),f=e.stationTitleLookup=new Map;for(const i of[t,"en"])for(const t of e.railways.getAll())for(const e of t.stations){const{title:t,utitle:n}=e,r=n&&n[i]||W(t[i]||t.en),s=r.toUpperCase();f.has(s)||(Q("option",{value:r},p),f.set(s,e))}if(e.searchControl){const t=new je({title:e.dict.search,placeholder:e.dict["station-name"],list:"stations",eventHandler:({value:t})=>{const i=e.stationTitleLookup.get(t.toUpperCase());if(i&&i.coord)return e.markObject(),e.trackObject(e.stationGroupLookup.get(i.group)),!0}});r.addControl(t)}if(e.navigationControl){const t=e.navControl=new ae.NavigationControl;t._setButtonTitle=function(e){const{_zoomInButton:t,_zoomOutButton:n,_compass:r}=this,s=e===t?i["zoom-in"]:e===n?i["zoom-out"]:e===r?i.compass:"";e.title=s,e.setAttribute("aria-label",s)},r.addControl(t)}if(e.fullscreenControl){const e=new ae.FullscreenControl({container:o});e._updateTitle=function(){const e=this._fullscreenButton,t=i[this._isFullscreen()?"exit-fullscreen":"enter-fullscreen"];e.title=t,e.setAttribute("aria-label",t)},r.addControl(e)}if(e.modeControl){const t=new Ve([{className:"mapboxgl-ctrl-underground",title:i["enter-underground"],eventHandler(){e._setViewMode("ground"===e.viewMode?"underground":"ground")}},{className:"mapboxgl-ctrl-playback",title:i["enter-playback"],eventHandler(){e._setClockMode("realtime"===e.clockMode?"playback":"realtime")}},{className:"mapboxgl-ctrl-eco",title:i["enter-eco"],eventHandler(){e._setEcoMode("eco"===e.ecoMode?"normal":"eco")}}]);r.addControl(t)}if(e.layerPanel=new QH({layers:e.plugins}),e.trackingModePanel=new cq,e.aboutPanel=new JH,e.configControl&&r.addControl(new Ve([{className:"mapboxgl-ctrl-layers",title:i["select-layers"],eventHandler(){e.layerPanel.addTo(e)}},{className:"mapboxgl-ctrl-tracking-mode",title:i["select-tracking-mode"],eventHandler(){e.trackingModePanel.addTo(e)}},{className:"mapboxgl-ctrl-about",title:i.about,eventHandler(){e.aboutPanel.addTo(e)}}])),e.clockControl){const s=e.clockCtrl=new Ue({lang:t,dict:i,clock:n});s.on("change",e.onClockChange.bind(e)),r.addControl(s)}r.on("mousemove",t=>{e.markObject(e.pickObject(t.point))}),r.on("mouseout",()=>{e.markObject()}),r.on("click",t=>{const i=e.pickObject(t.point);e.markObject(i),e.trackObject(i)}),r.on("zoom",t=>{t.tracking||e.updateBaseZoom();const i=r.getZoom(),n=e.layerZoom,s=e.layerZoom=qq(i);if(i<13){const e=G(Math.pow(2,i-12),.125,1);for(const t of["stations-marked-13","stations-selected-13","railways-ug-13","stations-ug-13","railways-routeug-13","stations-routeug-13","railways-routeog-13","stations-routeog-13"])L_(r,t,{lineWidthScale:e})}else if(i>19){const e=G(Math.pow(2,i-19),1,8);for(const t of["stations-marked-18","stations-selected-18","railways-ug-18","stations-ug-18","railways-routeug-18","stations-routeug-18","railways-routeog-18","stations-routeog-18"])L_(r,t,{lineWidthScale:e})}if(n!==s){for(const t of["railways","stations","stations-outline"])e.setLayerVisibility(`${t}-og-${n}`,"none"),e.setLayerVisibility(`${t}-og-${s}`,"visible");for(const{id:t}of e.gtfs.values())for(const i of["busstops","busstops-outline"])n>=14&&e.setLayerVisibility(`${i}-${t}-og-${n}`,"none"),s>=14&&e.setLayerVisibility(`${i}-${t}-og-${s}`,"visible");t.tracking?e.prevLayerZoom=n:delete e.prevLayerZoom}}),r.on("render",()=>{e.markedObject&&e.updatePopup(),e.updateAdTrainPopup()});for(const t of e.plugins.slice().reverse())t.addTo(e);Ie.init(),Ie.start({callback:()=>{const t=e.clock,i=t.getTime(),{minDelay:n,refreshInterval:o,realtimeCheckInterval:a}=s;i-e.lastTimetableRefresh>=864e5&&(e.refreshTrainTimetableData(),e.refreshBusData(!0),e.lastTimetableRefresh=t.getTime("03:00")),Date.now()-e.lastFrameRefresh>=s.refreshTimeout&&e.stopAll(),e.lastFrameRefresh=Date.now();const l=Math.floor((i-n)/o)!==Math.floor(e.lastRefresh/o);l&&("none"!==e.searchMode||"playback"!==e.clockMode||e.removing||(e.refreshTrains(),e.refreshFlights(),e.refreshBuses(),$q(e.trackedObject)&&e.detailPanel.updateContent()),e.lastRefresh=i-n);const c=r.getCenter(),u=Date.now()-e.lastSunlightRefresh,h=function(e,t){return!t||Math.abs(e.lat-t.lat)>=1||Math.abs(e.lng-t.lng)>=1}(c,e.lastSunlightCenter);if((l||h)&&u>=1e3){const n=h||Math.abs(i-e.lastSunlightTime)>=t.speed*u*2;k_(r,i,"ground"===e.viewMode?1:0,!1,n),e.lastSunlightCenter=c,e.lastSunlightTime=i,e.lastSunlightRefresh=Date.now()}const d=O_(r),p=B_(r),f=`${p} ${d.direction[0]} ${d.direction[1]}`;if(f!==e.lastLightSignature&&(e.lastLightSignature=f,e.fire({type:"light",directional:d,ambient:D_(r),brightness:p})),Math.floor((i-n)/a)!==Math.floor(e.lastRealtimeCheck/a)&&("none"!==e.searchMode||"realtime"!==e.clockMode||e.removing||(e.refreshRealtimeTrainData(),e.refreshRealtimeFlightData(),e.refreshRealtimeBusData(),$q(e.trackedObject)&&e.detailPanel.updateContent()),e.lastRealtimeCheck=i-n),"normal"===e.ecoMode&&r._loaded||Date.now()-e.lastRepaint>=1e3/e.ecoFrameRate){let i;if(e.trafficLayer.setTimeOffset(t.getTimeOffset()),e.markedObject&&Xq(e.markedObject)&&(i=e.updateObjectPosition(e.markedObject),void 0!==i.standing&&e.updatePopup({setHTML:!0})),e.trackedObject&&Xq(e.trackedObject)&&(e.trackedObject!==e.markedObject&&(i=e.updateObjectPosition(e.trackedObject)),i.viewMode&&e._setViewMode(i.viewMode),!(e.viewAnimationID||r._zooming||r._rotating||r._pitching))){const{coord:t,altitude:i,bearing:n}=e.trackedObject;e._jumpTo({center:t,altitude:i,bearing:n,bearingFactor:.02}),e.markedObject===e.trackedObject&&e.updatePopup()}for(const t of e.adTrains)e.updateObjectPosition(t);Xq(e.trackedObject)||e.trackedObject&&e.refreshStationOutline(),r.triggerRepaint(),e.lastRepaint=Date.now()}}}),e.initialized=!0,e.fire({type:"initialized"})}_jumpTo(e){const t=this,{map:i,trackingMode:n,trackingParams:r}=t,s="normal"===t.ecoMode||t.viewAnimationID?t.frameRateFactor:60/t.ecoFrameRate,o=performance.now(),a=i.getZoom(),l=i.getBearing(),c=i.getPitch(),u=i.scrollZoom._active;let h,d,{center:p,altitude:f,bearing:m,easeOutFactor:g,easeInFactor:_,bearingFactor:y}=e;"position"===n?(h=t.baseZoom,m=l,d=c):"helicopter"===n?(h=15,m=r.bearing.fn(o),d=60):"drone"===n?(h=17,m=r.bearing.fn(o),d=75):"bird"===n?(t.updateTrackingParams(),h=r.zoom.fn(o),m=r.bearing.fn(o),d=r.pitch.fn(o)):("front"!==n&&"topfront"!==n||(m=(m+360)%360-180),y>=0&&(y=1-Math.pow(1-y,s),m=l+((m-l+540)%360-180)*y),"back"===n||"front"===n?(h=18.5,d=85):(h=15,d=60));const v=i.getFreeCameraOptions().position.z/Math.cos(c*Uq)*Math.pow(2,a-h),x=t.getModelPosition(p,f).z/Math.cos(d*Uq);if(h=Math.min(h-Math.log2(Math.max(v+x,0)/v),22),p=t.adjustCoord(p,f,m),g>=0){const e=i.getCenter();g=1-Math.pow(1-g,s),p=new ae.LngLat(j(e.lng,p.lng,g),j(e.lat,p.lat,g))}_>=0&&(_=1-Math.pow(1-_,s),h=j(a,h,_),d=j(c,d,_)),Math.floor(h+1)-h<1e-6&&(h=Math.floor(h+1)),t.prevLayerZoom===qq(h)?h=a:delete t.prevLayerZoom,i.jumpTo({center:p,zoom:h,bearing:m,pitch:d},{tracking:!0}),u&&(i.scrollZoom._active=!0)}refreshTrains(){const e=this,t=e.initialSelection,i=e.clock.getTimeOffset();for(const t of e.timetables.getAll())t.start<=i&&i<=t.end&&!e.standbyTrainLookup.has(t.id)&&e.trainStart(new nt(t));e.trafficLayer.refreshDelayMarkers(),e.trainLoaded=!0,t&&e.setSelection(t)}trainStart(e,t={}){const i=this,n=e.r;i.checkActiveTrains(e)||n.status&&n.dynamic&&!i.realtimeTrains.has(e.id)||n.suspended||i.setSectionData(e,t.index)&&(i.activeTrainLookup.set(e.id,e),i.trafficLayer.addObject(e),i.trainRepeat(e,t.index),t.marked&&i.markObject(e),t.tracked&&i.trackObject(e),e.ad&&i.showAdTrainPopup(e))}trainRepeat(e,t){const i=this,{activeTrainLookup:n,clock:r}=i,o=e.timetable,a=r.getTimeOffset(),l=s.minStandingDuration;let c;if(o){if(c=!i.setSectionData(e,t),c){const e=o.nt;if(e){let t=!1;for(const{t:i}of e[0].pt){const e=n.get(i);e&&e.arrivalStation&&(t=!0)}if(!t){let t=!1,r=!1;for(const{t:s}of e[0].pt){const e=n.get(s);e&&(i.markedObject===e&&(t=!0),i.trackedObject===e&&(r=!0),i.stopTrain(e))}e.forEach((e,n)=>{const s=i.standbyTrainLookup.get(e.id)||new nt(e);i.trainStart(s,0===n?{index:0,marked:t,tracked:r}:{index:0})})}return}}}else c=!i.setSectionData(e,void 0,!i.realtimeTrains.has(e.id));i.markedObject===e&&(e.standing=!0,i.updatePopup({setHTML:!0}));const u=e.sectionLength;if(c||0===u)e.animationID=Ie.start({complete:()=>{c?i.stopTrain(e):i.trainRepeat(e)},duration:o?Math.max(e.departureTime-a,l):c?l:s.realtimeCheckInterval,clock:r});else{const n=e.delay||0,c=s.minDelay,{departureTime:h,arrivalTime:d,nextDepartureTime:p,sectionIndex:f}=e,m=i.featureLookup.get(`${e.r.id}.18`).properties["station-offsets"],g=Math.abs(m[f+u]-m[f]),_=void 0!==t?Math.max(h+n,a+(1===r.speed?l:0)):void 0!==h?h+n:a;let y,v,x,b,{maxSpeed:w,acceleration:T,maxAccelerationTime:S,maxAccDistance:E}=s;void 0!==p&&(x=p-l+6e4+n-c-_),void 0!==d&&(v=d+n-c-_,x<v+6e4||(x=v+6e4)),g<=2*E?(y=2*Math.sqrt(g/T),x>0&&(y=G(y,v||0,x),T=4*g/y/y),b=y/2):(y=2*S+(g-2*E)/w,x>0&&(y=G(y,v||0,x),E=T*y*y/8,g>=2*E?(w=2*g/y,T=2*w/y):w=T*y/2-Math.sqrt(T*(2*E-g))),b=w/T),i.trafficLayer.updateObject(e,_,y,b,T/g,b,T/g),e.animationID=Ie.start({complete:()=>{i.trainRepeat(e,o?e.timetableIndex+1:void 0)},duration:_+y-a,clock:r})}}refreshFlights(){const e=this,t=e.initialSelection,i=e.clock.getTimeOffset();for(const t of e.flightLookup.values())t.entry<=i&&i<=t.end&&e.flightStart(t);e.flightLoaded=!0,t&&e.setSelection(t)}flightStart(e){const t=this,{activeFlightLookup:i,clock:n}=t,r=e.id;if(i.has(r))return;i.set(r,e),t.trafficLayer.addObject(e);const s=n.getTimeOffset(),o=e.feature.properties.length,a=e.maxSpeed,l=e.acceleration>0?e.acceleration:0,c=e.acceleration>0?0:-e.acceleration,u=l>0?a/l:0,h=c>0?a/c:0;t.trafficLayer.updateObject(e,e.start,u/2+o/a+h/2,u,l/o,h,c/o),e.animationID=Ie.start({complete:()=>{t.stopFlight(e)},duration:e.end-s,clock:n})}refreshBuses(e){const t=this,i=t.clock.getTimeOffset();for(const n of e?[t.gtfs.get(e)]:t.gtfs.values())for(const e of n.trips.getAll()){const r=e.departureTimes,s=n.routes.get(e.route);if(r[0]<=i&&i<=r[r.length-1]&&!n.activeBusLookup.has(e.id)&&s&&!s.hidden){let i=0;const r=n.featureLookup.get(e.shape);if(!r)continue;const s=e.stops.map(e=>i=Nq(r,n.stops.get(e).coord,i).properties.location);t.busStart(new We({gtfsId:n.id,trip:e,feature:r,offsets:s,offset:0}))}}}busStart(e){const t=this;t.setBusSectionData(e)&&(t.gtfs.get(e.gtfsId).activeBusLookup.set(e.trip.id,e),t.trafficLayer.addObject(e),t.busRepeat(e))}busRepeat(e,t){const i=this,n=i.clock,r=n.getTimeOffset(),o=s.minBusStandingDuration;let a;a=void 0===e.stop?!i.setBusSectionData(e,t):!i.setBusSectionData(e,void 0,!i.gtfs.get(e.gtfsId).realtimeBuses.has(e.trip.id)),i.markedObject===e&&i.updatePopup({setHTML:!0}),i.trackedObject===e&&i.detailPanel&&i.detailPanel.updateHeader();const{offsets:l,sectionIndex:c,sectionLength:u}=e,h=Math.abs(l[c+u]-l[c]);if(!a&&u>0&&h>0){const a=s.minDelay,{departureTime:l,nextDepartureTime:c}=e,u=void 0!==t?Math.max(l,r+(1===n.speed?o:0)):q(l,r);let d,p,f,{maxBusSpeed:m,busAcceleration:g,maxBusAccelerationTime:_,maxBusAccDistance:y}=s;void 0!==c&&(p=c-o+6e4-a-u),h<=2*y?(d=2*Math.sqrt(h/g),p>0&&(d=G(d,0,p),g=4*h/d/d),f=d/2):(d=2*_+(h-2*y)/m,p>0&&(d=G(d,0,p),y=g*d*d/8,h>=2*y?(m=2*h/d,g=2*m/d):m=g*d/2-Math.sqrt(g*(2*y-h))),f=m/g),i.trafficLayer.updateObject(e,u,d,f,g/h,f,g/h),e.animationID=Ie.start({complete:()=>{i.busRepeat(e,void 0===e.stop?e.sectionIndex+1:void 0)},duration:u+d-r,clock:n})}else e.animationID=Ie.start({complete:()=>{a?i.stopBus(e):i.busRepeat(e)},duration:void 0===e.stop?Math.max(e.nextDepartureTime-r,o):a?o:s.realtimeCheckInterval,clock:n})}updateTrackingParams(e){const t=this,{map:i,trackingMode:n,trackingParams:r}=t,s=performance.now();if("bird"===n){const{zoom:n,bearing:o,pitch:a}=r;if(!n.time||e){const e=n.time=[0,s,0,0],i=n.value=[0,t.baseZoom,0,0];for(const[t,n]of[[0,1],[2,1],[3,2]])e[t]=e[n]+Math.sign(t-n)*(1e4*Math.random()+3e4),i[t]=5*Math.random()+15;n.fn=Wq(e,i)}else s>=n.time[2]&&(n.time=n.time.slice(1).concat(n.time[3]+1e4*Math.random()+3e4),n.value=n.value.slice(1).concat(5*Math.random()+15),n.fn=Wq(n.time,n.value));if(!o.time||e){const e=o.time=[0,s,0,0],t=o.value=[0,i.getBearing(),0,0];for(const[i,n]of[[0,1],[2,1],[3,2]])e[i]=e[n]+Math.sign(i-n)*(1e4*Math.random()+4e4),t[i]=360*Math.random()-180;o.fn=Wq(e,t)}else s>=o.time[2]&&(o.time=o.time.slice(1).concat(o.time[3]+1e4*Math.random()+4e4),o.value=o.value.slice(1).concat(360*Math.random()-180),o.fn=Wq(o.time,o.value));if(!a.time||e){const e=a.time=[0,s,0,0],t=a.value=[0,i.getPitch(),0,0];for(const[i,n]of[[0,1],[2,1],[3,2]])e[i]=e[n]+Math.sign(i-n)*(1e4*Math.random()+2e4),t[i]=30*Math.random()+45;a.fn=Wq(e,t)}else s>=a.time[2]&&(a.time=a.time.slice(1).concat(a.time[3]+1e4*Math.random()+2e4),a.value=a.value.slice(1).concat(30*Math.random()+45),a.fn=Wq(a.time,a.value))}else if(delete r.zoom.time,delete r.bearing.time,delete r.pitch.time,"drone"===n){const e=i.getBearing();r.bearing.fn=t=>(e-(t-s)/200)%360}else if("helicopter"===n){const e=i.getBearing();r.bearing.fn=t=>(e+(t-s)/400)%360}}updateHandlersAndControls(){const e=this,{map:t,trackedObject:i,trackingMode:n}=e,r=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];if(Xq(i)&&"position"!==n){for(const e of r)t[e].disable();e.navControl.disable()}else{for(const e of r)t[e].enable();Xq(i)&&"position"===n&&t.dragPan.disable(),e.navControl.enable()}}startViewAnimation(){const e=this;let t=0,i=0;e.viewAnimationID=Ie.start({callback:(n,r)=>{const s=e.trackedObject,o=function(e){return-((e-=1)*e*e*e-1)}(n/r),a=1-(1-o)/(1-t),l=function(e){return e*e}(n/r);e._jumpTo({center:s.coord,altitude:s.altitude,bearing:s.bearing,easeOutFactor:a,easeInFactor:1-(1-l)/(1-i),bearingFactor:a}),t=o,i=l},complete:()=>{delete e.viewAnimationID},duration:1e3})}stopViewAnimation(){const e=this;e.viewAnimationID&&(Ie.stop(e.viewAnimationID),delete e.viewAnimationID)}adjustCoord(e,t,i){if(!t)return ae.LngLat.convert(e);const{map:n,trafficLayer:r}=this;if(!isNaN(i)){const r=ae.MercatorCoordinate.fromLngLat(e,t),s=r.z*Math.tan(n.getPitch()*Uq),o=r.x+s*Math.sin(i*Uq),a=r.y-s*Math.cos(i*Uq);return new ae.MercatorCoordinate(o,a,0).toLngLat()}return n.unproject(r.project(e,t))}getLocalizedRailwayTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedTrainNameOrRailwayTitle(e,t){const i=this;return e?e.map(e=>e[i.lang]||e.en).join(i.dict.and):i.getLocalizedRailwayTitle(t)}getLocalizedTrainTypeTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedStationTitle(e){const t=this;return(Array.isArray(e)?e:[e]).map(e=>{const i=(e||{}).title||{};return i[t.lang]||i.en}).join(t.dict.and)}getLocalizedRailDirectionTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedDestinationTitle(e,t){const i=this;return e?i.dict.for.replace("$1",i.getLocalizedStationTitle(e)):i.getLocalizedRailDirectionTitle(t)}getLocalizedOperatorTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedAirportTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedFlightStatusTitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedPOITitle(e){const t=(e||{}).title||{};return t[this.lang]||t.en}getLocalizedPOIDescription(e){const t=(e||{}).description||{};return t[this.lang]||t.en}getTrainDescription(e){const t=this,{lang:i,dict:n}=t,{r:r,ad:s,departureTime:o,arrivalStation:a}=e,l=s&&s.color||(e.v||r).color,c=e.delay||0,u=q(e.arrivalTime,e.nextDepartureTime),h=r.status;return['<div class="desc-header">',Array.isArray(l)?["<div>",...l.slice(0,3).map(e=>`<div class="line-strip" style="background-color: ${e};"></div>`),"</div>"].join(""):`<div style="background-color: ${l};"></div>`,"<div><strong>",t.getLocalizedTrainNameOrRailwayTitle(e.nm,r),"</strong>",`<br> <span class="train-type-label">${t.getLocalizedTrainTypeTitle(e.y)}</span> `,t.getLocalizedDestinationTitle(e.ds,e.d),"</div></div>",`<strong>${n["train-number"]}:</strong> ${e.n}`,e.timetable?"":` <span class="desc-caution">${n.special}</span>`,"<br>",s?`<span class="desc-ad-cars" style="color: ${s.textcolor};">${s.description[i]}</span><br>`:"",c>=6e4?'<span class="desc-caution">':"","<strong>",n[e.standing?"standing-at":"previous-stop"],":</strong> ",t.getLocalizedStationTitle(e.departureStation),void 0!==o?` ${X(o+c)}`:"",a?[`<br><strong>${n["next-stop"]}:</strong> `,t.getLocalizedStationTitle(a),void 0!==u?` ${X(u+c)}`:""].join(""):"",c>=6e4?`<br>${n.delay.replace("$1",Math.floor(c/6e4))}</span>`:"",h&&"ja"===i?`<br><span class="desc-caution"><strong>${h}:</strong> ${r.text}</span>`:""].join("")}getFlightDescription(e){const t=this,i=t.dict,{a:n,n:r,ds:s}=e,o=n.tailcolor||"#FFFFFF",a=q(e.sdt,e.sat),l=q(e.edt,e.eat),c=q(e.adt,e.aat),u=(void 0!==l||void 0!==c)&&a!==q(l,c);return['<div class="desc-header">',`<div style="background-color: ${o};"></div>`,`<div><strong>${t.getLocalizedOperatorTitle(n)}</strong>`,`<br>${r[0]} `,i[s?"to":"from"].replace("$1",t.getLocalizedAirportTitle(s||e.or)),"</div></div>",`<strong>${i.status}:</strong> ${t.getLocalizedFlightStatusTitle(e.s)}`,"<br><strong>",i[s?"scheduled-departure-time":"scheduled-arrival-time"],`:</strong> ${X(a)}`,u?'<span class="desc-caution">':"",void 0!==l?["<br><strong>",i[s?"estimated-departure-time":"estimated-arrival-time"],`:</strong> ${X(l)}`].join(""):void 0!==c?["<br><strong>",i[s?"actual-departure-time":"actual-arrival-time"],`:</strong> ${X(c)}`].join(""):"",u?"</span>":"",r.length>1?`<br><strong>${i["code-share"]}:</strong> ${r.slice(1).join(" ")}`:""].join("")}getBusDescription(e){const t=this.dict,i=this.gtfs.get(e.gtfsId),n=i.stops,{route:r,headsigns:s,stops:o}=e.trip,{shortName:a,longName:l,color:c,textColor:u}=i.routes.get(r),h=[u?`color: ${u};`:"",c?`background-color: ${c};`:""].join(" "),d=e.sectionIndex+(e.standing?0:e.sectionLength),p=n.get(o[d]).name,f=Math.max(0,d-1),m=n.get(o[f]).name;return['<div class="desc-header">',`<div style="background-color: ${i.color};"></div>`,`<div><strong>${i.agency}</strong>`,void 0!==e.stop?'<span class="realtime-small-icon"></span>':"","<br>",a||l?` <span class="bus-route-label" style="${h}">${a||l}</span> `:"",0===s.length?l:s[1===s.length?0:f],"</div></div>",e.id?`<strong>${t["vehicle-number"]}:</strong> ${e.id}<br>`:"",`<strong>${t["previous-busstop"]}:</strong> ${m}<br>`,`<strong>${t["next-busstop"]}:</strong> ${p}`].join("")}checkActiveTrains(e){const t=this;function i(e,n){const r=t.activeTrainLookup.get(e.t);if(r&&e.id===r.timetable.id)return!0;const s=e[n];if(s)for(const e of s)if(i(e,n))return!0;return!1}return!!e.timetable&&(i(e.timetable,"pt")||i(e.timetable,"nt"))}stopTrain(e){const t=this;return Ie.stop(e.animationID),t.hideAdTrainPopup(e),e===t.markedObject&&t.markObject(),e===t.trackedObject&&t.trackObject(),t.activeTrainLookup.delete(e.id),t.trafficLayer.removeObject(e)}stopFlight(e){const t=this;return Ie.stop(e.animationID),e===t.markedObject&&t.markObject(),e===t.trackedObject&&t.trackObject(),t.activeFlightLookup.delete(e.id),t.trafficLayer.removeObject(e)}stopBus(e){const t=this;return Ie.stop(e.animationID),e===t.markedObject&&t.markObject(),e===t.trackedObject&&t.trackObject(),t.gtfs.get(e.gtfsId).activeBusLookup.delete(e.trip.id),t.trafficLayer.removeObject(e)}stopAll(){const e=this,t=[];for(const i of e.activeTrainLookup.values())t.push(e.stopTrain(i));e.standbyTrainLookup.clear(),e.realtimeTrains.clear(),e.adTrains.clear();for(const i of e.activeFlightLookup.values())t.push(e.stopFlight(i));for(const{activeBusLookup:i,realtimeBuses:n}of e.gtfs.values()){for(const n of i.values())t.push(e.stopBus(n));n.clear()}e.removing=!0,Promise.all(t).then(()=>{delete e.removing,delete e.lastRefresh,delete e.lastRealtimeCheck})}resetRailwayStatus(){for(const e of this.railways.getAll())delete e.status,delete e.text,delete e.suspended}refreshTrainTimetableData(){const e=this;var t,i;!function(e){const t=e.querySelector("#loader");t.style.opacity=1,t.style.display="block"}(e.container),e.timetables.clear(),(t=e.dataUrl,i=e.clock,Promise.all(t?[jH(i),...GH(i)].map(e=>`${t}/${e}`).map(V):[[]]).then(e=>[].concat(...e))).then(t=>{e.timetables=new rt(t,e.dataReferences),delete e.lastRefresh,delete e.lastRealtimeCheck,Gq(e.container)})}refreshBusData(e){const t=this,i=t.map,n=t.dataSources.filter(e=>e.gtfsUrl&&!WH(e)),r=new Set(n.map(({id:e})=>e)),s=({id:e,activeBusLookup:n,layerIds:r,routeGroupIndex:s,colorGroupIndex:o})=>{const a=t.styleOpacities,l=[];for(const e of r){t.removeLayer(e);for(let t=0,i=a.length;t<i;t++)if(a[t].id===e){a.splice(t,1);break}}i.removeSource(e);for(const e of n.values())l.push(t.stopBus(e));return t.gtfs.delete(e),Promise.all(l).then(()=>{t.trafficLayer.removeRouteGroup(s),t.trafficLayer.removeColorGroup(o)})};for(const[e,i]of t.gtfs)r.has(e)||s(i);for(const r of n){const n=r.id;t.gtfsLoading.has(n)||t.gtfs.has(n)&&!e||(t.gtfsLoading.add(n),qH(r,t.clock.getTime(),t.lang).then(e=>t.initialized?e:new Promise(i=>{t.once("initialized",()=>i(e))})).then(e=>t.gtfs.has(n)?s(t.gtfs.get(n)).then(()=>e):e).then(e=>{const{agency:s,timezone:o,featureCollection:a,version:l}=e;if(void 0===t.timezone)t.timezone=o,t.clock.setTimezone(o);else if(o!==t.timezone)return void t.gtfsLoading.delete(n);const c=new Map,u=new Set,h=[];we(a,e=>{const t=e.properties;0===t.type&&(c.set(t.id,e),h.push({id:`${n}.${t.id}`,feature:e}))}),t.gtfs.set(n,{id:n,agency:s,version:l,featureLookup:c,stops:new Ge(Ze,e.stops),routes:new Ge($e,e.routes),trips:new Ge(Ye,e.trips),layerIds:u,activeBusLookup:new Map,realtimeBuses:new Set,vehiclePositionUrl:r.vehiclePositionUrl,color:r.color,routeGroupIndex:t.trafficLayer.addRouteGroup(h),colorGroupIndex:t.trafficLayer.addColorGroup([{id:n,color:r.color}])}),i.addSource(n,{type:"geojson",data:a,promoteId:"id"});for(const e of["busroute","busroute-highlighted"]){const i="busroute"===e?["get","width"]:["*",["get","width"],4];t.addLayer({id:`${e}-${n}-og-`,type:"line",source:n,filter:["==",["get","type"],0],paint:{"line-color":{busroute:["get","color"],"busroute-highlighted":["string",["feature-state","route-highlight"],["feature-state","trip-highlight"],["get","color"]]}[e],"line-opacity":{busroute:["case",["to-boolean",["feature-state","hidden"]],0,1],"busroute-highlighted":["case",["all",["any",["to-boolean",["feature-state","route-highlight"]],["to-boolean",["feature-state","trip-highlight"]]],["!",["to-boolean",["feature-state","hidden"]]]],1,0]}[e],"line-width":["interpolate",["exponential",2],["zoom"],11,["/",i,2],12,i,19,i,22,["*",i,8]],"line-emissive-strength":1},metadata:{busroute:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-route":.1,"mt3d:opacity-underground":0,"mt3d:opacity-underground-route":0},"busroute-highlighted":{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-route":.1,"mt3d:opacity-underground":.25,"mt3d:opacity-underground-route":.1}}[e]},"railways-og-13"),u.add(`${e}-${n}-og-`)}for(const e of[14,15,16,17,18]){const i=["get","width"],r=18===e?[...["interpolate",["exponential",2],["zoom"]],19,i,22,["*",i,8]]:i;for(const i of["busstops","busstops-outline"])t.addLayer({id:`${i}-${n}-og-${e}`,type:"busstops"===i?"fill":"line",source:n,filter:["all",["==",["get","zoom"],e],["==",["get","type"],1]],layout:{visibility:e===t.layerZoom?"visible":"none"},paint:{busstops:{"fill-color":["get","color"],"fill-opacity":.7,"fill-emissive-strength":1},"busstops-outline":{"line-color":["get","outlineColor"],"line-width":r,"line-emissive-strength":1}}[i],metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-route":.1,"mt3d:opacity-underground":.25,"mt3d:opacity-underground-route":.1}},"railways-og-13"),u.add(`${i}-${n}-og-${e}`)}t.addLayer({id:`busstops-poi-${n}`,type:"symbol",source:n,filter:["==",["get","type"],2],layout:{"text-field":["get","name"],"text-font":["Open Sans Bold","Arial Unicode MS Bold"],"text-max-width":9,"text-padding":2,"text-size":12,"text-anchor":"bottom","text-offset":[0,-1]},paint:{"text-color":"rgba(102,102,102,1)","text-halo-blur":.5,"text-halo-color":"rgba(255,255,255,1)","text-halo-width":1},minzoom:14}),u.add(`busstops-poi-${n}`);const d=t.styleOpacities,p=new Set(d.map(({id:e})=>e));for(const e of U_(i,"mt3d:opacity-effect"))p.has(e.id)||d.push(e);t.refreshMap(),"none"===t.searchMode&&("playback"===t.clockMode?t.refreshBuses(n):"realtime"===t.clockMode&&t.refreshRealtimeBusData(n)),t.gtfsLoading.delete(n)}).catch(()=>{t.gtfsLoading.delete(n)}))}t.updateBusRouteVisibility()}refreshRealtimeTrainData(){const e=this;(function(e){const t=new Map,i=[],n=e.filter(e=>(e.trainUrl||e.trainInfoUrl)&&!WH(e)),r=e=>{const i=t.get(e.id);i?Object.assign(i,e):t.set(e.id,e)};return Promise.all(n.map(({trainUrl:e,trainInfoUrl:t})=>Promise.all([e?V(e):[],t?V(t):[]]).then(([e,t])=>({trains:e,trainInfos:t})))).then(e=>{for(const{trains:t,trainInfos:n}of e){for(const e of t)if("odpt:Train"===e["@type"]){const t=Z(e["odpt:trainType"]),i=Z(e["odpt:destinationStation"]),n=HH(Z(e["owl:sameAs"]),t,i);r({id:n,o:Z(e["odpt:operator"]),r:Z(e["odpt:railway"]),y:t,n:e["odpt:trainNumber"],os:Z(e["odpt:originStation"]),d:Z(e["odpt:railDirection"]),ds:i,ts:Z(e["odpt:toStation"]),fs:Z(e["odpt:fromStation"]),delay:1e3*(e["odpt:delay"]||0),carComposition:e["odpt:carComposition"],date:e["dc:date"].replace(/([\d\-])T([\d:]+).*/,"$1 $2")})}else delete e.date,r(e);for(const e of n)i.push("odpt:TrainInformation"===e["@type"]?{operator:Z(e["odpt:operator"]),railway:Z(e["odpt:railway"]),status:e["odpt:trainInformationStatus"],text:e["odpt:trainInformationText"]}:e)}return{trainData:Array.from(t.values()),trainInfoData:i}})})(e.dataSources).then(({trainData:t,trainInfoData:i})=>{const{activeTrainLookup:n,standbyTrainLookup:r,realtimeTrains:s,dataReferences:o}=e,a=e.clock.getTimeOffset();e.resetRailwayStatus();for(const t of i){const i=e.railways.get(t.railway),n=t.status;i&&n&&n.ja&&(i.status=n.ja,i.text=t.text.ja),t.suspended&&(i.suspended=!0)}r.clear(),s.clear();for(const i of t){const{id:t,r:l,n:c,y:u,d:h,os:d,ds:p,ts:f,fs:m,v:g,ad:_,delay:y,carComposition:v}=i,x=t.replace(".Marunouchi.",".MarunouchiBranch.");i.date>(e.lastDynamicUpdate[i.o]||"")&&(e.lastDynamicUpdate[i.o]=i.date),s.add(i.id);const b=n.get(t)||n.get(x);let w,T;if(b){if(!(u&&u!==b.y.id||d&&b.os&&d[0]!==b.os[0].id||p&&b.ds&&p[0]!==b.ds[0].id||g&&g!==(b.v||{}).id||_&&!b.ad||!isNaN(v)&&v!==b.carComposition||!isNaN(y)&&y!==b.delay)){b.timetable||b.update({ts:f,fs:m},o);continue}w=e.markedObject===b,T=e.trackedObject===b,e.stopTrain(b)}let S=e.timetables.getByTrainId(t);if(0===S.length&&(S=e.timetables.getByTrainId(x)),0===S.length)l&&("TokyoMetro.Namboku"===l&&(d[0].startsWith(kq)||p[0].startsWith(kq))||"Toei.Arakawa"!==l&&e.trainStart(new nt({id:t,r:l,n:c,y:u,d:h,os:d,ds:p,ts:f,fs:m,delay:y,carComposition:v},o)));else for(const t of S){const i=new nt(t);i.update({y:u,os:d,ds:p,v:g,ad:_,delay:y,carComposition:v},o),t.start+(y||0)<=a&&a<=t.end+(y||0)?e.trainStart(i,{marked:w,tracked:T}):r.set(t.id,i)}}for(const t of n.values()){const i=t.r;((i.status&&i.dynamic||!t.timetable)&&!s.has(t.id)||i.suspended)&&e.stopTrain(t)}e.refreshTrains(),e.aboutPanel.updateContent()}).catch(t=>{e.refreshTrains()})}refreshRealtimeFlightData(){const e=this;(function(e){const t=e.filter(e=>(e.flightUrl||e.atisUrl)&&!WH(e)),i=new Map;let n;return Promise.all(t.map(({flightUrl:e,atisUrl:t})=>Promise.all([t?V(t):void 0,e?V(e):[]]).then(([e,t])=>({atis:e,flights:t})))).then(e=>{for(const{atis:t,flights:r}of e){t&&(n=t);for(const e of r){const t=i.get(e.id);t?Object.assign(t,e):i.set(e.id,e)}}return{atisData:n,flightData:Array.from(i.values())}})})(e.dataSources).then(({atisData:t,flightData:i})=>{if(!t)return;const n=e.flightLookup,{landing:r,departure:o}=t,a=[r.join("/"),o.join("/")].join(" "),l={},c={};let u={},h={},d=!0;if(e.flightPattern!==a){e.flightPattern=a,e.lastFlightPatternChanged=Date.now();for(const t of e.activeFlightLookup.values())e.stopFlight(t)}H(r,["R16L","R16R"])?(u={S:"R16L",N:"R16R"},h={S:"22",N:"16R"},d=!1):H(r,["L22","L23"])?(u={S:"L23",N:"L22"},h={S:"O16R",N:"16L"},d=!1):H(r,["I16L","I16R"])?(u={S:"I16L",N:"I16R"},h={S:"22",N:"16R"},d=!1):H(r,["I22","I23"])?(u={S:"I23",N:"I22"},h={S:"16R",N:"16L"},d=!1):H(r,["I34L","H34R"])?(u={S:"IX34L",N:"H34R"},h={S:"05",N:"34R"},d=!0):H(r,["I34L","I34R"])?(u={S:"IZ34L",N:"H34R"},h={S:"05",N:"34R"},d=!0):1!==r.length||(H(r,"I23")?(u={S:"IY23",N:"IY23"},d=!1):H(r,"L23")?(u={S:"LY23",N:"LY23"},d=!1):H(r,"I34L")?(u={S:"IX34L",N:"IX34L"},d=!0):H(r,"I34R")?(u={S:"IY34R",N:"IY34R"},d=!0):H(r,"L22")&&(u={S:"L22",N:"L22"},d=!1),H(o,"16L")?h={S:"N16L",N:"N16L"}:H(o,"05")?h={S:"N05",N:"N05"}:H(o,"16R")&&(h={S:"16R",N:"16R"}));for(const e of i)if(H(zq,e.a)){const{dp:t,ds:i,sdt:n,or:r,ar:s,sat:o}=e;l[`${t||r}.${i||s}.${n||o}`]=e}for(const t of i){const{id:i,n:r,dp:o,ds:a,sdt:p,or:f,ar:m,sat:g}=t;let _=n.get(i),y=t.s,{maxFlightSpeed:v,flightAcceleration:x}=s;if(i.match(/NH\d{4}$/)){const e=l[`${o||f}.${a||m}.${p||g}`];if(e){e.n.push(...r);continue}}if(!_){if(H(["Cancelled","PostponedTomorrow"],y))continue;const s=e.airports.get(a||f),l=s?s.direction:"S",c="NRT"===o?`NRT.${d?"34L":"16R"}.Dep`:"NRT"===m?`NRT.${d?"34R":"16L"}.Arr`:"HND"===o?`HND.${h[l]}.Dep`:"HND"===m?`HND.${u[l]}.Arr`:void 0,p=e.featureLookup.get(c);if(!p)continue;_=new qe({id:i,n:r,a:t.a,dp:o,ar:m,ds:a,or:f},{airports:e.airports,operators:e.operators}),_.runway=c.replace(/^([^.]+\.)[A-Z]*([^.]+).+/,"$1$2"),_.feature=p,n.set(_.id,_)}_.update({edt:t.edt,adt:t.adt,sdt:p,eat:t.eat,aat:t.aat,sat:g});const b=q(_.edt,q(_.adt,_.sdt)),w=q(_.eat,q(_.aat,_.sat));void 0===w||y?void 0===b||y&&"CheckIn"!==y&&"NowBoarding"!==y&&"FinalCall"!==y&&"BoardingComplete"!==y&&"Departed"!==y||(b<_.sdt?y="NewTime":b>_.sdt?y="Delayed":b===_.sdt&&(y="OnTime")):w<_.sat?y="NewTime":w>_.sat?y="Delayed":w===_.sat&&(y="OnTime"),_.update({s:y},{flightStatuses:e.flightStatuses}),void 0!==w&&(v/=2,x/=-2);const T=v/Math.abs(x)/2+_.feature.properties.length/v,S=s.standingDuration;b?(_.start=_.base=b,_.entry=_.start-S,_.end=_.start+T):(_.start=_.entry=w-T,_.base=_.start+T-S,_.end=_.start+T+S),_.maxSpeed=v,_.acceleration=x;(c[_.runway]=c[_.runway]||[]).push(_),t.date>(e.lastDynamicUpdate[t.o]||"")&&(e.lastDynamicUpdate[t.o]=t.date)}for(const e of Object.keys(c)){const t=c[e];let i=0;t.sort((e,t)=>e.base-t.base);for(const e of t){const t=e.base,n=Math.max(t,i+s.minFlightInterval)-t;n&&(e.start+=n,e.base+=n,e.entry+=n,e.end+=n),i=e.base}}e.refreshFlights(),e.aboutPanel.updateContent()}).catch(t=>{e.refreshFlights()})}refreshRealtimeBusData(e){const t=this;for(const i of e?[t.gtfs.get(e)]:t.gtfs.values()){const{id:e,vehiclePositionUrl:n,featureLookup:r,stops:s,routes:o,trips:a,activeBusLookup:l,realtimeBuses:c}=i;n?XH(n).then(n=>{c.clear(),i.date=t.clock.getString(1e3*n.header.timestamp);for(const{id:i,vehicle:u}of n.entity){if(!u)continue;const n=u.vehicle,h=u.currentStopSequence,d=u.position,p=u.trip&&u.trip.tripId;if(!h&&!d||!p)continue;c.add(p);const f=a.get(p),m=f&&r.get(f.shape),g=f&&o.get(f.route);if(!f||!m||!g||g.hidden)continue;const _=l.has(p);let y;if(_)y=l.get(p);else{let t=0;const r=f.stops.map(e=>t=Nq(m,s.get(e).coord,t).properties.location);y=new We({id:n?n.licensePlate||n.id:i,gtfsId:e,trip:f,feature:m,offsets:r,offset:0})}if(h)y.stop=h;else{const e=y.offsets,t=y.offset=Nq(m,[d.longitude,d.latitude],y.offset).properties.location;y.stop=f.stopSequences[e.reduce((i,n,r)=>n<t?Math.min(r+1,e.length-1):i,0)]}_||t.busStart(y)}t.aboutPanel.updateContent()}).catch(e=>{}):t.refreshBuses(e)}}updateUndergroundButton(e){const{container:t,dict:i}=this,n=t.querySelector(".mapboxgl-ctrl-underground");if(n){const t=n.classList;"underground"===e?(n.title=i["exit-underground"],t.add("mapboxgl-ctrl-underground-visible")):(n.title=i["enter-underground"],t.remove("mapboxgl-ctrl-underground-visible"))}}updatePlaybackButton(e){const{container:t,dict:i}=this,n=t.querySelector(".mapboxgl-ctrl-playback");if(n){const t=n.classList;"playback"===e?(n.title=i["exit-playback"],t.add("mapboxgl-ctrl-playback-active")):(n.title=i["enter-playback"],t.remove("mapboxgl-ctrl-playback-active"))}}updateEcoButton(e){const{container:t,dict:i}=this,n=t.querySelector(".mapboxgl-ctrl-eco");if(n){const t=n.classList;"eco"===e?(n.title=i["exit-eco"],t.add("mapboxgl-ctrl-eco-active")):(n.title=i["enter-eco"],t.remove("mapboxgl-ctrl-eco-active"))}}refreshMap(){const e=this,{map:t,viewMode:i,searchMode:n}=e,r="underground"===i,s="mt3d:opacity"+(r?"-underground":"");!function(e,t,i){const n=e.style.transition.duration;for(const{id:r,key:s,opacity:o,metadata:a}of t){let t,l;if(t=Array.isArray(i)?i.reduce((e,t)=>q(e,a[t]),void 0):a[i],s){if(Array.isArray(o)){l=e.getPaintProperty(r,s);for(const{index:e,value:i}of o)l[e]=i*t}else l=o*t;e.setPaintProperty(r,s,l)}else{const i=performance.now(),s=q(e.getLayer(r).props.opacity,1);(function o(){const a=performance.now()-i;L_(e,r,{opacity:j(s,t,Math.min(a/n,1))}),a<n&&requestAnimationFrame(o)})()}}}(t,e.styleOpacities,"none"===n||"edit"===n?s:[`${s}-route`,s]),k_(t,e.clock.getTime(),r?0:1,!0),e.setLayerVisibility("hd-area",r?"none":"visible"),e.setLayerVisibility("hd-elevated-area",r?"none":"visible"),e.trafficLayer.setMode(i,n)}updateLayerVisibility(){const e=this,t=e.layerVisibility,i=t.tile3d.values().some(e=>"visible"===e);for(const[n,r]of t.model.entries())e.map.setLayoutProperty(n,"visibility",i?"none":r)}_setSearchMode(e){const t=this;if(t.searchMode!==e){t.searchMode=e,t.stopAll();for(const i of t.plugins)i.setVisibility("none"===e);t.refreshMap()}}_setViewMode(e){const t=this;t.viewMode!==e&&(t.updateUndergroundButton(e),t.viewMode=e,t.refreshMap(),t.fire({type:"viewmode",mode:e}))}_setTrackingMode(e){const t=this;t.trackingMode!==e&&(t.trackingMode=e,Xq(t.trackedObject)&&(t.updateBaseZoom(),t.updateTrackingParams(!0),t.updateHandlersAndControls(),t.startViewAnimation()),t.fire({type:"trackingmode",mode:e}))}_setClockMode(e){const t=this;t.clockMode!==e&&(t.updatePlaybackButton(e),t.clockMode=e,t.clock.reset(),t.onClockChange(),t.clockControl&&t.clockCtrl.setMode(e),"playback"===e&&t.resetRailwayStatus(),t.fire({type:"clockmode",mode:e}))}_setEcoMode(e){const t=this;t.ecoMode!==e&&(t.updateEcoButton(e),t.ecoMode=e,t.fire({type:"ecomode",mode:e}))}onClockChange(){const e=this,t=e.clock.getTime("03:00");e.stopAll(),e.markObject(),e.trackObject(),e.lastTimetableRefresh!==t&&(e.refreshTrainTimetableData(),e.lastTimetableRefresh=t)}getLight(){const e=this.map;return{directional:O_(e),ambient:D_(e),brightness:B_(e)}}pickObject(e){const t=this,{map:i,layerZoom:n}=t,r=["ground","underground"];let s;"underground"===t.viewMode&&r.reverse();for(const o of r){if(s=t.trafficLayer.pickObject(o,e),s)return s;if(s="ground"===o?i.queryRenderedFeatures(e,{layers:[`stations-og-${n}`]})[0]:Um(i.__deck,`stations-ug-${n}`,e),s)return t.stationGroupLookup.get(s.properties.group)}}markObject(e){const t=this,{markedObject:i,trafficLayer:n,map:r,popup:s}=t;Zq(i,e)||(i&&(delete t.markedObject,Xq(i)?(n.markObject(),"bus"===i.type&&t.updateBusTripHighlight(i)):t.removeStationOutline("stations-marked"),s&&s.isOpen()&&(r.getCanvas().style.cursor="",s.remove())),e&&(t.markedObject=e,Xq(e)?(t.updateObjectPosition(e),n.markObject(e),"bus"===e.type&&t.updateBusTripHighlight(e)):t.addStationOutline(e,"stations-marked"),r.getCanvas().style.cursor="pointer",t.popup=new Me({className:z()?"popup-object popup-touch":"popup-object",closeButton:!1,closeOnClick:!1,maxWidth:"300px",offset:{top:[0,10],bottom:[0,-30]},openingAnimation:{duration:300,easing:"easeOutBack"}}),t.updatePopup({setHTML:!0,addToMap:!0})),t.updateAdTrainPopup(),r.triggerRepaint())}trackObject(e){const t=this,{searchMode:i,lang:n,map:r,trackedObject:s,trafficLayer:o,lastCameraParams:a,sharePanel:l,detailPanel:c}=t;if("edit"===i&&c&&$q(e)){const{title:t,utitle:i}=e.stations[0],r=i&&i[n]||W(t[n]||t.en);return void c.fillStationName(r)}if(Zq(s,e))(Xq(e)||$q(e))&&c&&c.reset();else if(!s&&e?(a.viewMode=t.getViewMode(),delete a.center,a.zoom=r.getZoom(),a.bearing=r.getBearing(),a.pitch=r.getPitch()):s&&!e&&(t._setViewMode(a.viewMode),r.flyTo({center:a.center||r.getCenter(),zoom:a.zoom,bearing:a.bearing,pitch:a.pitch})),s&&(delete t.trackedObject,Xq(s)?(o.trackObject(),"bus"===s.type&&t.updateBusTripHighlight(s),t.fire({type:"deselection",deselection:s.id})):$q(s)?(t.removeStationOutline("stations-selected"),t.fire({type:"deselection",deselection:s.stations.map(({id:e})=>e)}),t._setSearchMode("none"),t.hideStationExits()):t.fire(Object.assign({type:"deselection"},s)),t.updateHandlersAndControls(),t.stopViewAnimation(),l&&(l.remove(),delete t.sharePanel),c&&(c.remove(),delete t.detailPanel)),e)if(t.trackedObject=e,Xq(e))t.updateObjectPosition(e),t.updateBaseZoom(),t.updateTrackingParams(!0),t.updateHandlersAndControls(),t.startViewAnimation(),t._setViewMode(e.altitude<0?"underground":"ground"),H(["train","flight"],e.type)&&"realtime"===t.clockMode&&navigator.share&&(t.sharePanel=new eW({object:e}),t.sharePanel.addTo(t)),e.timetable?(t.detailPanel=new uq({object:e}),t.detailPanel.addTo(t)):e.trip&&(t.detailPanel=new KH({object:e}),t.detailPanel.addTo(t)),o.trackObject(e),"bus"===e.type&&t.updateBusTripHighlight(e),t.fire({type:"selection",selection:e.id});else if($q(e)){const i=e.stations.concat(e.hidden||[]),n=i.map(e=>e.coord),s=a.center=P_(n).getCenter();if("ground"===e.layer)t._setViewMode("ground");else if(r.getCenter().distanceTo(s)){let e=r.getZoom();const i=e,n=()=>{const n=r.getZoom();n<e&&n<i-.5?t._setViewMode("ground"):n>e&&n>15&&t._setViewMode("underground"),e=n};r.on("zoom",n),r.once("zoomend",()=>{t._setViewMode("underground"),r.off("zoom",n)})}else t._setViewMode("underground");r.flyTo({center:s,zoom:15.5}),navigator.share&&(t.sharePanel=new eW({object:e}),t.sharePanel.addTo(t)),t.detailPanel=new aq({object:i}),t.detailPanel.addTo(t),t.addStationOutline(e,"stations-selected"),t.fire({type:"selection",selection:e.stations.map(({id:e})=>e)})}else t.fire(Object.assign({type:"selection"},e))}updateObjectPosition(e){const{altitude:t,standing:i}=e,{coord:n,altitude:r,bearing:s,_t:o}=this.trafficLayer.getObjectPosition(e);let a,l;return e.coord=n,e.altitude=r,e.bearing=s,e._t=o,e.standing=0===o||1===o,t<0&&r>=0?a="ground":t>=0&&r<0&&(a="underground"),i&&!e.standing&&(l=e.standing),{viewMode:a,standing:l}}showAdTrainPopup(e){const t=this,i=t.adTrains;if(i.has(e))return;const n=e.ad;e.popup=new Me({className:"popup-ad-cars",closeButton:!1,closeOnClick:!1,offset:{top:[0,10],bottom:[0,-30]}}),e.popup.setHTML(`<span style="color: ${n.textcolor};">${n.title[t.lang]}</span>`),i.add(e),t.updateObjectPosition(e),t.updateAdTrainPopup()}updateAdTrainPopup(){const e=this,t=e.markedObject;for(const i of e.adTrains)i.popup.setLngLat(e.adjustCoord(i.coord,i.altitude)),i===t||i.popupVisible?i===t&&i.popupVisible&&(i.popup.remove(),delete i.popupVisible):(i.popup.addTo(e.map),i.popupVisible=!0)}hideAdTrainPopup(e){const t=this.adTrains;t.has(e)&&e.popup&&(e.popup.remove(),delete e.popup,delete e.popupVisible,t.delete(e))}showStationExits(e){const t=this,i=t.map,n=[].concat(...e.map(e=>e.exit||[]));if(n.length>0){const e=[];t.exitPopups=n.map((r,s)=>{const{coord:o,facilities:a=[]}=r,l=a.map(e=>`<span class="exit-${e}-small-icon"></span>`).join(""),c=()=>{t.exitPopups[s]=setTimeout(()=>{const e=new Me({className:"popup-exit",closeButton:!1,closeOnClick:!1});e.setLngLat(o).setHTML(l+t.getLocalizedPOITitle(r)).addTo(i).getElement().id=`exit-${s}`,t.exitPopups[s]=e},s/n.length*1e3)};return i.once("moveend",c),e.push(o),c}),i.fitBounds(P_(e),{bearing:i.getBearing(),pitch:i.getPitch(),offset:[0,-i.transform.height/12],padding:{top:20,bottom:20,left:10,right:60},retainPadding:!1,maxZoom:18})}}hideStationExits(){const e=this;for(const t of e.exitPopups)t instanceof Me?t.remove():"function"==typeof t?e.map.off("moveend",t):clearTimeout(t);e.exitPopups=[]}updateBaseZoom(){const e=this,{map:t,trackedObject:i}=e;if(Xq(i)){const n=e.getModelPosition(i.coord,i.altitude).z,r=t.getFreeCameraOptions().position.z;e.baseZoom=t.getZoom()+Math.log2(r/Math.abs(r-n))}}updatePopup(e){const t=this,{markedObject:i,map:n,popup:r}=t,{setHTML:s,addToMap:o}=e||{};if(Xq(i)){const e=i===t.trackedObject?n.getBearing():void 0;r.setLngLat(t.adjustCoord(i.coord,i.altitude,e)),s&&r.setHTML("train"===i.type?t.getTrainDescription(i):"flight"===i.type?t.getFlightDescription(i):t.getBusDescription(i))}else{const e=t.featureLookup.get(`${i.id}.${t.layerZoom}`),n=jm(Wg(e)),o=function(e){return Gm(e)[0][0][2]}(e);if(r.setLngLat(t.adjustCoord(n,o)),s){const e=i.stations,n={};for(const i of e){const e=t.getLocalizedStationTitle(i),r=i.railway;(n[e]=n[e]||{})[t.getLocalizedRailwayTitle(r)]=r.color}r.setHTML(['<div class="thumbnail-image-container">','<div class="ball-pulse"><div></div><div></div><div></div></div>',`<div class="thumbnail-image" style="background-image: url('${e[0].thumbnail}');"></div>`,"</div>",'<div class="railway-list">',Object.keys(n).map(e=>{const t=Object.keys(n[e]).map(t=>`<div class="line-strip" style="background-color: ${n[e][t]};"></div><span>${t}</span>`).join("<br>");return`<strong>${e}</strong><br>${t}`}).join("<br>"),"</div>"].join(""))}}o&&r.addTo(n)}updateBusRouteVisibility(){const e=this,t=e.map;for(const i of e.gtfs.values()){const{id:n,routes:r}=i,s=new Set;for(const e of r.getAll())if(!e.hidden)for(const t of e.shapes)s.add(t);for(const e of i.featureLookup.keys())s.has(e)?t.removeFeatureState({source:n,id:e},"hidden"):t.setFeatureState({source:n,id:e},{hidden:!0});for(const t of i.activeBusLookup.values()){const i=r.get(t.trip.route);i&&!i.hidden||e.stopBus(t)}}delete e.lastRefresh,delete e.lastRealtimeCheck}updateBusRouteHighlight(e,t){const i=this,n=i.map;if(e){const r=i.gtfs.get(e),s=r.routes.get(t);for(const t of s.shapes)n.setFeatureState({source:e,id:t},{"route-highlight":s.color||r.color})}else for(const e of i.gtfs.values())for(const t of e.featureLookup.keys())n.removeFeatureState({source:e.id,id:t},"route-highlight")}updateBusTripHighlight(e){const t=this,{map:i,markedObject:n,trackedObject:r}=t,{gtfsId:s,trip:o}=e,a=s,l=o.shape;if(n&&"bus"===n.type&&n.gtfsId===s&&n.trip.shape===l||r&&"bus"===r.type&&r.gtfsId===s&&r.trip.shape===l){const e=t.gtfs.get(s),n=e.routes.get(o.route).color;i.setFeatureState({source:a,id:l},{"trip-highlight":n||e.color})}else i.removeFeatureState({source:a,id:l},"trip-highlight")}addStationOutline(e,t){const i=this,n=e.stations[0].id;for(const e of[13,14,15,16,17,18])L_(i.map,`${t}-${e}`,{data:Xg(i.featureCollection,t=>t.zoom===e&&t.ids&&t.ids[0]===n),visible:!0})}removeStationOutline(e){for(const t of[13,14,15,16,17,18])L_(this.map,`${e}-${t}`,{visible:!1})}refreshStationOutline(){const e=Y();for(const t of[13,14,15,16,17,18])L_(this.map,`stations-selected-${t}`,{opacity:e,visible:!0})}setSectionData(e,t,i){const n=e.r.stations,{direction:r,timetable:s}=e,o=(e.ds||[])[0],a=e.delay||0,l=this.clock.getTimeOffset();let c,u,h,d,p,f,m,g;if(s){const e=s.stations;c=s.arrivalTimes,u=s.departureTimes,h=q(t,u.reduce((e,t,i)=>void 0!==t&&t+a<=l?i:e,0)),d=e[h],p=e[h+1]}else d=e.fs||e.ts,p=e.ts||e.fs;if(r>0?(f=n.indexOf(d),m=n.indexOf(p,f),g=n.indexOf(o,f),-1===g&&(g=n.length-1)):(f=n.lastIndexOf(d),m=n.lastIndexOf(p,f),g=n.lastIndexOf(o,f),-1===g&&(g=0)),s){if(e.timetableIndex=h,e.departureStation=d,e.departureTime=q(u[h],c[h]),f>=0&&m>=0)return e.sectionIndex=f,e.sectionLength=m-f,e.arrivalStation=p,e.arrivalTime=c[h+1],e.nextDepartureTime=u[h+1],!0}else{let t;if(t=void 0===e.sectionIndex?m=f:e.sectionIndex+e.sectionLength,e.departureStation=d,t>=0&&t!==g&&(!i&&m>=0||i&&g>=0))return e.sectionIndex=t,e.sectionLength=(i?g:m)-t,e.arrivalStation=p===d?n[t+r]:p,!0}e.arrivalStation=e.arrivalTime=void 0}setBusSectionData(e,t,i){const n=e.trip.stopSequences,r=this.clock.getTimeOffset();let s,o;void 0===e.stop?(s=e.trip.departureTimes,o=q(t,s.reduce((e,t,i)=>t<=r?i:e,0))):o=n.indexOf(e.stop);const a=n.length-1;if(void 0===e.stop){if(o!==a)return e.sectionIndex=o,e.sectionLength=1,e.departureTime=s[o],e.nextDepartureTime=s[o+1],!0}else{let t,n;if(void 0===e.sectionIndex?t=n=o:(t=e.sectionIndex+e.sectionLength,n=Math.min(o+1,a)),!i&&t!==a)return e.sectionIndex=t,e.sectionLength=n-t,!0}}},e.Marker=class extends ae.Evented{constructor(e){super();const t=this,i=document.createElement("div"),n=e.element;n.style.transition=`opacity ${s.transitionDuration}ms`,n.style.opacity=0,n.style.pointerEvents="none",i.style.pointerEvents="none",t._element=i.appendChild(n),t._marker=new ae.Marker({element:i}),t._minZoom=e.minZoom||0,t._visible=!1,t._added=!1,function(e,t){for(const i of e)t[i]&&(t[i]=t[i].bind(t))}(["_onClick","_onMouseEnter","_onMouseLeave","_onZoom"],t)}addTo(e){const t=this,i=t._element;return t._removeTimer&&(clearTimeout(t._removeTimer),delete t._removeTimer),t._added||(t._added=!0,t._map=e,t._zoom=e.getZoom(),t._marker.addTo(e.map),e.on("zoom",t._onZoom),i.addEventListener("click",t._onClick),i.addEventListener("mouseenter",t._onMouseEnter),i.addEventListener("mouseleave",t._onMouseLeave),i.addEventListener("mousemove",t._onMouseMove),i.getBoundingClientRect()),t._visible=!0,t._setVisibility(t._zoom>=t._minZoom),t}remove(){const e=this;return e._added?(e._visible=!1,e._setVisibility(!1),e._removeTimer&&clearTimeout(e._removeTimer),e._removeTimer=setTimeout(()=>{const t=e._element;t.removeEventListener("click",e._onClick),t.removeEventListener("mouseenter",e._onMouseEnter),t.removeEventListener("mouseleave",e._onMouseLeave),t.removeEventListener("mousemove",e._onMouseMove),e._map.off("zoom",e._onZoom),e._marker.remove(),e._added=!1,delete e._removeTimer},s.transitionDuration),e):e}setLngLat(e){return this._marker.setLngLat(e),this}setActivity(e){const t=this._element.classList;return e?t.add("active"):t.remove("active"),this}setVisibility(e){const t=this,i=t._visible;return t._visible=e,t._zoom>=t._minZoom&&(!i&&e?t._setVisibility(!0):i&&!e&&t._setVisibility(!1)),t}_setVisibility(e){const t=this,i=t._element.style,n=t._marker.getElement().style;e?(i.opacity=1,i.pointerEvents="auto",n.pointerEvents="auto"):(i.opacity=0,i.pointerEvents="none",n.pointerEvents="none",t._hover&&t._onMouseLeave())}_onClick(e){this.fire({type:"click"}),e.stopPropagation()}_onMouseEnter(){this._hover=!0,this.fire({type:"mouseenter"})}_onMouseLeave(){delete this._hover,this.fire({type:"mouseleave"})}_onMouseMove(e){e.stopPropagation()}_onZoom(){const e=this,t=e._zoom,i=e._zoom=e._map.getZoom(),n=e._minZoom;e._visible&&(t<n&&i>=n?e._setVisibility(!0):t>=n&&i<n&&e._setVisibility(!1))}},e.Panel=YH,e.Plugin=hq,e.Popup=class{constructor(){this._popup=new Me({className:z()?"popup-object popup-touch":"popup-object",closeButton:!1,closeOnClick:!1,maxWidth:"300px",offset:{top:[0,10],bottom:[0,-30]},openingAnimation:{duration:300,easing:"easeOutBack"}})}addTo(e){return this._popup.addTo(e.map),this}remove(){return this._popup.remove(),this}setLngLat(e){return this._popup.setLngLat(e),this}setHTML(e){return this._popup.setHTML(e),this}},e.THREE=YX,e.ThreeLayer=ND,e.mapboxgl=le});
//# sourceMappingURL=mini-tokyo-3d.min.js.map
